Sprite move through tile map walls?

Is there a way to allow sprites to go through tilemap walls whilst also being able to have collisions? This could be useful if had an enemy ghost, which could go through the tilemap walls while the player couldn’t but could deal damage to the player.

I was thinking of setting the ghost’s ghost flag to true and checking the distance between the player and the ghost and if was less than like 16 or something that would count as a “collision”.

Any ideas?

3 Likes

Idea…
No walls and make the player move backward if they touch a ‘wall’
Or make some code to make it a wall only if the player is near it
But yes your idea would be cooler
And easier

1 Like

That is a good idea, but the player would be able to walk halfway into a wall before I detect the tile overlap and push him back. My game also relies on the pathfinding extension which relies on walls too…

huh.
what about my second idea?

also have you found someone to help me with the map box scrolling?

Well, if a sprite that could go through walls goes near a player that has walls around him, still would be the same.

Sorry, no. :frowning:

I had the same sort of issue while making Frogging Fun. I wanted the cars and logs to overlap with the player, but still be able to move through the walls. That way it gives the appearance of leaving the tilemap. If that were possible, I don’t think there is a way of locating the sprite outside the tilemap. As you mention, you could make the sprite a ghost so that it leaves, but then it doesn’t overlap the player.
My solution was to add an extra column where the player may not move over, so that it looks like the enemy leaves the screen, when in fact it just stops at the wall. I use a on hit wall event to add the sprite to an array, and then a game update interval event to put the wall hitting sprites back to other side.

1 Like

I think that is reasonable to assume. The current sprite collision detection does take into account not overlapping transparent pixels, but if your sprites are all the same size and occupy most of the 16x16 space, then that shouldn’t be an issue.

1 Like

Yeah, they are all 16x16 and they mostly take up the whole space. Hopefully, the player won’t notice the fact they are taking damage even though the ghost is really close but not touching. The ghosts deal lots of damage and should provide a good distraction. :sweat_smile:

They should also add a distance function, like distance between [sprite] and [sprite] in pixels. Those functions are humongous in blocks.

Jacob made an interesting video explaining the distance between the two sprites, and I’m sure you know how to calculate it. What I didn’t know, is that you can have a block function return a value if you use the
‘beta’ version of the editor. I hope they incorporate that into the main editor, as returning values is essential.

1 Like

Well, it’s already here!

image

As you can see, I’m not in beta.

It’s been on our todo list for a while to separate out a flag for ghost collisions and ghost tilemap collisions. I’ll try and get it into the next release if I have time

2 Likes

The amazing @jwunderl comes through with a fix!

3 Likes

Yes! It’s been merged!

Just wondering - in the example @jwunderl provided, he had this link:


Is arcade.makecode.com/app beta beta (or something similar)? I don’t see it in arcade.makecode.com/beta.

It’s nothing super interesting - just a one off test build, specified by the long hex values following the /app :slight_smile:

1 Like