could anyone look through this and see if im using any bad coding practices or anything? im still very noobish and wanna make sure im doing okay...
(this code compiles and runs fine, i just wanna know if im doing it in a way that makes it fast)
Rem Project: kirby fighter
Rem Created: 2/29/2008 3:48:45 PM
Rem ***** Main Source File *****
`set up the screen and sprites/images
gosub _setup
create_broto(100,400,240)
`main loop
do
gosub _draw_kirby
gosub _move_kirby
play sprite 100,1,4,20
sync
loop
`sunroutines
remstart
below are all the codes used to make the game actually run. Above is only
the order that all the code is used in to keep this program organized
the following code sets up the game (loads all the images/music. Makes sprites
variable starts, sprite starts. screensetups
remend
_setup:
`set screen
set image colorkey 0,0,255
set display mode 640,480,16
sync on
sync rate 60
`load images
load image "kirby/strait.bmp",1
load image "kirby/movedown.bmp",2
load image "kirby/moveup.bmp",3
load image "kirby/forward.bmp",4
load image "kirby/sparkle.bmp",5
load image "kirby/back.bmp",6
load image "enemies/brotoburt.bmp",10
`create variables
kx=100
ky=240
incriment=2
`create sprites
sprite 1,kx,ky,1
sprite 2,kx,ky,2
sprite 3,kx,ky,3
sprite 4,kx,ky,4
create animated sprite 5,"kirby/sparkle.bmp",5,1,5
sprite 5,kx-35,ky+10,5
sprite 6,kx,ky,6
mirror sprite 5
`set up sprites
hide sprite 2
hide sprite 3
hide sprite 4
hide sprite 6
return
`kirby code
remstart
this code draws kirby and his trail at the designated position on screen to ensure that
he is in place and animated
remend
_draw_kirby:
`draw all of kirbys sprites
sprite 1,kx,ky,1
sprite 2,kx,ky,2
sprite 3,kx,ky,3
sprite 4,kx,ky,4
sprite 5,kx-35,ky+10,5
sprite 6,kx,ky,6
play sprite 5,1,5,20
return
remstart
this code moves kirby according to the up and down key
remend
_move_kirby:
`controls kirby
if upkey()=1 and downkey()=0`player is pressing up and not down
ky=ky-incriment
gosub _hide_k
show sprite 3
else
if upkey()=0 and downkey()=1 `player is pressing down and not up
ky=ky+incriment
gosub _hide_k
show sprite 2
else
gosub _hide_k
show sprite 1
endif
endif
if rightkey()=1`moves player right
if kx>50 and kx<590
kx=kx+incriment
endif
else
if leftkey()=1`moves player left
if kx>50 and kx<590
kx=kx-incriment
endif
endif
endif
`check for left and right animation
if leftkey()=0 and rightkey()=1 and upkey()=0 and downkey()=0`only rightkey is pressed
gosub _hide_k
show sprite 4
else
if leftkey()=1 and rightkey()=0 and upkey()=0 and downkey()=0`only leftkey is pressed
gosub _hide_k
show sprite 6
endif
endif
return
remstart
this code hides all kirby sprites so that only the one i want to be drawn can
be easily chosen
remend
_hide_k:
hide sprite 1
hide sprite 2
hide sprite 3
hide sprite 4
hide sprite 6
return
`Functions
function create_broto(id,x,y)
create animated sprite id,"enemies/brotoburt.bmp",4,1,10
sprite id,x,y,10
endfunction
edit: Forgot to say this is for a side/scrolling shooter