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 / 2d/3d space shooter

Author
Message
Sir Ollie
20
Years of Service
User Offline
Joined: 29th Sep 2004
Location:
Posted: 30th Apr 2006 12:40 Edited at: 30th Apr 2006 12:43
i am making a game that is a cross between space invaders and asteroids. I have done most of the stuff but my bullet does'nt work. It goes in the corner of the screen and moves when i move the ship. Could someone help?

Source attached

I use DBP

"Thank you, come again!"
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 30th Apr 2006 14:41 Edited at: 30th Apr 2006 14:47
If you go through your code logically you will see that it is working perfectly!
When I say perfectly, I mean that what you have written will do exactly what you have described it does.

Let's go through it together:

Sprite 999 is your bullet. It doesn't exist at all until you press the spacekey. At which point you position it on screen. However, you are positioning it at the objects co-ordinates, which causes a problem:

Sprites (your bullet) use screen co-ordinates.
Objects (your Ship) use world co-ordinates.

There are two ways around to get around the problem.
1) Position the bullet at the objects screen co-ordinates by using the OBJECT SCREEN X() and OBJECT SCREEN Y() commands.

or

2) (preferred method) Don't use a sprite for your bullet ... it causes problems with positioning (as we have mentioned) but it will also make collision detection unneccesarily awkward. Instead make a plain and texture that with the bullet image. You can then position it as you would any other 3D object.

There are several other errors with your code. The bullet wont move as you would expect. Nor will it ever disappear.
Also this line:
When the help file says image number it doesn't mean for you to type in 'image number', you are supposed to supply the number which references the image that you want to use for you particles.


TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 30th Apr 2006 16:14
There's also a tutorial on the different methods of shooting bullets on my web site if you are still not sure about it. (Link at bottom of my post).

TDK_Man

Sir Ollie
20
Years of Service
User Offline
Joined: 29th Sep 2004
Location:
Posted: 30th Apr 2006 19:26 Edited at: 30th Apr 2006 19:29
its now


but when i press the spacebar it comes up with an error message - "object already exists at line 52"

sos

by the way i used the dbp help example for the particles - thats why it said "ImageNumber"

"Thank you, come again!"
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 30th Apr 2006 21:23 Edited at: 30th Apr 2006 21:28
Yes, it would do!

Every time you the press space bar, you try to make object 999. You can't do that. You need to make it before your main loop and only position it when you want to use it.


and ...
Quote: "i used the dbp help example for the particles - thats why it said "ImageNumber""

... and quoting myself:
Quote: "When the help file says image number it doesn't mean for you to type in 'image number', you are supposed to supply the number which references the image that you want to use for you particles."

That's why you don't

I recommend that you read TDK's bullet tutorial. If your eyes can handle the horrendous colour scheme on his website then you will find some pretty useful info there.


Sir Ollie
20
Years of Service
User Offline
Joined: 29th Sep 2004
Location:
Posted: 1st May 2006 10:58
ty

"Thank you, come again!"

Login to post a reply

Server time is: 2024-11-26 21:27:41
Your offset time is: 2024-11-26 21:27:41