Quixe (or alternative) running multiple games at once

Hello all!

Does anyone know if Quixe (or a similar JS alternative) can run more than one game at once? From my reading of the Quixe code, it seems to assume one game at a time.

Thank you for any pointers!

I’m not quite sure how you’re envisaging “running more than one game at once”. I certainly can’t picture what that would actually look like. How would you provide input?

You can, of course, simply run multiple separate copies of the interpreter – separate app instances or separate tabs/frames. These can even communicate with each other under controlled circumstances.

Quixe is currently designed to be a singleton, not a class, so this isn’t really possible to do in one JS context. But you can, as @mirality suggests, put up multiple Quixe instances in frames next to each other.

I have proposed moving GlkOte over to using JS classes, and it wouldn’t take much to do the same for Quixe. It just hasn’t been a priority for anyone yet.

That’s what I was looking at but I didn’t want to embark on it if I was missing a simpler approach. Would there be an appropriate way for me to approach this? I’m asking both about the code refactoring and with making it available to others after. This is my first time making such large changes to someone else’s library, should I discuss a github fork with @zarf?

Are you asking about a browser context (a web page) or a headless process in node.js?

In a browser context, as mirality says, the simple way is to have two iframes on a page. Restructuring the interpreter into JS classes doesn’t help here, because GlkOte is built to use unique element IDs (like #window1); it doesn’t have a notion of two separate element trees in the same DOM. But putting them in separate iframes is fine.

If you’re talking about node.js, then class refactoring makes sense. Dannii’s notes on using JS classes are here: https://github.com/erkyrath/glkote/issues/37 . That PR is out of date, though. Feel free to take another stab at it.

Now, there’s the work of refactoring the code, and then there’s the work of looking at all the other ways to solve the problem and making sure you’ve found the best one…

1 Like

Yep, iframes is the way I’m going. I’m not using Node.js so they’re the simplest solution. I’ve tested them and they can run more than one game at once. Now I’m working on cross-frame communication. I’ll release what I’ve come up with once it’s stable.