P
Pendy
Guest
So I have a platformer game project in mind that has a grappling hook system. I have made a "gun" and a crosshair that moves up and down. The Issue is I would like to have the maximum angle of the crosshair to 90 and 270. So that you can't aim behind yourself. Also when you turn around the crosshair would basically flip too.
I am very new to game maker and programming so proper explanations would be appreciated.
If my explanation didn't help. basically like in Worms games.
Guns code:
Crosshair Create Event:
Crosshair Step Event:
Thank you in advance! And if you have any questions please ask away!
I am very new to game maker and programming so proper explanations would be appreciated.
If my explanation didn't help. basically like in Worms games.
Guns code:
GML:
x = o_player.x
y = o_player.y +1.5
image_angle = point_direction(x,y,o_crosshair.x,o_crosshair.y);
GML:
Orbit = 20; //Orbit distance
Angle = 0; //Angle set
Speed = 3; //Orbital speed
GML:
//Orbital motion
if (keyboard_check(ord("W"))){
Angle += Speed //Orbit Counterclockwise
if(Angle > 360) Angle -=360; //keep angle below 360
}
if (keyboard_check(ord("S"))){
Angle -= Speed //Orbit Clockwise
if(Angle < 0) Angle +=360; //keep angle below 360
}
//Update position
x = lengthdir_x(Orbit,Angle) + o_gun.x
y = lengthdir_y(Orbit, Angle) + o_gun.y
Last edited by a moderator: