Simple 2D camera movement with player!! by Alastair Zotos30th Dec 2003 18:28
|
---|
Summary A cool 2D camera thingy, you walk around and the camera follows you from ontop, like the old Zelda games and an awful lot of other games! Description A cool 2D camera thingy, you walk around and the camera follows you from ontop, like the old Zelda games and an awful lot of other games! Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Syncronize SYNC ON SYNC RATE 15 HIDE MOUSE `====== `PLAYER `====== `load images player=1 load bitmap "player.bmp",player `get parts of image(right) get image 1,0,0,128,128 get image 2,128,0,256,128 get image 3,256,0,384,128 get image 4,384,0,512,128 `get parts of image(left) get image 5,0,128,128,256 get image 6,128,128,256,256 get image 7,256,128,384,256 get image 8,384,128,512,256 `get parts of image(up) get image 9,0,256,128,384 get image 10,128,256,256,384 get image 11,256,256,384,384 get image 12,384,256,512,384 `get parts of image(down) get image 13,0,384,128,512 get image 14,128,384,256,512 get image 15,256,384,384,512 get image 16,384,384,512,512 `===== `LEVEL `===== load bitmap "level.bmp",2 get image 17,0,0,700,700 `start frame leftframe=5 rightframe=1 upframe=9 downframe=13 levelx=0 levely=0 `========= `MAIN LOOP `========= DO `control right if rightkey()=1 `level movement sprite 2,levelx,levely,17 dec levelx,10 scale sprite 2,200 sprite 1,320,240,rightframe inc rightframe if rightframe>4 then rightframe=1 scale sprite 1,50 endif `control right if leftkey()=1 `level movement sprite 2,levelx,levely,17 inc levelx,10 scale sprite 2,200 sprite 1,320,240,leftframe inc leftframe if leftframe>8 then leftframe=5 scale sprite 1,50 endif `control up if upkey()=1 `level movement sprite 2,levelx,levely,17 inc levely,10 scale sprite 2,200 sprite 1,320,240,upframe inc upframe if upframe>12 then upframe=9 scale sprite 1,50 endif `control down if downkey()=1 `level movement sprite 2,levelx,levely,17 dec levely,10 scale sprite 2,200 sprite 1,320,240,downframe inc downframe if downframe>16 then downframe=13 scale sprite 1,50 endif `update level if levelx>0 then levelx=0 if levelx<-750 then levelx=-750 if levely>0 then levely=0 if levely<-750 then levely=-750 `======== `END LOOP `======== sync loop |