This document explains how the Flappy Bird console game works and how to use the code.
This game lets you control a bird in a console window, avoiding obstacles while trying to score as many points as possible. The bird moves up when you press a key and falls due to gravity.
-
Compile:
g++ -o flappybird flappybird.cpp -std=c++11
-
Run:
./flappybird
- Controls: Press any key to move the bird up. The bird falls automatically.
- Goal: Avoid hitting obstacles or the map's edges.
- Scoring: Gain 1 point for every obstacle passed.
- Levels: Difficulty increases every 5 points up to level 15.
Obstaclestruct: Stores obstacle positions.- Functions:
- Game setup and updates.
- Obstacle and bird movement.
- Map rendering.
- Main Game Loop:
- Handles the gameplay, user input, and game restarts.
initMap: Sets up the game map and initial obstacle positions.obstacleMove: Moves obstacles and resets them when they exit the map.birdMove: Moves the bird, checks collisions, and updates the score.render: Draws the game map, score, and level on the console.setCursorPosition: Adjusts the cursor position for smooth display updates.
Windows system (usesnow you can play in linux too<windows.h>for cursor control).- Console large enough for the game map.
Enjoy playing!