View Full Version : horse racing
luksy
November 29th, 2002, 07:41 PM
ok, so there is an MC on the stage. He is going straight but with different speed. Slow, then fast then slow...randomly.
Thanx.
WobblyFork
November 30th, 2002, 12:47 AM
createHorse = function () {
var horse = this.attachMovie("linkage name to horse library symbol", "horse", 10);
horse.onEnterFrame = horse.xmove;
};
this.onEnterFrame = function() {
horse.rate = (Math.random()*10)-3;
};
MovieClip.prototype.xmove = function() {
this._x += this.rate;
};
createHorse();
That should do it. Play around with the numbers in the horse.rate function until you're happy with it.
Cheers! :)
- wobbly
Bezzer
November 30th, 2002, 07:49 AM
This code will do basically the same thing as the the other code..it just smooths the movement of the "horse".
targetPos=50;
createEmptyMovieClip("line",1);
line.lineStyle(50);
line.moveTo(0,200);
line.lineTo(0,200+.15);
onEnterFrame=function(){
targetPos+=Math.random()*10;
line._x+=(targetPos-line._x)*.09;
}
If you want to try it out with your horse symbol you could just do this...
targetPos=50;
onEnterFrame=function(){
targetPos+=Math.random()*10;
horseInstance._x+=(targetPos-horseInstance._x)*.09;
}
:)
Replace the smiley image thingys with 0...
luksy
November 30th, 2002, 12:20 PM
thank you all. Really...thanx. But i'll be back! ;)
luksy
November 30th, 2002, 02:22 PM
Well, yes...like i thought...it works and it works awesome!! Just like I wanted!! Thanksssss! This will be an awesome game! ;)
But there is just one more thing i want to add to the game. The betting system. (huh :)
So, it's like this. You have...like....500$ at the begginning. You have a choice to bet on the horse with x amount of money. If he wins you get a random number of money from 50 to 200.
Huh...i got a bit carried on but I think this could be a very original game don't you think? I never saw this kind of game on flash. And there is no doubt that you guys will be in the credits ;)
Tell me what do you think?
Oh yeah, to ease the things for the betting system...Every horse has a number. From 1 to 5. Then you can type 400 for the amount of money and in the horse field you type from 1 to 5.
Jeez. Well...huh....
-luksy
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.