Grapple Gun

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

Grapple Gun

Postby jimmynewguy » Thu Jul 14, 2011 9:33 pm

I've always wanted to implement a grappling gun into a game, but never did. So I got bored and made one for kicks, and thought I'd share.
Attachments
Chain.zip
(48.64 KiB) Downloaded 383 times
screen.PNG
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Grapple Gun

Postby Hblade » Thu Jul 14, 2011 9:39 pm

interesting! :) I remember a long time ago, sgt.sparky made something similar. Good job :D I'd never understand the physics of it.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Grapple Gun

Postby jimmynewguy » Thu Jul 14, 2011 9:51 pm

Haha, it's okay. But there really aren't "physics" to it. Plus I like trying to explain things so I'll try for you (and anyone else) line by line;

Code: Select all
int num = distance(player.x, player.y, mouse.x, mouse.y)/6;

This makes the variable num = the number of chains we need to get from point a to point b. It's the distance/6 because a chain is 6 pixels long.
Code: Select all
int i;

makes the variable i for the loop
Code: Select all
angle = direction(player.x, player.y, mouse.x, mouse.y);

gets the angle that the player will be heading
Code: Select all
if(!hooks)

If we don't have any hooks (so you cannot just keep shooting)
Code: Select all
breaks = 0;
player.angle = angle;
player.directional_velocity = 6;

all this together because its simple. We reset the breaks variable in case it was triggered last shot, set the player's angle, and make him go
Code: Select all
for(i=0;i<num;i++)

a loop for the number of chains
Code: Select all
Actor * this = CreateActor("hook", "chain_01", "(none)", "(none)", player.x, player.y, true);

make the chain at the player's and y and make it called "this" temporarily
Code: Select all
this->angle = angle;

set the chains angle
Code: Select all
this->directional_velocity = 7.5 * i;

make it as fast as it's number. In other words were making it 7.5 pixels away from the last created chain (7.5 so theres a little gap between chains for visual)
Code: Select all
this->animpos = angle/10;

set the chain's animation position

then when the chain is drawn we stop it from moving in the draw actor script and when there are no more hooks the player has gravity in his draw actor

sorry hblade I know some of that is obvious to you since you've used GE before, but others might not understand. I never saw sgt. sparkys though, his was probably better since mine doesn't have a distance limit and you can sometimes go through the ground a little if shot at the right angle. It would just make it more confusing for an example if I did all that though
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Grapple Gun

Postby Hblade » Thu Jul 14, 2011 11:29 pm

Thank you so much :) And hehe, I dont really have a lot of time to program so that tutorial was helpful in more ways than 1. You know how to explain things pretty good :) Thanks
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Grapple Gun

Postby jimmynewguy » Thu Jul 14, 2011 11:35 pm

No problem! Thanks for actually downloading things I make :) nothing's worse than no replies, I'd rather have people say it sucks!
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Grapple Gun

Postby Hblade » Fri Jul 15, 2011 6:53 am

Lol I know that feeling :P
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Grapple Gun

Postby Jagmaster » Sun Jul 17, 2011 2:56 am

Haha, Sweet!

I would have replied but my internet was down XD.

Mind if I use? I think it would make a good vine or rope or something like that. How would you make an actor "Stick" to a vine anyway? I tried dissecting (Or mutilating :P)
Dst's snake bone thing and having the player parent on to one of the bones. That did not work :(. Any suggestions?
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score

Re: Grapple Gun

Postby sunnybubblegum » Tue Jul 19, 2011 9:28 am

Super neat! I was having fun trying to swing non-stop.

How hard would it be to make it so that you can travel only part of the chain's distance? Like say on left-click up, the chain disappears and you're free to grapple to another spot. Do you see what I mean?

I like the look of the animations as well. Great job!
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score

Re: Grapple Gun

Postby jimmynewguy » Tue Jul 19, 2011 11:53 am

Super Easy.

On mousebutton up-> left
Code: Select all
DestroyActor("hook");
hooks = 0;
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Grapple Gun

Postby SuperSonic » Thu Jul 21, 2011 2:10 am

Wow, I'm very impressed. I tried to do something like this before but badly failed Image
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Grapple Gun

Postby happyjustbecause » Mon Apr 02, 2012 10:27 pm

Excuse me for the huge bump, but I was wondering if I could maybe use the chain animations that you have. And maybe some of the coding for this grapple gun, to work on my own.

So I got bored and made one for kicks, and thought I'd share.


You probably don't mind at all, but I just want to make sure.
For small creatures such as we the vastness is bearable only through love.
-Carl Sagan

Night Knight Development Thread
User avatar
happyjustbecause
 
Posts: 267
Joined: Tue Jul 26, 2011 3:10 pm
Location: Frazier Park, Ca
Score: 15 Give a positive score


Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest

cron