Fork me on GitHub
#clojure-gamedev
<
2022-11-09
>
mx200013:11:02

I released my small 2d game engine based on libgdx: https://github.com/damn/engine

🎉 8
Noah Bogart14:11:36

Looks pretty cool! Any plans to write up some documentation?

zane17:11:41

Link to libgdx, http://libgdx.badlogicgames.com/, is broken. Looks like maybe it should be to https://libgdx.com/ instead?

1
mx200005:11:55

What kind of documentation would you suggest ? Function docs, a wiki page and more demos ? Maybe demo code would be self explaining

Noah Bogart14:11:58

Well, when i open the code directly, core.clj has multiple TODOs, commented out code, empty functions. And there are both engines and test files with trailing underscores. The whole thing feels in progress. So any sort of example or demonstration would be nice.

genRaiy08:06:14

@U0ALH6R89 tried to start it up as on the README and got this

Compiling 4 source files to /Users/raymcdermott/dev/engine/target/classes
engine.repl
Started nrepl server on port 7888.
Execution error (IllegalStateException) at org.lwjgl.glfw.EventLoop/<clinit> (EventLoop.java:30).
GLFW may only be used on the main thread and that thread must be the first thread in the process. Please run the JVM with -XstartOnFirstThread. This check may be disabled with Configuration.GLFW_CHECK_THREAD0.

Full report at:
/var/folders/gy/0hq5_8w14p1c3js2xp_56nch0000gn/T/clojure-7944764583082658076.edn
➜  engine git:(main) java --version
openjdk 17.0.7 2023-04-18
OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7)
OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode)
➜  engine git:(main) uname -a
Darwin Rays-MacBook-Air.local 22.5.0 Darwin Kernel Version 22.5.0: Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64

mx200009:06:03

Hey As written there you need to start the JVM on Mac with -XstartOnFirstThread .

mx200009:06:49

It's required for libgdx to run on Mac. Oh and don't use the latest commit 'WIP'. I hacked some stuff together last days

genRaiy11:06:15

Ok. Will let you know how it goes. Thanks for responding so quickly. Very eager to learn about your project!

genRaiy09:06:51

ok, so I uncommented the -Xflag and reset the branch to this point

genRaiy09:06:55

commit ec3fd98d85fe416c1d0b6a8715d44769de51d9d1
Author: Michael Sappler <[email protected]>
Date:   Fri Jun 16 19:04:06 2023 +0545

    A bunch of changes
    
    * Added raycaster
    * Improved image performance
    * Move camera-position out of render-map
    * Remove special tiled map generation code out of the engine

genRaiy09:06:26

But it fails with a different error

lein run -m engine.repl
engine.repl
Started nrepl server on port 7888.
Starting Lwjgl3Application
Execution error (ArityException) at engine.input-test/render* (input_test.clj:15).
Wrong number of args (7) passed to: engine.graphics/render-readable-text

Full report at:
/var/folders/gy/0hq5_8w14p1c3js2xp_56nch0000gn/T/clojure-18265034290915869168.edn

mx200009:06:20

Hey i fixed the latest wip commit, just use latest main please.

genRaiy09:06:22

I guess I'm at the wrong commit. Could tell me which commit to be at or make a tag for the "working" version.

genRaiy09:06:34

OK - it's up! Thanks ... now to see how the magic happens 🙂

mx200009:06:07

It's very simple not any magic

genRaiy09:06:04

sure but I'm a total newb to this stuff so it feels like magic right now 🙂

genRaiy09:06:48

Maybe I should get to the point though: I want to make pong. Will it be simple with this engine?

mx200009:06:05

There are two coordinate systems, the GUI and world. Here i call two functions to render in the respective coordinate systems: https://github.com/damn/engine/blob/77658650490ce59ca5402e5750525f5c343cd6e4/test/engine/simple_test.clj#L93

mx200009:06:43

The point of this is because I am making an rpg game on top of this , so i can work directly with world coordinates/zoom/etc.

mx200009:06:25

Yeah for pong just don't use the map/world coordinate system, you can render everything in gui

genRaiy09:06:56

ok - thanks for the tip!

mx200009:06:38

I wanted to write some tutorial or explanation for the engine but didn't have time yet. Because there is really nothing for games in clojure yet

genRaiy09:06:58

yeah, I'm feeling that too

mx200009:06:01

The main thing you have to know is the Game screen protocol: https://github.com/damn/engine/blob/main/src/engine/core.clj#L36

mx200009:06:37

Basically the game is a loop of render<->update happening X times per second

2
genRaiy09:06:01

@U080181PF made a talk in 2014 to suggest gamedev was important but it seems to have fizzled

mx200009:06:28

Also I am just using a minimal thin layer of clojure on top of the libgdx classes/methods i required for my game, so if you want to dive deeper check out more of libgdx. But this should theoretically work fine for 2d games

genRaiy09:06:04

Ok … I’m wondering why there isn’t a Clojure library for libgdx

mx200009:06:35

There is, called play-clj. But it is more like a wrapper implementing all or trying to implement all Java code. With my library i tried to keep it focuses on 2d games and very minimal and simple, you shouldn't need to know too much libgdx stuff.

mx200009:06:39

Probably should write some nice documentation and examples for the library, maybe pong 😉

😂 2
😍 2
genRaiy09:06:47

Ha - maintained still by @U080181PF :man-facepalming::skin-tone-2:

mx200009:06:47

You should be able to close the window and the. The dev-loop namespace calls refresh all on your code, loading all changed files without restarting the jvm

mx200009:06:02

Or you connect with repl , but if you make more changes it's useful

😍 2
genRaiy11:06:44

Gotta say that play-cljc seems like the bomb. But it’s good to have options!

markx21:06:47

Hi! Is there a way to use this engine as a lib?

markx21:06:47

Hi! Is there a way to use this engine as a lib?