Skip to content

Silver.hpp Cheatsheet

Imagment edited this page Apr 15, 2025 · 1 revision

💡 Tip: For details on classes such as Actors or Components, refer to their respective wiki pages.

Macros

#define SPActor std::shared_ptr<Actor> // Shorthand writing for std::shared_ptr<Actor>

#define until(condition)                                                       \
  {                                                                            \
    while (1) {                                                                \
      if (condition)                                                           \
        break;                                                                 \
    }                                                                          \ 
  }
// Loops until the specified condition is true.

Configurations / Data Structures

extern Rect StageArea; // The stage area for the game. If `showOutOfStagePatterns` is set to true in a random camera, it will display a different pattern for out-of-stage areas.

extern std::map<std::string, Actor> Prefabs; // A collection to store pre-made objects
extern World Workspace; // Represents the game world

extern bool debugMode; // Does not print debug alerts if set to false

Object management

std::shared_ptr<Actor> InstanceIDToActor(int objID); // Returns an Actor with a certain ID
bool IsAlive(int obj); // Check if an object with a certain id is present in the workspace
void Destroy(std::shared_ptr<Actor> actor); // Removes the actor from the game world

Debugging

void Debug(const char *fmt, ...); // Debug a message using notify-send command

Drawing

// Drawing functions
void Rectangle(SPActor object, const Rect &rect, double layer);
void RectangleHollow(SPActor object, const Rect &rect, double layer);
void Circle(SPActor object, const Vector3 &center, int radius);
void CircleHollow(SPActor object, const Vector3 &center, int radius);
void Line(SPActor object, const Vector3 &start, const Vector3 &end);
void Oval(const std::string name, int number, Vector3 center, Vector3 scale);
void OvalHollow(SPActor object, const Vector3 &center, const Vector3 &scale);

void SprayRectangle(SPActor object, int spawns, const Rect &rect, double layer);
void SprayOval(SPActor object, int spawns, const Vector3 &center, const Vector3 &scale);
void Spray(SPActor object, int spawns, const Vector3 &center, int range);
void SprayLine(SPActor object, int spawns, const Vector3 &start, const Vector3 &end);
void SprayCircle(SPActor object, int spawns, const Vector3 &center, float radius);

Random

int GetRandom(int min, int max); 

Tags

// Find object(s) with a certain tag
std::vector<std::shared_ptr<Actor>> FindObjectsWithTag(const std::string tag);
std::shared_ptr<Actor> FindObjectWithTag(const std::string tag);

Console

void SetRawMode(bool value); // Sets the terminal to raw mode (disables input buffering)
void SetCursorVisibility(bool value); // Sets the visibility of the cursor in the console
void setNonBlockingMode(bool value); // Enables or disables non-blocking (async) mode
void SetConsoleTitle(const std::string title); // Sets the console window title

Vector2 GetConsoleSize(); // Returns the size of the console (width, height)
Vector2 GetConsoleCenter(); // Returns the center point of the console

bool Gotoxy(int x, int y); // Moves the cursor to (x, y) in the console
void Clear(); // Clears the entire console screen

Time

double DeltaTime(); // Returns time elapsed since last frame (in seconds)
void Wait(int time); // Waits for the specified time (in milliseconds)
void Hold(); // Pauses execution forever

Overview

Cheatsheets

Structure of the engine

Silver Mathematics

Components

Clone this wiki locally