I have made a tutorial on a top view shooter that can be applied to pretty much any shooter. Eg Asteroids, Space invaders. Tell me what you think.
The Media And Project Files Are attached to this post.
Rem Project: 2D Tutorial
Rem Created: 10/08/2005 03:42:29
Rem Created By: BIGGADD
Rem ***** Main Source File *****
Rem Set Sync
Sync on
Sync rate 60
Rem sets the image colour key so the blue background in the sprites will be made transparent
Set Image Colorkey 0,0,255
Rem create Backdrop and Colour Backdrop
Backdrop on
Color backdrop rgb(255,255,255)
Rem Load the Ship Image
Load image "Media/Ship.bmp",1,1
Rem Load the bullet Image
Load image "Media/Bullet.bmp",2,1
Rem create sprite Ship
Sprite 1,320,240,1
Rem offset sprite so when the sprite is rotated, the ship will turn on its center axis.
Offset Sprite 1,100,100
Rem create variable for Ship rotation
Y#=0
Rem create variable for Bullet sprite
B=20
Rem Bbegin loop
Do
Rem Set the ship Sprite to always draw to the front
Set sprite priority 1,1
REM ************* MOVEMENT ***************
Rem if Upkey is pressed, the ship will move forwards
If upkey()=1 then Move sprite 1,2
Rem if Downkey is pressed, the ship will move backwards
If downkey()=1 then Move sprite 1,-2
Rem Increase the variable Y# if the right key is pressed
If rightkey()=1 then Inc Y#
Rem Decrease the variable Y# if the left key is pressed
If leftkey()=1 then Dec Y#
Rem rotate the sprite by the value of Y#
Rotate sprite 1,Y#
REM *************** BULLET CREATION ******************
Rem Only allow bullets to be fired as soon as Wait# has reached 0
If Wait#=0
Rem If the control key is pressed then start the If loop.
If Controlkey()=1
REM Create a Bullet Sprite and position it at the Ships position
Sprite B,Sprite X(1),Sprite Y(1),2
Rem Offset The Bullet so its Rotation is in the center
Offset Sprite B,10,40
Rem Rotate the Bullet to match the ships Direction
Rotate Sprite B,Y#
Rem Move the sprite closer to the ships Gun
Move sprite B,110
Rem Increase the bullet Sprite number by 1
Inc B
Rem Set Wait# to 20 so after 20 counts a new bullet can be fired. Change this variable to alter the fire speed.
Wait#=20
Rem End if loop
Endif
Rem End if loop
Endif
Rem Decrease Wait for a new bullet
dec Wait#
Rem If Wait# Gets less than Zero, Make Wait# stay at zero
if Wait#<0 then Wait#=0
REM ************** BULLET MOVEMENT ****************
Rem set upa For Next Loop. This prevents typing out streams of code to make each individual bullet move. Change the
Rem higher Value (Which is currently 10) so more bullets can be moved at a time. This code will allow 10 bullets at
Rem a time to be moved. if 11 bullets are shot, the first bullet shot will stop moving.
For X=1 to 10
Rem Check if a bullet has been created and if so move it by the speed of 5. Notice in the Sprite number its B-X. This links in with the
Rem For Next Loop
If Sprite exist (B-X) then move sprite B-X,5
REM ************* BULLET DELETION *******************
Rem If sprite goes out past the top of the screen, Delete the sprite.
If Sprite exist (B-X) Then If Sprite Y(B-X)<0 then Delete sprite B-X
Rem If sprite goes out past the bottom of the screen, Delete the sprite.
If Sprite exist (B-X) Then If Sprite Y(B-X)>480 then Delete sprite B-X
Rem If sprite goes out past the left of the screen, Delete the sprite.
If Sprite exist (B-X) Then If Sprite X(B-X)<0 then Delete sprite B-X
Rem If sprite goes out past the Right of the screen, Delete the sprite.
If Sprite exist (B-X) Then If Sprite X(B-X)<0 then Delete sprite B-X
Rem Next X Value
Next X
Rem Screen refresh
sync
Rem End Loop
loop
SSDD
Same Sh** Different Day