/ Published in: C++
physics component for the heli
Expand |
Embed | Plain Text
//base speed = .03 enum direction{LEFT=1, RIGHT=2, UP=3, DOWN=4}; float v_x=.03, v_y=.03; float move_x(float deltaX, float deltaTime, int direction) { //deltaX = current speed if (direction == RIGHT) { float A = v_x/deltaTime; v_x+=A; return(v_x); } if (direction == LEFT) { float A = v_x-(v_x/deltaTime); v_x+=A; return(v_x); } } float move_y(float deltaY, float deltaTime, int direction) { //deltaY = current speed if (direction == RIGHT) { float A = v_y/deltaTime; v_y+=A; return(v_y); } if (direction == LEFT) { float A = v_y-(v_y/deltaTime); v_y+=A; return(v_y); } } ///////**---USAGE---**/////// if (you press 'a') { myX += move_x(v_x, 5, RIGHT); glutSetWindow(1); Reshape(winHeight, winWidth); glutPostRedisplay(); } //////////////////////////////
You need to login to post a comment.
