DEV Community

xeroup
xeroup

Posted on

[Showdev] Blitzy: a lightweight 2D game engine in Kotlin

Lately i've been working on creating my own game engine in Kotlin. Why? i wanted to create my game, but whenever I found some engine for Kotlin, i constantly ran into problems: either it was too complex, or it lacked features, or the documentation was outdated. In the end, i decided - it's better to make my own, minimalistic one, but tailored precisely to my needs.

that's how Blitzy appeared: a simple and minimalistic 2D engine.

what functions does it have?

  • playing sounds and their control
  • creating simple hitboxes
  • keyboard and mouse input checking
  • tile system (tileset, tilemap), loading tilemaps from csv
  • entity classes
  • loading ttf fonts and creating texts
  • quick switching between scenes and saving them
  • drawing simple geometric shapes

example code:

import org.xeroup.blitzy.core.Game
import org.xeroup.blitzy.core.Settings
import org.xeroup.blitzy.graphics.Color
import org.xeroup.blitzy.graphics.DrawContext

// main class
// red square on a gray background
class ExampleGame : Game() {

    override fun settings(settings: Settings) {
        settings.width = 800
        settings.height = 600
        settings.title = "Game"
        settings.decorated = true
        settings.background = Color(0x222222)  // dark gray
    }

    override fun create() {
        // here you can initialize something, for example create a tileset
    }

    override fun update(delta: Float) {
        // update every frame
    }

    override fun render(draw: DrawContext) {
        draw.fillRect(350, 250, 100, 100, Color.WHITE) // fill square
    }
}

// start game
fun main() {
    Game.run(ExampleGame())
}
Enter fullscreen mode Exit fullscreen mode

technical side:

built on LWJGL3 with OpenGL rendering. the codebase is straightforward and easy to modify - perfect for learning or customization.


the project is fully open source under the LGPL license. I welcome feedback, bug reports, and contributors!

and also, i made a game pong on the engine:

links

github: https://github.com/xerooup/blitzy2d
docs: https://github.com/xerooup/blitzy2d/tree/main/documentation

Top comments (0)