// on B button pressed controller.B.onEvent(ControllerButtonEvent.Pressed, function () { if (canStack == true) { sugarCookie = sprites.create(assets.image`myImage0`, SpriteKind.Player) sugarCookie.setPosition(110, sugarCookieY) sugarCookieY += 0 - 2 sugarCookieStack += 1 } }) // on A button pressed controller.A.onEvent(ControllerButtonEvent.Pressed, function () { if (canStack == true) { chocCookie = sprites.create(assets.image`myImage`, SpriteKind.Player) chocCookie.setPosition(50, chocCookieY) chocCookieY += 0 - 2 chocCookieStack += 1 } }) // on countdown end info.onCountdownEnd(function () { canStack = false askForNumber() pause(1000) music.play(music.melodyPlayable(music.powerUp), music.PlaybackMode.UntilDone) cookieStackTotal = chocCookieStack + sugarCookieStack if (playerGuess == cookieStackTotal) { game.showLongText("You geussed it!" + cookieStackTotal + " cookies were stacked!", DialogLayout.Bottom) } else if (playerGuess != cookieStackTotal) { game.showLongText("Wow! You geussed " + playerGuess + " but you acctulay stacked " + cookieStackTotal + " cookies instead!", DialogLayout.Bottom) game.showLongText("Wow! You geussed corectly " + cookieStackTotal + " cookies were stacked", DialogLayout.Bottom) } game.showLongText("Wow! You geussed " + playerGuess + " but you acctulay stacked" + cookieStackTotal + " cookies instead!", DialogLayout.Bottom) }) function askForNumber () { playerGuess = game.askForNumber("how many cookies did you think you stacked?", 2) } let playerGuess = 0 let cookieStackTotal = 0 let chocCookieStack = 0 let chocCookie: Sprite = null let sugarCookieStack = 0 let sugarCookie: Sprite = null let sugarCookieY = 0 let chocCookieY = 0 let canStack = false // set up scene.setBackgroundColor(5) game.showLongText("Stack cookies then geuss how many you stacked!", DialogLayout.Bottom) // plate sprite code let plate1 = sprites.create(img` ...............bbbbbbbbbbbbbbbbbbb............... ...........bbbbdd111111111111111ddbbbb........... ........bbbd1111111111111111111111111dbbb........ ......bbd11111111dddddddddddddd111111111dbb...... ....bbd1111111ddd11111111111111dddd1111111dbb.... ...bd111111ddd111111111111111111111ddd111111db... ..bd11111ddd111ddddddddddddddddddd111ddd11111db.. .bd11111dd111dddd111111111111111dddd111dd11111db. .b11111d111ddd111111111111111111111ddd111d11111b. bd11111d1ddd1111111111111111111111111ddd1111111db b11111d1ddd111111111111111111111111111ddd1d11111b b11111ddddd111111111111111111111111111ddddd11111b b11111ddddd111111111111111111111111111dddbd11111b b111111dddd111111111111111111111111111dddb111111b bd111111dddd1111111111111111111111111dddbd11111db .b1111111dddd11111111111111111111111dddbd111111b. .bd1111111dbbdd1111111111111111111dddbbd111111db. ..bd11111111dbbdd111111111111111dddbbd1111111db.. ...bd111111111dbbbbbbdddddddddddddd111111111db... ....bbd11111111111dbbbbbbbbbddd11111111111dbb.... ......bbdd11111111111111111111111111111ddbb...... ........bbbdd11111111111111111111111ddbbb........ ...........bbbbbddd11111111111dddbbbbb........... ................bbbbbbbbbbbbbbbbb................ `, SpriteKind.Player) plate1.setPosition(50, 100) let plate2 = sprites.create(img` ...............bbbbbbbbbbbbbbbbbbb............... ...........bbbbdd111111111111111ddbbbb........... ........bbbd1111111111111111111111111dbbb........ ......bbd11111111dddddddddddddd111111111dbb...... ....bbd1111111ddd11111111111111dddd1111111dbb.... ...bd111111ddd111111111111111111111ddd111111db... ..bd11111ddd111ddddddddddddddddddd111ddd11111db.. .bd11111dd111dddd111111111111111dddd111dd11111db. .b11111d111ddd111111111111111111111ddd111d11111b. bd11111d1ddd1111111111111111111111111ddd1111111db b11111d1ddd111111111111111111111111111ddd1d11111b b11111ddddd111111111111111111111111111ddddd11111b b11111ddddd111111111111111111111111111dddbd11111b b111111dddd111111111111111111111111111dddb111111b bd111111dddd1111111111111111111111111dddbd11111db .b1111111dddd11111111111111111111111dddbd111111b. .bd1111111dbbdd1111111111111111111dddbbd111111db. ..bd11111111dbbdd111111111111111dddbbd1111111db.. ...bd111111111dbbbbbbdddddddddddddd111111111db... ....bbd11111111111dbbbbbbbbbddd11111111111dbb.... ......bbdd11111111111111111111111111111ddbb...... ........bbbdd11111111111111111111111ddbbb........ ...........bbbbbddd11111111111dddbbbbb........... ................bbbbbbbbbbbbbbbbb................ `, SpriteKind.Player) plate2.setPosition(110, 100) // varibel set up canStack = true info.startCountdown(10) chocCookieY = 100 sugarCookieY = 100