Best way to check what a user has clicked
Posted: Sat Jan 12, 2013 11:59 pm
I'm starting work on a fairly simple RTS, more so to advance my knowledge in Love and less so to make an amazing game. My question is- what is the best way to determine what a user has clicked on? My game is on a grid, so that helps simplify this problem. I've got one approaches which I feel might work;
1) Store every active entity (anything the player can interact with) in an X by Y matrix. When the player clicks, determine what tile was clicked. Check the matrix to see if theres any object in that location. Object move fluidly between tiles, which poses a small problem here.
2) I think I'm going to have another list that contains any entities that are in motion. The game will just have to check that entire list if it doesn't find anything in the first matrix.
3) This then leaves the environmental objects to be checked. Luckily, this one won't change much, as depleting a resource takes some time.
Overall, I think this should be a good strategy. Any thoughts on other ways to optimize this?
1) Store every active entity (anything the player can interact with) in an X by Y matrix. When the player clicks, determine what tile was clicked. Check the matrix to see if theres any object in that location. Object move fluidly between tiles, which poses a small problem here.
2) I think I'm going to have another list that contains any entities that are in motion. The game will just have to check that entire list if it doesn't find anything in the first matrix.
3) This then leaves the environmental objects to be checked. Luckily, this one won't change much, as depleting a resource takes some time.
Overall, I think this should be a good strategy. Any thoughts on other ways to optimize this?