API Reference
Complete documentation of all SSOEngine classes, methods, and functions
Quick Navigation
📹 Camera System
SSO::Camera
High-performance 2D camera with smooth interpolation, zoom control, and screen shake effects.
Constructor
Camera(Vector2 target, int screenWidth, int screenHeight)
Camera(float x, float y, int screenWidth, int screenHeight)
Creates a new camera instance with the specified target position and screen dimensions.
Public Methods
Follow(Vector2 target)
Sets the camera to follow a target position with smooth interpolation.
mainCam.Follow(player.position);
SetZoom(float zoom)
Sets the camera zoom level. 1.0 = normal, >1.0 = zoom in, <1.0 = zoom out.
mainCam.SetZoom(1.5f); // 150% zoom
mainCam.SetZoom(0.5f); // 50% zoom
Shake(float intensity, float duration)
Applies screen shake effect with specified intensity and duration.
mainCam.Shake(5.0f, 0.5f); // Medium shake for half second
SetBounds(Rectangle bounds)
Sets movement boundaries for the camera to prevent it from going outside the specified area.
Rectangle bounds = {0, 0, 2000, 1000};
mainCam.SetBounds(bounds);
Update(float deltaTime)
Updates the camera state. Must be called every frame.
mainCam.Update(GetFrameTime());
GetCamera2D()
Returns the Raylib Camera2D struct for use with Raylib rendering functions.
BeginMode2D(mainCam.GetCamera2D());
// Draw game objects
EndMode2D();
Example Usage
// Initialize camera
SSO::Camera mainCam({640.0f, 360.0f}, 1280, 720);
// In game loop
void Update(float deltaTime) {
// Follow player
mainCam.Follow(player.position);
// Update camera state
mainCam.Update(deltaTime);
// Add screen shake on explosion
if (explosion) {
mainCam.Shake(8.0f, 0.3f);
}
}
void Render() {
BeginMode2D(mainCam.GetCamera2D());
DrawPlayer();
DrawEnemies();
DrawEnvironment();
EndMode2D();
}
⏱️ Timer System
SSO::Timer
Delta-time based precision timer for countdowns, stopwatches, and game events.
Constructor
Timer() // Creates a timer with default settings
Public Methods
Reset()
Resets the timer to zero and starts it running.
countdownTimer.Reset();
SetDuration(float seconds)
Sets the duration for the timer in seconds.
countdownTimer.SetDuration(30.0f); // 30 seconds
Pause()
Pauses the timer without resetting it.
gameTimer.Pause();
Resume()
Resumes a paused timer.
gameTimer.Resume();
IsFinished()
Returns true if the timer has reached its duration.
if (countdownTimer.IsFinished()) {
GameOver();
}
GetProgress()
Returns the progress as a value between 0.0 and 1.0.
float progress = countdownTimer.GetProgress(); // 0.0 to 1.0
GetRemaining()
Returns the remaining time in seconds.
float remaining = countdownTimer.GetRemaining();
Example Usage
// Initialize timer
SSO::Timer countdownTimer;
countdownTimer.SetDuration(60.0f); // 60 seconds
countdownTimer.Reset();
// In game loop
void Update(float deltaTime) {
if (!gamePaused) {
countdownTimer.Update(deltaTime);
// Check if time's up
if (countdownTimer.IsFinished()) {
GameOver();
}
// Display remaining time
float remaining = countdownTimer.GetRemaining();
DrawText(TextFormat("Time: %.1f", remaining), 10, 10, 20, WHITE);
}
}
// Pause game
void PauseGame() {
gamePaused = true;
countdownTimer.Pause();
}
// Resume game
void ResumeGame() {
gamePaused = false;
countdownTimer.Resume();
}
🖥️ Window Management
SSO::Window
Complete window management system with resolution control, fullscreen support, and V-Sync management.
Constructor
Window(const char* title, int width, int height)
Creates a new window with the specified title and dimensions.
Public Methods
SetSize(int width, int height)
Changes the window size.
window.SetSize(1920, 1080);
SetFullscreen(bool fullscreen)
Toggles fullscreen mode.
window.SetFullscreen(true); // Enter fullscreen
window.SetFullscreen(false); // Exit fullscreen
SetVSync(bool vsync)
Enables or disables V-Sync.
window.SetVSync(true); // Enable V-Sync (60 FPS)
window.SetVSync(false); // Disable V-Sync (unlimited FPS)
Center()
Centers the window on the screen.
window.Center();
ShouldClose()
Returns true if the window should close (user clicked X).
while (!window.ShouldClose()) {
// Game loop
}
Example Usage
// Initialize window
SSO::Window window("My Awesome Game", 1280, 720);
window.Center();
window.SetVSync(true);
// Game loop
while (!window.ShouldClose()) {
// Handle window resizing
if (IsKeyPressed(KEY_F11)) {
bool fullscreen = !window.IsFullscreen();
window.SetFullscreen(fullscreen);
}
// Game logic and rendering
UpdateGame();
RenderGame();
}
// Window automatically closes when loop ends
🎨 UI Components
SSO::Button
Interactive button component with mouse support and visual feedback.
Constructor
Button(Rectangle bounds, const char* text)
Button(float x, float y, float width, float height, const char* text)
Public Methods
IsClicked()
Returns true if the button was clicked this frame.
if (startButton.IsClicked()) {
StartGame();
}
IsHovered()
Returns true if the mouse is hovering over the button.
if (button.IsHovered()) {
// Change cursor or show tooltip
}
Draw()
Draws the button with appropriate styling based on state.
startButton.Draw();
SetText(const char* text)
Changes the button text.
button.SetText("New Text");
Example Usage
// Create buttons
SSO::Button startButton({100, 100, 200, 50}, "Start Game");
SSO::Button optionsButton({100, 170, 200, 50}, "Options");
SSO::Button quitButton({100, 240, 200, 50}, "Quit");
// In game loop
void UpdateMainMenu() {
if (startButton.IsClicked()) {
gameState = GAMEPLAY;
}
if (optionsButton.IsClicked()) {
gameState = OPTIONS;
}
if (quitButton.IsClicked()) {
window.ShouldClose() = true;
}
}
void RenderMainMenu() {
startButton.Draw();
optionsButton.Draw();
quitButton.Draw();
}
🧮 Math Utilities
SSO::Math
Static utility class providing common mathematical functions and operations.
Vector Operations
Normalize(Vector2 vector)
Returns a normalized version of the vector (length = 1).
Vector2 direction = SSO::Math::Normalize({10, 5});
Distance(Vector2 a, Vector2 b)
Returns the distance between two points.
float dist = SSO::Math::Distance(player.pos, enemy.pos);
Lerp(Vector2 a, Vector2 b, float t)
Linear interpolation between two vectors.
Vector2 result = SSO::Math::Lerp(start, end, 0.5f); // Midpoint
Collision Detection
CheckCollision(Rectangle a, Rectangle b)
Returns true if two rectangles collide.
if (SSO::Math::CheckCollision(playerRect, enemyRect)) {
TakeDamage();
}
CheckCollision(Vector2 point, Rectangle rect)
Returns true if a point is inside a rectangle.
if (SSO::Math::CheckCollision(mousePos, buttonRect)) {
// Mouse is over button
}
CheckCollision(Vector2 point, Vector2 circleCenter, float radius)
Returns true if a point is inside a circle.
if (SSO::Math::CheckCollision(bulletPos, enemyPos, enemyRadius)) {
HitEnemy();
}
Utility Functions
Clamp(float value, float min, float max)
Clamps a value between minimum and maximum.
float health = SSO::Math::Clamp(currentHealth + healAmount, 0, maxHealth);
RandomRange(float min, float max)
Returns a random float between min and max.
float damage = SSO::Math::RandomRange(10.0f, 20.0f);
ToRadians(float degrees)
Converts degrees to radians.
float radians = SSO::Math::ToRadians(45.0f);
ToDegrees(float radians)
Converts radians to degrees.
float degrees = SSO::Math::ToDegrees(PI / 4);
📦 Asset System
Asset Packing & Loading
SSOEngine automatically packs assets from the assets/ folder into a single file during build.
How Asset Packing Works
When you run build.bat, the system automatically:
- Scans the assets/ folder for all files
- Converts each file to a C++ byte array
- Creates assets_data.h with the embedded data
- Packs everything into assets.sso for distribution
Accessing Embedded Assets
After building, assets are available as global variables:
// Include the generated header
#include "assets_data.h"
// Assets are available as:
// asset_filename[] - Binary data
// asset_filename_size - Data size in bytes
// Example usage
Texture2D playerTexture = LoadTextureFromMemory(
asset_player_png,
asset_player_png_size
);
Sound explosionSound = LoadSoundFromMemory(
asset_explosion_wav,
asset_explosion_wav_size
);
Supported Asset Formats
Images
- • PNG (recommended)
- • JPG/JPEG
- • BMP
- • TGA
- • PSD
- • GIF
Audio
- • WAV (recommended)
- • OGG
- • MP3
- • FLAC
Fonts
- • TTF (recommended)
- • OTF
- • FNT (Raylib format)
Data
- • JSON
- • XML
- • TXT
- • CFG
Asset Organization
Recommended folder structure for assets:
assets/
├── images/
│ ├── player.png
│ ├── enemies/
│ └── backgrounds/
├── sounds/
│ ├── sfx/
│ └── music/
├── fonts/
│ └── main.ttf
└── data/
├── config.json
└── levels.xml
Example Asset Loading
// Load all game assets at startup
void LoadAssets() {
// Load textures
playerTexture = LoadTextureFromMemory(asset_images_player_png, asset_images_player_png_size);
enemyTexture = LoadTextureFromMemory(asset_images_enemies_zombie_png, asset_images_enemies_zombie_png_size);
backgroundTexture = LoadTextureFromMemory(asset_images_backgrounds_level1_jpg, asset_images_backgrounds_level1_jpg_size);
// Load sounds
shootSound = LoadSoundFromMemory(asset_sounds_shoot_wav, asset_sounds_shoot_wav_size);
explosionSound = LoadSoundFromMemory(asset_sounds_explosion_wav, asset_sounds_explosion_wav_size);
// Load font
gameFont = LoadFontFromMemory(asset_fonts_main_ttf, asset_fonts_main_ttf_size, 32, NULL);
// Load data
// Parse JSON data from memory
// This depends on your JSON library
}
// Clean up assets when done
void UnloadAssets() {
UnloadTexture(playerTexture);
UnloadTexture(enemyTexture);
UnloadTexture(backgroundTexture);
UnloadSound(shootSound);
UnloadSound(explosionSound);
UnloadFont(gameFont);
}
📋 Quick Reference
Common Usage Patterns
Basic Game Loop
#include "raylib.h"
#include "tools/sso_camera.h"
#include "tools/sso_timer.h"
#include "tools/sso_window.h"
int main() {
// Initialize window
SSO::Window window("My Game", 1280, 720);
window.SetVSync(true);
// Initialize systems
SSO::Camera camera({640, 360}, 1280, 720);
SSO::Timer gameTimer;
gameTimer.SetDuration(60.0f);
gameTimer.Reset();
// Game loop
while (!window.ShouldClose()) {
float deltaTime = GetFrameTime();
// Update
camera.Update(deltaTime);
gameTimer.Update(deltaTime);
// Render
BeginDrawing();
ClearBackground(BLACK);
BeginMode2D(camera.GetCamera2D());
// Draw game objects
EndMode2D();
// Draw UI
EndDrawing();
}
return 0;
}
Player Movement with Camera
void UpdatePlayer(float deltaTime) {
// Input
Vector2 input = {0, 0};
if (IsKeyDown(KEY_RIGHT)) input.x += 1;
if (IsKeyDown(KEY_LEFT)) input.x -= 1;
if (IsKeyDown(KEY_UP)) input.y -= 1;
if (IsKeyDown(KEY_DOWN)) input.y += 1;
// Normalize and apply speed
input = SSO::Math::Normalize(input);
player.position = SSO::Math::Lerp(
player.position,
player.position + input * speed * deltaTime,
0.1f
);
// Update camera to follow player
mainCam.Follow(player.position);
}
UI Menu System
SSO::Button buttons[3] = {
SSO::Button({100, 100, 200, 50}, "Start"),
SSO::Button({100, 170, 200, 50}, "Options"),
SSO::Button({100, 240, 200, 50}, "Quit")
};
void UpdateMenu() {
if (buttons[0].IsClicked()) StartGame();
if (buttons[1].IsClicked()) OpenOptions();
if (buttons[2].IsClicked()) window.ShouldClose() = true;
}
void RenderMenu() {
for (int i = 0; i < 3; i++) {
buttons[i].Draw();
}
}