Changes

Jump to navigation Jump to search
no edit summary
Line 85: Line 85:  
===Position===
 
===Position===
 
A Character's position indicates the Character's coordinates in the current location.  
 
A Character's position indicates the Character's coordinates in the current location.  
 +
 +
====Position Relative to the Map====
 
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.  
 
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.
 
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>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.
 
<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:
+
Each tile is 64x64 pixels as specified by <code>Game1.tileSize</code>. The conversion between absolute and tile is as follows:
 
<source lang='c#'>
 
<source lang='c#'>
 
// Absolute position => Tile position
 
// Absolute position => Tile position
Line 106: Line 110:  
</source>
 
</source>
    +
====Position Relative to the Viewport====
 +
The viewport represents the visible area on the screen. Its dimensions are <code>Game1.viewport.Width</code> by <code>Game1.viewport.Height</code> in pixels; this is the same as the game's screen resolution.
 +
 +
The viewport also has an absolute position relative to the map, where the top-left corner of the viewport is at ''(Game1.viewport.X, Game1.viewport.Y)''.
 +
 +
 +
The player's position relative to the viewport is as follows:
 +
<source lang='c#'>
 +
Game1.player.Position.X - Game1.viewport.X
 +
Game1.player.Position.Y - Game1.viewport.Y
 +
</source>
    
==NPC==
 
==NPC==
17

edits

Navigation menu