Fork me on GitHub
#beginners
<
2023-12-01
>
Jonathan Bennett11:12:05

Bit of a conceptual question about cljfx. I'm building a game, it's going to end up being relatively complex. In particular, I want it to eventually be able to allow network play, so atoms seem like exactly what I need.

Jonathan Bennett11:12:38

So I created a *game atom that holds a map with all the game data. But it seems that cljfx recommends you have a *state atom as well. So now, I have a list of the forces in this game (the teams, if you will). That ought to be part of the *game atom. But when I put it there, then I don't know how to get the display listing all the forces to update when I add one.

Jonathan Bennett11:12:57

I feel certain that I should not mix the GUI state and the game state into the same atom, because if I do that then I can't use that atom to share game state between different clients. But how do I tell the GUI that the variable has updated if it isn't in the one that it's watching?

Jonathan Bennett11:12:30

Is this the wrong channel to ask in? I don't mind moving somewhere else if this conversation is beyond "beginner"

daveliepmann12:12:11

maybe #CGHHJNENB

šŸ‘ 1
Jonathan Bennett12:12:48

Aha, still remembering how to interact with Slack. Forgot about channel searching.

practicalli-johnny12:12:06

I suggest multiple games should contained within the cljfx application state atom, e.g. using a unique game-id as the top level key for each game state. The game data and application state is data about the game and the functions define how the UI is rendered, so there is separation. Specific info can easily be extracted from a hash-map (and nested hash-maps with get-in or threading macro)

practicalli-johnny12:12:58

Sharing a specific game state over the net would be a matter of pulling out that data out of the application state (assuming not all state is to be sent)

Jonathan Bennett12:12:35

So within the single *state atom, I would have a :game key which has the game's state in it.

Jonathan Bennett12:12:30

Or even just merge the two previously separate maps and not nest them

practicalli-johnny12:12:04

Having a single map in an atom is the approach I've taken with reagent. I pull only the relevant part of the state (hash-map) and send it to the relevant function

āœ… 1
practicalli-johnny12:12:26

If the starting state become a very large amount of data, it could be separate for convenience of development, but using multiple states does make more cognitive work for the developer (remembering which state has what data)

Jonathan Bennett12:12:07

Yeah, that's why I was basically just trying to say "This atom is the save game, the other atom is anything else."

Jonathan Bennett12:12:17

At any rate, this'll work and we'll see how far I get till we get stuck.

Isabel12:12:36

Hey, guys I'm working in a new project from the company I work for and there is this uberjar file I'm trying to run but it doesnt work on my machine, so I thought it could be specific from the Java version I was using Things I've tried already to solve it 1. uninstall and install clojure again The aplication was built on this java version: openjdk 11.0.21 (wich I'm currently using) and I am using this clojure version: Clojure CLI version 1.11.1.1413 So, everytime I try to run clj -T:build uberjar :project project-name I receive the following error

WARNING: random-uuid already refers to: #'clojure.core/random-uuid in namespace: monger.util, being replaced by: #'monger.util/random-uuid
Building uberjar target/project-name.jar...
Execution error (NullPointerException) at clojure.tools.build.tasks.uber/copy-stream! (uber.clj:50).
null
I couldn't find references on dealing with this error in specific Does anyone know what could try next?

Ed12:12:20

You've probably got an alias in your deps.edn file called build that points to a build script in your project that is calling copy-stream! with something that's null ... maybe you've missed a step in project setup, like creating a config file that's not checked in to git or something?

Ed12:12:52

https://clojure.org/guides/tools_build#_compiled_uberjar_application_build ... this is the guide that describes how to set up this tooling ... maybe what you have to that will give you some pointers?

Alex Miller (Clojure team)14:12:47

which version of tools.build are you using?

Alex Miller (Clojure team)14:12:09

you would find this in your deps.edn under the :build alias

Alex Miller (Clojure team)14:12:13

v0.9.4 fixes a case where ephemeral files (in particular editor backup files) that exist on your disk could cause this issue, so if you are are on something older, I would definitely update to latest (v0.9.6)

Alex Miller (Clojure team)14:12:32

the other thing it could be is a symlink (see https://clojure.atlassian.net/browse/TBUILD-36) which is an open issue

Isabel14:12:19

@U064X3EF3 I was using the version 0.9.3 and that was causing the problem, thank you so much for the suggestion, it solved the problem We've updated our application to the version 0.9.6 of tools.build too

Roman Liutikov19:12:10

Heads up for beginners. Iā€™m doing Christmas YouTube series on web dev in clojurescript, the first episode is already out https://youtu.be/w5CCZQBNFSc Also make sure to check out the intro episode to learn more about the project https://youtu.be/_2PBcVv210g

ā­ 4
Alex Miller (Clojure team)20:12:33

might also want to x-post these in #C8NUSGWG6 so they get picked up for Deref

Roman Liutikov21:12:24

Makes sense, thank you