I took out all of your
sleep commands, and don't mind the bit at the start, that's just for generating some custom images because I don't have the images you used. I also found a
sync command in your bullet_fire subroutine. This should work:
Rem Project: galaxy
Rem Created: Thursday, April 28, 2011
Rem ***** Main Source File *****
SYNC ON
SYNC RATE 60
HIDE MOUSE
gw=800
gh=600
SET DISPLAY MODE gw,gh,16
REM ---------------------
REM Load Images
create bitmap 1,64,64
ink rgb(255,0,0),0
box 0,0,63,63
get image 1,0,0,64,64
get image 2,0,0,64,64
get image 3,0,0,64,64
delete bitmap 1
REM ----------------------
REM Setup Variables
basePosX = 400
FiredBullet = 0
alienX = 1
REM -----------------------
REM Backround Color
COLOR BACKDROP black
REM Load Sprites
SPRITE 1, basePosX, 580, 1
SPRITE 3, alienX, 1, 3
REM Main Loop
DO
REM Alien setup
GOSUB move_alien
REM Player control
IF RIGHTKEY() = 1 THEN basePosX = basePosX + 10
IF basePosX <= 0 THEN basePosX = 0
IF LEFTKEY() = 1 THEN basePosX = basePosX - 10
IF basePosX >= 730 THEN basePosX = 730
SPRITE 1, basePosX, 500, 1
REM Player fire
IF SPACEKEY() = 1 and FiredBullet = 0
FiredBullet = 1
bulletPosX = basePosX + 5
bulletPosY = 580 - 16
ENDIF
IF FiredBullet = 1
GOSUB bullet_fire
ENDIF
SYNC
LOOP
REM Bullet firing and movement
bullet_fire:
DEC bulletPosY, 40
SPRITE 2, bulletPosX + 28, bulletPosY - 50, 2
SPRITE 2, bulletPosX + 28, bulletPosY - 50, 2
GOSUB alien_hit
IF BulletPosY <= 0 THEN FiredBullet = 0
RETURN
REM -----------------------------------------------
REM Alien hit detection
alien_hit:
IF SPRITE HIT(2,3) = 1 THEN
DELETE SPRITE 3
RETURN
REM ------------------------
REM Alien movement
move_alien:
REM Direction flag
changeDirection = 0
SPRITE 3, alienX, 1, 3
alienX = alienX + 5
RETURN
Your coding style so far is pretty good compared to what we usually get around here from newcomers, just 2 things that are questionable:
SPRITE 3, alienX, 1, 3
alienX = alienX + 5
Things like that don't need an extra indentation, you should only do that when a command has an "end" command as well:
for - next
do - loop
repeat - until
while - endwhile
if - endif
function - endfunction
subroutine - return
lock vertexdata for limb - unlock vertexdata
open to read - close file
open to write - close file
etc...
Your comments are all around the place, what I've learned is to always have a new line before every comment:
rem setup screen
sync on
sync rate 60
backdrop on
color backdrop 0
hide mouse
rem load images
load image "bla.bmp",1
load image "haha.mp3",2
load image "...png",3
rem main loop
do
rem control stuff
gosub control_ship
gosub control_enemies
gosub control_bullet
gosub control_if_the_cake_is_a_lie
rem refresh screen
sync
rem end of main loop
loop
control_ship:
rem do stuff
...
return
I'm not sure about writing all commands with capital letters, I write them all small... But yeah, let's see what others say about that.
TheComet