ikarth / game-boy-rom-generator

Game Boy ROM Generator
MIT License
7 stars 0 forks source link

Add interpreter for GBStudio files #119

Closed ikarth closed 4 years ago

ikarth commented 4 years ago

It would be useful for us to be able to edit templates and examples in GBStudio and then have the generator parse the GBS project file and translate it into the code for the generator.

ikarth commented 4 years ago

Rough plan: Step one: Ideally, we can store the GBSproj files in the repo, in a place they can reference the assets, without moving the assets. Step two: load and parse the JSON Step three: translate the data structures into templates Step four: write templates out as Python code Step five: test round-tripping the changes

A separate question is if a JSON-native format is a better way to express the generator templates compared to a set of Python functions.

ikarth commented 4 years ago

The complication turns out to be that turning the JSON into a template with one fixed output is relatively easy, but handling things like links to other scenes and referencing specific variables and actors makes it more complicated.

ikarth commented 4 years ago

Current architectural question: how to handle connections.

Connections serve as a test case for variables in the templates--we have a bunch of stuff that we'll want to vary eventually. (Think of Spelunky's room generators, for one example of how that can work.)

The problem right now is that right now when we run the scene-generation-function (in the project-generation function) we don't know what the connections are going to be: we're creating the pool of rooms and only after that deciding how they should be connected.

We can restructure the generator to hang on to the room functions and only invoke them once we know what the connects are going to be (using a scene-template-data-object that has the scene-generation function and a list of connection slots) or we can generate the scene and append the connections after the fact, or we can do some other reordering.

ikarth commented 4 years ago

A rough sketch of how the import pipeline works right now: GBStemplate_pipeline

I think, based on what I've discovered so far, is that the best way to store the scene generation information is as a data structure with the following parts:

Right now, the scene generation functions are generated Python code that runs the Python commands to create Scenes, backgrounds, spriteSheets and so on and attaches scripts to them. Could probably be equally handled by something that took the JSON structure and more directly translated it into a scene template dictionary, plus a function that translates that template dictionary into the generated scene and supporting data.

The generator doesn't care where the sceneGenerationData comes from, after all.

ikarth commented 4 years ago

Turns out that when I take my own advice and start by making a concrete example of what I want the generator to make things go a lot faster.

ikarth commented 4 years ago

Mostly works as of #142 though I suspect that there are some possible bugs that testing will reveal.