Posted By

Desoxena on 02/16/12


Tagged

fe afea


Versions (?)

Physics component - lolcopter


 / Published in: C++
 

physics component for the heli

  1. //base speed = .03
  2.  
  3. enum direction{LEFT=1, RIGHT=2, UP=3, DOWN=4};
  4. float v_x=.03, v_y=.03;
  5. float move_x(float deltaX, float deltaTime, int direction) { //deltaX = current speed
  6. if (direction == RIGHT) {
  7. float A = v_x/deltaTime;
  8. v_x+=A;
  9. return(v_x);
  10. }
  11. if (direction == LEFT) {
  12. float A = v_x-(v_x/deltaTime);
  13. v_x+=A;
  14. return(v_x);
  15. }
  16. }
  17. float move_y(float deltaY, float deltaTime, int direction) { //deltaY = current speed
  18. if (direction == RIGHT) {
  19. float A = v_y/deltaTime;
  20. v_y+=A;
  21. return(v_y);
  22. }
  23. if (direction == LEFT) {
  24. float A = v_y-(v_y/deltaTime);
  25. v_y+=A;
  26. return(v_y);
  27. }
  28. }
  29. ///////**---USAGE---**///////
  30. if (you press 'a') {
  31. myX += move_x(v_x, 5, RIGHT);
  32. glutSetWindow(1);
  33. Reshape(winHeight, winWidth);
  34. glutPostRedisplay();
  35. }
  36. //////////////////////////////

Report this snippet  

You need to login to post a comment.