Why is overlapping a wall not the same as hitting it, and how can I work around this?

I’m making a snake game, where obviously the snake has to die if it overlaps a wall (the boundaries of the screen) or its own body (which is made of walls).

For good reasons, I have decided that detecting overlapping sprite kinds will not work in this situation, and I also don’t want to check for overlaps of every single tile as there are quite a few of them.

So, I turned the bad tiles into walls and put an hits wall at location block. However this wasn’t working, and I think I know why. The snake head does not ever “hit” the wall; rather, it overlaps it. This is because it is moving forward by chunks of 16 pixels at a time, rather than one. So I can see why the block may not work. However, I was wondering if anyone knew an easy way to fix this somehow… maybe? … hopefully…

Anyway, here’s the link:

Hopefully someone can help me… if not, I guess I’ll just have to place millions of overlap tile blocks (exaggeration)

– DogSquid :slight_smile:

1 Like

It should be easy to check if the tile at the location of the snake head sprite is a wall, just using the blocks in the tilemap area! You could even get fancy and detect the tile in front of the snake if you wanted! The blocks would be something like:
If (tile at (location(tile to [center] of (mySprite) ) ) is wall) then…

2 Likes

Thank you so much! I had a closer look at all of the blocks in the tilemap section and successfully solved my problem. I guess I’ll look more carefully before asking next time…

1 Like