clojure-gamedev

2022-11-09T13:27:02.880709Z

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

πŸŽ‰ 7
markx 2023-06-24T21:28:47.106459Z

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

2022-11-09T14:53:36.160669Z

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

zane 2022-11-09T17:30:41.992879Z

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

βœ… 1
2022-11-10T05:39:55.732369Z

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

ray 2023-06-18T09:14:51.391369Z

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

ray 2023-06-18T09:14:55.663839Z

commit ec3fd98d85fe416c1d0b6a8715d44769de51d9d1
Author: Michael Sappler <michaelsappler@gmail.com>
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

ray 2023-06-18T09:15:26.254889Z

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

2023-06-18T09:16:20.456639Z

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

ray 2023-06-18T09:16:22.674569Z

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

ray 2023-06-18T09:16:31.719389Z

ha, ok

ray 2023-06-18T09:18:34.638359Z

OK - it's up! Thanks ... now to see how the magic happens πŸ™‚

2023-06-18T09:18:53.125469Z

Nice !

2023-06-18T09:19:07.094039Z

It's very simple not any magic

ray 2023-06-18T09:20:04.316659Z

sure but I'm a total newb to this stuff so it feels like magic right now πŸ™‚

ray 2023-06-18T09:20:48.471489Z

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

2023-06-18T09:21:05.546369Z

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

2023-06-18T09:21:43.030759Z

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.

2023-06-18T09:22:25.426899Z

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

ray 2023-06-18T09:22:56.950529Z

ok - thanks for the tip!

2023-06-18T09:23:38.122539Z

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

ray 2023-06-18T09:23:58.452629Z

yeah, I'm feeling that too

2023-06-18T09:24:01.859339Z

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

2023-06-18T09:24:37.201559Z

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

πŸ™πŸΌ 1
ray 2023-06-18T09:25:01.266479Z

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

2023-06-18T09:26:28.793979Z

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

ray 2023-06-18T09:28:04.577889Z

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

2023-06-18T09:29:35.418639Z

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.

2023-06-18T09:30:39.304599Z

Probably should write some nice documentation and examples for the library, maybe pong πŸ˜‰

😍 1
πŸ˜‚ 1
ray 2023-06-18T09:30:47.786249Z

Ha - maintained still by @sekao πŸ€¦πŸ»β€β™‚οΈ

2023-06-18T09:42:47.294419Z

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

2023-06-18T09:43:02.135449Z

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

😍 1
ray 2023-06-18T11:44:44.197929Z

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

2022-11-10T14:24:58.468319Z

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.

ray 2023-06-16T08:41:14.989989Z

@mx2000 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

2023-06-16T09:47:03.803289Z

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

2023-06-16T09:51:49.159729Z

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

ray 2023-06-16T11:53:15.878219Z

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