943,758 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1321
  • C++ RSS
Jan 19th, 2009
0

A shoot function with DarkGDK

Expand Post »
I am making a shoot function with my game and my dad ( being the geinous programmer that he is ) suggested that i should generate an imaginary line from the gun to whatever it's aiming at and then, if the user clicks then put a bulet hole at what its aiming at.
I am using vc++
i have windows XP pro sp3
and i am using The DarkDGK engine and library

any help would be good
Last edited by tomtetlaw; Jan 19th, 2009 at 2:25 am.
Reputation Points: 9
Solved Threads: 5
Posting Pro
tomtetlaw is offline Offline
591 posts
since Sep 2008
Jan 19th, 2009
0

Re: A shoot function with DarkGDK

Is it 2d/3d ???

If it is 2d then create a line factoring in the angle of the gun and other variables don't draw it on the screen, just keep track of the end point.

In the current frame if the user click on the FIRE button, before rendering the next frame load the texture of a bullet hole in the target area.

If its 3d, schedule another talk with dad.

This is me, just "shootin in the dark" :wink.

Hope i have helped.

Edit: You are using an engine, i gave you the logic i am sorry i have no experience in DARKDGK engine.

Edit2:I assumed that the bullet travels in a straight line, from the barrel to the destination and then you stop tracking the bullet.
Last edited by d0pedup; Jan 19th, 2009 at 6:55 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
d0pedup is offline Offline
14 posts
since Dec 2008
Jan 19th, 2009
0

Re: A shoot function with DarkGDK

its 3d and yes it is a str8 line
Reputation Points: 9
Solved Threads: 5
Posting Pro
tomtetlaw is offline Offline
591 posts
since Sep 2008
Jan 19th, 2009
0

Re: A shoot function with DarkGDK

if the barrel is held parallel to the ground then
target = (x,y,z+RANGE_OF_BULLET).
if FIRE BUTTTON IS PRESSED {
load bullet hole texture at target
}
else {
do nothing
}

render frame().

I am sorry, i cant help you with gun held at an angle. Refer some books like physics for game programmers (or the documentation of your game engine).
Reputation Points: 10
Solved Threads: 0
Newbie Poster
d0pedup is offline Offline
14 posts
since Dec 2008
Jun 10th, 2010
0
Re: A shoot function with DarkGDK
I have tried this before, i found the best approach is not to use actual bullet object. Just animate the gun firing and put an aimer in the middle of the screen. From here you could test if the aimer is pointing at anything and that the gun has fired, if so place a bullet hole on the object being shot at.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
green_frog is offline Offline
13 posts
since Apr 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Combine 3 Step Process
Next Thread in C++ Forum Timeline: oop project...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC