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 / A Bullet Problem That Makes No Sense!!! (DBPro)

Author
Message
Allanon Shadeslayer
17
Years of Service
User Offline
Joined: 28th Dec 2006
Location:
Posted: 1st Mar 2007 19:30
Hi.

I'm making a tank game. So, Naturally, I need bullet code.

Here's what I have so far


Now, I thought this would work but it doesn't. For some reason when I fire the bullet moves the direction I want it to but when I move my tank at all the bullet just stops and I'm pretty sure I'm using the right axis.

Just in case, here's my entire code.


If at first you don't succeed, lower your expectations.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 2nd Mar 2007 03:23 Edited at: 11th Mar 2007 19:57
A few observations which may help you:

I'm sure you've been told this before, but another reminder...

Use indentation!

You also need to read up on procedures and use them.

This will make your code a lot easier to read and follow - especially if you want others to figure out what is wrong with your programs.

Then there's For..Next loops when creating objects.



could be done with



You use color backdrop rgb(0,0,0). Although you could have used color backdrop 0, on the next line you turn the backdrop off.

You shouldn't set up players 1 and 2 in the main loop. Their health values will be set to max 60 times per second!

As for your bullet problem, you appear to be basing the bullets position and rotation on other objects. You should have separate variables (or arrays if you want multiple bullets) to store the positions.

Take a look at my tutorial on 2D firing to see how this is done - the method is exactly the same for 3D, but with an added axis.

TDK_Man

Allanon Shadeslayer
17
Years of Service
User Offline
Joined: 28th Dec 2006
Location:
Posted: 3rd Mar 2007 01:17
Thank you. That's a lot of useful information that I will definitely use.

If at first you don't succeed, lower your expectations.
Allanon Shadeslayer
17
Years of Service
User Offline
Joined: 28th Dec 2006
Location:
Posted: 11th Mar 2007 02:36
Is this better?





If at first you don't succeed, lower your expectations.

Login to post a reply

Server time is: 2024-09-25 19:26:09
Your offset time is: 2024-09-25 19:26:09