Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Tiny – A 2D Game Engine in Kotlin Working with Lua (minigdx.github.io)
100 points by dwursteisen on May 29, 2023 | hide | past | favorite | 28 comments
I created a small 2D game engine named Tiny.

The engine was created using Kotlin Multiplatform and can run on a JVM and JS. Funny things: Games can be created using the programming language Lua.

Tiny is designed to help you create and test your ideas quickly and effectively. Not only can you run your games on your desktop computer, but you can also export them for the web, making it easy to share your creations with others.

You can create games easily with the hot reload, small API and Lua, which is very easy to learn.

If you want to test a game idea, to try to create your first game or just have fun, give it a try to Tiny.



Kotlin is pretty nice as a language: quite strong type system, good tooling (like JetBrain's IDEA Community), terse, supports functional programming quite well, etc.

Lua OTOH is not so much a favorite of mine. Could I use this without Lua, just using Kotlin throughout?


Not a the time.

If you want to try Kotlin for creating games, I advise to check other game engine:

- https://littlekt.com/ (LittleKt (Little Kotlin) is a multiplatform 2D game framework written in Kotlin)

- https://korge.org/ (Korge - Modern Multiplatform Game Engine for Kotlin.)

- https://github.com/minigdx/minigdx (Minigdx - Minimalist Game Framework using Kotlin Multiplatform / I created it before creating Tiny)

- https://libgdx.com/ (LibGDX, it's for Java but you can use Kotlin, if you don't want to target the web platform)


I used LibGDX with a Kotlin wrapper that's available. Worked well!


As opposed to a 2D Game Engine in Kotlin Working with Kotlin? Why?!?


Lua is easy to learn, dynamically typed and doesn't need to be compiled: it's perfect to get instant reload and it's perfect for small projects.

If you want to create games using Kotlin, you can try my 3D Game Engine: minigdx (https://github.com/minigdx/minigdx).

Or other game engine:

- https://littlekt.com/ (LittleKt (Little Kotlin) is a multiplatform 2D game framework written in Kotlin)

- https://korge.org/ (Korge - Modern Multiplatform Game Engine for Kotlin.)

- https://libgdx.com/ (LibGDX, it's for Java but you can use Kotlin, if you don't want to target the web platform)


Because Lua is popular among game development enthusiasts? It is THE scripting language of game development. It's the language of choice by Roblox Studio.


I'd say its the language of choice for game modding (which roblox pretty much is) specifically, but not game dev as a whole. In fact I'd go so far as to say its not used in game-dev enough, it seems to be greatly under-appreciated. The only engines I can think that use it are PICO-8 and Love2D.


Feels like we've been getting a lot more fantasy-console-style frameworks/engines lately and I've gotta say I'm all for it. Not sure this one is for me, but love to see it regardless!


Which one would you prefer? Any favourites? Looking to create simple games/animations that I can embed into a web page without too much hassle.


I like PICO-8. The limitations it has (e.g. 16 colors, 128x128 screen) seem to "offend" some folk though. I have learned to like the limitations.


The fact it has a fixed colour palette as well is fantastic, takes a lot of the guess work out of choosing the perfect colour, also means PICO-8 games have a shared look which is nice.

I'm working on a game at the moment which is inspired by old ZX Spectrum games, so sadly that rules PICO-8 out (different colour palettes), but otherwise those limitations make the whole thing really nice


Right out, the most interesting ones to me are WASM-4, because it seems to be one of the strictest and most minimal, and Pyxel, because it uses Python. Though to be fair I haven't actually tried either of them yet.

If you just want the "best" one (obviously very subjective, but its the easiest answer), try Pico8


Nice work. I was just looking at that other Lua game engine outlined in that post about simple coding. The first thing I wondered was how to handle resolution. It wasn’t clear to me in the docs for that older game engine. It’s one of the early things you mention in your docs. I think I’ll give this a try.

I have never created a game but I built a hobby slot machine cabinet and I need to build the game. The attached TV is 1080P turned in portrait mode. I’ve hidden a raspberry pi in the cabinet but I could use anything.


I didn't build Tiny for performance, I'm afraid that you might get poor performance. But you can give it a try!


Looks pretty cool. I’m curious how Lua scripting support is handled for the web platform. There have been one or two different projects for Lua support on the web in the past.


Looks like it uses luaj to run scripts from kotlin, and the whole kotlin project can use the Kotlin/JS compiler to target the browser.


Actually, it's using Luak (https://github.com/korlibs/korge-luak). It's a port of LuaJ for Kotlin Multiplatform.


Why not just use Java and hot deploy on the JVM?


It's in the first like 20 words of the post:

  > The engine was created using Kotlin *Multiplatform* and can run on a JVM and JS.
Kotlin allows you to have a single codebase that compiles and runs on:

- JVM

- WASM

- JS

- Native Windows/Linux/Mac (LLVM)

- Android, iOS/tvOS/watchOS

This is disregarding any notions about the language benefits of Kotlin vs Java.


Oh, ok I thought the demo was a picture because nothing happended when you clicked the thing...

The JS version has very high latency. How does it work under the hood?

Can the same pipeline port Java Applets to WASM/JS?


  > How does it work under the hood?
The Kotlin is transpiled to JavaScript by the Kotlin compiler:

https://kotlinlang.org/docs/js-overview.html


Not sure about Kotlin, but there is alreadt CheerpJ that can run Java applets unmodified both as normal JS, or as WASM.

For non-applets there is even more possibilities: there is google’s closure compiler and teawm, both can produce really great code!


It literally is the first thing you see.

The docs at https://minigdx.github.io/tiny/ have a demo "BREAKOUT" game embedded in the page under the first paragraph with a link to the source code lol

Screenshot for reference: https://i.imgur.com/TVzQwiu.png


I think it would be more interesting to expose how the bytecode becomes JS.

But I guess I'll dig through at some point...

nm, that breakout (that you could run on a 6502) maxxes a 15W modern CPU core. That's 10.000x less efficient.


  > I think it would be more interesting to expose how the bytecode becomes JS.
There's no bytecode emitted -- Kotlin is unique among JVM languages in that it acts more like a frontend, similar to LLVM or GCC.

The Kotlin code is translated from an IR/AST into JS directly. The JS is one of many target languages for the Kotlin compiler.

    Kotlin Source Code
            |
    Kotlin Compiler
            |
            IR
       /   /    \    \
    JVM  WASM  Native JS


> Kotlin is unique among JVM languages in that it acts more like a frontend, similar to LLVM or GCC.

"Unique among JVM languages" lol. Like most of the good parts of Kotlin, this was actually copied from Scala.


Scala has good parts?


browser games no have fps limiter and/or vsync?

oh i forgot, 2000 fps is good for bragging rights




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: