Kiefer Greenspan
If the red example works then that suggests you havent applied the backdrop example components, which I cant see in your code.
Place them before the main loop as suggested before.
Here is an example for your collision problem.
Please tell me if the example works and the background is black.
use the arrow keys to move one of the sprites, press escape to exit the program.
REM TEMP SETUP
sync rate 60 : sync on : randomize timer()
set text font "verdana" : set text size 24 : ink rgb(255,255,255),1
backdrop on : color backdrop rgb(0,0,0)
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
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
zen, firstly you spelt sync wrong in your example within the remark.
In this first example the background is blue, even though I have turned the backdrop off.
As stated once again for you only zen, please do not confuse people with incorrect information regarding sprites and backdrop.
here is a working example of the problem at hand and how incorrect you are with your idea zen.
REM TEMP SETUP
sync on : sync rate 60
REM TEMP IMAGE
ink rgb(255,255,0),1
box 0,0,32,32
get image 1,0,0,32,32
REM SHUFFLE THE BACKDROP ANYWHERE YOU LIKE MATE
sprite 1,mousex(),mousey(),1
backdrop off
REM TEMP MAIN LOOP
disable escapekey : while escapekey()=0
sprite 1,mousex(),mousey(),1
sync : endwhile
REM CLEANUP
delete image 1
delete sprite 1
end
Please dont make it harder for everyone as well as moderators in supplying incorrect information thats clear you havent tested it.
Please backup your statements with a snippet so it can be evaluated.
As for getting your panties in a bunch, as mods its painful to see information thrown around without it being tested correctly.
If you make our job harder then your going to get the short stick.
Take it anyway you like mate, I asked you politely from the start, and now I can see what to expect from you in the future.
Your most welcome to add advice, but make sure you have tested it before hand please.