| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- // set up
- scene.setBackgroundColor(5)
- game.showLongText("Stack cookies then geuss how many you stacked!", DialogLayout.Bottom)
- //variable set up
- let chocCookieY = 100
- let sugarCookieY = 100
- let chocCookieStack = 0
- let sugarCookieStack = 0
- let canStack = true //init to true
- info.startCountdown(10)
- //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)
- //on A button pressed
- controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
- if (canStack == true) {
- let chocCookie = sprites.create(assets.image`myImage`, SpriteKind.Player)
- chocCookie.setPosition(50, chocCookieY)
- chocCookieY -=2
- chocCookieStack += 1
- }
- })
- //on B button pressed
- controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
- if (canStack == true) {
- let sugarCookie = sprites.create(assets.image`myImage0`, SpriteKind.Player)
- sugarCookie.setPosition(110, sugarCookieY)
- sugarCookieY -=2 // changed from 0-2
- sugarCookieStack += 1
- }
- })
- //on countdown end
- info.onCountdownEnd(function () {
- canStack = false
- pause(1000)
- music.play(music.melodyPlayable(music.powerUp), music.PlaybackMode.UntilDone)
- //cleaned up playerGuess
- let playerGuess = game.askForNumber("How manyt cookies do you think you stacked?", 2)
- let cookieStackTotal = chocCookieStack + sugarCookieStack
- game.showLongText("Wow! You stacked " + chocCookieStack + " chocolate chip cookies and " + sugarCookieStack + " sugar cookies!", DialogLayout.Full)
- //cleaned up if
- if (playerGuess == cookieStackTotal) {
- game.showLongText("You guessed correctly - you're one smart cookie! " + cookieStackTotal + " cookies were stacked!", DialogLayout.Full)
- } else if (playerGuess != cookieStackTotal) {
- game.showLongText("You guessed "+ playerGuess + " cookies, but you stacked " + cookieStackTotal + " cookies instead!", DialogLayout.Full)
- }
- })
|