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.

DarkBASIC Discussion / how do you make a grenade throw

Author
Message
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 21st Feb 2004 23:30
can anyone tell me how to make a grenade throw not just go straight like throw up and gradually drop you know like when you throw somthing

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 22nd Feb 2004 03:54
You will need to use Sin and/or Cos and/or Tan to create a curve so that when you throw the object, you can determin it's height.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 22nd Feb 2004 04:02
@jess if you want it to go in a forever loop you would use sin/cos/tan

well for when you trow it make it point at a certain angle then make it gradually point toward the ground, and adjust the speed according to the angle

of course thats the cheap way to do it, it could be much more complecated but im to tired to explain

John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 22nd Feb 2004 05:58
Using SIN COSINE and TANGINE functions along with gravity and speed agrothims you could mathematically determine the arch and falling speed of the object and create a path from these calculations...too many maths to explain at 11 PM tho...time for bed


We need help! Email us! [email protected]
Floyd
21
Years of Service
User Offline
Joined: 11th Sep 2003
Location:
Posted: 22nd Feb 2004 07:42
You will have 3 components of velocity and only one (the vertical component) is affected by gravity. Uh, actually I've forgotten whether the vertical component is y or z for DB ( my applications seem to alternate, the next one I get will be opposite of the one I got last). For the x component and the other horizontal component, you can just figure out some convenient deltaX and deltaZ, say, that you add to the current position to get the next position. The vertical component will conform to the equation:

y = initial_height + (initial_vertical_speed * time) - 1/2 * g * t^2

where g = 32 feet per second per second or 9.8 meters/sec^2 I think.
I suppose you would use trig functions to derive the components of velocity from your initial heading.

To get true bounces off any object you might hit, you would probably have to use one of the collision add-ons, but you could probably fake pretty good bouncing by just checking ground height and checking for collisions.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 22nd Feb 2004 08:33 Edited at: 22nd Feb 2004 08:33
@Dark Coder, Yeah, that's a cheap/easy way to do it.

@RPGamer,
Quote: "SIN COSINE and TANGINE"


lol, it's; Sine, Cosine and Tangent... Just so you know.

@Floyd, yeah, you got it, Y is the vertical axis for DB, and the force due to gravity is 32ft.sec^-2 or 9.8m.s^-2.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 23rd Feb 2004 04:10
like this:


i didnt make this, it was phaolax or however you spell it i think

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Feb 2004 09:36
lol, close enough I suppose.

"eureka" - Archimedes
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 23rd Feb 2004 12:15
Won't sin cos tan make an infinite wave? Can't we just settle for quadratic equations? Faster and easier IMO, and it looks accurate enough. I don't know how to go about bouncing it on walls though.

zane
21
Years of Service
User Offline
Joined: 23rd Feb 2004
Location: manchester, england
Posted: 23rd Feb 2004 13:59
i would have tryed it like this
you make it move horizontaly to the ground, useing the move object command.
you then control the vertical movement seperately.
depending on the vertical angle the the grenade wants to move you set a value, and as the grenade is in flight you subtract from this value. you then set the y position of the object at object position y(x)+value. and that should work.
of cause i havnt tryed this out, so it may not.

www.zaneproductions.tk - lots of games, no Dark basic ones though (yet)!
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 23rd Feb 2004 14:49
It would work, but it wouldn't give you a proper parabolic curve... The projectile's motion is depicted by a parabola, and thus, all the equations and ideas on how to make it look as real as possible.

But, Good idea zane

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 23rd Feb 2004 16:18
can you give me a bit of code that just throws the grenade pls

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 24th Feb 2004 00:07
Darwin already did...

Man, you're getting close to CMC here...

You have to try things for yourself... try and adapt someone elses code to a specific need, and take the code apart so that you understand it...

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 24th Feb 2004 00:42 Edited at: 24th Feb 2004 00:47
my code is the best thing you are going to be getting out of this post...

oh yeah: "Won't sin cos tan make an infinite wave?"
thats calculus dude. we wont be GRAPHING them.
we're talking about physics, you have to use sin cos and tan to do stuff like this, thats how 3d crap works there are ways around it, but in the end, its really all hte same

Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 24th Feb 2004 04:26
i believe the sin and cosine would only be used to determine the magnitude of the vectors in the horizontal and vertical planes, just to clarify. you don't want to use sin and cosine for the actual movement, just the velocity of the movement, yes?

oh, wow. insignificantpunks.cjb.net. we like orange treble clef notes, just for future reference.

no: website for progs yet.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 24th Feb 2004 12:42 Edited at: 24th Feb 2004 12:43
Right on...

The direction of the velocities are just taken for granted, ie, the object will always be moving away from the camera/object ( where it was "thrown" from ) in the horizontal component, and when the apex of the curve is reached, the Direction of the vertical component is swaped in direction ( ie, if using Sin, once the result is one, then the next movement must be down [ If the grenade is thrown "up" initially that is ] ).

Hope That cleared that up for you NightGiant.
Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 24th Feb 2004 17:28
ah interesting way to do it, i was talking about just using trig at the beginning of the process to break the main velocity vector down into three vectors, one for x,y and z, then you just use v=v0+a(t) where a is gravity and t is time (just use a timer function for that, easy enough) and modify the y vector, it will automatically switch to downward motion once the y vector becomes negative, just keep incrementing the x and z vectors with a constant speed, i mean that's pretty much how it works in real life.

oh, wow. insignificantpunks.cjb.net. we like orange treble clef notes, just for future reference.

no: website for progs yet.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 25th Feb 2004 00:29
Yeah, that would work too... and give a more realistic effect, as it is using the laws of physics as it's guide.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-22 22:00:39
Your offset time is: 2025-05-22 22:00:39