Get Started
This guide will help you create your first multiplayer game with Piggo. We’ll build a simple game that demonstrates the core concepts of the framework.This quickstart assumes you’ve already completed the installation steps.
Create Your First Game
Define Your Game Builder
Every Piggo game starts with a The
GameBuilder that defines the game’s configuration:GameBuilder returns a Game object with:- renderer: Choose “pixi” for 2D or “three” for 3D
- netcode: “delay” or “rollback” for multiplayer sync
- settings: Immutable game configuration
- state: Networked game state that syncs across clients
- systems: Behavior and logic processors
- entities: Starting game objects
Add Systems for Game Logic
Systems contain the logic that runs every tick. Here’s an example from the Hoops game:Common built-in systems:
PhysicsSystem- Rapier physics integrationSpawnSystem- Player spawn managementPixiRenderSystem/ThreeRenderSystem- RenderingPixiCameraSystem/ThreeCameraSystem- Camera controlHUDSystem- UI overlays
Create the World
The The
World is the runtime that manages your game. Use DefaultWorld to get started:DefaultWorld includes essential systems:RandomSystem- Deterministic random numbersExpiresSystem- Auto-remove timed entitiesControlSystem- Input handlingInputSystem- Keyboard/mouse/touchCommandSystem- Chat commandsNPCSystem- Non-player character logicActionSystem- Player actionsPositionSystem- Transform updates
Initialize Your Game
Put it all together in your entry point:This initializes the canvas, sets up audio, and starts the game loop.
Full Example: Simple 2D Game
Here’s a complete example based on the Lobby game structure:core/src/games/mygame/MyGame.ts
Project Structure
Your game files should follow this structure:Understanding the Game Loop
Piggo runs on a fixed tick rate (default: 20 ticks/second):- onTick: Systems process game logic
- onRender: Visual updates (can run at 60 FPS)
- Network sync: State synchronizes across clients
The tick rate determines game simulation frequency, while rendering can run at higher frame rates for smooth visuals.
Next Steps
ECS Concepts
Deep dive into Entity Component System architecture
Creating Entities
Learn how to build game objects
Building Systems
Write custom game logic
Multiplayer Netcode
Implement rollback and delay netcode