# Flap Hero Code Review

DevFeed: [Flap Hero Code Review](<https://devfeed.tech/articles/flap-hero-code-review-21019.md>)

Original publisher: [Read original article](<https://preshing.com/20201210/flap-hero-code-review>)

Author: Jeff Preshing

Published: 2020-12-10T20:23:00Z

Content type: article

Language: en

Sources: [Jeff Preshing](<https://devfeed.tech/sources/jeff-preshing.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Code](<https://devfeed.tech/topics/code.md>), [Game engine](<https://devfeed.tech/topics/game-engine.md>), [Framework](<https://devfeed.tech/topics/framework.md>), [OpenGL](<https://devfeed.tech/topics/opengl.md>), [GitHub](<https://devfeed.tech/topics/github.md>), [Android](<https://devfeed.tech/topics/android.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [macOS](<https://devfeed.tech/topics/macos.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [build](<https://devfeed.tech/tags/build.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [code](<https://devfeed.tech/tags/code.md>), [framework](<https://devfeed.tech/tags/framework.md>), [general](<https://devfeed.tech/tags/general.md>), [github](<https://devfeed.tech/tags/github.md>), [ios](<https://devfeed.tech/tags/ios.md>), [linux](<https://devfeed.tech/tags/linux.md>), [macos](<https://devfeed.tech/tags/macos.md>)

## AI overview

This code review examines Flap Hero, a small C++ game built without an existing game engine. It explains the project's architecture, reusable modules, dependencies, gameplay state management, platform-specific projects, and deliberately limited subsystem design. The article also discusses the use of Plywood, OpenGL, and advanced C++ features in lower-level modules.

## Source excerpt

Flap Hero is a small game written entirely in C++ without using an existing game engine. All of its source code is available on GitHub. I think it can serve as an interesting resource for novice and intermediate game developers to study. In this post, I'll explain how Flap Hero's code is organized, how it differs from larger game projects, why it was written that way, and what could have been done better. Very little information in this post is specific to C++. Most of it would still be relevant if Flap Hero was written in another language like C#, Rust or plain C. That said, if you browse (or build) the source code, you will need some fluency in C++. Learn C++ and Learn OpenGL are two great resources for beginners. For the most part, Flap Hero's source code sticks to a fairly straightforward subset of C++, but the deeper you go into its low-level modules (like runtime), the more you'll encounter advanced C++ features like templates and SFINAE. General Architecture Flap Hero was developed using Plywood, a C++ framework that helps organize code into reusable modules. Each yellow box in the diagram below represents a Plywood module. The blue arrows represent dependencies. platform runtime image math plywood repo flapGame glfwFlap GameFlow.cpp GameState.cpp Collision.cpp Text.cpp FlapHero repo Public.h glfw soloud glad assimp Main.cpp iOS project Android project iOS project iOS project Windows,Linux& macOS Assets.cpp GLHelpers.cpp The biggest chunk of Flap Hero's game code is located in the flapGame module, which contains roughly 6400 physical lines of code. The two most important source files in the flapGame module are GameFlow.cpp and GameState.cpp. All the state for a single gameplay session is held inside a single GameState object. This object is, in turn, owned by a GameFlow object. The GameFlow can actually own two GameState objects at a given time, with both gameplay sessions updating concurrently. This is used to achieve an animated "split screen" effect during