The Daily Click ::. Forums ::. Klik Coding Help ::. Grenade physics
 

Post Reply  Post Oekaki 
 

Posted By Message

Plooscva



Registered
  25/10/2006
Points
  149

Has Donated, Thank You!
20th July, 2008 at 17:55:55 -

Well, basically I am creating a platformer/shooter, and it's come to a point where I'd like to implement grenades into the gameplay. The problem is - I haven't got the slightest idea how to code the grenade's physics. The top priorities are that you can choose the direction to throw in, speed/power, the fall/gravity of it, collisions with the walls. What I'd appreciate the most is for someone to actually code such physics so I can see how it's done, understand it and then modify it further to my needs, I doubt I'd understand it if someone would explain how to do this to me.

Ploo

 
n/a

-Dark Martin-

The dark is most certainly not your friend

Registered
  05/06/2008
Points
  21

Has Donated, Thank You!KlikCast StarSonic SpeedWii Owner360 Owner
20th July, 2008 at 20:27:00 -

Meh, i would just use Pinball movement

 
<a href="http://s50.photobucket.com/albums/f315/Martin_Bodger/?action=view¤t=signature_stripcopy.png" target="_blank">Image

Codemonkey

Always Serious

Registered
  06/11/2007
Points
  164

Code MonkeyKlikCast StarVIP MemberAttention GetterWii Owner360 OwnerThe Cake is a LieCardboard BoxHero of TimeI'm a Storm Trooper
I'm on a BoatIt's-a me, Mario!PS3 OwnerSonic SpeedGOTM - SEPTEMBER 2009 - WINNER!Evil klikerPokemon Ball!I am an April Fool
20th July, 2008 at 20:28:17 -

That's just asking for bugs, I wouldn't do that.

Image Edited by the Author.

 
You can log off any time you like, but you can't ever leave.

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
21st July, 2008 at 01:00:24 -

Firstly, I'm sure I've seen many examples of this before - suggest you search the forums/articles/downloads here and at the clickteam website.

Anyways, I knocked up a quick example for you - hope it helps

http://www.angelfire.com/mech/banshee/Grenade.mfa
(you may need to copy&paste link - I don't know how angelfire is about hotlinking)


Limitations;

Currently only supports 1 grenade on screen at a time (you'd need to fastloop through all grenades otherwise). You can probably get away with just limiting the rate of fire so the last grenade will have exploded before the player can throw another.

The bouncing will only work with horizontal and vertical walls. If you want proper bounces off walls at other angles it becomes a fair bit more complicated (every face of every wall must be a separate active object with its angle stored in an alterable value). If you *really* need it let me know, but like I said, it's more hassle both in terms of the number of objects needed and of the complexity of the events.

EDIT: hope you've got MMF2 after all that! If not I guess I could convert to MMF1 (don't have TGF or anything else though)

Image Edited by the Author.

 
n/a

Plooscva



Registered
  25/10/2006
Points
  149

Has Donated, Thank You!
24th July, 2008 at 11:13:02 -

Yeah, I got MMF2, thanks for the example and your time. =]

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th July, 2008 at 16:03:01 -

no problem. let me know if you need anyhting explaining.

by the way; line 36 should read "alterable value C = 100" not 150.

Ideally you want to use fastloops to move the grenade only a pixel or two at a time, before checking for collisions (stops it going through very thin walls when moving fast). Depends on the game though - might not need to.

 
n/a

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
25th July, 2008 at 08:04:07 -

I was going to write something on it but I was lazy and found an old guide to doing klik physics here: http://www.create-games.com/article.asp?id=1594

Should help you if you want a little more physics than just grenades

 
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

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
25th July, 2008 at 10:28:03 -

"found an old guide" lmao YOU wrote it

 
n/a

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
30th July, 2008 at 14:50:55 -

Lol, it's better that way. It says exactly everything I was going to say!

 
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
   

Post Reply



 



Advertisement

Worth A Click