hello... ive been using DBP for about a month on and off... im trying to write a space shoot em up game to get some of the basic 2d functions down before i try to move on to anything to crazy... I have my ship on screen and moving, then if u hit space bar he will fire a missle... to do this i just used a seperate sprite cause i want only one on screen at a time... i also want to fire a laser when the up key is pressed... i can get it to work as a sprite as well but only one at a time on screen... someone said that i need an array and gave an example but i just couldnt seem to get it to work in my code... i just need help setting up (and understanding) the array needed to fire the laser from myship... here is the working code that i have now
Rem Project: ProjectX
Rem Created: 8/31/2006 12:30:36 AM
Rem ***** Main Source File *****
REM Set Screen
Set Display Mode 640, 480, 16
Hide Mouse
sync on
sync rate 30
cls
Print " ProjectX v0.1"
Print " By Chris Fodge"
REM Variables
REM Laser
REM Load Theme Music
Load Music "ProjectX Theme.MID", 1
Loop Music 1
REM Load Main Ship sprite
load image "ship2.bmp", 1
sprite 1, 320, 445,1
set sprite 1, 1, 1
Size Sprite 1,30,30
Rotate sprite 1, 90
REM Load Missle sprite
load image "missle.bmp", 2
REM Main Loop
DO
REM Move sprite left
IF Leftkey() THEN MOVE SPRITE 1, -4
REM Move sprite right
IF Rightkey() THEN MOVE SPRITE 1, 4
REM Move Sprite Up
if upkey() then
REM Fire a missle
if spacekey() then firemissle()
REM Set border on the X axis
if sprite x(1) < 30 then sprite PLYR, 30, sprite y(1), 1
if sprite x(1) > screen width() then sprite 1, screen width(), sprite y(1), 1
REM Set border on the Y axis (not used by Main Ship)
if sprite y(1) < 0 then sprite 1, sprite x(1), 0, 1
if sprite y(1) > screen height() then sprite 1, sprite x(1),screen height(), 1
sync
LOOP
REM Functions
REM Fire a Missle
function firemissle
REM Display missle (can't get to work right outside of the function)
sprite 2,sprite x(1)- 18,sprite y(1),2
set sprite 2,1,1
size sprite 2,7,10
Rotate sprite 2, 360
Repeat
REM Allow sprite(1) to move while firing
IF Leftkey() THEN MOVE SPRITE 1, -4
IF Rightkey() THEN MOVE SPRITE 1, 4
REM Set Borders for sprite(1) while fireing
if sprite x(1) < 30 then sprite 1, 30, sprite y(1), 1
if sprite x(1) > screen width() then sprite 1, screen width(), sprite y(1), 1
if sprite y(1) < 0 then sprite 1, sprite x(1), 0, 1
if sprite y(1) > screen height() then sprite 1, sprite x(1),screen height(), 1
REM Update the Y Position
if sprite y(2) > -10 then move sprite 2, 4
sync
until sprite y(2) < -10
endfunction
Thanks