PDA

View Full Version : racing game advice needed



adsmithy
February 13th, 2007, 10:30 PM
hi,

im developing a simple racing game using code posted by members of this forum. i need some advice on a few things.

1.) i want to change the starting position of the player car (to the start line).

2.) since i've added a title screen the AI cars have stopped working. i think its because the onEnterFrame function cannot work now that ive told it to stop on that frame, otherwise it will loop back to the title screen. how can i get around this?

3.) currently the AI cars have no collision detection. i want to use the existing collision detection that is being used for the track walls. how could i add this to the AI cars?

4.) i want to record the number of the laps the player has compeleted. after a certain amount of laps e.g. 10 the race ends and depending on whether the player has won or not produce a suitable ending screen. i already have a checkpoint to facilitate this, not sure how to code it now?

any help would be much appreciated indeed. i have hosted my .fla and .swf files externally (the .fla was too big for Kirupa hosting) for you to view. cheers. :thumb2:

racing game.fla (http://www.filefactory.com/file/0d1924/)
racing game.swf (http://www.filefactory.com/file/f86894/)

DangerousDan
February 14th, 2007, 06:43 PM
1.) i want to change the starting position of the player car (to the start line).
something like...


movieclip.onLoad = function()
{
movieclip._x = whateverx;
movieclip._y = whatevery;
}


2.) since i've added a title screen the AI cars have stopped working. i think its because the onEnterFrame function cannot work now that ive told it to stop on that frame, otherwise it will loop back to the title screen. how can i get around this?
You probably should have seperate frames for title screens... but:


titleScreen = true;

//when it proceeds off the titleScreen put
//titleScreen = false;
movieclip.onEnterFrame = function()
{
if(!titleScreen)
{
//put put code in here.
}
}



3.) currently the AI cars have no collision detection. i want to use the existing collision detection that is being used for the track walls. how could i add this to the AI cars?
Loop through the cars and check if any of them touch the player, do this on the car's onEnterFrame function.

4.) i want to record the number of the laps the player has compeleted. after a certain amount of laps e.g. 10 the race ends and depending on whether the player has won or not produce a suitable ending screen. i already have a checkpoint to facilitate this, not sure how to code it now?
Check to see if your character goes past the checkpoints x (assuming the Y is equal on the checkpoint and the character) Just think about it logically, what happens when it passes the check point? (most likely x <= checkpoint's x and y = checkpoint's y but I haven't looked at your source.