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.

Author
Message
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 8th Jun 2003 09:35
I'm working on a shooter game, and I've finally gotten to the part where I need to implement bullets and their collision vs. enemies. However, I cannot figure out a way to keep my shooter from turning into the one that came with DBPro (no offense to it, I took part of the character movement from it) where you cannot shoot more than once until the bullet dies.

I noticed the command "clone object" and thought that might have some relation, but I couldn't produce a working solution using it. I thought I might have to use a function, but even then I'm still confused.

If all else fails, is there possibly any way to check if the enemy is in the crosshair and if the mouse was clicked during that time to execute the corresponding code?

My game code is attached. Any other suggestions about the game not relating to this subject would be appreciated as well.

(PS: Sorry for posting so many threads and such on this game. It's my first game and I'm definitely still learning.)
OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 8th Jun 2003 11:32
What i do is set up an array of how many bullets I want and load the bullet x amount of times.

then I have a counter say set to one, when the bullet is fired I increment the counter and that is the nect bullet available for shooting.

I also check the distance from the bullets original firing position and if the distance is over an amount i hide the bullet.

When counter gets to the last bullet I reset the counter back to the first bullets number.


Regards to the cross Hair what I do is model an object which is just a huge 3d line a box that is say (1,1,1000) every frame I set that object to the cameras position and cameras orientation and then (if the object is say 1000 units long) move it 500, reason for this is so that it doesn't detect collission behind you.
I also hide the object so it is not visible.

At this point you have an object sticking directly ahead of you at all time, then just check collision against this object. works a treat for me...

I hope you can understand my babble,

regards,

OzBot
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 8th Jun 2003 11:48
I think I understand. So I would have something like

if mouseclick()=1 and object collision hit(1,2)
blah blah
blah
endif

?
Or am I not understanding correctly?
UberTuba
23
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Brittania
Posted: 8th Jun 2003 12:27
dim bullettime(30)

if spacekey() = 1
bnum = bnum + 1
if bnum = 31 then bnum = 1
position object bnum,{where u want the bullet to be fired from}
set object to object/camera orientation bnum{,other objectnum}
endif

for t = 1 to 30
if bulletime(t) > 0
move object t,{speed}
{collision rotine,if object collision bultime(t) = 0 etc etc}
endif

Life is a terminal disease.
You never survive it.
OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 8th Jun 2003 12:44
Yes but that method you seem to be describing will be an instant hit if the enemy collides with the aiming object. You wouldn't need to make any bullets with this method, but it should work.


I have bullets moving (so you see them) and check the collision on the bullet.

What i use the aiming object for is to check if something is in the crosshairs.

If an object is in the crosshair than the crosshair will change from green to red, if the red is displayed for a set time than another sprite is displayed signifying Lock on then if you right click missiles will lock on to the object that is in the cross hairs.
If the object is not locked on then the missile just flys straight ahead.


For bullets I always set them to the cameras position and cameras orientation and make them visible when the mouse1 button is clicked. Then another bit of code moves the bullet if the bullet is visible.
Then I do object collision on the bullet and enemy. The bullet will move in the direction of the crosshair.

So it depends on what you want to do if you are doing if your firing a machine gun, rifle or pistol then your method is best as you won't want a delay. If your firing rockets then you will need to do collision on the rockets as you will want to see the rocket fly towards the object. I am making a space game so I want to see the laser trials in space fly towards the enemy.

But yes what you have said is correct for instantaneous hits when in the crosshair.

Regards,
Ozbot.
OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 8th Jun 2003 12:46
My response above is to MasterInsan0, just so there is no confusion.
UberTuba
23
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Brittania
Posted: 8th Jun 2003 13:00
this is the uncompressed source from theimportant part's of my
no media asteroids game- feel free to use it

Life is a terminal disease.
You never survive it.
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 9th Jun 2003 07:56
Darkfluff that's an awesome game! *hehe*

Pneumatic Dryll
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 12th Jun 2003 13:04 Edited at: 12th Jun 2003 20:45
Ok, I've been taking a few cracks at it. As a matter of fact, I've been working on it all night long. And, well, here's what I have now. This doesn't work at all.

You'll probably just have to load this to see what is going wrong, because I don't honestly even know. It doesn't seem to be consistant. However, sometimes the bullet will load to the right of the camera and not move. Sometimes the bullet either just doesn't load or moves too fast to be seen. I think it doesn't move when I have the speed at around 10, but at 50 (that's the only other speed I tried it at other than 200) it just doesn't appear.

I really have no idea what I am doing, and I had a lot of trouble applying darkfluff's code to my game in any way. I guess I'm just not good enough to figure it out yet.

My code is posted. Does anyone have absolutely any idea what's going up with this?
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 12th Jun 2003 23:03
Can anyone help?
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 13th Jun 2003 10:29
Alright, after working with it for a while, I have a moving aiming line. It follows me, but it won't follow my camera angle movements. For example, I can't point it, I have to position myself to where it will collide, and then click to kill it. It will move forwards, backwards, left, and right, but it won't follow my looking. How can I get it to do that?

The code included in my subroutine for the gun control.
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 13th Jun 2003 20:07
Here's how I would do it-

: Have an array to hold the "birth" time of the bullet

: Every loop:

- check which bullets have exceed their life and destroy them
- move any bullets which are still "alive"

- IF the user is firing create a new bullet, storing the current time in an array.

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 14th Jun 2003 01:48
I hate psuedo-code (I can't fill in the stuff you leave out very well), but thanks David, I'll try it.
OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 14th Jun 2003 12:45
I recommend that the bullet objects are all loaded before firing them. I.E Don't load them when the mouse button gets clicked..


regards,
OzBot
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 14th Jun 2003 14:50
Quote: "I hate psuedo-code (I can't fill in the stuff you leave out very well), but thanks David, I'll try it."


Pseudo-code presents ideas on how to do things, not simple templates for people to fill in.

It's a good exercise to try and code something yourself from an idea. It gest you thinking: "well how do I do that? in what way could I acheive this?" instead of just recieving heaps of someone else's code ready for you to slot into your game.

Plus, my bullet code is too heavily integrated into my game. BUt is you really want it, here it is:


endfunction Distance#

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 14th Jun 2003 14:50
...well you know to include the last line.

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....

Login to post a reply

Server time is: 2026-07-17 19:33:31
Your offset time is: 2026-07-17 19:33:31