Advertisement
Guest User

Rapid Roll

a guest
Dec 15th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. // Creating variables
  2. var myX = 0, myY = 0, platformaX=[], platformaY=[], iPl, vragplX=300, vragplY=860;
  3. var score=0
  4. platformaX[0]=200
  5. platformaY[0]=620
  6. platformaX[1]=300
  7. platformaY[1]=700
  8. platformaX[2]=430
  9. platformaY[2]=780
  10.  
  11. function update() {
  12. myX = mouseX
  13. myY = myY+1
  14. vragplY=vragplY-3
  15. if(vragplY<0){
  16. vragplY=860
  17. vragplX=randomInteger(720)
  18. }
  19.  
  20. platformaY[0] = platformaY[0]-3
  21. platformaY[1] = platformaY[1]-3
  22. platformaY[2] = platformaY[2]-3
  23.  
  24.  
  25. for(iPl=0;iPl<3;iPl=iPl+1){
  26. if(areColliding(myX, myY, 15, 15, platformaX[iPl], platformaY[iPl], 80, 10)){
  27. myY = myY-2
  28. myY=platformaY[iPl]-15
  29. score=score+1
  30. }
  31. }
  32. for(iPl=0;iPl<3;iPl=iPl+1){
  33. if(platformaY[iPl]<0){
  34. platformaX[iPl]=randomInteger(720)
  35. platformaY[iPl]=620
  36. }
  37. }
  38.  
  39.  
  40.  
  41.  
  42. if(myY>600){
  43. myY=99999
  44. score=score
  45. window.alert("Sry Ma Frend. Press F12 to see your score");
  46. console.log("Your score is", score)
  47.  
  48. }
  49.  
  50. if(myY<0){
  51.  
  52. myY=99999
  53. score=score
  54. window.alert("Sry Ma Frend. Press F12 to see your score");
  55. console.log("Your score is", score)
  56. }
  57.  
  58. if(areColliding(myX, myY, 15, 15, vragplX, vragplY, 80, 10)){
  59. myY=99999
  60. score=score
  61. window.alert("Sry Ma Frend. Press F12 to see your score") ;
  62. console.log("Your score is", score)
  63. }
  64.  
  65.  
  66.  
  67. }
  68.  
  69. function draw() {
  70. // This is how you draw a rectangle
  71. context.fillStyle="Black"
  72. context.fillRect(0, 0, 800, 600);
  73. context.fillStyle="blue"
  74. context.fillRect(myX, myY, 15, 15);
  75. context.fillStyle="Red"
  76. context.fillRect(platformaX[0], platformaY[0], 80, 10);
  77. context.fillRect(platformaX[1], platformaY[1], 80, 10);
  78. context.fillRect(platformaX[2], platformaY[2], 80, 10);
  79. context.fillStyle="purple"
  80. context.fillRect(vragplX, vragplY, 80, 10);
  81. };
  82.  
  83. function keyup(key) {
  84. // Show the pressed keycode in the console
  85. console.log("Pressed", key);
  86.  
  87.  
  88. };
  89.  
  90. function mouseup() {
  91. // Show coordinates of mouse on click
  92. console.log("Mouse clicked at", mouseX, mouseY);
  93. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement