Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let x_winning = 0
- let score = 0
- let start = false
- let agent = 0
- let difficulty = 0
- let j = 0
- input.onButtonPressed(Button.A, () => {
- led.unplot(agent, 4)
- if (agent > 0) {
- agent += -1
- }
- led.plot(agent, 4)
- })
- input.onButtonPressed(Button.B, () => {
- led.unplot(agent, 4)
- if (agent < 4) {
- agent += 1
- }
- led.plot(agent, 4)
- })
- input.onGesture(Gesture.Shake, () => {
- if (!(start)) {
- basic.clearScreen()
- led.stopAnimation()
- }
- start = true
- })
- j = 0
- difficulty = 500
- score = 0
- start = false
- x_winning = 0
- agent = 2
- basic.forever(() => {
- if (start) {
- led.plot(agent, 4)
- x_winning = Math.random(5)
- for (let i = 0; i <= 4; i++) {
- for (let k = 0; k <= 4; k++) {
- led.plot(k, i)
- }
- led.unplot(x_winning, i)
- if (i == 4) {
- led.plot(agent, 4)
- if (agent != x_winning) {
- basic.showString("Game over! Score", 75)
- basic.showNumber(score)
- basic.pause(2000)
- control.reset()
- }
- }
- basic.pause(difficulty)
- for (let l = 0; l <= 4; l++) {
- led.unplot(l, i)
- }
- if (i == 4) {
- led.plot(agent, 4)
- }
- }
- score += 1
- if (difficulty > 75) {
- difficulty = difficulty - 20
- }
- } else {
- basic.showString("Shake it off!", 70)
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment