@ hodgey
thanks for replying. here my idea of how the code should work, by using random or case select i want the enemy appear on top,bottom, left, or ride side from the screen.
this code shows how it move from the right side going to the left side.
dim speed# [ 500 ]
dim move# [ 500 ]
setvirtualresolution (1200,752)
setclearcolor ( 211,129,159)
setsyncrate( 60,0)
setuptank()
do
Print( "Frame rate = " + str ( screenFPS ( ) ) )
alottank()
sync()
loop
function setuptank()
loadimage(1,"tank.png")
for tnk = 1 to 35
CreateSprite ( tnk, 1 )
SetSpriteAngle( tnk, 90 )
setSpritePosition ( tnk, 0 , 0 )
speed# [ tnk] = Random ( 10, 50 ) / 10.0
next tnk
endfunction setuptank
function alottank()
// update all tanks
for mvtnk= 1 to 35 ````mvtnk = moving tank
// move all sprites
x# = GetSpriteX ( mvtnk )
y# = GetSpriteY ( mvtnk )
move# [ mvtnk ] = move# [ mvtnk ] + speed# [ mvtnk ]
SetSpritePosition ( mvtnk, x# - speed# [ mvtnk ], y# )
if x# < -10
SetSpritePosition ( mvtnk, Random (1000,1200 ), Random ( 0,700 ) )
endif
next mvtnk
endfunction
this code show the AI moving from bottom towards the top of screen.
just exchange this function in to the main code by replacing the other function from the code snippit above.
function alottank()
// update all tanks
for tnk= 1 to 35
// move all stars up
SetSpriteY ( tnk, GetSpriteY ( tnk) - speed# [ tnk] )
// when sprite has top the screen reset it
if ( GetSpriteY ( tnk) < 15)
SetSpriteDepth(tnk,15)
SetSpritePosition ( tnk, Random ( 0, 1100 ), Random ( 650, 700 ) )
speed#[tnk] = Random ( 1, 50 ) / 10.0
move#[tnk] = 1.0
endif
next tnk
// move all sprites left to right
endfunction
this code is were i be using select case to pick were the AI will appear, this is basic structure form.
select moving_tanks
case moveleft: //move the tank from left to right screen
endcase
case moveright:// move the tank from right to left screen
endcase
case moveup: // move the tank from button to up screen
endcase
case movedown: // move the tank from up to buttom screen
endcase
endselect
another thing i trying to figure out is how not the sprite overlay on each other. i think in the for/next statement i was trying to use a step 2 but it didn't work.