Sorry about the sloppy code. I am makeing some progress but I still can't get my guy to move diagonal and my sprite collision's won't work. Please any pointers or insight at all will be appricated.
REMSTART --------------------------------------------
Author : Katz Sprite Demo
Version : 003
Creation Date : Sat Oct 28 2006
Created for DBP[ x ] | DBC[ ]
Description : Move arno sprite move with arrowpad. Move spider sprite either up and down or left and right automaticly.
Make a collision between arno and spider sprites exit the game.
Testing Sprite handling
Notes:
Cleaned up code, isolated command position errors
REMEND
REM SETUP ----------------------------
set display mode 1024, 768, 32
sync on : sync rate 60 : hide mouse
set text font "verdana" : set text size 14 : ink rgb(255,255,255),1
REM INIT / LOAD SPRITES ----------------------------
set image colorkey 220, 220, 220
REM arno sprite
create animated sprite 1, "runR.bmp", 8, 1, 1
create animated sprite 2, "runL.bmp", 8, 1, 2
create animated sprite 3, "runU.bmp", 8, 1, 3
create animated sprite 4, "runD.bmp", 8, 1, 4
create animated sprite 5, "runUL.bmp", 8, 1, 5
create animated sprite 6, "runUR.bmp", 8, 1, 6
create animated sprite 7, "runDL.bmp", 8, 1, 7
create animated sprite 8, "runDR.bmp", 8, 1, 8
create animated sprite 9, "stopped.bmp", 1, 1, 9
REM spider sprite
create animated sprite 11, "spiderU.bmp", 8, 1, 11
create animated sprite 12, "spiderD.bmp", 8, 1, 12
create animated sprite 13, "spiderL.bmp", 8, 1, 13
create animated sprite 14, "spiderR.bmp", 8, 1, 14
spiderx = 320
spidery = 240
speedx = 1
speedy = -1
border = 25
REM LOAD BACKGROUND
Load bitmap "bg.bmp", 10
REM PRE MAIN
set current bitmap 0
REM this value helps negotiate the value for arno's play sprite
n=1
t=11
REM MAIN LOOP
disable escapekey : while escapekey()=0
REMSTART
For some reason when the game first comes up my spider sprite shows up as my guy and not the spider.
I am also still haveing problems with my guys diagnal movements.
REMEND
REM UPDATE SPRITE
`do
REM copy's BG.bmp to current background
copy bitmap 10, 0
REM PLAYER CONTROLS
REM up, down, left, right movemeant
`UP
if scancode()=200 then y=y-5: play sprite 3, 1, 8, 50: n=3
`DOWN
if scancode()=208 then y=y+5: play sprite 4, 1, 8, 50: n=4
`RIGHT
if scancode()=205 then x=x+5: play sprite 1, 1, 8, 50: n=1
`LEFT
if scancode()=203 then x=x-5: play sprite 2, 1, 8, 50: n=2
REM sprite for arno standing still
if scancode()=0 then play sprite 9, 1, 1, 50 : n=9:
REM DIAGONAL MOVEMEANT
`up and right
`if scancode()=200 and scancode()=205 then y=y-5 and x=x+5: play sprite 7, 1, 8, 50: n=7
`up and left
`if scancode()=200 and scancode()=203 then y=y-5 and x=x-5: play sprite 8, 1, 8, 50: n=8
`down and right
`if scancode()=208 and scancode()=205 then y=y+5 and x=x+5: play sprite 6, 1, 8, 50: n=6
`down and left
`if scancode()=208 and scancode()=203 then y=y+5 and x=x-5: play sprite 5, 1, 8, 50: n=5
REM play arno sprite
play sprite 9, 1, 1, 50
`draw the current sprite frame at X,Y
paste sprite n, x, y
REM play spidery sprite
play sprite t, 1, 8, 50
`draw the current sprite frame at X,Y
paste sprite t, spiderx, spidery
REM play spidery sprite
`play sprite p, 1, 8, 50
`draw the current sprite frame at X,Y
`paste sprite p, nox, spidery
REM move spiders
spiderx = spiderx + speedx
spidery = spidery + speedy
REM check condition for spidery
if spidery > 758 `- border
spidery = 758 `- border
speedy = speedy * -1: play sprite 12, 1, 8, 50: t=11
else
if spidery < border
spidery = border
speedy = speedy * -1: play sprite 11, 1, 8, 50: t=12
endif
endif
REM check condition for spiderx
if spiderx > 1020 `- border
spiderx = 1020 `- border
speedx = speedx * -1: play sprite 12, 1, 8, 50: t=12
else
if spiderx < border
spiderx = border
speedx = speedx * -1: play sprite 11, 1, 8, 50: t=11
endif
endif
`until
REMSTART
I am having a problem with my collisions. The syntax is sprite number , target sprite number,
but nothing happens. My sprites just just pass right over each other.
remend
REM sprite collision
`REMSTART
if sprite hit(1, 11) then spritecolide=1:
if sprite hit(2, 11) then spritecolide=2:
if sprite hit(3, 11) then spritecolide=3:
if sprite hit(4, 11) then spritecolide=4:
if sprite hit(5, 11) then spritecolide=5:
if sprite hit(6, 11) then spritecolide=6:
if sprite hit(7, 11) then spritecolide=7:
if sprite hit(9, 11) then spritecolide=9:
if sprite hit(1, 12) then spritecolide=10:
if sprite hit(2, 12) then spritecolide=11:
if sprite hit(3, 12) then spritecolide=12:
if sprite hit(4, 12) then spritecolide=13:
if sprite hit(5, 12) then spritecolide=14:
if sprite hit(6, 12) then spritecolide=15:
if sprite hit(7, 12) then spritecolide=16:
if sprite hit(9, 12) then spritecolide=17:
if spritecolide=1 then exit
`REMEND <> 17 then print "GAME OVER":
`remstart
text 1,1,STR$(screen fps())
REM END MAIN LOOP
fastsync : endwhile
REM CLEANUP
for i = 1 to 100
if sprite exist(i)=1
delete sprite i
endif
next i
REM END GAME
end
`remend
FNG