RPGH
Projects
Projects

Backend

WEBSOCKETS TICTACTOE VERTX HAZELCAST CLUSTER GO ECS ROGUELIKE DOTNET SELENIUM CRAWLER
VERTX HAZELCAST CLUSTER
DOTNET SELENIUM CRAWLER

Go + ECS + Roguelike

Project Link

This was a real fun project to work on. Implementing an entity component system in golang from a basic tutorial. Next steps would be to experiment utilizing SQLite instead of in-memory storage.

  • https://www.roguebasin.com/index.php?title=How_to_Write_a_Roguelike_in_15_Steps
  • https://www.fatoldyeti.com/

ECS: The Game Server

An Entity-Component-System (ECS) is a software architecture pattern commonly used in game development to organize and manage game objects and their behavior. It separates objects into three main parts: Entities, Components, and Systems, which helps improve flexibility, scalability, and performance. Here’s a high-level explanation of each part:


Entities

  • What They Are: Entities are unique identifiers (often just an integer or a lightweight object) that represent individual game objects.
  • What They Do: By themselves, entities don’t have any data or behavior. They are essentially placeholders or tags to which components can be attached.

Example:

  • Entity 1 represents a player.
  • Entity 2 represents an enemy.

Components

  • What They Are: Components are modular pieces of data that define the attributes or properties of an entity.
  • What They Do: Components don’t have behavior; they only store data. An entity becomes meaningful by attaching a collection of components to it.

Example:

  • A player (Entity 1) might have:
    • A Position component (x: 10, y: 20).
    • A Health component (value: 100).
    • A Sprite component (image: player.png).
  • An enemy (Entity 2) might have:
    • A Position component (x: 50, y: 30).
    • A Health component (value: 50).
    • A Behavior component (type: aggressive).

Systems

  • What They Are: Systems are functions or processes that operate on entities with specific components.
  • What They Do: Systems contain the logic of the game. They query entities that have the components the system cares about and perform operations on them.

Example:

  • A Render System might:
    • Query all entities with Position and Sprite components.
    • Draw the sprites at their respective positions.
  • A Movement System might:
    • Query all entities with Position and Velocity components.
    • Update their positions based on velocity.

Why ECS is Useful

  1. Decoupling:
    • Data (components) is separated from logic (systems), making code easier to maintain and extend.
  2. Flexibility:
    • You can dynamically add, remove, or modify components for an entity, allowing objects to change behavior at runtime.
  3. Performance:
    • Systems often operate on flat, contiguous arrays of data (all components of a specific type), making ECS cache-friendly and efficient for large-scale simulations.
  4. Scalability:
    • It’s easier to manage thousands of entities since ECS focuses on efficient processing of data.

Example in Practice

Imagine a 2D game with a player and some enemies:

  • Entities: Player, Enemy1, Enemy2.
  • Components:
    • Position: (x, y) for spatial data.
    • Velocity: (vx, vy) for movement.
    • Health: For tracking hit points.
    • Sprite: For graphical representation.
  • Systems:
    • MovementSystem: Updates position based on velocity.
    • CollisionSystem: Detects collisions between entities.
    • RenderSystem: Draws entities with a Sprite at their Position.

Game Loop Workflow:

  1. MovementSystem updates all Position components.
  2. CollisionSystem checks for collisions between entities and adjusts their Health.
  3. RenderSystem draws all entities with a Sprite at their updated Position.

Summary

  • Entities: Unique IDs representing objects.
  • Components: Modular data that defines object properties.
  • Systems: Logic that processes entities with specific components.
VERTX HAZELCAST CLUSTER
DOTNET SELENIUM CRAWLER

    Backend

    WEBSOCKETS TICTACTOE VERTX HAZELCAST CLUSTER GO ECS ROGUELIKE DOTNET SELENIUM CRAWLER