Difference between revisions of "Legacy:Functions/Map/Camera"

From Spherical
Jump to: navigation, search
(created, needs reformatting)
 
(Reformat for new convention)
 
Line 1: Line 1:
==== Following persons ====
+
==== Following entities ====
  
* [[API:AttachCamera]](''person''): Make the camera follow ''person''.
+
* [[API:GetCameraPerson|GetCameraPerson]](): Get the name of the person the camera is attached to.
* [[API:DetachCamera]](): Stop the camera from following any person.
+
* [[API:IsCameraAttached|IsCameraAttached]](): Check if the camera is attached to a person.
 
+
* [[API:AttachCamera|AttachCamera]](''person''): Make the camera follow ''person''.
* [[API:IsCameraAttached]](): Check if the camera is attached to a person.
+
* [[API:DetachCamera|DetachCamera]](): Stop the camera from following any person.
* [[API:GetCameraPerson]](): Get the name of the person the camera is attached to.
 
  
 
==== Camera position ====
 
==== Camera position ====
  
* [[API:GetCameraX]](): Get the map X coordinate the camera is focusing on.
+
* [[API:GetCameraX|GetCameraX]](): Get the map X coordinate the camera is focusing on.
* [[API:SetCameraX]](''x_pos''): Set the X coordinate of the camera.
+
* [[API:SetCameraX|SetCameraX]](''x_pos''): Set the X coordinate of the camera.
 
+
* [[API:GetCameraY|GetCameraY]](): Get the map Y coordinate the camera is focusing on.
* [[API:GetCameraY]](): Get the map Y coordinate the camera is focusing on.
+
* [[API:SetCameraY|SetCameraY]](''y_pos''): Set the Y coordinate of the camera.
* [[API:SetCameraY]](''y_pos''): Set the Y coordinate of the camera.
 
  
 
==== Coordinate conversion ====
 
==== Coordinate conversion ====
 +
Coordinate conversion translates the current map position to screen coordinates based on the current camera position, and vice versa. Some functions (like checking obstructions) require map coordinates, while others (like image blitting) require screen coordinates. Both map and screen coordinates consider the top-left corner to be (0,0) and extend right-ward and down-ward for X and Y position, respectively.
  
* [[API:MapToScreenX]](''layer'', ''x''): Convert a map X coordinate to screen X.
+
* [[API:MapToScreenX|MapToScreenX]](''layer'', ''x''): Convert a map X coordinate to screen X.
* [[API:MapToScreenY]](''layer'', ''y''): Convert a map Y coordinate to screen Y.
+
* [[API:MapToScreenY|MapToScreenY]](''layer'', ''y''): Convert a map Y coordinate to screen Y.
* [[API:ScreenToMapX]](''layer'', ''x''): Convert a screen X coordinate to map ''layer'' X.
+
* [[API:ScreenToMapX|ScreenToMapX]](''layer'', ''x''): Convert a screen X coordinate to map ''layer'' X.
* [[API:ScreenToMapY]](''layer'', ''y''): Convert a screen Y coordinate to map ''layer'' Y.
+
* [[API:ScreenToMapY|ScreenToMapY]](''layer'', ''y''): Convert a screen Y coordinate to map ''layer'' Y.

Latest revision as of 23:59, 1 June 2013

Following entities

Camera position

  • GetCameraX(): Get the map X coordinate the camera is focusing on.
  • SetCameraX(x_pos): Set the X coordinate of the camera.
  • GetCameraY(): Get the map Y coordinate the camera is focusing on.
  • SetCameraY(y_pos): Set the Y coordinate of the camera.

Coordinate conversion

Coordinate conversion translates the current map position to screen coordinates based on the current camera position, and vice versa. Some functions (like checking obstructions) require map coordinates, while others (like image blitting) require screen coordinates. Both map and screen coordinates consider the top-left corner to be (0,0) and extend right-ward and down-ward for X and Y position, respectively.

  • MapToScreenX(layer, x): Convert a map X coordinate to screen X.
  • MapToScreenY(layer, y): Convert a map Y coordinate to screen Y.
  • ScreenToMapX(layer, x): Convert a screen X coordinate to map layer X.
  • ScreenToMapY(layer, y): Convert a screen Y coordinate to map layer Y.