Line 84: |
Line 84: |
| //todo describe section | | //todo describe section |
| ===Position=== | | ===Position=== |
− | //todo | + | A Character's position indicates the Character's coordinates in the current location. |
| + | Each location has an ``xTile`` map where the top-left corner of the map is ''(0, 0)'' and the bottom-right corner of the map is ''(location.Map.DisplayWidth, location.Map.DisplayHeight)'' in pixels. |
| + | |
| + | There are two ways to get a Character's position in the current location: by absolute position and by tile position. |
| + | <code>Position.X</code> and <code>Position.Y</code> will give the XY coordinates in pixels. |
| + | <code>getTileX()</code> and <code>getTileY()</code> will give the XY coordinates in tiles. |
| + | |
| + | Each tile is 64x64 pixels as specified by <code>Game1.tileSize</code>. The conversion between the two is as follows: |
| + | <source lang='c#'> |
| + | // Absolute position => Tile position |
| + | Math.Floor(Game1.player.Position.X / Game1.tileSize) |
| + | Math.Floor(Game1.player.Position.Y / Game1.tileSize) |
| + | |
| + | // Tile position => Absolute position |
| + | Game1.player.getTileX() * Game1.tileSize |
| + | Game1.player.getTileY() * Game1.tileSize |
| + | |
| + | // Tilemap dimensions |
| + | Math.Floor(Game1.player.currentLocation.Map.DisplayWidth / Game1.tileSize) |
| + | Math.Floor(Game1.player.currentLocation.Map.DisplayHeight / Game1.tileSize) |
| + | </source> |
| + | |
| + | |
| ==NPC== | | ==NPC== |
| | | |