This snippet might help you get better structure to your coding layout, it has player control, enemy collision, and a moving enemy.
It moves the moving enemy by the sine wave stored in an array.
rem --------------------------------------------------------------------
rem BASIC SPRITE STUFF
rem dec 2006 DBP 5.9
rem indi
rem --------------------------------------------------------------------
REM BASIC GAME SETUP
sync rate 0 : sync on : randomize timer()
set text font "verdana" : set text size 24
ink rgb(255,255,255),1
REM PRECALC SIN into an array : Usage is tSin#(var)
Dim tSin#(360) : For i = 0 To 360 : tSin#(i) = Sin(i) : Next i
REM PLAYER ARRAYS FOR X AND Y
dim plr1x(1) : dim plr1y(1)
REM PLAYER START LOCATION
plr1_start_pos_x = 10 : plr1_start_pos_y = 10
REM FILL PLAYER ARRAYS WITH DATA
plr1x(1) = plr1_start_pos_x : plr1y(1) = plr1_start_pos_y
REM CREATE AN ARRAY TO STORE THE OLD LOCATION WHEN COLLISION OCCURS
dim oldplr1x(1) : dim oldplr1y(1)
REM FILL OLD PLAYER LOCATION ARRAYS WITH DATA
oldplr1x(1) = plr1_start_pos_x : oldplr1y(1) = plr1_start_pos_y
REM CREATE A PLAYER LIVES ARRAY AND FILL IT
dim plr1lives(1) : plr1lives(1) = 5
REM CREATE AN ENEMY ARRAY
dim enemyx(6) : dim enemyy(6)
REM MAKE COLOURS FOR THE SPRITES WITH CODE
REM PLAYER COLOUR
cls
ink rgb(rnd(255),rnd(255),rnd(255)),1
box 0,0,16,16
get image 1,0,0,16,16
cls
REM ENEMY COLOURS
for i = 2 to 6
ink rgb(rnd(255),rnd(255),rnd(255)),1
box 0,0,16,16
get image i,0,0,16,16
next i
cls
REM PLACE ENEMIES FROM ARRAY DATA
for i = 2 to 6
enemyx(i) = i * 50
enemyy(i) = i * 50
sprite i,enemyx(i),enemyy(i),i
next i
REM MAIN LOOP START
disable escapekey : while escapekey()=0
REM CONTROL PLAYER
if upkey()=1 then plr1y(1)=plr1y(1)-3
if downkey()=1 then plr1y(1)=plr1y(1)+3
if leftkey()=1 then plr1x(1)=plr1x(1)-3
if rightkey()=1 then plr1x(1)=plr1x(1)+3
REM UPDATE PLAYERS POSITION
sprite 1,plr1x(1),plr1y(1),1
REM UPDATE MOVING ENEMY Number 6
h = h + 1
h = wrapvalue(h)
v = v + 4
v = wrapvalue(v)
enemyx(6) = int(tSin#(h)*-145)+320
enemyy(6) = int(tSin#(v)*-145)+240
sprite 6,enemyx(6),enemyy(6),6
REM CHECK PLAYERS COLLISION FOR ALL ENEMYS
REM CHANGE LIVES AND END GAME IF LIVES = 0
if sprite hit(1,0)>0
if sprite collision(1,0)>0
plr1x(1)=oldplr1x(1)
plr1y(1)=oldplr1y(1)
plr1lives(1) = plr1lives(1) - 1
if plr1lives(1) = -1
cls
REM GAME OVER
end
endif
text 100,10," plr1 lives :" + STR$(plr1lives(1))
sprite 1,plr1x(1),plr1y(1),1
endif
endif
REM UPDATE THE SCREEN EACH LOOP WITH TEXT
text 1,1,"fps:"+STR$(screen fps())
text 1,30,"Lives :"+STR$(plr1lives(1))
REM END MAIN LOOP
sync : endwhile
REM END
end