oakes / play-clj

A Clojure game library
The Unlicense
939 stars 73 forks source link

REPL development in Light Table #2

Closed Misophistful closed 10 years ago

Misophistful commented 10 years ago

I know that play-clj is built to work out-of-the-box in Nightcode, but I've been trying to get the REPL workflow up-and-running in Light Table. So far I haven't been successful.

I can connect a lein-light-nrepl within LT (by evaluating a play-clj CLJ file), which launches the game window, but when I make code changes and re-evaluate them, the game isn't updated. I have to close the game window and relaunch it with another evaluation to see the changes.

REPL development works when I launch the project from a terminal using lein repl, so I think the problem is specific to Light Table. Do you know what I'm missing to get it working there?

Cheers, James

oakes commented 10 years ago

I haven't tried it in Light Table, but are you sure you are in the right namespace and are re-evaluating the entire defscreen call? Keep in mind that in the desktop project, the main function and the defscreen call are in separate namespaces.

shaharz commented 10 years ago

I just tried re-evaluating a defscreen after changing the on-key-down handler (in the minicraft example, not that it should matter) and that seemed to work ok.

Interestingly, evaluating any of the project's clj files didn't open a window. I had to evaluate a call to minicraft.core.desktop-launcher/-main for the game to start.

oakes commented 10 years ago

Right, the main function is within src, while the game code itself is within src-common. The reason for this is that Android and iOS projects don't have main functions, so that needed to be kept out of src-common.

Misophistful commented 10 years ago

Thanks, it's working. In fact, I think that REPL development was working all along - the problem was actually me not using my brain. I was following along with the tutorial, but instead of changing :on-key-down I thought I'd be "smart" and try changing something visible instead; the size of the image. The problem was that the image is defined in :on-show and not re-evaluated every frame. D'oh!