Hi there, I'm new to posting so I hope I've done this right. Actually I'm new to DarkBasic, and have only been trying to learn it for 5 days now. I have put my version of this tutorial below. I was hoping to get some advice on how I can correct the following problems:
1. After making modifications to the original code, my sprite based collision detection is no longer functioning and I have no idea why or how to fix it.
2. The actual fire weapons method I have setup, seems to be cumbersome, with jumping from Playerfire to Shoot, for basically a very similar function. Any thoughts on the proper way to address this?
3.I had the hardest time figuring out how to get this program(the original to loop), while I think I have it looping well now, I'd like to know the best way to do so, as I'm really trying to learn as much as I can.
Thank you for your help!
Nathan
sync on
sync rate 30
color backdrop 0
hide mouse
rem this are the graphics the game will be using
load image "yourship.bmp",1
load image "alienship.bmp",2
load image "orb.bmp",3
load image "greenlazer.bmp",4
load image "yellowlazer.bmp",5
load image "exp1.bmp",6
load image "exp2.bmp",7
load image "exp3.bmp",8
load image "exp4.bmp",9
load image "exp5.bmp",10
load image "exp6.bmp",11
load image "stars.bmp",50
load image "title.bmp",9999
load sound "phaser03.wav",1
load sound "boom2.wav",2
rem this makes an object for use as a background
Make Object Plain 4,600,56
rem this makes the object semi-transparent
ghost object on 4
rem this positions the above object
Position Object 4,0,-4,80
rem this puts stars.jpg image onto the object
Texture Object 4,50
rem then lock the object (although not exactly sure why) I'm learning
Lock Object on 4
rem now make background black to create starfield.
color backdrop rgb(0,0,0)
pf=0:score=0:Levels=1:Lives=3
ysx=50:ysy=200
rem this should put playership into starting position
Sprite 1,ysx,ysy,1
rem these are used to position the laser fire sprites
lx=sprite x(1)+20
ly=sprite y(1)+10
rem display's the sprite of the enemy ship
Sprite 3,500,200,2
rem this sets the title to the screen
Sprite 9999,10,10,9999
do
rem this sets up the Game score and info fields
set cursor 200,400: Print "SCORE:";score; " LEVEL:";level;" LIVES:";lives
rem this checks to make sure you are not closer than 100 pixels to the top of screen then moves you 10 units
IF upkey()=1 and ysy>100
dec ysy,5
endif
rem this checks if you are closer than 420 to the bottom of screen, if not it moves you down 10 units
IF downkey()=1 and ysy<420
inc ysy,5
endif
rem greenlazer.bmp's variables
lx=sprite x(1)+20
ly=sprite y(1)+10
rem re-draws the ship to the screen
Sprite 1,ysx,ysy,1
Sprite 3,500,200,2
rem function call to MoveAll()
MoveAll()
rem function call to MoveStars()
MoveStars()
rem Function Call to Shoot()
Shoot()
rem Function Call to Playerfire
Playerfire()
rem Refreshes the screen
sync
rem end of Do Loop
loop
rem If spacebar is pressed, go to function Shoot()
Function Playerfire()
If Spacekey()=1
shoot()
endif
endfunction
rem Has the texture on the object scroll to simulate motion
Function movestars()
Scroll Object Texture 4,0.01,0.0
Endfunction
rem if spacebar is pressed, display greenlazer.bmp play sound and
rem goto blowup()
Function shoot()
if Spacekey()=1
sprite 2,lx,ly,4
play Sound 1
Blowup()
endif
Endfunction
Function MoveAll()
If Sprite Exist(2)=1
If Sprite x(2)<640
LX= LX+30
Sprite 2,lx,ly,4
endif
endif
IF Sprite Exist(2)=1
IF Sprite x(2)>640
PF=0
LX= Sprite x(1)+20
LY= Sprite y(1)+10
endif
endif
EndFunction
Function blowup()
Sprite 2,lx,ly,4
If Sprite Exist(2)=1
If Sprite Hit(2,3)=1
delete sprite 3
play sound 2
for t=6 to 11
Sprite 3,500,200,t
wait 1
next t
delete sprite 3
Sprite 3,500,200,2
endif
endif
Endfunction
Hello.
Goodbye.
