After having gotten the bulk of my current universe generation code ported to Game Maker 2, I found myself before a wall of immense proportions. My goal (regardless of platform) is to have something like a 10×100 grid (1000 coordinates) that makes up “the universe”. Each coordinate holds a star system. Each star system holds up to 8 planets, maybe an asteroid belt, wormhole, black hole or another steller artifact. Maybe there will be a station in orbit around a terrestrial planet, and each station will have a shipyard, which will have ships and ship parts; a bar for jobs and missions; a bank for storing and investing; and the commodity market, each instance continaing at least (as of last count) 70 some-odd items whose prices and quantities are unique to that station.

That’s a lot of data to create, which is why I’ve been working with a “procedural” method. The distribution of all of these elements doesn’t concern me except to ensure that it makes logical sense and that everyone has a little bit of something. This is the easy part because I’m a developer and the hardest thing I’ve had to rectify has been settling on just one method of approach. What’s stimying me, though, is getting all of this data into the eyeballs of the eventual player.

When I was working with Unity the tack was to create prototype objects that had exposed properties relevant to what they represented. A planet would have orbit and name and type as properties, and some of those properties, like type, would determine what model and texture the prototype would receive when instantiated in the scene. Because these prototypes could be instantiated with full functionality (i.e. scripts and stuff), I could build them using dummy data, test them, and then when the properties were populated with data from the database, everything would “just work”.

In the web version of the game, I don’t have to worry so much about that. Instead, I have to figure a way to transport data from the back end the front end in the most efficient way possible. I still rely on templates, since I have to effectively “build” the display based on what data I am receiving. In the Data panel, clicking on a planet should give different data than you’d get if you clicked on a jump gate or a station or an asteroid. Here, I have to build for all eventualities and swap them out based on the type of data I’m receiving from the back end.

I haven’t quite gotten a handle on how GM2 should be approached. With 1000 star systems, I don’t want to create 1000 “rooms” beforehand. GM2 has code that allows for the creation of rooms at runtime, but there’s a whole lot of bare-metal coding for this to happen, the instance doesn’t show up in the IDE for inspection the way it does in Unity, and there’s no way to save a room once it’s been created except to save the state of everything in the room and rebuild it if the player returns. Technically I’d be building it from the data already written to file in the Big Bang process, but it doesn’t seem feasible to do it this way (based on what little I understand about the process at this point). I could also create a “template” room and duplicate it, use the data to instantiate objects, set properties, and swap sprites, but I don’t know that this buys me anything that creating a room at runtime doesn’t provide except that I could create the room in the visual editor to make sure it meets the specs I need. After all, the room is just a container.

My current approach is to try and create rooms at runtime. I can actually do this before the control is passed to that room, which is helpful, so I can have the room cleaned and set before the player gets there. On the way out of a room, I can save the state of relevant information for the system they are leaving, and keep a time and date stamp so if that data exceeds a “freshness period” we don’t load the particulars next time — just the structure. Activities like buying and selling at the station are loaded and saved when the user begins and ends their transaction, so that’s not so much of a problem. I just hope I can understand the process of creating these rooms well enough so I can be sure that what I think is happening in there is actually happening in there, since I won’t be able to debug it.


Owner and author.

Leave a Reply

Your email address will not be published. Required fields are marked *