Alright, back to this.
Work Since Last Devlog
- For drawing tilemaps and handling collision detection, I added a tile ID table to consolidate attributes, such as whether a tile is an obstacle, if it should damage the player on contact, etc.
- Fixed some bugs related to map cell lookups, caused by me incorrectly converting zero-indexed 2D coordinates to one-indexed 1D arrays. Oops. Seems good now.
- Added some flags to control scrolling behavior: whether to scroll off the map or remain within it, and a flag to force flick-screen scrolling (that is, the view doesn’t scroll at all, only jumping from one screen to the next as the player moves off the edge.) The above indexing issue was uncovered by scroll positioning errors that became apparent while adding these flags.
- Added an animation change function: the player now shows the correct animations for standing, walking and jumping. Also added center XY parameters for animation frames so that they can be offset from their associated actor’s bounding box.
- Consolidated global variables and resources into one parent table to better organize things. Moved graphics and map coordinate functions out of main.lua into their own source files.
- Added a table of ‘template’ actors, and functions to add or remove actors from a given map.
- Added basic object spawnpoints (really just a marker for the player for now).
- Worked on organizing collision detection and tile attribute checks into wrapper functions, and improved collision checks between bounding boxes and maps in cases where the actor’s box is substantially larger than the map tiles. There are still issues with very small boxes, but this is a start.
- Wrapped input so that keys / button rebinding can be handled later, and also added a check to prevent both left+right and up+down from being considered “on” when they are held at the same time.
Thoughts
The existing code is not so rosy, and far from what would be considered proper use of Lua, but I think I can shape it into something that fits my needs, for this game and for future projects of the same style. Before this week, the map wasn’t displaying correctly, collision detection only worked against one hard-coded tile, and animations were technically present, but not actually connected to the player’s actions. I’m happy with this week’s progress.
My earlier goal to get this done in two weeks could have (maybe?) resulted in a finished game, but the underlying scripts wouldn’t be useful for future projects. I’m enjoying working on issues and getting things working, but at the same time, I don’t want to spend forever on this. What to do…
Plans For Next Post
- Checkpoints with working object respawns
- Coins, Spikes, Jump power-ups
- Integrate sound and music into project
- Make wrapper function to displace actors while accounting for collision checks