w
and s
for player 1
i
and k
for player 2
Unfocus window to pause (also gives your CPU a break since the game engine runs in real time)
In order to build this, you will need SFML headers installed in your search path
Then, the following should get you going:
mkdir build
cd build
cmake ..
make
./bin/pong
On of my goals with this project (as with most of my projects) was to keep the depedency footprint small - SFML is a very lightweight (the lightest weight I could find...) library that provides us with a cross-platform method of making a window and "drawing stuff". If you know of something lighter weight let me know.
This project utilizes the Entity-Component-System design pattern to a fault (I think even the walls are Entities) to simulate a very rough clone of pong.
Some of the main features of this project:
- Everything is an Entity - I realize that is overkill, but I wanted to really get a firm understanding all the pros/cons of the ECS pattern
- Based on the fabulous Fix Your Timestep! article, a fixed timestep is used.
- A custom (very basic) Engine is used: it's simple, but effective (two of my favourite adjectives)
- Since everything is an Entity, we have some pretty specific systems to operate
on them
InputHandlerSystem
manages input from the user - two players can play together!PhysicsSystem
manages momemtum, speed, dragEventCollissionSystem
reacts to broadcasted events from the PhysicsSystem, and figures out if things went "bump"TextSinkRenderSystem
is used to render textRenderSystem
is used to draw to the screen