S
silverfrost
Guest
Hi. I'm decided to make slowmo in my game. I created an object that moves up for 2 seconds (or 4 seconds in slowmo) with increasing accelereation over time. While object moves it should travel same distance in normal and slowmo time.
In create event I have:
My default room_speed is 30. So when I slow time x2 variables are:
And in step event I have:
The problem is that object in normal time & in slowmo travels different distance while it should travel the same distance, because in slowmo it's move speed decreased according to more frames. In normal time it travels about 281 pixel and in slowmo about 520 (measured on destroy by travel_distance).
I also tried to use 1/10 second interval in alarm to increase speed, insted of doing it every frame, but have also different travel distances.
What is wrong? Is this rounding problem? How this can be fixed?
Thanks in advance.
In create event I have:
Code:
//time handle
global.time_speed = 1; //time multiplier 0.5 - x2 slower, 0.25 - x4 slower etc.
global.time_fps = room_speed / global.time_speed; //frames needed to draw 1 second of game
//start params
speed_base = 10; //pixels per second
speed_acceleration = 4; //pixel per second
speed_base_current = 0; //current obj speed
speed_acceleration_current = 0; //current obj acceleration
travel_distance = 0; //obj travel distance
move_time = 2; //in seconds
move_counter = 0;
move_current = 0; //current distance to move
Code:
global.time_speed = 0.5;
global.time_fps = 60;
Code:
//change animation speed according to current time scale
speed_base_current = speed_base / global.time_fps; //divided by 30 for normal time or by 60 for slowed time
speed_acceleration_current += speed_acceleration / global.time_fps; //divided by 30 for normal time or by 60 for slowed time
move_current = speed_base_current + speed_acceleration_current;
//move object
travel_distance += move_current;
y -= move_current;
//move counter
if (move_counter <= move_time) move_counter += 1 / global.time_fps;
else instance_destroy();
I also tried to use 1/10 second interval in alarm to increase speed, insted of doing it every frame, but have also different travel distances.
What is wrong? Is this rounding problem? How this can be fixed?
Thanks in advance.