• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Grapple with sprites

I

Insidious Crow

Guest
I’m fairly new to gamemaker studio 2 and want to create a rope swing type game but I want to texture the rope and grappling hook with sprites instead of just drawing a line between two points. I also want the rope to shoot out and extend until it hits a surface instead of just appearing.
Please help.
 
T

Taddio

Guest
What do you have so far?
I would do an obj_target, an obj_hook and a variable hooked. When you fire obj_hook with a button and if both obj_hook and obj_target collision, set hooked to true and allow the player to use the rope.
As for the rope itself, lenghtdir would he useful, as well as some sine (or whatever looks/feels good) function for the swinging.
Jumping off the rope according to it's swing could be a little more involved if you want it super smooth.
I'd say it's one of those easy-ish to do at it's basic form, but hard to really nail down to feel smooth and fluid. Will probably require quite a bit of tweaking, especially if you're just starting out.
 
I

Insidious Crow

Guest
So far I literally just copied Shaun Spalding’s rope swing tutorial. So based on that I know how to make a simple rope swing mechanic and I already know how to fire projectiles. What I don’t know is how to combine them together and how to stretch an object/sprite to simulate the rope extending.
 
I

immortalx

Guest
Since you want to use a sprite for the rope, it won't look at all like a rope texture if you stretch it enough.
A solution is to draw several sprite segments with a seamless pattern until you reach the target. To account for the times that these segments don't exactly fit the distance, you could do a little setup:
Say your base rope sprite is 64x8. You can add some subimages, each one half the width of the original (32,16,8,4).
You can then calculate how many "whole" segments fit between the player and target (make sure to round the distance) and draw them (each one drawn at the end of the previous). Take the remainder and check if one of your subimages fits exactly, or has an overlap of no more than the width of the smallest subimage. If there isn't any, draw the subimage with the second biggest width, again checking for an exact fit or an overlap of no more than the width of the smallest subimage.
Depending on the distance, the above will get repeated a couple of times.

Of course you'd have to account for the drawing of the grappling hook, so you could subtract its size from the distance.
Another idea is to use draw_sprite_part and have only one sprite with no subimages.
 

JeanSwamp

Member
Sorry for resurrecting this post, but I'm actually interested in something similar to this, to make drawing a line feel a bit more dynamic and alive
 
Top