Hey, I just put enemies in my game, using the curved basic AI tutorial:
http://www.curvedbasic.com/Forum2/viewtopic.php?t=103
which is very good and helps explain a lot about many aspects of dark basic, but i just was wondering if it is possible to do a certain thing. the code i put in my game is
Number_of_Enemies=10
dim EnemyState(Number_of_Enemies)
Enemy_Aware#=50
Enemy_Speed#=1
for x = 1 to Number_of_Enemies
make object sphere x,3
EnemyState(x)=rnd(2)
position object x,rnd(Size),1,rnd(Size)
next x
before the do loop, and in the do loop a function called gosub Enemies is called which is :
Enemies:
for x=1 to Number_of_Enemies
x2#=object position x(x)
z2#=object position z(x)
y2#=get ground height(World,x2#,z2#)
ay2#=object angle y(x)
Distance#=sqrt( ((x2#-x1#)^2)+((y2#-y1#)^2)+((z2#-z1#)^2) )
if Distance#<=Enemy_Aware#
EnemyState(x)=3
endif
if Distance#>Enemy_Aware# and EnemyState(x)=3
EnemyState(x)=2
endif
if EnemyState(x)=1
color object x,RGB(0,190,0)
endif
if EnemyState(x)=2
color object x,rgb(0,0,128)
if Upright=0 `This variable determines the direction the enemy should wander.
x2#=x2#+Enemy_Speed#
z2#=z2#+Enemy_Speed#
if x2#>=Size or z2#>=Size then Upright=1
endif
if Upright=1 `This variable determines the direction the enemy should wander.
x2#=x2#-EnemySpeed#
z2#=z2#-EnemySpeed#
if x2#<=0 or z2#<=0 then Upright=0
endif
endif
if EnemyState(x)=3
color object x,rgb(128,0,0)
if x2#<x1# then x2#=x2#+Enemy_Speed#
if x2#>x1# then x2#=x2#-Enemy_Speed#
if z2#<z1# then z2#=z2#+Enemy_Speed#
if z2#>z1# then z2#=z2#-Enemy_Speed#
endif
position object x,x2#,y2#+1,z2#
rotate object x,object angle x(x),ay2#,object angle z(x)
next x
return
i was wondering if, like i have with the guy the user controls, if it is possible to have acceleration, i tried it but it would be very buggy and you would have to keep him chasing u int he same direction, because if you turned it would just go back to 0 then back up again, so i was wondering if using that code or just an example, of being able to have the enemy slowly get faster and faster until a certian speed, and then go back down, thanks so much.