I have a lot of issues I know... Now it's about the sprite priority in my game. Here is the problem: I want my game to show my sprites in a specific order. For this, I have set the sprite priority for my sprites, with no effect. The player is supposed to be drawn above the background but below the shading of the scene. My code look like this:
Rem Project: The Art Walkthrough
Rem Created: Saturday, October 10, 2009
Rem ***** Main Source File *****
rem *** Game Main Setup ***
set display mode 1024, 768, 32
autocam off
hide mouse
sync on
sync rate 130
rem *** End Game Main Setup ***
rem *** Load media ***
`Load music and sound
LOAD SOUND "Media\Sounds\Footstep.wav", 1
LOAD MUSIC "Media\Music\Frank Sinatra - How little we know.mp3", 1
`Load the logo
LOAD IMAGE "Media\Sprites\Logo.png", 1
`Load the player sprite
LOAD IMAGE "Media\Sprites\Charles_trans.png", 2
rem *** Levels have extension of hundred
`Load the backgrounds
LOAD IMAGE "Media\Sprites\Level 01\City_Background.png", 100
LOAD IMAGE "Media\Sprites\Level 01\City_Ground.png", 101
LOAD IMAGE "Media\Sprites\Level 01\City_Shading.png", 102
LOAD IMAGE "Media\Sprites\Level 01\Star.png", 103
rem *** Create sprites ***
CREATE ANIMATED SPRITE 2, "Media\Sprites\Charles_trans.png", 8,3, 2
runleft_flag as boolean
runright_flag as boolean
mirrored as boolean
px = 30
py = 600
DO
loadbackground(100, 101, 102)
gosub moveplayer
if escapekey()=1 then exit
placeplayer(px, py)
sync
LOOP
function loadbackground(background, ground, shade)
SPRITE background, 0,0, background
SET SPRITE PRIORITY background, 1
SPRITE ground, 0,700, ground
SET SPRITE PRIORITY ground, 2
SPRITE shade, 0,0, shade
SET SPRITE PRIORITY shade , 4
endfunction
function placeplayer(px, py)
PASTE SPRITE 2, px, py
SET SPRITE PRIORITY 2, 3
endfunction
moveplayer:
rem ** Move Right **
if rightkey()=1
runright_flag = 1
if mirrored = 0
mirrored = 1
MIRROR SPRITE 2
endif
if footsteptime < timer() - 300
PLAY SOUND 1
footsteptime = timer()
endif
PLAY SPRITE 2, 1,8, 60
px = px + 2
endif
if rightkey()=0 and runright_flag = 1
runright_flag = 0
SET SPRITE frame 2, 17
endif
rem ** Move Left **
if leftkey()=1
runleft_flag = 1
if mirrored = 1
mirrored = 0
MIRROR SPRITE 2
endif
if footsteptime < timer () - 300
PLAY SOUND 1
footsteptime = timer()
endif
PLAY SPRITE 2, 1,8, 60
px = px - 2
endif
if leftkey()=0 and runleft_flag = 1
runleft_flag = 0
SET SPRITE frame 2, 17
endif
rem ** if both left and right is pressed, stop
if leftkey()=1 and rightkey()=1
SET SPRITE frame 2, 17
STOP SOUND 1
endif
return
As you can see, the background have a priority of 1, ground 2, player 3, and shading 4. But! Whenever I start the game, the player is drawn below every sprite, which is totally not what I want.
Please help me out, it'll be very much appreciated!