Guest User

Untitled

a guest
May 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. if(kbhit())
  2. {
  3. ch=getch();
  4.  
  5. if(ch=='e'){break;} //exit
  6.  
  7. if(ch=='d') //move right
  8. {
  9. ax=1;
  10. if(vx<vellim){vx=vx+ax*dt;}
  11. dx=vx*dt;
  12. x+=dx;
  13. s_mario(x,y); //This function draws the character at the appropriate place
  14.  
  15. }
  16.  
  17. if(ch=='a') //move left
  18. {
  19. ax=-1;
  20. if(vx>-vellim){vx=vx+ax*dt;}
  21. dx=vx*dt;
  22. x+=dx;
  23. s_mario(x,y);
  24. }
  25.  
  26. if(ch=='w'&&jumpkey==0) //jump
  27. {
  28. vy=60;
  29. jumpkey=1;
  30. }
  31.  
  32. }
  33.  
  34. if(jumpkey==1)
  35. {
  36. vy=vy-g;
  37. dy=vy*dt;
  38. y-=dy*0.1;
  39. if(y>400){y=399;vy=0;jumpkey=0;}
  40. s_mario(x,y);
  41.  
  42. }
  43.  
  44. if(!kbhit())
  45. { vx*=c;
  46. dx=vx*dt;
  47. x+=dx;
  48. s_mario(x,y);
  49. delay(5);
  50. }
Add Comment
Please, Sign In to add comment