Dodo12wScripts

Untitled

Jul 23rd, 2021
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let myXPos = 100;
  2. let myYPos = 400;
  3. let enemyXPos = 1500;
  4. let enemyYPos = 400;
  5. let enemySpeedValue = 10;
  6.  
  7. let myLeft, myRight, myTop, myBottom;
  8. let enemyLeft, enemyRight, enemyTop, enemyBottom;
  9.  
  10.  
  11. function setup() {
  12.     createCanvas(1500, 700);
  13.     background(0);
  14.     rectMode(CENTER);
  15. }
  16.  
  17. let jump = 0;
  18.  
  19. let gameOver = 0;
  20.  
  21. function draw() {
  22.  
  23.     if (gameOver == 0) {
  24.  
  25.         myLeft = myXPos - 50;
  26.         myRight = myXPos + 50;
  27.         myTop = myYPos - 50;
  28.         myBottom = myYPos + 50;
  29.  
  30.         enemyLeft = enemyXPos - 50;
  31.         enemyRight = enemyXPos + 50;
  32.         enemyTop = enemyYPos - 50;
  33.         enemyBottom = enemyYPos + 50;
  34.        
  35.         if (myLeft > enemyRight || myRight < enemyLeft || myTop > enemyBottom || myBottom < enemyTop){
  36.  
  37.             console.log("It didn't hit")
  38.        
  39.         } else {
  40.             gameOver = -1
  41.         }
  42.  
  43.         background(0);
  44.  
  45.         ellipse(myXPos, myYPos, 100, 100);
  46.  
  47.         if (myYPos > 200 && jump == 1) {
  48.  
  49.             myYPos -= 7;
  50.  
  51.             if (myYPos <= 200) {
  52.  
  53.                 jump = 2;
  54.  
  55.             }
  56.  
  57.             //myYPos = 400;
  58.  
  59.         }
  60.        
  61.         if (jump == 2) {
  62.  
  63.             if (myYPos <= 400) {
  64.  
  65.                 myYPos += 7;
  66.  
  67.             } else {
  68.  
  69.                 jump = 0;
  70.  
  71.             }
  72.  
  73.         }
  74.        
  75.  
  76.         ellipse(enemyXPos, enemyYPos, 100, 100);
  77.  
  78.         enemyXPos -= enemySpeedValue;
  79.        
  80.         if (enemyXPos < -100) {
  81.  
  82.             enemyXPos = 1500;
  83.  
  84.         }
  85.  
  86.     }
  87.    
  88. }
  89.  
  90. function mouseClicked() {
  91.  
  92.     if (jump == 0) {
  93.  
  94.         jump = 1;
  95.  
  96.     }
  97.  
  98. }
  99.  
Advertisement
Add Comment
Please, Sign In to add comment