Hey fellow gamemakers!
My problem is the following. I have an object moving with speed 1 moving in direction 0.
STEP EVENT
x += x_lengthdir(1, 0);
y += y_lengthdir(1, 0);
So far so good! now I want the object to maintain constant speed, while being able to move it up or doen aswell.
if(arrow_up){
x += x_lengthdir(1, 90);
y += y_lengthdir(1, 90);
}
Once again so far so good, it moves diagonally forward. Now where my problem occurs is when I have diagonal constant movement, and need to be able to have the same turn angle and speed when turning.
STEP EVENT
x += x_lengthdir(1, 315); // Right bottom
y += y_lengthdir(1, 315); // Right bottom
So far so good, it moves diagonally right bottom.
if(arrow_right){
x += x_lengthdir(1, 315+90);
y += y_lengthdir(1, 315+90);
}
This dosent work, as when I hold the key, the object moves staight at direction 0, if I set vales to 45 degress,
it increases speed, which I dont want, I need to to maintin same as for horisont movement.
How do I go about this the right way for the diagnal movement and turning?
Dev_M
My problem is the following. I have an object moving with speed 1 moving in direction 0.
STEP EVENT
x += x_lengthdir(1, 0);
y += y_lengthdir(1, 0);
So far so good! now I want the object to maintain constant speed, while being able to move it up or doen aswell.
if(arrow_up){
x += x_lengthdir(1, 90);
y += y_lengthdir(1, 90);
}
Once again so far so good, it moves diagonally forward. Now where my problem occurs is when I have diagonal constant movement, and need to be able to have the same turn angle and speed when turning.
STEP EVENT
x += x_lengthdir(1, 315); // Right bottom
y += y_lengthdir(1, 315); // Right bottom
So far so good, it moves diagonally right bottom.
if(arrow_right){
x += x_lengthdir(1, 315+90);
y += y_lengthdir(1, 315+90);
}
This dosent work, as when I hold the key, the object moves staight at direction 0, if I set vales to 45 degress,
it increases speed, which I dont want, I need to to maintin same as for horisont movement.
How do I go about this the right way for the diagnal movement and turning?
Dev_M