Pong game to practice ECS pattern, new C++17 features, SFML library and basic physics.
Build tool required: scons
$ cd ecs-pong/
$ scons
$ ./ecs-pong
- Player bat controlled with user mouse
- Basic AI bat handling multiple balls
- Number of balls increases as game advance
- Brick walls behind player and AI bats
- Destroyed on ball contact
- Restored when scored on
This little project proved me that the ECS pattern is really for game development, the extensibility is key.
Components (with fields):
AI ()
Body (Circle (Radius) | Rectangle (Width, Height))
Bound (Min (X, Y), Max (X, Y))
Brick (With)
Contact (Normal (X, Y), TrueNormal (X, Y), Penetration, With)
Fade (Diff, Alpha)
Input ()
Movement (Velocity (X, Y))
Position (Coords (X, Y))
Entities (with components):
Ball (Body, Movement, Position)
Bot (AI, Body, Bound, Position)
Player (Body, Bound, Input, Position)
Wall (Body, Position)
Brick (Body, Position, Brick)
Systems (with components and in order):
Input (Input, Position)
AI (AI, Position)
Bound (Bound, Position)
Collision (Body, Movement, Position)
Impulse (Contact, Movement, Position)
Movement (Movement, Position)
Game (Movement, Position)
Fade (Body, Fade)
Render (Body, Position)
- Improve the AI behavior
- Add menus and game modes
- Add collision between balls
- Avoid collision tunneling
- And many more...