Today has been dedicated to getting the destructible blocks working correctly. I decided to change my strategy regarding these blocks. The player no longer interacts with them using the collide function of GMS2. Instead, the blocks create a normal block tile in the collision layer. When the block is destroyed, the tile is reverted to a blank.
This will work for normal blocks like the ones above. However, there will be indestructible blocks in the game that can be placed more freely. Those will be dealt with tomorrow.
Getting the rebound working smoothly was pretty challenging. My first sort-of-working implementation, see the video below, had a strange “jump” that was difficult for me to figure out why it was happening in real time. When I played it back frame-by-frame after recording it, the answer became clear to me: a binary flooring was taking place at the wrong location.
The binary flooring takes into account where the player is going to be. However, I had already adjusted the player’s y acceleration before it gets to that stage. As a result, it is bouncing from the wrong location, 16 pixels too high.
The other issue I had was that the rebound was too sudden before. I needed to treat the rebound and a normal jump separately. This allowed me to control the hop so that it was smoother.