I'm developing a map kind of simple game using slick 2D library, and I want to get the current location of the user. When the user runs into a special location (ex: hole) to indicate that is dangerous. How can I achieve this? I'm a new comer to games.
Tell me more
×
Game Development Stack Exchange is a question and answer site for
professional and independent game developers. It's 100% free, no registration required.
|
|
Assuming that I understand what you are trying to do, that is, a 2D dungeon-like tiled game, here is what I would do: The current location of the player can be stored in a Point class, and the entire player entity into a sprite, as is typically done in simple 2D game. I.e.:
So, to move your player all you do is listen for keyboard events and update the location:
As for informing the player of dangerous locations, have a list of triggers that will fire whenever the player is inside an area. The triggers could be a rectangular location, a circle or anything. In general, you would have something like this:
EDIT: Totally forgot to mention the "current location" part. |
||||
|
|