if(instructx)
//checks if the x movement is positive (EAST)
if(instructx>0)
if(movement_x+movement_accel>movement_limit)movement_x=movement_max
else movement_x+=movement_accel
//checks if the x movement is negative (WEST)
if(instructx<0)
if(movement_x-movement_accel<-movement_limit)movement_x=-movement_max
else movement_x-=movement_accel
//checks if there is a movement_x to decelerate
else if(movement_x)
if(movement_x>0)
if(movement_x-movement_decel<0)movement_x=0
else movement_x-=movement_decel
if(movement_x<0)
if(movement_x+movement_decel>0)movement_x=0
else movement_x+=movement_decel
//checks if a constant y movement is being carried out
if(instructy)
//checks if the y movement is positive (NORTH)
if(instructy>0)
if(movement_y+movement_accel>movement_limit)movement_y=movement_max
else movement_y+=movement_accel
//checks if the y movement is negative (SOUTH)
if(instructy<0)
if(movement_y-movement_accel<-movement_limit)movement_y=-movement_max
else movement_y-=movement_accel
//checks if there is a movement_y to decelerate
else if(movement_y)
if(movement_y>0)
if(movement_y-movement_decel<0)movement_y=0
else movement_y-=movement_decel
if(movement_y<0)
if(movement_y+movement_decel>0)movement_y=0
else movement_y+=movement_decel
Problem description:
How can i make the if(instructx) and if(instructy) run at the same time instead of one after another?
#define clamp(v,l,h) min(max(v, l), h)