Boulders start to fall
Implemented falling boulders, including when boulder slides to the side. Gems (or diamonds?) will also have this behavior, though there's no gems for now.
I've made list of entities for that. When boulder starts to fall (triggered when space appears under, i.e. by eating ground by main character), an entity is created for it. When it settles to the ground and there's nowhere to fall further, entity is deleted and boulder is just a map tile value again. This might be overkill, it might be enough to just iterate over all map tiles and apply cellular automata logic, but what is done is done. I don't know how original game (i.e. on ZX Spectrum) does it, didn't look into it with disassembler. Entities also allow for smoother animation of boulders moving, but it's not at priority for now.
Table of entities is somewhat inspired by ECSes, but I didn't implement real ECS. It's a regular Lua table, but accessed like hash table, not like a list, so when entity is deleted (by assigning nil, pretty cool feature of Lua), it just disappears, further indices are not renumbered (it's not table.delete). It works like autoincrementing ids in relational database. What's interesting is that in Lua it's safe to delete table entries while iterating, but not to create new entries, for that reason I defer created entities to dump into main entity table at the end of game loop.
Entities don't have types, I distinguish between them by presence of hash keys, in its way it's similar to ECS, and it's something related to "row polymorphism", which is somewhat at hype now, lol.
Too bad boulders duplicate when falling to slippery surface, will be fixed later. And there's no cool sound when boulder drops.
Knockoff
A knockoff of Boulder Dash
Status | Prototype |
Author | kolen |
Genre | Puzzle |
Tags | 2D, boulder-dash, boulderdash, TIC-80 |
Languages | English |
More posts
- Implemented winningApr 28, 2019
- Some falling blocks' fixesApr 27, 2019
- Added title screenApr 27, 2019
- Fixed slipping (partially), added gems, added camera movementApr 26, 2019
- Initial importApr 22, 2019
Leave a comment
Log in with itch.io to leave a comment.