U
Undead Hero
Guest
Uh, sorry for the weird title, but I couldn't think of how to sum this up.
Basically, I'm making a game where an object travels to the right shmup style, but you use the mouse to direct it up and down. Here is the basic code:
The variables are excessive just because a lot of other functions will be added later.
This works, and keeps the object within the play area, but obviously it also makes the object teleport to the mouse wherever you click. The goal is to make the object "float" to the mouse (y position only), then function the same as the previous grab code.
The problem is, I tried using this to accomplish that (in place of the previous grab code):
But this makes the object slide seemingly randomly to the right along the x axis in weird fits. And when it hits the top or bottom boundary, it slides smoothly to the right. How can I use code like this without affecting the x movement of the object? My limited GML knowledge hits a wall.
Basically, I'm making a game where an object travels to the right shmup style, but you use the mouse to direct it up and down. Here is the basic code:
Code:
x += spd;
if mouse_check_button(mb_left) {
ObjectGrabbed = true;
} else if mouse_check_button_released(mb_left) {
ObjectGrabbed = false;
}
if ObjectGrabbed = true {
y = median(RoomTopY, mouse_y, RoomBottomY)
}
This works, and keeps the object within the play area, but obviously it also makes the object teleport to the mouse wherever you click. The goal is to make the object "float" to the mouse (y position only), then function the same as the previous grab code.
The problem is, I tried using this to accomplish that (in place of the previous grab code):
Code:
move_towards_point(x, median(RoomTopY, mouse_y, RoomBottomY), spd);