A very simple starter setup for an SFML game with a minimal finite state machine (FSM).
Clone the repo git clone https://github.com/kiswa/SFML_Starter
, enter the directory you cloned into, and run cmake .
(note the .
after the command). This should generate the necessary project files to build on your system.
For Linux, follow this with make
and you will have an executable named sfml
which you can run to see the demo.
All source files are in the src
directory.
main.cpp
The main entry point that starts everything going.game.*pp
The Game class contains a GameData struct that holds the FSM, Asset Manager, and SFML Window.asset_manager.*pp
The AssetManager class provides long-lived access tosf::Texture
s andsf::Font
s.state_machine.*pp
The StateMachine class is just a simple wrapper around astd::stack
which handles transitioning between states.state.hpp
The State class is an abstract class that each state inherits.game_state.*pp
The GameState class is a simple implementation of a game state to show how it might be used.pause_state.*pp
The PauseState class is just to demonstrate changing states without replacing the current state.
The "alien" image is courtesy of Kenney.
The font used is Fira Mono from Mozilla (specifically, FiraMono-Regular.otf
).