Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / moving a sprite

Author
Message
VG Teacher
12
Years of Service
User Offline
Joined: 27th Oct 2011
Location:
Posted: 14th Dec 2011 19:43
I am trying to move a sprite, but cannot get sprite to move without it copying and pasting. I think that it has something to do with the copy bitmap function. Is there anything that I can do to work around this issue? Thanks!


set display mode 800,600,32

set image colorkey 128,0,128
#constant plyr =1



sync on
sync rate 40



load image "guy.bmp",1
load bitmap "maze3.bmp",5



x=screen width ()/2
y=screen width ()/2

sync




width=screen width()-1
height = screen height()-1

repeat


movex=mousemovex()
movey=mousemovey()

if movex <> 0
x=x+movex
if x <0 then x=0
if x>bitmap width(5)-width
x= bitmap width(5)-width
endif
endif

if movey <> 0
y=y+movey
if y>bitmap height(5)-height
y= bitmap height (5)-height
endif
endif



sprite 1, 10+o, 1004+p, plyr
set sprite 1,0,1
hide sprite 1
copy bitmap 5,x,y,x+width,y+height,0,0,0,width,height
show sprite 1

if rightkey() then o=o+2
if leftkey() then o=o-2

if upkey() then p=p-2
if downkey() then p=p+2


sync

until escapekey() =1

end
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 15th Dec 2011 00:33
I think loading the maze in as an image and converting it to a sprite would be the better option compared to loading it as a bitmap. You can also control the order of drawing of sprites with the 'Set Sprite Priority' command.

Login to post a reply

Server time is: 2024-05-20 04:54:40
Your offset time is: 2024-05-20 04:54:40