Camera

Camera

Description

SwinGame's Camera functionality can be used to create scrolling games where the camera moves around a virtual game world. Using the camera allows you to position and draw game elements using game world coordinates, and then to move the camera around within this game world.

Camera Pos

Returns the current camera position in world coordinates. This is the top left hand corner of the screen.

  • Camera Pos () : Point2D [show]

    Returns the current camera position in world coordinates. This is the top left hand corner of the screen.

    Returns:
    Point2D :
    Signatures by Language:
    C/C++: point2d camera_pos();
    Pascal: function CameraPos(): Point2D;

Camera Screen Rect

Returns the rectangle that encompases the area of the game world that is currently on the screen.

  • Camera Screen Rect () : Rectangle [show]

    Returns the rectangle that encompases the area of the game world that is currently on the screen.

    Returns:
    Rectangle :
    Signatures by Language:
    C/C++: rectangle camera_screen_rect();
    Pascal: function CameraScreenRect(): Rectangle;

Camera X

Returns 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 CameraX + ScreenWidth.

  • Camera X () : Single [show]

    Returns 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 CameraX + ScreenWidth.

    Returns:
    Single :
    Signatures by Language:
    C/C++: float camera_x();
    Pascal: function CameraX(): Single;

Camera Y

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 CameraY + ScreenHeight.

  • Camera Y () : Single [show]

    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 CameraY + ScreenHeight.

    Returns:
    Single :
    Signatures by Language:
    C/C++: float camera_y();
    Pascal: function CameraY(): Single;

Center Camera On

Set the camera view to be centered over the specific Character. The offset vector allows you to move the sprite from the direct center of the screen.

  • Center Camera On (c, const offset) [show]

    Set the camera view to be centered over the specific Character. The offset vector allows you to move the sprite from the direct center of the screen.

    Parameters:
    c : Character
    offset : Vector
    Signatures by Language:
    C/C++: void center_camera_on_character(character c, const vector *offset);
    C/C++: void center_camera_on_character_byval(character c, const vector offset);
    C++: void center_camera_on(character c, const vector &offset);
    Pascal: procedure CenterCameraOn(c: Character; const offset: Vector);
  • Center Camera On (s, const offset) [show]

    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:
    s : Sprite
    offset : Vector
    The amount of offset from sprite center for the camera to use.
    Signatures by Language:
    C/C++: void center_camera_on(sprite s, const vector *offset);
    C/C++: void center_camera_on_byval(sprite s, const vector offset);
    C++: void center_camera_on(sprite s, const vector &offset);
    Pascal: procedure CenterCameraOn(s: Sprite; const offset: Vector);
  • Center Camera On (s, offsetX, offsetY) [show]

    Set the camera view to be centered over the specified sprite, with an offset from the center of the sprite if needed. The sprites size (width and height) are taken into account. Use x and y offset of 0.0 if you want the camera to be exaclty over the center of the sprite.

    Parameters:
    s : Sprite
    The sprite to center the camera on
    offsetX : Longint
    The amount of x axis offset for the camaera to use
    offsetY : Longint
    The amount of y axis offset for the camaera to use
    Signatures by Language:
    C/C++: void center_camera_on_with_xyoffset(sprite s, int32_t offsetX, int32_t offsetY);
    C++: void center_camera_on(sprite s, int32_t offsetX, int32_t offsetY);
    Pascal: procedure CenterCameraOn(s: Sprite; offsetX: Longint; offsetY: Longint);

Move Camera By

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.

  • Move Camera By (const offset) [show]

    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:
    offset : Vector
    The offset vector to move the camera world position by.
    Signatures by Language:
    C/C++: void move_camera_by(const vector *offset);
    C/C++: void move_camera_by_byval(const vector offset);
    C++: void move_camera_by(const vector &offset);
    Pascal: procedure MoveCameraBy(const offset: Vector);
  • Move Camera By (dx, dy) [show]

    Move the camera (offset its world x and y values) using the specified dx (change in x) and dy (change in x) values.

    Parameters:
    dx : Single
    the amount of x axis offset to apply
    dy : Single
    the amount of x axis offset to apply
    Signatures by Language:
    C/C++: void move_camera_by_xy(float dx, float dy);
    C++: void move_camera_by(float dx, float dy);
    Pascal: procedure MoveCameraBy(dx: Single; dy: Single);

Move Camera To

Move the camera view to a world location specified as a Point2D. This will be the new top left corner of the screen.

  • Move Camera To (const pt) [show]

    Move the camera view to a world location specified as a Point2D. This will be the new top left corner of the screen.

    Parameters:
    pt : Point2D
    The point to move the camera view to.
    Signatures by Language:
    C/C++: void move_camera_to(const point2d *pt);
    C/C++: void move_camera_to_byval(const point2d pt);
    C++: void move_camera_to(const point2d &pt);
    Pascal: procedure MoveCameraTo(const pt: Point2D);
  • Move Camera To (x, y) [show]

    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:
    x : Single
    The world x axis value to move the camera to.
    y : Single
    The world y axis value to move the camera to
    Signatures by Language:
    C/C++: void move_camera_to_xy(float x, float y);
    C++: void move_camera_to(float x, float y);
    Pascal: procedure MoveCameraTo(x: Single; y: Single);

Point On Screen

Tests if the point pt is on the screen.

  • Point On Screen (const pt) : Boolean [show]

    Tests if the point pt is on the screen.

    Parameters:
    pt : Point2D
    Returns:
    Boolean :
    Signatures by Language:
    C/C++: bool point_on_screen(const point2d *pt);
    C/C++: bool point_on_screen_byval(const point2d pt);
    C++: bool point_on_screen(const point2d &pt);
    Pascal: function PointOnScreen(const pt: Point2D): Boolean;

Rect On Screen

Tests if the rectangle rect is on the screen.

  • Rect On Screen (const rect) : Boolean [show]

    Tests if the rectangle rect is on the screen.

    Parameters:
    rect : Rectangle
    Returns:
    Boolean :
    Signatures by Language:
    C/C++: bool rect_on_screen(const rectangle *rect);
    C/C++: bool rect_on_screen_byval(const rectangle rect);
    C++: bool rect_on_screen(const rectangle &rect);
    Pascal: function RectOnScreen(const rect: Rectangle): Boolean;

Set Camera Pos

Change 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.

  • Set Camera Pos (const pt) [show]

    Change 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:
    pt : Point2D
    Signatures by Language:
    C/C++: void set_camera_pos(const point2d *pt);
    C/C++: void set_camera_pos_byval(const point2d pt);
    C++: void set_camera_pos(const point2d &pt);
    Pascal: procedure SetCameraPos(const pt: Point2D);

Set Camera X

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.

  • Set Camera X (x) [show]

    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:
    x : Single
    Signatures by Language:
    C/C++: void set_camera_x(float x);
    Pascal: procedure SetCameraX(x: Single);

Set Camera Y

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.

  • Set Camera Y (y) [show]

    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:
    y : Single
    Signatures by Language:
    C/C++: void set_camera_y(float y);
    Pascal: procedure SetCameraY(y: Single);

To Screen

Translate a Point2D from world coordinates to screen coordinates.

  • To Screen (const worldPoint) : Point2D [show]

    Translate a Point2D from world coordinates to screen coordinates.

    Parameters:
    worldPoint : Point2D
    The screen coordinate to translate
    Returns:
    Point2D : A screen coordinate point
    Signatures by Language:
    C/C++: point2d to_screen(const point2d *worldPoint);
    C/C++: point2d to_screen_byval(const point2d worldPoint);
    C++: point2d to_screen(const point2d &worldPoint);
    Pascal: function ToScreen(const worldPoint: Point2D): Point2D;
  • To Screen (const rect) : Rectangle [show]

    Translate the points in a rectangle to screen coordinates. This can be used to indicate the screen area used by a rectangle in game coordinates.

    Parameters:
    rect : Rectangle
    Returns:
    Rectangle :
    Signatures by Language:
    C/C++: rectangle to_screen_rect(const rectangle *rect);
    C/C++: rectangle to_screen_rect_byval(const rectangle rect);
    C++: rectangle to_screen(const rectangle &rect);
    Pascal: function ToScreen(const rect: Rectangle): Rectangle;

To Screen X

Translate a world x value to the current screen x value which is based on the camera position.

  • To Screen X (worldX) : Longint [show]

    Translate a world x value to the current screen x value which is based on the camera position.

    Parameters:
    worldX : Single
    The world x value to be translated
    Returns:
    Longint : The translated screen x value
    Signatures by Language:
    C/C++: int32_t to_screen_x(float worldX);
    Pascal: function ToScreenX(worldX: Single): Longint;

To Screen Y

Translate a world y value to the current screen y value set by the camera.

  • To Screen Y (worldY) : Longint [show]

    Translate a world y value to the current screen y value set by the camera.

    Parameters:
    worldY : Single
    The world y value to be converted
    Returns:
    Longint : A screen y value
    Signatures by Language:
    C/C++: int32_t to_screen_y(float worldY);
    Pascal: function ToScreenY(worldY: Single): Longint;

To World

Translate a Point2D from screen coordinates to world coordinates.

  • To World (const screenPoint) : Point2D [show]

    Translate a Point2D from screen coordinates to world coordinates.

    Parameters:
    screenPoint : Point2D
    The screen coordinate to translate
    Returns:
    Point2D : A world coordinate point
    Signatures by Language:
    C/C++: point2d to_world(const point2d *screenPoint);
    C/C++: point2d to_world_byval(const point2d screenPoint);
    C++: point2d to_world(const point2d &screenPoint);
    Pascal: function ToWorld(const screenPoint: Point2D): Point2D;

To World X

Translate a screen x value (based on the camera) to a world x value

  • To World X (screenX) : Single [show]

    Translate a screen x value (based on the camera) to a world x value

    Parameters:
    screenX : Longint
    The current screen x value to be converted
    Returns:
    Single : A world x value
    Signatures by Language:
    C/C++: float to_world_x(int32_t screenX);
    Pascal: function ToWorldX(screenX: Longint): Single;

To World Y

Translate a screen y value (based on the camera) to a world y value

  • To World Y (screenY) : Single [show]

    Translate a screen y value (based on the camera) to a world y value

    Parameters:
    screenY : Longint
    The current screen y value to be converted
    Returns:
    Single : A world y value
    Signatures by Language:
    C/C++: float to_world_y(int32_t screenY);
    Pascal: function ToWorldY(screenY: Longint): Single;