Jump to content
Search

This wiki is under development. Features may be missing. Data loss is unlikely, but possible. Read the announcement.

Karl2D

From Ubuntu Wiki

Testing

This page has been identified as needing testing.

Karl2D is a library for developing games using the Odin programming language.

Prerequisites

Make sure you follow the guide to install the Odin language and compiler on your Ubuntu system.

Create a project

Make a directory for your project:

mkdir my-new-game

Change into the project directory and clone the karl2d library:

cd my-new-game && git clone https://github.com/karl-zylinski/karl2d

Create a file named game.odin and edit it with your favorite text editor:

touch game.odin && vim game.odin

Add the code below:

package hello

import k2 "karl2d"

main :: proc() {
  k2.init(1280, 720, "Hello program")

  for k2.update() {
    k2.clear(k2.LIGHT_BLUE)
    k2.draw_text("Hello world!", {50, 50}, 100, k2.DARK_BLUE)
    k2.present()
  }

  k2.shutdown()
}

Still in the project directory, compile and run the game with:

odin run .

Resources