ive looked at the tutorials, read the previous threads on this topic, and i still do have a clue what im meant to do.
im trying to make a racing game where you are trying to beat the computer, but i dont know how to use the four lists (UP, DOWN, LEFT, RIGHT) to recall all the buttons pressed and use that information to move the ghost car/"AI" car.
i can get the lists to note down the buttons pressed using ones and zeros, but after that im clueless.
what i really need is not the script (ive got that, but i dont want to simply transfer it directly), but an in-depth explaination of how the script works, so that i can replicate it properly in the game.
Offline
Basically all you are doing is recording whatever the user pressed and playing it back. So first, you record the user's input using those 4 lists and you also make your car move.
The recording part is pretty straight forward. If the button was pressed add a 1 otherwise add a 0.
Like this:
forever
if key up pressed
add 1 to UP
else
* 0 to UP
And just do that for all the other lists.
So basically how your car moves at the start is something like this.
forever
if up pressed{
go forward
}
if down pressed{
go back
}
if left pressed{
turn left
}
if right pressed{
turn right
}
When you have your lists recorded your car will move based on the values in the lists instead of direct user input.
It should look something like this
variable i=0
Repeat until i= length of UP
//This will make it so that it stops when the recording is done
if value i in UP = 1{
go forward
}
if value i in DOWN = 1{
go back
}
if value i in LEFT = 1{
turn left
}
if value i in RIGHT = 1{
turn right
}
So basically all you are doing is recording when each button was pressed and making the car behave normally except reacting to the values in the lists instead of button presses.
Last edited by archmage (2008-09-29 20:56:59)
Offline