Is it possible to make a sprite react to being over a certain tile color

hello. I’m new here. I have been using makecode for a while now, but just now became old enough to use the forums. I’ve been wondering if there is a way to make a sprite react to a certain color that its on. Like, if a sprite is on a green part of a tilemap you could move freely, but if the said sprite is on a brown part of a tile, your gravity would increase and you would start falling. If there’s not a way can you tell me if there is a substitute. thanks.

3 Likes

The most efficient solution would be to create an array of all the green tiles and another of all the brown ones, then check if a sprite overlaps a tile in either array and apply the effect. If you mean brown and green on the same 16x16 tile, then you might have to map the players X and Y to the tile they’re on and checking the color matches up, but I can go into more detail later if that is what you need!

1 Like

Thanks @randomuser , you were a big help!

1 Like

No problem! I’m glad I could help! :sparkling_heart: