/Flappy-Bird

My C++ implementation of the famous Flappy Bird game on Desktop

Primary LanguageC++

Flappy-Bird

About

This is my desktop implementation of the famous Flappy Bird using the C++ language and SFML GUI library.

The main purpose of this project is to familiarize myself with the structures of a "quite" complex game. It also helps improving my knowledge in making a game/ app in general.

Screenshots

  1. Splash Screen

    Splash Screen

  2. Main Menu Screen

    Main Menu Screen

  3. Flash Screen on Death

    Flash Screen

  4. Game Over Screen

    GameOver Screen

How the game is designed

The game is designed based on the states machine model.

A finite-state machine (FSM) or finite-state automaton (FSA, plural: automata), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number of states at any given time. The FSM can change from one state to another in response to some external inputs and/or a condition is satisfied; the change from one state to another is called a transition.[1] An FSM is defined by a list of its states, its initial state, and the conditions for each transition.

Inputs

Inputs (i.e. clicks) are handled by the InputManager class.

Assets

All assets (i.e. textures and fonts) are handled using the AssetManager class.

States

Every state transitions, add/ remove a state, active state are processed by the StateMachine class (Different from State class).

Main game loop

  • Game object is created.
  • Setup a window - video mode.
  • Move on to Splash State
  • Game run()
  • Show Main Menu State
  • Main game happens in Game State
  • If bird crashes, move to GameOver State
  • Back to Game State if replay is clicked.

State class

    class State {
    public:
        void init() { /* ... */ };
        void handleInput() { /* ... */ };
        void update() { /* ... */ };
        void draw() { /* ... */ };
    };

Issues

  • The pipes are still quite far from each other.
  • Pipe heights do not change much.
  • The game consumes a high CPU power.