How do I reference when an image touches another?
이전 댓글 표시
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
N.
2017년 11월 15일
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
2017년 11월 15일
Wouldn't it be more straightforward to save position separately? Because now a player can be overwritten by a monster.
Josh Ondayko
2017년 11월 15일
Image Analyst
2017년 11월 15일
Why is world a cell array instead of a regular numerical array????? Don't complicate things!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Strategy & Logic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!