SOLVED Help making W and S control my Aim

So in my game the Player 1 (left) uses the arrow keys to move and mouse to control the aim so the Player 2 (right) will need move using WASD, i'm trying to make him able to control his Aim using W and S for up and down and created that green aim which is just a 100x13 with the actual sprite in the end so I can create projectiles based on the Player to the Aim using point_direction.
1632569905390.png
I tried making something using image_angle but it didn't worked out, I think I should use point_direction but how to make so the x2 and y2 can be changed in real time by the Player?
 

Gamebot

Member
Image angle should work assuming that image_angle is based on your sprite origin being in the correct spot. This should be somewhere near the middle or bottom left.
Remeber that zero degrees is right and -= down ( S ) therfore, += is up ( W ). Other than that...

STEP:
Code:
if ( keyboard_check(vk_up) ) { image_angle += 1; }
if ( keyboard_check(vk_down) ) { image_angle -= 1; }
 
Last edited:
Image angle should work assuming that image_angle is based on your sprite origin being in the correct spot. This should be somewhere near the middle or bottom left.
Remeber that zero degrees is right and += down ( S ) therfore, -= is up ( W ). Other than that...

What have you tried as far as code?

EDIT:
What version are you using?
The best I could do was this:

GML:
x = oMech2.x
y = oMech2.y


var ux = (oMech2.ukey2 * camspd)
var dy = (oMech2.dkey2 * camspd)

image_angle = point_direction(x, y, ux, dy);
with the Camera Speed on create event being 9 but I don't think that's the problem, it moves some pixels but that's it. Also version is 1.4

EDIT: This is the code of the Aim btw
 

Gamebot

Member
I reposted the code above. A simple image_angle += and image_angle -= should do it. Just += or -= by your speed on each...so

STEP:
Code:
if ( keyboard_check (vk_up )) { image_angle += rotspd }
if ( keyboard_check (vk_down )) { image_angle -= rotspd }
WHEN rotspd is your camspd.

EDIT: Also remember that your spd is directly related to your game speed ( room_speed in your case ). If your game is running at 30 FPS you will travel 30 pixels per second or ( 1 pixel per step ). If your room speed is at 60 you will travel 60 pixels per second again ( 1 pixel per step ). If it's going too slow try using higher numbers such as 15 or 30. You can in your step event also do this:

GML:
camspd = room_speed;   
camspd = room_speed/3;
camspd = room_speed * 3;
 
Last edited:
I reposted the code above. A simple image_angle += and image_angle -= should do it. Just += or -= by your speed on each...so

STEP:
Code:
if ( keyboard_check (vk_up )) { image_angle += rotspd }
if ( keyboard_check (vk_down )) { image_angle -= rotspd }
WHEN rotspd is your camspd.

EDIT: Also remember that your spd is directly related to your game speed ( room_speed in your case ). If your game is running at 30 FPS you will travel 30 pixels per second or ( 1 pixel per step ). If your room speed is at 60 you will travel 60 pixels per second again ( 1 pixel per step ). If it's going too slow try using higher numbers such as 15 or 30. You can in your step event also do this:

GML:
camspd = room_speed; 
camspd = room_speed/3;
camspd = room_speed * 3;
Yeah that solved it! It was simpler than I thought actually, Thanks mate!
also thanks for the room_speed stuff.
 
Top