How do I reference when an image touches another?
Ältere Kommentare anzeigen
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 Kommentare
N.
am 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
am 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
am 15 Nov. 2017
Image Analyst
am 15 Nov. 2017
Why is world a cell array instead of a regular numerical array????? Don't complicate things!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Strategy & Logic finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!