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 / Help with shooting!

Author
Message
BowserYo
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 3rd Aug 2009 21:49
Hi, I'm making a basic side scroller and I'm attempting to make my gun shoot. But for some reason, it only makes the bullet, but doesn't move it...



Am I missing something??? Please help! Thanks!

ßõw§€r¥¤
Softwizz
15
Years of Service
User Offline
Joined: 14th May 2009
Location: U.K.
Posted: 4th Aug 2009 00:13


This needs to be called more than once.
What you should be doing is having a variable that is set to 1 when the bullet is active and set to 0 when the bullet has gone, hit a target or whatever.
Then in the main loop you would have something like:


Nothing to see here, move along please.
BowserYo
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 4th Aug 2009 02:15
Oh okay! Thanks a lot! I'll give that a shot!

ßõw§€r¥¤
BowserYo
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 4th Aug 2009 03:32
Okay it will now move the object, but as soon as I shoot again it stops the bullet it was moving before to move the new one...



ßõw§€r¥¤
Softwizz
15
Years of Service
User Offline
Joined: 14th May 2009
Location: U.K.
Posted: 4th Aug 2009 17:25
Cant see from the code you have posted as I dont know when these subroutines are called.
Quote: "Move Object bullet,bulletspeed#
"

Looks like the problem, when a bullet is made it has the identity 'bullet'
When a new bullet is made it is given the same identity even though it has a different object number you are still referring to it as bullet.

Nothing to see here, move along please.
BowserYo
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 4th Aug 2009 18:37
Quote: "when a bullet is made it has the identity 'bullet'"


Yes I think that the problem... "bullet" is the next lowest free object number, and it increases everytime a bullet is made so my "move object bullet,bulletspeed#" only applies to the last bullet made... Any ideas how I should fix that?

This is my first game where my gun actually shoots an object...

Incase this helps, this is my code:



Thanks a lot!!

ßõw§€r¥¤

Login to post a reply

Server time is: 2024-09-28 08:19:04
Your offset time is: 2024-09-28 08:19:04