How do I reference when an image touches another?
Mostrar comentarios más antiguos
I am essentially creating a game within MATLAB. Currently I am having an issue with causing something to happen if two objects touch.
An example of how the world is set up is a 10x10 cell named World.
so if World{x, y} = Player; World{5, 5} = Monster;
How would I be able to decrease Health by 1 if the player touches the monster? A simple Player == Monster doesn't work and I need advice.
4 comentarios
N.
el 15 de Nov. de 2017
you can check if the player is next to the monster. That means, if the player is on (x,y) and the monster is on (x',y'), you check if (x,y) is equals to (x'-1,y') or (x'+1,y') or (x',y'-1) or (x',y'+1)
Rik
el 15 de Nov. de 2017
Wouldn't it be more straightforward to save position separately? Because now a player can be overwritten by a monster.
Josh Ondayko
el 15 de Nov. de 2017
Image Analyst
el 15 de Nov. de 2017
Why is world a cell array instead of a regular numerical array????? Don't complicate things!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Strategy & Logic en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!