Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Tutorial on 2D Shooters.

Author
Message
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 10th Aug 2005 06:23
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

Attachments

Login to view attachments
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 10th Aug 2005 06:58
New Code: Make the ship follow the mouse




SSDD
Same Sh** Different Day
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 10th Aug 2005 07:20
Pretty nice. But i think you need to make your code easyer to read.

When we talk to god, we're praying. When god talks to us, we're schizophrenic.
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 10th Aug 2005 07:49
What do u mean?


SSDD
Same Sh** Different Day
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 10th Aug 2005 15:59
eh i just find it hard for me to read it all probably only because i useually have a hard time reading tutorials on the net i preferr books myself heh. But whatever still a nice job.

When we talk to god, we're praying. When god talks to us, we're schizophrenic.
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 10th Aug 2005 18:11
Thanku.


SSDD
Same Sh** Different Day
Darkbasic MADPSP
18
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 14th Aug 2005 12:35
Yeah that is good and helped for what i need thanks

See you at the convention!
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 14th Aug 2005 18:22 Edited at: 14th Aug 2005 18:22
Your Welcome.


SSDD
Same Sh** Different Day
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 14th Aug 2005 23:48
hey big my new site which im making for DBP/DBC will have tutorials and stuff on it could you e-mail me this one. UnderLord@darkuniverse.net So right now i only have 2 =\

When we talk to god, we're praying. When god talks to us, we're schizophrenic.
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 15th Aug 2005 00:04
Would i be credeted?


SSDD
Same Sh** Different Day
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 15th Aug 2005 06:06
Yes. Im not going to pass it off as my own work even when i take someones code chop it up delete stuff and then put in my own code i still give credit to the original maker of the code. All it'd say is that you made it. It would be available for viewing =).

When we talk to god, we're praying. When god talks to us, we're schizophrenic.
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 12th Sep 2005 02:13
There i finally got around to updating my db site and now its on there Bigadd i lost the original fiel you sent to me so i just copyed and pasted what was in this thread into a text file and uploaded it to my site go have a look

dbworlds.darkuniverse.net

I really need to update my site more often.

When we talk to god, we're praying. When god talks to us, we're schizophrenic.
Fortune never calls on those that have no balls.
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 12th Sep 2005 19:38
Wow i'm famous. Everything is attached to my original post ^^^^


SSDD
Same Sh** Different Day
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 12th Sep 2005 20:52
LOL =P hahaha.

When we talk to god, we're praying. When god talks to us, we're schizophrenic.
Fortune never calls on those that have no balls.
piece of meat
18
Years of Service
User Offline
Joined: 13th Sep 2005
Location:
Posted: 14th Sep 2005 01:47
pls can one of u guys take 5 min to improve my game ?

http://www.savefile.com/files/6782709

thx alot

m-e-a-t
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 17th Sep 2005 05:09
wtf is a gm6 file format?

game maker? or something?

When we talk to god, we're praying. When god talks to us, we're schizophrenic.
Fortune never calls on those that have no balls.
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 18th Sep 2005 02:41
I cant help you sorry. It is a .gm6 file. and i dont know what that is.


SSDD
Same Sh** Different Day
Darkbasic MADPSP
18
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 18th Sep 2005 17:17
underlord can you put my dbpro sprite stuff on your site?

New game about to be unleashed steal un theif
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 18th Sep 2005 23:59
Yes darkbasic mad all you need to do is send it to me in a .zip file ot this e-mail address

UnderLord@darkuniverse.net

When we talk to god, we're praying. When god talks to us, we're schizophrenic.
Fortune never calls on those that have no balls.

Login to post a reply

Server time is: 2024-03-29 11:04:22
Your offset time is: 2024-03-29 11:04:22