Ron Dagdag
Published © MIT

Celebrate the New Year by Learning Programming

My kids celebrated New Year's Eve learning to code. Here's a simple and fun way to celebrate the New Year countdown.

BeginnerShowcase (no instructions)1 hour762
Celebrate the New Year by Learning Programming

Things used in this project

Story

Read more

Code

countdown timer

JavaScript
let star2: Image = null
let star1: Image = null
let countingdown = false
let counter = 0
input.onButtonPressed(Button.A, () => {
    counter += 1
})
input.onButtonPressed(Button.B, () => {
    countingdown = true
})
star1 = images.createImage(`
    . . . . .
    . . . . .
    . . # . .
    . . . . .
    . . . . .
    `)
star2 = images.createImage(`
    . . . . .
    . . # . .
    . # # # .
    . . # . .
    . . . . .
    `)
counter = 3
countingdown = false
basic.forever(() => {
    basic.showNumber(counter)
    if (countingdown == true) {
        basic.pause(1000)
        counter += -1
        if (counter <= 0) {
            countingdown = false
            for (let i = 0; i < 4; i++) {
                star1.showImage(0)
                basic.pause(200)
                star2.showImage(0)
                basic.pause(200)
            }
            basic.showString("HAPPY NEW YEAR!")
        }
    }
})

Credits

Ron Dagdag

Ron Dagdag

47 projects • 436 followers
Microsoft MVP award / Lead Software Engineer / Augmented Reality. Developer Passionate to learn about Robotics, VR, AR, ML, IOT

Comments