Michael Tang 1 gadu atpakaļ
vecāks
revīzija
88878da55b
1 mainītis faili ar 8 papildinājumiem un 2 dzēšanām
  1. 8 2
      orange/L6-build-shooting-hoops.js

+ 8 - 2
orange/L6-build-shooting-hoops.js

@@ -1,4 +1,5 @@
 // game set up
+let throwsMade = 0
 scene.setBackgroundImage(assets.image`myImage`)
 game.showLongText("press A when overlaping with the ball to throw it. Try to get more then 6 points.", DialogLayout.Center)
 info.startCountdown(20)
@@ -35,11 +36,16 @@ forever(function () {
     if (playerSprite.overlapsWith(ballSprite) && controller.A.isPressed()) {
         ballSprite.follow(hoopSprite, randint(50, 100))
     }
+    if (ballSprite.overlapsWith(hoopSprite)) {
+        throwsMade += 1
+        pause(500)
+        ballSprite.follow(null)
+        ballSprite.setPosition(randint(10, screen.width - 10), playerSprite.y)
+    }
 })
 
 // on countdown end
 info.onCountdownEnd(function () {
-    let throwsMade = 0
     if (throwsMade >= 6) {
         game.showLongText("You made " + throwsMade + " baskets.", DialogLayout.Center)
         effects.confetti.startScreenEffect()
@@ -48,4 +54,4 @@ info.onCountdownEnd(function () {
         effects.blizzard.startScreenEffect()
     }
     game.reset()
-})
+})