Discord
Login
Community
DARK THEME

How to detect wall touch?

How to detect if an object touches a wall in Quick?

You could use Quick.mapCellAt(map,x,y) for that. For example:

if Quick.mapCellAt(mymap,hero.x+10,hero.y) == "wall" then
  print("the right hand edge of my hero (hero.x+10) is touching a wall.")
end

Quick.mapCellAt() returns the name of the sprite which you painted on this map cell, thus I am assuming you have a sprite named "wall" and want to detect when the right edge of your hero touches it. Also the +10 can be adjusted depending on the size of your sprites and the tolerance zone you want to have.

Ok Cool!I was going to use that for enemies.

oh, that's an easy way to do collisions! Usually it's really complicated and requires lots of reasonably difficult code (for me at least). Thanks (again) Gilles!

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community