Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
camera.c File Reference

Game camera system. More...

#include <camera.h>
#include <app.h>
#include <input.h>

Functions

void Camera_UpdatePosition ()
 [PostUpdate] Updates the camera position based on player position and mouse input
 
Vec2 Camera_WorldVecToScreen (Vec2 worldPosition)
 [Utility] Converts world coordinates to screen coordinates
 
Vec2 Camera_ScreenVecToWorld (Vec2 screenPosition)
 [Utility] Converts screen coordinates to world coordinates
 
SDL_Rect Camera_ScreenRectToWorld (SDL_Rect screenRect)
 [Utility] Converts a screen rectangle to world coordinates
 
SDL_Rect Camera_GetWorldViewRect ()
 [Utility] Gets the current view rectangle in world coordinates
 
bool Camera_WorldRectIsOnScreen (SDL_Rect rect)
 [Utility] Checks if a rectangle is visible on screen
 
bool Camera_ScreenRectIsOnScreen (SDL_Rect rect)
 

Variables

CameraSystem camera
 

Detailed Description

Game camera system.

Manages the game's camera view, handling player tracking, coordinate transformations between screen and world space, and viewport calculations.

Author
Mango
Date
2025-03-01

Function Documentation

◆ Camera_GetWorldViewRect()

SDL_Rect Camera_GetWorldViewRect ( )

[Utility] Gets the current view rectangle in world coordinates

Returns
SDL_Rect Rectangle representing the camera's view in world space

◆ Camera_ScreenRectIsOnScreen()

bool Camera_ScreenRectIsOnScreen ( SDL_Rect  rect)

◆ Camera_ScreenRectToWorld()

SDL_Rect Camera_ScreenRectToWorld ( SDL_Rect  screenRect)

[Utility] Converts a screen rectangle to world coordinates

Parameters
screenRectRectangle in screen space
Returns
SDL_Rect Converted rectangle in world space

◆ Camera_ScreenVecToWorld()

Vec2 Camera_ScreenVecToWorld ( Vec2  screenPosition)

[Utility] Converts screen coordinates to world coordinates

Parameters
screenPositionPosition in screen space
Returns
Vec2 Converted position in world space

◆ Camera_UpdatePosition()

void Camera_UpdatePosition ( )

[PostUpdate] Updates the camera position based on player position and mouse input

◆ Camera_WorldRectIsOnScreen()

bool Camera_WorldRectIsOnScreen ( SDL_Rect  rect)

[Utility] Checks if a rectangle is visible on screen

Parameters
rectRectangle in world coordinates to check
Returns
bool True if the rectangle is at least partially visible, false otherwise

◆ Camera_WorldVecToScreen()

Vec2 Camera_WorldVecToScreen ( Vec2  worldPosition)

[Utility] Converts world coordinates to screen coordinates

Parameters
worldPositionPosition in world space
Returns
Vec2 Converted position in screen space

Variable Documentation

◆ camera

CameraSystem camera
Initial value:
= {
.position = {4200, 4200}
}