i've tried to make use of data statements in my code. It's actually the code for Limit Rush, i'm using the code to see how it will do in actual racing game. But the problem is i dont know WHERE TO PLACE the restore and read command so that the waypoints may be read. here's the code
main:
restore data_waypoints_positions
for spot=1 to 3
read xSpot(spot)
read zSpot(spot)
next id
do
`get keyboard input for movement
if upkey()=1 then forward=1 else forward=0
if downkey()=1 then backward=1 else backward=0
if leftkey()=1 then left=1 else left=0
if rightkey()=1 then right=1 else right=0
`update the player
move_player(1,forward,backward,left,right)
control_player(2)
`update the camera
chase_cam(1)
text 1,20,str$(object position x(2))
text 15,30,str$(object position z(2))
text 15,40,str$(object position x(1))
text 15,50,str$(object position z(1))
gosub update_collision
`update the screen
sync
loop
that's 4 d main loop and the AI is
function control_player(id)
if xPos#=xSpot(spot) and zPos#=zSpot(spot)
xSpot(spot)=xSpot(spot+1)
zSpot(spot)=zSpot(spot+1)
endif
`get positions
xPos#=object position x(id)
zPos#=object position z(id)
yAng=object angle y(id)
`set movement values
left=0
right=0
forward=1
backward=0
`work out angle between payer and target
angle#=atanfull(xPos#-xSpot(spot),zPos#-zSpot(spot))-yAng
`work out direction to turn
if angle#<-180
left=1
else
right=1
endif
move_player(id,forward,backward,left,right)
endfunction
i placed the data statements below the program (just like Ben did in Limit Rush) like this
data_waypoints_positions:
`1-targetxpos
`2-targetzpos
data 151.86,308.70
data 448.84,309.15
data 452.97,113.82
can you guys help me out as to where i could place the data for the waypoints? is it in the main loop, in the ai itself, or where?
thx you alots
phukol