#include <acknex.h>
#include <default.c>
#define PRAGMA_POINTER
// t = time passed
// b = initial value
// c = change in value
// d = duration in which initial value becomes b+c
var easeInOutQuad(var t, var b,var c,var d) {
if(t>=d)return b +c;
t /= d/2;
if (t < 1) return c/2*t*t + b;
t--;
return -c/2 * (t*(t-2) - 1) + b;
}
var easeInOutCubic(var t, var b,var c,var d) {
if(t>=d)return b +c;
t /= d/2;
if (t < 1) return c/2*t*t*t + b;
t -= 2;
return c/2*(t*t*t + 2) + b;
}
void main(){
level_load(NULL);
ENTITY* cube = ent_create(CUBE_MDL,nullvector,NULL);
camera->y -= 200;
camera->pan = 90;
var initial_value = -100;
var delta_value = 200; // value will be 100 in the end (-100+200 = 100)
var time_passed = 0;
var duration = 2;
while(!key_esc){
if(key_space){
cube->x = initial_value;
time_passed = 0;
}
if(time_passed<duration)cube->x = easeInOutQuad(time_passed,initial_value,delta_value,duration);
time_passed += time_step/16;//convert time_step to seconds
wait(1);
}
}