Kojo Wiki

docs for Kojo

View source on GitHub

Game refinement project 1 - Dino

This activity has the following desired goals:

  • Learning to understand a given game
  • Understanding the design ideas behind the game
  • Refinining the design ideas
  • Improving the game as per the design ideas and the game-dev process.
  • Adding images and sounds to the game as per the above.

Steps to be followed:

  1. Understand the game below.
  2. Write a one-page design sketch for the game
  3. Refine the game-play (add birds, increase obstacle speed as time passes, etc).
  4. Add background and character images to the game to make it more attractive.
  5. Add sounds to the game to make it more attractive.
  6. Implement any other ideas for improvement that you can come up with.
  7. Keep the game-dev process in mind as you do the above.

Game starter code

The code for the game is shown below. Study it to fully understand how the game works.

// #exec template /picgaming

cleari()
drawStage(white)
val cb = canvasBounds

val us = Picture.rectangle(30, 60)
us.setPosition(cb.x + 150, cb.y + 0)

draw(us)
def ob = {
    val obe = Picture.rectangle(40, 50)
    obe.setPosition(cb.x + cb.width - 40, cb.y)
    obe
}

val obsticles = HashSet.empty[Picture]

timer(1000) {
    val obs = ob
    obs.draw
    obsticles.add(obs)
}


var jump = Vector2D(0, 0)
val gravity = Vector2D(0, -1500)
var ovel = Vector2D(-400, 0)

val ground = stageBot

animate {
    val dt = frameDeltaTime
    jump = (jump + gravity * dt)
    us.translate(jump * dt)
    if (us.collidesWith(ground)) {
        us.setPosition(us.position.x, ground.position.y)
        if (isKeyPressed(Kc.VK_SPACE)) {
            jump = Vector2D(0, 500)
        }
    }
    repeatFor(obsticles) { o =>
        o.translate(ovel * dt)
        if (o.collidesWith(us)) {
            stopAnimation()
        }
        if (o.collidesWith(stageLeft)) {
            o.erase()
            obsticles.remove(o)
        }

    }
}

activateCanvas()

Copyright © 2010–2025 Kogics Foundation. Licensed as per Terms of Use.