The Daily Click ::. Forums ::. Klik Coding Help ::. Bow and arrow Adding Gravity
 

Post Reply  Post Oekaki 
 

Posted By Message

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  374

VIP MemberCardboard BoxThe Cake is a Lie
9th November, 2008 at 23:05:56 -

What I think I should do for a Bow is: "Upon pressing (a button)" Make active 1 Shoot Arrow in direction of Active 1. The Arrow itself will have Gravity added to it, using either Vector movement, or Platform movement. Any other suggestions?

 
An old and washed up once-kid

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
9th November, 2008 at 23:25:49 -

when you shoot the arrow, give it both X & Y velocities as variables. Use an "Always: Position = Position + Velocity" event for both X & Y. Then, always add 1 or whatever to the Y velocity, which simulates gravity downwards.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  374

VIP MemberCardboard BoxThe Cake is a Lie
10th November, 2008 at 02:21:23 -

Thx man, I hate using the Position = position + velocity thing, cause I'm not so hot at it. Anyway- thanks for the answer. I might try that.

 
An old and washed up once-kid

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
11th November, 2008 at 11:07:24 -

It's simple Newtonian physics. But very complicated physics if you haven't learned it yet

Anyway, the position+velocity thing is the easiest way to do it. Use the move safely object too, to prevent it from going through stuff.

My game uses it almost entirely, combined with the MMF built in engine:
http://smuzani.googlepages.com/cwsource.zip

I left the source code open so you guys could take it apart and look at how it works. I learned most of what I did by taking apart other people's code.

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  374

VIP MemberCardboard BoxThe Cake is a Lie
11th November, 2008 at 16:05:41 -

Sure enough, but I don't have the full version of MMF2 I was going to get some help on paying for a PS2 for christmas (PS3s are WAY out of my budget! ), and the full version of TGF2. And then I realize that MMF2 is more advanced (and more costly)than TGF2. So instead of the PS2 THAT I'VE BEEN TRYING TO SAVE UP FOR... May just have to wait. I think I'd rather have MMF2. As for the PS2, I wanted Kingdom Hearts, Kingdom Hearts II, Guitar Hero, Rock Band (DRUMSET?! ALRIGHT! ),and Sonic Riders: Zero gravity.




Decisions decisions...

 
An old and washed up once-kid

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
11th November, 2008 at 17:59:41 -

make sure you don't get MMF2 developer, just MMF2 standard. Many people have made that mistake; the only *real* difference is that MMF2 developer has a few less legal obligations for selling commercial products, which won't matter to you. And thats a big "not" difference for $200

as far as the velocity stuff; its very easy to make the X = X + V stuff work, its not complicated at all. However, finding out how to AIM the arrow, thats complicated. Very complicated. Theres some funky physics formulas that can reverse newtonian velocities, and you need to do trigonometry to convert a *DIRECTION* to *X/Y VELOCITIES* so yes it can be a little work

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  374

VIP MemberCardboard BoxThe Cake is a Lie
11th November, 2008 at 19:06:15 -

Yeah. MMF2 developer is WAAAAAAY out of my budget . I'll get either of the two (preferably MMF2... ).

And about the bow and arrow, it won't be controlled by mouse movement. It'll just be in two directions, as a basic attack used by an active object on Platform movement.

Anyways, thanks for the help!

 
An old and washed up once-kid

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
11th November, 2008 at 19:30:17 -

if you have X & Y velocities, and a constant Y acceleration for gravity, then to get from sitting still at point (X1,Y1) to some point (X2,Y2) at a constant projectile speed S, than first you set some variable D to Sqr((X2^2 - X1^2) + (Y2^2 - Y1^2)), for distance, than you set the X velocity to ((X2 - X1) / (D / S)), thats the easy part, than you find the Y parabola so the intercepts are X1 & X2, which are 0 & (X2-X1) relative to the initial point, so using Y = 0 = Y_velocity * T - Gravity * T^2, where T = (D/S), the point where X position is now at X2, we solve for Y = 0, which would be Y_velocity = (Gravity / (D/S)), thus we have:

Given (X1,Y1) & (X2,Y2)
D = Sqr((X2^2 - X1^2) + (Y2^2 - Y1^2))
S = Projectile speed in Pixels/Seconds, for overall movement
gives:
X velocity = ((X2 - X1) / (D / S))
Y velocity = (Gravity / (D/S))

mostly copy/pasted that from earlier work, hope its still right. Complicated, eh?

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
11th November, 2008 at 19:33:31 -

damn I made a few mistakes back then. That will only work from same Y level to same Y level, and I forgot to double gravity when I integrated. I'm gonna churn out a new one,sec

Image Edited by the Author.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
11th November, 2008 at 19:41:27 -

Given (X1,Y1) & (X2,Y2)
D = Sqr((X2^2 - X1^2) + (Y2^2 - Y1^2))
S = Projectile speed in Pixels/Frame, for overall movement
gives:
X velocity = ((X2 - X1) / (D / S))
Y_velocity = (Y2-Y1)/(D/S) - (Gravity *(D/S))/2

Ok thats the one that works

That can make enemies shoot projectiles that will ALWAYS arc towards the player, instead of shooting straight at him, or whatever. Very useful for making nifty little tanks in those flying-spaceship games that run along the ground and lob cannon balls up at you, or stuff like that.

Image Edited by the Author.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
11th November, 2008 at 19:58:55 -

you know what? how about just trying this out:
http://claniraq.googlepages.com/Projectile.gam
Made it in TGF, so you can run it even if you don't have MMF2, you just need the AMATH object

yup quadruple post

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  374

VIP MemberCardboard BoxThe Cake is a Lie
12th November, 2008 at 00:02:51 -

Sorry I was gone awhile, Can't remember what I was doing warlier but Oh well. Yeah, that stuff could work, but if this changes the topic (Guess I should've said this earlier. CRAP. ) it'll be the feature for a UI controlled active, on Platform movement of course. I'm not so hot at the expression editor. I'm not really a pro, but I'm not a beginner either. I'm kind of in between those two .

 
An old and washed up once-kid

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  374

VIP MemberCardboard BoxThe Cake is a Lie
12th November, 2008 at 00:11:43 -


Originally Posted by Drawcula
Yeah. MMF2 developer is WAAAAAAY out of my budget . I'll get either of the two (preferably MMF2... ).

And about the bow and arrow, it won't be controlled by mouse movement. It'll just be in two directions, as a basic attack used by an active object on Platform movement.

Anyways, thanks for the help!



When I said either of the two, I meant TGF2 or MMF2. In case you were wondering.

 
An old and washed up once-kid

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
12th November, 2008 at 03:53:57 -

I have developer but I want to sell commercial applications and games

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  374

VIP MemberCardboard BoxThe Cake is a Lie
12th November, 2008 at 17:10:48 -


Originally Posted by Assault Andy
I have developer but I want to sell commercial applications and games

I would too... but I don't really want to buy Developer that bad, if at all. So I'm just gonna get MMF2.

 
An old and washed up once-kid
   

Post Reply



 



Advertisement

Worth A Click