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.

Newcomers DBPro Corner / Space Ship Shoot'em'up

Author
Message
Game Master1330
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 20th Sep 2010 21:52 Edited at: 20th Sep 2010 22:20
Hi,
I haven't coded in ages so i decided to come back to it and this is my current project. It is my first game and consists of a spaceship that you control (cant stop) and you have to avoid the enemies and shoot them.

For now, you can control start/stop (Up arrow) but not when it is finished.

To do:
AI (Static enemies at the moment)


Issues:
Collision doesn't seem to work
If you shoot while moving, you have to change direction to release bullet.
If you repeat shoot, the first bullet disappears
Bullet is to the left of ship

Any help would be much appreciated, as I am still fairly new to dbpro.

Game is attached.



Matt

Umm...

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 21st Sep 2010 01:57
I have made a number of edits to your code and have inserted comments to help you with it. You don't need the backdrop on, as you are not using 3D objects. Also, you don't need to keep re-defining the sprite offsets in your game loop - just set them once and that's all normally.

Using sprite collision is not the greatest, but I put it in here just so you can see something. I normally use 'box' collision, which looks at the sprite's X & Y position along with it's width and height and checks to see if another sprite is in the same space.

Don't forget that when you use a function, the variables are local unless you tell it otherwise.

I didn't know what you wanted to do for the enemy movement, so I have them start off the screen at the top and move downward. This is easily changed.

I also gave the player three bullets, and got the positioning right.

Anyway, here is the code I put together:


Computers do exactly what you tell them.........don't you hate that sometimes?
Game Master1330
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 21st Sep 2010 13:07
Thanks for the help!
I need to look through this and learn =D

The reason I had a backdrop is because the ship sprite has a black background.

Matt

Umm...
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 21st Sep 2010 16:38
You're welcome. I made some more changes to help it run better and look a little cleaner:



Computers do exactly what you tell them.........don't you hate that sometimes?

Login to post a reply

Server time is: 2024-11-23 07:50:24
Your offset time is: 2024-11-23 07:50:24