I have a bug in my game that I’ve replicated in a small, test project. When I click on a Squibble object (pink ball), it starts moving down the screen. If it collides with a block, or the grass at the bottom, it’s supposed to stop moving. Every time I’ve tested this, Squibbles stop moving when they hit a block However, whether or not they stop when they hit the grass seems random (sometimes they stop, other times they keep going)
Squibbles and blocks are normal sprites, while grass and dirt are tiled sprites. None of the objects have any behaviours, effects or variables, except Squibbles which have a single boolean variable (‘moving’) which defaults to FALSE. I have an object group (‘Solids’) which contains blocks and grass. I have two global variables: ‘grid_size’ (a number that defaults to 64) and ‘interactive’ (a boolean that default to TRUE). Here’s my event sheet:
The issue appears to be with the ‘Pick the Solids that is nearest to…’ condition. If I remove that then things seem to work as expected.
I could’ve sworn I needed that for the movement to work though, otherwise the Squibbles were just falling through the blocks. But maybe that was before I made other changes. Can’t recall. Anyway, working now!
I won’t mark this topic as ‘solved’ yet though, just in case anyone has any insight on why that condition was causing the problem. I’d love to hear people’s thoughts on that…
I considered (and tried) various ways of moving my objects through the grid. One of which was using collision detection. This worked, somewhat, but it felt wrong to be doing it that way for this particular game. I’d have to move a Squibble into a space, then check if that space was already occupied, and move it away again if so. Since my game will require Squibbles to sometimes move horizontally (depending on the type of block they’re ‘sitting’ on), being able to determine what blocks are around them is better when I don’t have to be moving the Squibble there first.
I also had the idea to possibly make it so that a block will ‘collapse’ under the weight of multiple Squibbles (i.e. if 2 Squibbles are stacked on top of each other on top of a block, then when a third Squibble lands on top of the stack the block will disappear). Doing this will require checking what object is 1, 2, 3 spaces below a given Squibble. Collision detection wouldn’t work here.
So since I’d have to be using the ‘check what object is at a given point’ method anyway, I figure I’d use that for my movement too.