Heres my full code:
Rem Project: SHMUP_PlayerMove_Shoot_Wave
Rem Created: 3/7/2007 1:25:53 PM
Rem ***** Main Source File *****
Rem Project: SHMUP_playerMovement
Rem Created: 2/28/2007 8:11:16 PM
Rem ***** Main Source File *****
set display mode 800, 600, 32
load image "C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Battlestar gallatica\Viper.bmp", 1
load image "C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Battlestar gallatica\Viper_left.bmp", 2
load image "C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Battlestar gallatica\Viper_right.bmp", 3
load image "C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\SHMUP_playerMovement\Bullet.jpg", 4
load image "C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Battlestar gallatica\Viper_left_2.bmp", 5
load image "C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Battlestar gallatica\Viper_right_2.bmp", 6
set image colorkey 0,0,0
color backdrop 0
sync rate 60
sync on
randomize timer()
type particle_t
x as integer
y as integer
shape as string
speed as integer
time as integer
endtype
dim particles(NUM_PARTICLES) as particle_t
for n = 0 to NUM_PARTICLES
particles(n).x = rnd (1024)
particles(n).y = rnd(768)
particles(n).speed = rnd (3) + 5
particles(n).shape = "."
particles(n).time = timer()
next
EneChar = 1000
dim EnemyPosX(5)
dim EnemyPosY(5)
for ene = EneChar to EneChar + 4
randomY = rnd(100)
read EnemyPosY(ene-1000)
EnemyPosX(ene-1000)= 10 + rnd(800)
load image "C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\SHMUP_playerMovement\cylon.bmp",ene
sprite ene,EnemyPosX(ene-1000),EnemyPosY(ene-1000),ene
scale sprite ene, 70
rotate sprite ene,180
next ene
playerPositionX = 400
playerPositionY = 300
playerSpeed = 3
#constant maxBullets = 5
dim FiredBullet(maxBullets) as integer
dim BulletPosX(maxBullets) as integer
dim BulletPosY(maxBullets) as integer
`basePosX = sprite x(1)
for n = 1 to maxbullets
firedbullet(n) = 0
next n
sprite 1, PlayerPositionX, PlayerPositionY, 1
do
Gosub PlayerControl
Gosub _Star_Map
gosub _Enemy_Wave
set cursor 0, 0`debug
print maxbullets`debug
sync
loop
`paste image 1
_Star_Map:
#constant NUM_PARTICLES = 1000
`while inkey$() = ""
for n = 0 to NUM_PARTICLES
particles(n).y = particles(n).y + particles(n).speed
if particles(n).y >= 767
particles(n).x = rnd(1024)
particles(n).y = rnd(768)
particles(n).speed = rnd(3) + 5
endif
next
cls 0
ink 0, rgb(255, 255, 255)
for n = 0 to NUM_PARTICLES
ink rgb(255,255,255),0
dot particles(n).x, particles(n).y
next
`endwhile
return
_Enemy_Wave:
for ene = EneChar to EneChar + 4
inc EnemyPosY(ene-EneChar),5
sprite ene,EnemyPosX(ene-EneChar),EnemyPosY(ene-EneChar),ene
if EnemyPosY(ene-EneChar) >= screen height() + sprite height(ene)
EnemyPosY(ene-EneChar) = 0
EnemyPosX(ene-EneChar)= rnd(800)-sprite width(ene)
endif
next ene
data -10,-50,-100,-150,-200
return
PlayerControl:
playerPositionY = sprite y(1)
playerPositionX = sprite x(1)
if downkey() = 1 and playerPositionY =< screen height() - sprite height(1)
inc playerPositionY, playerSpeed
endif
if upkey() = 1 and playerPositionY => 0
dec playerPositionY, playerSpeed
endif
if leftkey() = 1 and playerPositionX => 0
dec playerPositionX, playerSpeed
sprite 1, playerPositionX, playerPositionY, 5`draw burst sprite
`need to find a way to make a delay without affecting processor speed
sprite 1, playerPositionX, playerPositionY, 2`draw left sprite
else
if rightkey() = 1 and playerPositionX =< screen width() - sprite width(1)
inc playerPositionX, playerSpeed
sprite 1, playerPositionX, playerPositionY, 6
sprite 1, playerPositionX, playerPositionY, 3`draw right sprite
else
sprite 1, playerPositionX, playerPositionY, 1
endif
endif
if spacekey() = 1 then gosub addBullet
if bulletCount > 0 then gosub moveBullet
return
moveBullet:
for n = 1 to maxBullets
if firedBullet(n) = 1
bulletPosY(n) = bulletPosY(n) - 10
sprite 2, bulletPosX(n), bulletPosY(n), 4
rem check for bullet going off screen
if bulletPosY(n) <= 0 - sprite height(2)
firedBullet(n) = 0
dec bulletCount
endif
rem NEED TO ADD IF BULLET HIT ENEMY HERE
if sprite hit (2, ene)
delete sprite ene
dec bulletCount
endif
rem play explosion sprite
rem play explosion sound
rem wait a little, delete specific enemy sprite
endif
next n
return
addBullet:
for n = 1 to maxBullets
if FiredBullet(n) = 0
firedBullet(n) = 1
BulletPosX(n) = sprite x(1) + 5
BulletPosY(n) = sprite y(1)
inc BulletCount
exit
endif
next n
return
Im trying to create a machine gun shooting routine, but for some reason, i cant get the bullets to 'Rapid fire' so to speak. this is just my prototype shooter with sprites, then im going to convert everything into objects.
Sometimes when a bullet is fired a second time, the 1st bullet on screen is deleted to.. i dont know why this is happening.
Help someone! please!
thanks.
Adam.
----------------------------------------------------
Just because they are paranoid, doesnt mean they arent out to get you.