P
Pyrokenisis
Guest
(I'm new to these forums, and to GMS2 in general, so if there is anything wrong with this post let me know!)
I've been trying to make a little minigame where you have to shift gears when prompted (like in a car). I want to be able to click and drag the handle along the paths towards the different gears, without it being able to deviate or get stuck if the mouse is a little above or below the allowed path.
Here is a crappy mockup of the idea in MS Paint to give a better idea of what I mean.
What I've tried so far is to create the handle object, with the collision mask only effecting the bottom of it, and created a solid object with a path around it, which kinda works, but feels really janky and the handle keeps getting stuck if it touches the wall.
Here is the code I was using for that:
The problems with this are that the handle can escape the path if I drag the mouse out too far, it gets stuck if I move it too quickly (even with the buffer), I can only grab it from the bottom (where the collision mask is), and the movement is not very smooth or fun (since it is just the direct mouse input with no smoothing or friction). I can only imagine that isn't the best way to approaching this problem, so any solutions (even totally different from the one I was working on) are greatly appreciated. Thanks!
I've been trying to make a little minigame where you have to shift gears when prompted (like in a car). I want to be able to click and drag the handle along the paths towards the different gears, without it being able to deviate or get stuck if the mouse is a little above or below the allowed path.
Here is a crappy mockup of the idea in MS Paint to give a better idea of what I mean.
What I've tried so far is to create the handle object, with the collision mask only effecting the bottom of it, and created a solid object with a path around it, which kinda works, but feels really janky and the handle keeps getting stuck if it touches the wall.
Here is the code I was using for that:
Code:
// Create
grabbed = false;
collisionSpeed = 2;
// Global Left Released
grabbed = false;
// Left Down
grabbed = true;
// Step
if (grabbed){
if(place_free(mouse_x + collisionSpeed, y) || place_free(mouse_x - collisionSpeed, y)){
x = mouse_x
}
if(place_free(x, mouse_y + collisionSpeed) || place_free(x, mouse_y - collisionSpeed)){
y = mouse_y;
}
}