Camera
Functions
Section titled “Functions”Returns the position of the camera in game coordinates. This will be the coordinate of the upper left corner of the screen.
Return Type: Point 2d
Returns: The position of the camera as a point_2d.
Signatures:
point_2d camera_position()public static Point2D Camera.Position { get }public static Point2D SplashKit.CameraPosition();def camera_position():function CameraPosition(): Point2DReturns the x location of the camera in game coordinates. This represents the left most x value shown on the screen, with the right of the screen being at camera x + screen width.
Return Type: Double
Returns: The x location of the camera in game coordinates.
Signatures:
double camera_x()public static double Camera.X { get }public static double SplashKit.CameraX();def camera_x():function CameraX(): DoubleUsage: {</>}
Returns the y location of the camera in game coordinates. This represents the stop most y value shown on the screen, with bottom of screen being at camera y + screen height.
Return Type: Double
Returns: The y location of the camera in game coordinates.
Signatures:
double camera_y()public static double Camera.Y { get }public static double SplashKit.CameraY();def camera_y():function CameraY(): DoubleUsage: {</>}
Set the camera view to be centered over the specific sprite. The offset vector allows you to move the sprite from the direct center of the screen.
Parameters:
| Name | Type | Description |
|---|---|---|
| s | Sprite | The sprite to track. |
| offset | Vector 2d | The amount to offset the camera, allowing you to position the sprite away from the center of the screen. |
Signatures:
void center_camera_on(sprite s, const vector_2d &offset)public static void Camera.CenterOn(Sprite s, Vector2D offset);public static void SplashKit.CenterCameraOn(Sprite s, Vector2D offset);def center_camera_on_vector(s, offset):procedure CenterCameraOn(s: Sprite; const offset: Vector2D)Set the camera view to be centered over the specific sprite. The offset vector allows you to move the sprite from the direct center of the screen.
Parameters:
| Name | Type | Description |
|---|---|---|
| s | Sprite | The sprite to track. |
| offset_x | Double | An additional offset added to the camera, allowing you to position the sprite offset from the center of the screen. |
| offset_y | Double | An additional offset added to the camera, allowing you to position the sprite offset from the center of the screen. |
Signatures:
void center_camera_on(sprite s, double offset_x, double offset_y)public static void Camera.CenterOn(Sprite s, double offsetX, double offsetY);public static void SplashKit.CenterCameraOn(Sprite s, double offsetX, double offsetY);def center_camera_on(s, offset_x, offset_y):procedure CenterCameraOn(s: Sprite; offsetX: Double; offsetY: Double)Move the camera (offset its world x and y values) using the specified vector. For example, if you move the camera by the same speed vector of a sprite the camera will “track” (be locked on to) the sprite as it moves.
Parameters:
| Name | Type | Description |
|---|---|---|
| offset | Vector 2d | The amount to move the camera. |
Signatures:
void move_camera_by(const vector_2d &offset)public static void Camera.MoveBy(Vector2D offset);public static void SplashKit.MoveCameraBy(Vector2D offset);def move_camera_by_vector(offset):procedure MoveCameraBy(const offset: Vector2D)Move the camera (offset its world x and y values) using the specified dx (change in x) and dy (change in x) values.
Parameters:
| Name | Type | Description |
|---|---|---|
| dx | Double | The amount to move the camera along the x axis. |
| dy | Double | The amount to move the camera along the y axis. |
Signatures:
void move_camera_by(double dx, double dy)public static void Camera.MoveBy(double dx, double dy);public static void SplashKit.MoveCameraBy(double dx, double dy);def move_camera_by(dx, dy):procedure MoveCameraBy(dx: Double; dy: Double)Usage: {</>}
Move the camera view (screen top left) to a specified point in the world. This will be the new top left corner of the screen.
Parameters:
| Name | Type | Description |
|---|---|---|
| pt | Point 2d | The new camera location |
Signatures:
void move_camera_to(const point_2d &pt)public static void Camera.MoveTo(Point2D pt);public static void SplashKit.MoveCameraTo(Point2D pt);def move_camera_to_point(pt):procedure MoveCameraTo(const pt: Point2D)Move the camera view to a world location specified by the x and y values. This will be the new top left corner of the screen.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | Double | The new camera x location |
| y | Double | The new camera y location |
Signatures:
void move_camera_to(double x, double y)public static void Camera.MoveTo(double x, double y);public static void SplashKit.MoveCameraTo(double x, double y);def move_camera_to(x, y):procedure MoveCameraTo(x: Double; y: Double)Tests if the point is in the window.
Parameters:
Return Type: Boolean
Returns: True if the point is on the screen.
Signatures:
bool point_in_window(window wind, const point_2d &pt)public static bool Camera.PointInWindow(Window wind, Point2D pt);public static bool SplashKit.PointInWindow(Window wind, Point2D pt);def point_in_window(wind, pt):function PointInWindow(wind: Window; const pt: Point2D): BooleanTests if the point is on the screen.
Parameters:
| Name | Type | Description |
|---|---|---|
| pt | Point 2d | The point to check. |
Return Type: Boolean
Returns: True if the point is on the screen.
Signatures:
bool point_on_screen(const point_2d &pt)public static bool Camera.PointOnScreen(Point2D pt);public static bool SplashKit.PointOnScreen(Point2D pt);def point_on_screen(pt):function PointOnScreen(const pt: Point2D): BooleanTests if the rectangle is within the bounds of the window.
Parameters:
Return Type: Boolean
Returns: True if any part of the rectangle is in the window.
Signatures:
bool rect_in_window(window wind, const rectangle &rect)public static bool Camera.RectInWindow(Window wind, Rectangle rect);public static bool SplashKit.RectInWindow(Window wind, Rectangle rect);def rect_in_window(wind, rect):function RectInWindow(wind: Window; const rect: Rectangle): BooleanTests if the rectangle is on the screen.
Parameters:
| Name | Type | Description |
|---|---|---|
| rect | Rectangle | The rectangle to check. |
Return Type: Boolean
Returns: True if any part of the rectangle is on the screen.
Signatures:
bool rect_on_screen(const rectangle &rect)public static bool Camera.RectOnScreen(Rectangle rect);public static bool SplashKit.RectOnScreen(Rectangle rect);def rect_on_screen(rect):function RectOnScreen(const rect: Rectangle): BooleanReturns the center of the screen in world coordinates.
Return Type: Point 2d
Returns: The center of the screen in world coordinates.
Signatures:
point_2d screen_center()public static Point2D Camera.ScreenCenter { get }public static Point2D SplashKit.ScreenCenter();def screen_center():function ScreenCenter(): Point2DReturns a rectangle that represents the dimensions of the window.
Return Type: Rectangle
Returns: A rectangle representing the dimensions of the current window.
Signatures:
rectangle screen_rectangle()public static Rectangle Camera.ScreenRectangle { get }public static Rectangle SplashKit.ScreenRectangle();def screen_rectangle():function ScreenRectangle(): RectangleChange the position of the camera to a specified world coordinate. This will then be the new top left most position of the screen within the world.
Parameters:
| Name | Type | Description |
|---|---|---|
| pos | Point 2d | The new location of the camera. |
Signatures:
void set_camera_position(point_2d pos)public static void Camera.Position { set }public static void SplashKit.SetCameraPosition(Point2D pos);def set_camera_position(pos):procedure SetCameraPosition(pos: Point2D)Change the X position of the camera to a specified world coordinate. This will then be the new left most position of the screen within the world.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | Double | The new x coordinate for the camera |
Signatures:
void set_camera_x(double x)public static void Camera.X { set }public static void SplashKit.SetCameraX(double x);def set_camera_x(x):procedure SetCameraX(x: Double)Change the Y position of the camera to a specified world coordinate. This will then be the new top most position of the screen within the world.
Parameters:
| Name | Type | Description |
|---|---|---|
| y | Double | The new y coordinate for the camera |
Signatures:
void set_camera_y(double y)public static void Camera.Y { set }public static void SplashKit.SetCameraY(double y);def set_camera_y(y):procedure SetCameraY(y: Double)Convert the passed in world coordinates to screen coordinates.
Parameters:
| Name | Type | Description |
|---|---|---|
| pt | Point 2d | The point to convert - this should be in world coordinates. |
Return Type: Point 2d
Returns: A point that represents pt in screen coordinates.
Signatures:
point_2d to_screen(const point_2d &pt)public static Point2D Camera.ToScreen(Point2D pt);public static Point2D SplashKit.ToScreen(Point2D pt);def to_screen_point(pt):function ToScreen(const pt: Point2D): Point2DConvert the rectangle in world coordinates to screen coordinates.
Parameters:
| Name | Type | Description |
|---|---|---|
| rect | Rectangle | The rectangle to convert - this should be in world coordinates. |
Return Type: Rectangle
Returns: A rectangle that represents rect in screen coordinates.
Signatures:
rectangle to_screen(const rectangle &rect)public static Rectangle Camera.ToScreen(Rectangle rect);public static Rectangle SplashKit.ToScreen(Rectangle rect);def to_screen_rectangle(rect):function ToScreen(const rect: Rectangle): RectangleTranslate a world x value to the current screen x value which is based on the camera position.
Parameters:
| Name | Type | Description |
|---|---|---|
| world_x | Double | The value of the x coordinate to translate to screen. |
Return Type: Double
Returns: The x location of the world coordinate on the screen.
Signatures:
double to_screen_x(double world_x)public static double Camera.ToScreenX(double worldX);public static double SplashKit.ToScreenX(double worldX);def to_screen_x(world_x):function ToScreenX(worldX: Double): DoubleTranslate a world y value to the current screen y value set by the camera.
Parameters:
| Name | Type | Description |
|---|---|---|
| world_y | Double | The value of the y coordinate to translate to screen. |
Return Type: Double
Returns: The y location of the world coordinate on the screen.
Signatures:
double to_screen_y(double world_y)public static double Camera.ToScreenY(double worldY);public static double SplashKit.ToScreenY(double worldY);def to_screen_y(world_y):function ToScreenY(worldY: Double): DoubleConverts the passed in point from screen coordinates to world coordinates.
Parameters:
| Name | Type | Description |
|---|---|---|
| pt | Point 2d | The point in screen coordinates. |
Return Type: Point 2d
Returns: The same point in world coordinates.
Signatures:
point_2d to_world(const point_2d &pt)public static Point2D Camera.ToWorld(Point2D pt);public static Point2D SplashKit.ToWorld(Point2D pt);def to_world(pt):function ToWorld(const pt: Point2D): Point2DTranslate a screen x value (based on the camera) to a world x value
Parameters:
| Name | Type | Description |
|---|---|---|
| screen_x | Double | The value of the x coordinate on screen to translate to the world. |
Return Type: Double
Returns: The x location of the screen coordinate in the world.
Signatures:
double to_world_x(double screen_x)public static double Camera.ToWorldX(double screenX);public static double SplashKit.ToWorldX(double screenX);def to_world_x(screen_x):function ToWorldX(screenX: Double): DoubleTranslate a screen y value (based on the camera) to a world y value
Parameters:
| Name | Type | Description |
|---|---|---|
| screen_y | Double | The value of the y coordinate on screen to translate to the world. |
Return Type: Double
Returns: The y location of the screen coordinate in the world.
Signatures:
double to_world_y(double screen_y)public static double Camera.ToWorldY(double screenY);public static double SplashKit.ToWorldY(double screenY);def to_world_y(screen_y):function ToWorldY(screenY: Double): DoubleReturns a vector that can transform points from world to screen coordinates.
Return Type: Vector 2d
Returns: A vector representing the distance and direction points need to move to map from world to screen coordinates.
Signatures:
vector_2d vector_world_to_screen()public static Vector2D Camera.VectorWorldToScreen { get }public static Vector2D SplashKit.VectorWorldToScreen();def vector_world_to_screen():function VectorWorldToScreen(): Vector2DReturns a rectangle that represents the dimensions of the window based on the camera.
Parameters:
| Name | Type | Description |
|---|---|---|
| wind | Window | The window |
Return Type: Rectangle
Returns: A rectangle representing the dimensions of the current window.
Signatures:
rectangle window_area(window wind)public Rectangle Window.Area { get }public static Rectangle SplashKit.WindowArea(Window wind);def window_area(wind):function WindowArea(wind: Window): Rectangle