Game2 W3/4
Why is it the third week that I finally gain any interest in actually working on the game? Now, when I think of it, this may be the whole reason I couldn’t get into game dev during earlier attempts in the past years. I consider myself an OK programmer and I know a bit of math that is required for making basic games, so I doubt it was due to a lack of knowledge. Maybe it is that by the third week, there are some actual results that produce enough stimulation to my brain making it act as a feedback loop that amplifies the feeling until it burns out, and I just never stuck enough for that to trigger before. Well, I experienced something like that during my first game jam, but not so much after when I made further attempts at this. I guess forcing myself was the right decision.
Anyways. I mostly figured out the map problem I talked about in the previous post and the whole thing started moving, like, literally. I ported the camera into this project and made a really basic way of moving in the world and it already feels like a game:
This, however, didn’t go as smoothly, as the previous time. I’m still figuring out the quirks, as my rendering pipeline is kinda weird. You see, in the previous post, I made it so the tiles, used to build up a level, are baked into the cart’s map memory block. This way I don’t have to recalculate projections of every floor tile on every tic and can do culling, drawing only what’s really is on screen, plus some extra boundary for smooth camera movement. However, it means that when projecting to the level I need to account for the map offset, somehow. This turned out to be a bit more challenging than I thought.
For now, I put that problem aside, as I can always get back to it when I have more complex levels, and I needed to figure out the opposite of what I was doing in the previous post - project screen coordinates back to the world’s coordinates. Because this game is meant to be a roguelike I’m going to use the mouse in this game for movement with some automatic path-finding. Path-finding will have to wait though.
After a bit of trial and error, I got it working:
But again, this only works either for the static camera position, or a specific level geometry because of all the magic numbers spread through my code. I didn’t have much time this week, only the first half, so I basically did nothing starting from Wednesday. While it’s a shame, Starting next week I’m on vacation and hopefully will be able to spend much more time on the game and finish it in time. Or at least get all of the mechanics working, and publish it as another demo.
So, next up - world generation. I looked at some interesting algorithms for dungeon generation in 2D roguelike games and while many of them are interesting in their own way, I don’t want to complicate things that much. So instead, I turned to my older project - wave function collapse.
I’m going a bit ahead of myself here as I haven’t started working on this yet, but I thought that it will be a nice and organic way to generate small, fixed-size levels. But a plain WFC won’t work for me, so I made some adjustments. The basic idea is to choose some points on the finite grid and assign them to specific elements.
Here’s a janky drawing with all of this in place:
These objects in the drawing are:
- Four rotations of room exits, connected to a floor tile, corridor tile, and two wall tiles;
- level entry and level exit, connected to 4 floor tiles at each side;
- spawn tile, also connected to 4 floor tiles.
To evenly distribute things in the level, I decided to divide the world into four sectors shown above as a gray grid. Each sector can have only so many objects to hold, with the exception of entries and exits - these are shared across all segments and there can be only one of each.
Once objects are in place, the actual WFC takes over and fills the world. The blue walls on the image and black corridor paths will be generated by WFC, and because it will not pick empty tiles by itself, I suppose isolated rooms won’t appear. The nice part is that the rules can be extremely simple, as there are basically 4 types of tiles used, unlike my previous project. Of course, I can add variety later. But that’s the topic for the next week.