Code Sketch


SUBG (Soldier Unkown Battlegrounds) [v: 1.0]
By: Soham Dabral
Category: Programming
//https://drive.google.com/drive/u/0/folders/1hNvF0sZjpuSTaANkJjor5rgQJx1FG6rE
//Download the above files and put it in your downloads folder

// A shooting game
//Press SPACE to shoot bullets
//and enter to shoot bombs
//or use the buttons on the screen
cleari()
clearOutput()
disablePanAndZoom()

//Part - 1 Defining objects
//Help us to shoot bullets and bombs
var shootBullet = false
var shootBomb = false

//Score
var score = 0

//Colors
//Button color
val buttonClr = cm.linearGradient(0, 0, ColorMaker.hsla(20, 0.62, 0.40, 0.70), 0, 30, ColorMaker.hsla(33, 0.61, 0.40, 0.28), false)

//Intro
val intro = Picture.image("~/Downloads/SD.png ")
drawCentered(intro)

//Creator
val creator = Picture.text("Soham Dabral", Font("Serif", 40))
creator.setPosition(-100, -150)
creator.setPenColor(cm.grey)
draw(creator)

showFps(green, 20)

//Pause
pause(3)

cleari()
disablePanAndZoom()
setBackground(cm.black)
showFps(green, 20)

//Background music
playMp3Loop("~/Downloads/Bg music.mp3")

//Box color
val boxclr = cm.linearGradient(0, 40, cm.white, 0, 0, cm.black, false)

//Box
val box1 = Picture.rectangle(500, 50).withPenColor(noColor).withFillColor(boxclr).withPenThickness(1).withOpacity(0.75)
drawCentered(box1)

val box2 = Picture.rectangle(500, 50).withPenColor(noColor).withFillColor(boxclr).withPenThickness(1).withOpacity(0.75)
draw(box2.withTranslation(-250, -80))

//Play button
val play = Picture.text("Play", Font("Space Game", 40))
play.setPenColor(cm.black)
drawCentered(play)

//Quit Game button
val quitGame = Picture.text("Quit Game", Font("Space Game", 40))
quitGame.setPenColor(cm.black)
quitGame.setPosition(-85, -30)
draw(quitGame)

play.onMouseClick { (x, y) =>
    showFps(green, 20)
    //Stage area
    val stageBorder = Picture.rectangle(cwidth * 1.75, cheight)
    stageBorder.setPosition(-cwidth / 2, -cheight / 2)
    stageBorder.setPenColor(noColor)
    draw(stageBorder)

    //Background
    val background = Picture.image("~/Downloads/battlefield.jfif").withTranslation(-110, -90)
    background.setScale(3.1)
    draw(background)

    //Bullet
    val bullet = Picture.image("~/Downloads/lazer bullet model.png")
        .withScaling(0.1)
        .withTranslation(200, -150)
        .withFlippedX
    draw(bullet)
    bullet.invisible()

    //Bomb
    val bomb = Picture.image("~/Downloads/Bomb.png")
        .withScaling(0.1)
        .withTranslation(200, -150)
        .withFlippedX
    draw(bomb)
    bomb.invisible()

    //Solider
    val soldier = Picture.image("~/Downloads/Soldier.png")
    soldier.setScale(0.2)
    soldier.setPosition(-300, -215)
    draw(soldier)

    //Enemy robot
    val enemy = Picture.image("~/Downloads/Robot.png")
    enemy.setScale(0.3)
    enemy.setPosition(random(300, 400), -700)
    draw(enemy)

    //Enemy robots
    val enemy2 = enemy.withTranslation(random(300, 400), -700
    )
    enemy2.setScale(0.3)
    draw(enemy2)

    val enemy3 = enemy.withTranslation(random(300, 400), -700)
    enemy3.setScale(0.3)
    draw(enemy3)

    val enemy4 = enemy.withTranslation(random(300, 400), -700)
    enemy4.setScale(0.3)
    draw(enemy4)

    val enemy5 = enemy.withTranslation(random(300, 400), -700)
    enemy5.setScale(0.3)
    draw(enemy5)

    val enemy6 = enemy.withTranslation(random(300, 400), -700)
    enemy6.setScale(0.3)
    draw(enemy6)

    val enemy7 = enemy.withTranslation(random(300, 400), -700)
    enemy7.setScale(0.3)
    draw(enemy7)

    //Bullet Button
    def button = Picture.circle(25)
    val bulletImg = Picture.image("~/Downloads/lazer bullet model.png")
    val bulletButton = picStack(
        button
            .withFillColor(buttonClr)
            .withPenColor(noColor),
        bulletImg
            .withScaling(0.1)
            .withRotation(-135)
            .withTranslation(10, 30)
    ).withTranslation(250, 200)
    draw(bulletButton)

    //Bomb button
    val bombImg = Picture.image("~/Downloads/Bomb.png")
    val bombButton = picStack(
        button
            .withFillColor(buttonClr)
            .withPenColor(noColor),
        bombImg
            .withScaling(0.2)
            .withTranslation(-60, -35)
    ).withTranslation(250, 140)
    draw(bombButton)

    showFps(green, 20)

    animate {
        //Part - 2 Animating objects
        //Translating objects
        enemy.translate(-random(5, 20), 0)
        enemy2.translate(-random(5, 20), 0)
        enemy3.translate(-random(5, 20), 0)
        enemy4.translate(-random(5, 20), 0)
        enemy5.translate(-random(5, 20), 0)
        enemy6.translate(-random(5, 20), 0)
        enemy7.translate(-random(5, 20), 0)

        //Collison with stage border
        if (enemy.collidesWith(stageBorder)) {
            enemy.setPosition(random(300, 400), -200)
        }

        if (enemy2.collidesWith(stageBorder)) {
            enemy2.setPosition(random(300, 400), -200)
        }

        if (enemy3.collidesWith(stageBorder)) {
            enemy3.setPosition(random(300, 400), -200)
        }

        if (enemy4.collidesWith(stageBorder)) {
            enemy4.setPosition(random(300, 400), -200)
        }

        if (enemy5.collidesWith(stageBorder)) {
            enemy5.setPosition(random(300, 400), -200)
        }

        if (enemy6.collidesWith(stageBorder)) {
            enemy6.setPosition(random(300, 400), -200)
        }

        if (enemy7.collidesWith(stageBorder)) {
            enemy7.setPosition(random(300, 400), -200)
        }

        //Collison with soldier
        if (enemy.collidesWith(soldier)) {
            enemy.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy2.collidesWith(soldier)) {
            enemy2.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy3.collidesWith(soldier)) {
            enemy3.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy4.collidesWith(soldier)) {
            enemy4.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy5.collidesWith(soldier)) {
            enemy5.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy6.collidesWith(soldier)) {
            enemy6.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy7.collidesWith(soldier)) {
            enemy7.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        //Collison with bullet
        if (enemy.collidesWith(bullet)) {
            enemy.setPosition(random(300, 400), -350)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy2.collidesWith(bullet)) {
            enemy2.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy3.collidesWith(bullet)) {
            enemy3.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy4.collidesWith(bullet)) {
            enemy4.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy5.collidesWith(bullet)) {
            enemy5.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy6.collidesWith(bullet)) {
            enemy6.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy7.collidesWith(bullet)) {
            enemy7.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        //Collison with bomb
        if (enemy.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy2.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy3.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy4.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy5.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy6.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy7.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        //Shoot bullet
        if (isKeyPressed(Kc.VK_SPACE)) {
            shootBullet = true
        }

        if (shootBullet == true) {
            bullet.visible()
            bullet.translate(-60, 0)
        }

        if (bullet.collidesWith(stageBorder)) {
            bullet.setPosition(-200, -700)
            shootBullet = false
        }
        //Shoot bomb
        if (isKeyPressed(Kc.VK_ENTER)) {
            shootBomb = true
        }

        bulletButton.onMouseClick { (x, y) =>
            shootBullet = true
        }

        bombButton.onMouseClick { (x, y) =>
            shootBomb = true
        }

        if (shootBomb == true) {
            bomb.visible()
            bomb.translate(-60, 0)
        }

    }
    showGameTimeCountdown(15, s"You Win :) Your score is $score", green, 20, 10, 50)
    activateCanvas()
}

box1.onMouseClick { (x, y) =>
    showFps(green, 20)
    //Stage area
    val stageBorder = Picture.rectangle(cwidth * 1.75, cheight)
    stageBorder.setPosition(-cwidth / 2, -cheight / 2)
    stageBorder.setPenColor(noColor)
    draw(stageBorder)

    //Background
    val background = Picture.image("~/Downloads/battlefield.jfif").withTranslation(-110, -90)
    background.setScale(3.1)
    draw(background)

    //Bullet
    val bullet = Picture.image("~/Downloads/lazer bullet model.png")
        .withScaling(0.1)
        .withTranslation(200, -150)
        .withFlippedX
    draw(bullet)
    bullet.invisible()

    //Bomb
    val bomb = Picture.image("~/Downloads/Bomb.png")
        .withScaling(0.1)
        .withTranslation(200, -150)
        .withFlippedX
    draw(bomb)
    bomb.invisible()

    //Solider
    val soldier = Picture.image("~/Downloads/Soldier.png")
    soldier.setScale(0.2)
    soldier.setPosition(-300, -215)
    draw(soldier)

    //Enemy robot
    val enemy = Picture.image("~/Downloads/Robot.png")
    enemy.setScale(0.3)
    enemy.setPosition(random(300, 400), -700)
    draw(enemy)

    //Enemy robots
    val enemy2 = enemy.withTranslation(random(300, 400), -700
    )
    enemy2.setScale(0.3)
    draw(enemy2)

    val enemy3 = enemy.withTranslation(random(300, 400), -700)
    enemy3.setScale(0.3)
    draw(enemy3)

    val enemy4 = enemy.withTranslation(random(300, 400), -700)
    enemy4.setScale(0.3)
    draw(enemy4)

    val enemy5 = enemy.withTranslation(random(300, 400), -700)
    enemy5.setScale(0.3)
    draw(enemy5)

    val enemy6 = enemy.withTranslation(random(300, 400), -700)
    enemy6.setScale(0.3)
    draw(enemy6)

    val enemy7 = enemy.withTranslation(random(300, 400), -700)
    enemy7.setScale(0.3)
    draw(enemy7)

    //Bullet Button
    def button = Picture.circle(25)
    val bulletImg = Picture.image("~/Downloads/lazer bullet model.png")
    val bulletButton = picStack(
        button
            .withFillColor(buttonClr)
            .withPenColor(noColor),
        bulletImg
            .withScaling(0.1)
            .withRotation(-135)
            .withTranslation(10, 30)
    ).withTranslation(250, 200)
    draw(bulletButton)

    //Bomb button
    val bombImg = Picture.image("~/Downloads/Bomb.png")
    val bombButton = picStack(
        button
            .withFillColor(buttonClr)
            .withPenColor(noColor),
        bombImg
            .withScaling(0.2)
            .withTranslation(-60, -35)
    ).withTranslation(250, 140)
    draw(bombButton)

    showFps(green, 20)

    animate {
        //Part - 2 Animating objects
        //Translating objects
        enemy.translate(-random(5, 20), 0)
        enemy2.translate(-random(5, 20), 0)
        enemy3.translate(-random(5, 20), 0)
        enemy4.translate(-random(5, 20), 0)
        enemy5.translate(-random(5, 20), 0)
        enemy6.translate(-random(5, 20), 0)
        enemy7.translate(-random(5, 20), 0)

        //Collison with stage border
        if (enemy.collidesWith(stageBorder)) {
            enemy.setPosition(random(300, 400), -200)
        }

        if (enemy2.collidesWith(stageBorder)) {
            enemy2.setPosition(random(300, 400), -200)
        }

        if (enemy3.collidesWith(stageBorder)) {
            enemy3.setPosition(random(300, 400), -200)
        }

        if (enemy4.collidesWith(stageBorder)) {
            enemy4.setPosition(random(300, 400), -200)
        }

        if (enemy5.collidesWith(stageBorder)) {
            enemy5.setPosition(random(300, 400), -200)
        }

        if (enemy6.collidesWith(stageBorder)) {
            enemy6.setPosition(random(300, 400), -200)
        }

        if (enemy7.collidesWith(stageBorder)) {
            enemy7.setPosition(random(300, 400), -200)
        }

        //Collison with soldier
        if (enemy.collidesWith(soldier)) {
            enemy.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy2.collidesWith(soldier)) {
            enemy2.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy3.collidesWith(soldier)) {
            enemy3.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy4.collidesWith(soldier)) {
            enemy4.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy5.collidesWith(soldier)) {
            enemy5.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy6.collidesWith(soldier)) {
            enemy6.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        if (enemy7.collidesWith(soldier)) {
            enemy7.setPosition(random(300, 400), -200)
            drawCenteredMessage(s"You lose :( Your score is $score", red, 40)
            stopAnimation()
            activateEditor()
        }

        //Collison with bullet
        if (enemy.collidesWith(bullet)) {
            enemy.setPosition(random(300, 400), -350)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy2.collidesWith(bullet)) {
            enemy2.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy3.collidesWith(bullet)) {
            enemy3.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy4.collidesWith(bullet)) {
            enemy4.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy5.collidesWith(bullet)) {
            enemy5.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy6.collidesWith(bullet)) {
            enemy6.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        if (enemy7.collidesWith(bullet)) {
            enemy7.setPosition(random(300, 400), -200)
            bullet.setPosition(-200, -150)
            bullet.invisible()
            shootBullet = false
            score += 1
        }

        //Collison with bomb
        if (enemy.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy2.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy3.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy4.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy5.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy6.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        if (enemy7.collidesWith(bomb)) {
            enemy.setPosition(random(300, 400), -200)
            enemy2.setPosition(random(300, 400), -200)
            enemy3.setPosition(random(300, 400), -200)
            enemy4.setPosition(random(300, 400), -200)
            enemy5.setPosition(random(300, 400), -200)
            enemy6.setPosition(random(300, 400), -200)
            enemy7.setPosition(random(300, 400), -200)
            bomb.setPosition(-200, -150)
            bomb.invisible()
            shootBomb = false
            score += 1
        }

        //Shoot bullet
        if (isKeyPressed(Kc.VK_SPACE)) {
            shootBullet = true
        }

        if (shootBullet == true) {
            bullet.visible()
            bullet.translate(-60, 0)
        }

        if (bullet.collidesWith(stageBorder)) {
            bullet.setPosition(-200, -700)
            shootBullet = false
        }
        //Shoot bomb
        if (isKeyPressed(Kc.VK_ENTER)) {
            shootBomb = true
        }

        bulletButton.onMouseClick { (x, y) =>
            shootBullet = true
        }

        bombButton.onMouseClick { (x, y) =>
            shootBomb = true
        }

        if (shootBomb == true) {
            bomb.visible()
            bomb.translate(-60, 0)
        }

    }
    showGameTimeCountdown(15, s"You Win :) Your score is $score", green, 20, 10, 50)
    activateCanvas()
}

quitGame.onMouseClick { (x, y) =>
    stopMp3Loop()
    clear()
    activateEditor()
}

box2.onMouseClick { (x, y) =>
    stopMp3Loop()
    quitGame.onMouseClick { (x, y) =>
        clear()
        activateEditor()
    }
}