How do I reference when an image touches another?
Afficher commentaires plus anciens
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 commentaires
N.
le 15 Nov 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
le 15 Nov 2017
Wouldn't it be more straightforward to save position separately? Because now a player can be overwritten by a monster.
Josh Ondayko
le 15 Nov 2017
Image Analyst
le 15 Nov 2017
Why is world a cell array instead of a regular numerical array????? Don't complicate things!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Strategy & Logic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!