After my freshman year came the summer of 2017. I was full of ideas for new games I wanted to create, most of them being from a 2D perspective. In web programming, we worked a lot with the concept of tile engines. Tile engines are just the idea of storing the maps as a two-dimensional array which can be used for easy level creation, drawing, and collision detection. These have a lot of downsides, everything must be designed on a grid system and level geometry usually must be squares or at least have the hitboxes of squares. In the future I would go on to experiment with things like line engines, which store levels as a bunch of pairs of coordinates that make up lines that the player can't cross. These allow you to make some more complex shapes but they are not very practical for large maps.
I had all these ideas for games and I had a lot of experience in tile engines, so I decided it would be best to make my own tile engine that would allow me to make all these different games with much greater speed. I'm not a framework guy, since I like to make everything myself, but I figured if I made my own framework it could have all of the features I need, and I could understand exactly how it worked. I wanted to go all out with features, and make it playable from both top-down or side-on perspectives. I figured a tile engine would be suitable for any of the games I would be making and would be beneficial for its simplicity.
I would not end up finishing this project, mainly because I kept getting distracted by other projects, but I hope that one day I will complete it. What I did get done was a camera system I am very proud of, and a collision detection system I think is approaching being amazing. I'll first talk about the camera system since that's what the bulk of the current development time went to. I knew from the start that I would want to make the camera an object, so that it could have it's own X and Y coordinates, allowing it to move independently of the player. Figuring out the math for this was difficult. The render function has to figure out how to draw the tiles by looking at where the camera is in the map, going out half the dimensions of the canvas in all directions, plus going out a little bit more to draw things like half tiles. This sounds simple enough on paper but it took me a good deal of visualisation and deep thought to actually implement it. Another point I had to keep in mind was the idea of the coordinates in the pixel grid as opposed to the coordinates in the map array, which were scaled down by a factor of the size of a tile.
Despite the headache that it caused, I was quite happy to have gotten this system implemented, since it allowed me to add a few different fun camera styles. Making the camera stick to the player was easy enough, just match its X and Y to those of the player, but I was also able to make a dynamic system which measured the relative distance between the camera and the player. From this it was able to cap that distance, allowing the player to effectively push the camera when it hit the limits of an invisible box, the location and size of which the user could control. Even simple things such as camera pans or zooms were exciting to me, since I had not been able to do them on any of the tile engines I had made or worked with previously.
The other large feature I wanted to add was pixel-perfect collision detection. This basically meant that if a player was moving so fast that their position in the next game tick would be inside a tile, rather than not moving at all, they would get as close to the edge of the tile as possible and then stop. I like this idea a lot, but my implementation was imperfect. Some of you may notice in the demo that if you collide with a solid tile while you have a lot of upwards momentum you will teleport to the top of the tile. This is likely caused by the engine trying to put the player right up against edge when their predicted movement position lands above the tile, despite the path there obstructed. I'm sure the fix for this isn't too difficult if I put some thought into it, and it'll probably be the first thing I do whenever I pick this project up again.
A big goal of the Spire engine project was that it would be easy to develop with. This mostly consisted of me writing lots of comments, but it also resulted in me making many constructors for things like new tiles or animations. To demonstrate a bit of these features I made some pretty basic artwork and some pretty ugly levels. I packaged this into what I called an alpha and that is currently where the engine stands. I had big ambitions for this project: I planned to add enemies and NPCs with pathfinding, weapons, level switching, and save states, among other things. Where it currently stands, this was a fun little baby project, but someday it might become one of my largest and most useful.