Simple tower defense game using C++ with Entity Component System (ECS)

Related tags

Game CubbyTower
Overview

CubbyTower

License Windows Ubuntu macOS Ubuntu - Codecov Build Status

codecov Codacy Badge Total alerts Language grade: C/C++ CodeFactor

Quality Gate Status Lines of Code Maintainability Rating Reliability Rating Security Rating

CubbyTower is a simple tower defense game using C++ with Entity Component System (ECS). The code is built on C++17 and can be compiled with commonly available compilers such as g++, clang++, or Microsoft Visual Studio. CubbyTower currently supports macOS (10.14 or later), Ubuntu (18.04 or later), Windows (Visual Studio 2017 or later), and Windows Subsystem for Linux (WSL). Other untested platforms that support C++17 also should be able to build CubbyTower.

Key Features

  • C++17 and ECS based simple tower defense game
  • C++ and Python API

Quick Start

You will need CMake to build the code. If you're using Windows, you need Visual Studio 2017 in addition to CMake.

First, clone the code:

git clone https://github.com/utilForever/CubbyTower.git --recursive
cd CubbyTower

C++ API

For macOS or Linux or Windows Subsystem for Linux (WSL):

mkdir build
cd build
cmake ..
make

For Windows:

mkdir build
cd build
cmake .. -G"Visual Studio 15 2017 Win64"
MSBuild CubbyTower.sln /p:Configuration=Release

Docker

docker pull utilforever/cubbytower:latest

Documentation

TBA

How To Contribute

Contributions are always welcome, either reporting issues/bugs or forking the repository and then issuing pull requests when you have completed some additional coding that you feel will be beneficial to the main project. If you are interested in contributing in a more dedicated capacity, then please contact me.

Contact

You can contact me via e-mail (utilForever at gmail.com). I am always happy to answer questions or help with any issues you might have, and please be sure to share any additional work or your creations with me, I love seeing what other people are making.

License

The class is licensed under the MIT License:

Copyright © 2021 CubbyTower Team

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Implement placer system and size pulse animation

    Implement placer system and size pulse animation

    This revision includes:

    • Implement placer system
      • Create struct 'Placer': This struct listens to inputs to place something on the map and Place() is then called
      • Add function 'CreatePlacer()': Creates a tower placer cursor with a callback
      • Add function 'UpdatePlaceSystem()': Update the cursor for placing a tower
      • Add constants for the size and color of the tower
      • Add code to emplace some components for tower icon
    • Implement size pulse animation (Resolves #9)
      • Create struct 'SizePulseAnim': This struct stores the animation size of the component
      • Add function 'UpdateSizePulseAnimSystem()': Update size pulse animations
      • Add function 'Simulate()': Simulates game system according to delta time
    • Refactor code
      • Add namespace 'Tower' to improve readability
      • Change function parameter 'const Position&'
    • Screenshots
      • Placer image
      • Size pulse animation image
    size/L 
    opened by utilForever 5
  • Implement monster destroy event

    Implement monster destroy event

    This revision includes:

    • Implement monster destroy event (When health is equal or less than 0)
      • Create struct 'Enemy'
        • This struct stores OnDestroy event
      • Add param OnDestroy to CreateMonster
      • Add DestroyMonster function
        • This is a basic function that just destroys an entity.
      • Update AttackSystem to destroy monster
      • Update AttackSystemTests to testing destroy monster
    size/L 
    opened by red1108 3
  • Implement GUI system, Part 1

    Implement GUI system, Part 1

    This revision includes:

    • Implement GUI system (#8)
      • Add library 'gl3w' to use OpenGL
      • Create structs
        • Inputs: This struct stores the position of mouse and the state of key/button
        • Size: This struct stores the size of the component for mouse picking
        • Color: This struct stores the color of the component
        • TextRenderer: This struct stores the data for rendering text at position with color
        • ShapeRenderer: This struct stores the functor for rendering shape
        • VertexPC: This struct stores the data for the position and color
        • CashButtonToggler: This struct stores the value of threshold to toggle the owner button depending on the cash threshold held by the player
        • Button: This struct defines basic properties of a button
        • Hoverable: This struct stores the value of normal/hover color
        • Resources: This struct stores resource handles
      • Add functions
        • OnMouseButtonPressed(): Callback when the mouse button is pressed
        • OnMouseButtonReleased(): Callback when the mouse button is released
        • CreateTowerButton(): Create a tower button
        • DrawBox(): Draws an box shape
        • UpdateShapeRenderSystem(): Draws entities that contains the component 'ShapeRenderers'
        • DrawLines(): Draw lines for Position + Color rendering
        • Update(): Updates game system according to delta time
        • Render(): Renders game system
        • PrepareForPC(): Prepare the rendering pipeline for Position + Color rendering
        • BeginFrame(): Start a rendering frame. This will clear background to black and set defaults render states
        • CreateProgram(): Create a shader program from vertex/fragment shader source
        • CreateVertexBuffer(): Create an empty vertex buffer
      • Refactor code
        • Change the type 'double' to 'float'
        • Remove unnecessary included headers
        • Move files 'Game.hpp/cpp' to parent folder
        • Delete file 'GameTests.cpp'
      • Update version of the library 'SFML' to 'latest' due to Visual Studio 2022 support
      • Add 'Game.hpp/cpp' to ingore list in Codecov
    size/XXL 
    opened by utilForever 3
  • Implement monster creation function

    Implement monster creation function

    This revision includes:

    • Add component 'Health'
    • Handle monster health
    • Add function 'CreateMonster()'
    • Make monster with properties
    • Make monster and check
    size/M 
    opened by IHIHHIHI 3
  • Prepare GUI code based on SFML

    Prepare GUI code based on SFML

    This revision includes:

    • Prepare GUI code based on SFML (#8)
      • Add library 'SFML'
      • Add command to install packages for SFML
      • Add base code to open/close window and process event
    size/M 
    opened by utilForever 3
  • Implement key input system

    Implement key input system

    This revision includes:

    • Implement key input system (Resolves #36)
      • Add variable 'upgradeKeyState' and 'upgradeKey'
        • Add code to update the value of 'upgradeKeyState'
      • Add function 'OnKeyPressed()': Handles key pressed event
        • Add code to process 'sf::Event::KeyPressed'
      • Add function 'OnKeyReleased()': Handles key released event
        • Add code to process 'sf::Event::KeyReleased'
    • Refactor upgrade system (Resolves #37)
      • Add code to emplace component 'Hoverable'
      • Change the logic of function 'UpdateUpgradeSystem()'
        • Delete parameter 'from'
        • Add code to check upgrade key state and hover
        • Apply changes of function 'UpdateUpgradeSystem()'
      • Add code to call function 'UpdateUpgradeSystem()'
    • Screenshot
      • Tower level 1 image
      • Tower level 2 by pressing 'U' while hovering arrow tower image
    size/L 
    opened by utilForever 2
  • Implement GUI system, Part 2

    Implement GUI system, Part 2

    This revision includes:

    • Implement GUI system (Resolves #8)
      • Add library 'stb' to import font resource
      • Create structs
        • StaticLinesRenderer: This struct stores the data for drawing static lines. This is used by the map entity
        • LineRenderer: This struct stores the functor for rendering line
        • PointRenderer: This struct stores the functor for rendering point
        • VertexPTC: Vertex data for Point + TexCoord + Color
        • TexCoord: This struct stores the coordinate of the texture
      • Add functions
        • EndFrame(): End a rendering frame. It does nothing, but might eventually
        • UpdateStaticLinesRenderSystem(): Draws entities that contains the component 'StaticLineRenderers'
        • CreateVertexBuffer(): Create an static vertex buffer
        • DrawLine(): Draw a line for Position + Color rendering
        • UpdateLineRenderSystem(): Draws entities that contains the component 'LineRenderers'
        • DrawPoints(): Draw points for Position + Color rendering
        • UpdatePointRenderSystem(): Draws entities that contains the component 'PointRenderers'
        • DrawRect(): Draw a rect for Position + Color rendering
        • DrawQuads(): Draw quads for Position + Color rendering
        • UpdateHealthBarRenderSystem(): Draws a health bar of the player
        • PrepareForPTC(): Prepare the rendering pipeline for Position + TexCoord + Color rendering
        • CreateTexture(): Load a texture from an image file
        • DrawPTC(): Draw a vertex data for Position + TexCoord + Color
        • DrawSimpleText(): Draw a text for Position + Texture + Color rendering
        • UpdateTextRenderSystem(): Draws entities that contains the component 'TextRenderers'
      • Change extension '.h' to '.hpp'
    size/XXL 
    opened by utilForever 2
  • Add distance-based attack system

    Add distance-based attack system

    This revision includes:

    • Add some components
      • AttackRange
      • Health
      • TargetPriority
    • Add position parameter to BuyArrowTower and add update new components
    • Add distance-based attack system to Attack function
    • Add new testing code for Attack function
    • Refactor TargetMask component code
    • Refactor TypeMask component code
    size/L 
    opened by red1108 2
  • feat: Add distance-based attack system

    feat: Add distance-based attack system

    The following items have been implemented.

    • Add AttackRange component
    • Add HealthPoint component
    • Add TargetPriority component
    • Add position parameter to BuyArrowTower and add update new components
    • Add distance-based attack system to Attack function
    • Add testing system for Attack function
    • Refactor TargetMask component code
    • Refactor TypeMask component code
    size/L 
    opened by red1108 2
  • Implement simple attack-related codes

    Implement simple attack-related codes

    This revision includes:

    • Add "Enemy" tag
    • Add targeter mask and corresponding type mask.
    • Add attackable system and corresponding testing system
    size/L 
    opened by red1108 2
  • Implement simple code to buy and upgrade tower

    Implement simple code to buy and upgrade tower

    This revision inculdes:

    • Implement simple code to buy and upgrade tower
      • Add library entt
      • Create components
        • Damage
        • Name
        • Gold
        • Upgradable
      • Add entt tags
        • Player
        • Tower
      • Create helpers
        • GoldHelpers: Withdraw()
        • TowerHelpers: BuyArrowTower(), UpgradeArrowTowerLv2()
      • Create system
        • UpgradeSystem: UpdateUpgradeSystem()
    • Create project 'CubbyTowerConsole'
    size/XL 
    opened by utilForever 2
Owner
Chris Ohk
Nexon Korea Game Programmer, Microsoft Developer Technologies MVP, @CppKorea Group Administrator
Chris Ohk
A fast entity component system (ECS) for C & C++

Flecs is a fast and lightweight Entity Component System with a focus on high performance game development (join the Discord!). Highlights of the frame

Sander Mertens 3.4k Nov 25, 2022
Gaming meets modern C++ - a fast and reliable entity-component system (ECS) and much more

EnTT is a header-only, tiny and easy to use entity-component system (and much more) written in modern C++. Among others, it's also used in Minecraft by Mojang and The Forge by Confetti.

Sean Middleditch 8 Feb 16, 2021
A C++14 Entity Component System

NOTICE: This project is currently in the progress of being rewritten for C++17. Check out this issue if you have any suggestions/know a good way to tr

Elnar Dakeshov 187 Nov 9, 2022
This is an ECS archetecture in Game implemented by C++

ECS This is an implement of the ECS archetecture in Game by C++17 ⭐ Star us on GitHub — it helps! ECS Sun Entity-Component-System Compiler compatibili

yao tang 40 Nov 16, 2022
An open source C++ entity system.

anax ARCHIVED: as I haven't maintained this library for at least a couple of years. I don't have the time or interest to work on this. Please use anot

Miguel Martin 457 Nov 16, 2022
Yet another component system

Yet another component system Header-only c++11 entity component system Depends on Parallel hashmap for fast pointer container Compile time type name a

Devil Devilson 11 Jul 30, 2022
Godex is a Godot Engine ECS library.

Godex Godex is a Godot Engine ecs library. Disclaimer: this module is still in development, open an issues to report any problem or a new discussion i

GodotECS 745 Nov 27, 2022
A lightweight but complete ECS implementation for modern C++.

ECS A lightweight but complete ECS implementation for modern C++. Features Cache friendly design implemented on top of an EnTT-like sparse set. Clean,

null 7 Sep 3, 2022
Replace Minecraft entity with MMD model.

KAIMyEntity Replace Minecraft entity with MMD model. KAIMyEntitySaba 将Github项目 benikabocha/saba (https://github.com/benikabocha/saba) 魔改成一个以JNI形式Expor

null 30 Oct 16, 2022
A foobar2000 component which allows you to load and play ncm files directly.

Play NCM files directly with our favourite How to setup and build project Download foobar2000 SDK and extract into vendor/sdk Download WTL from source

null 37 Nov 25, 2022
Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World.

OpenXRay OpenXRay is an improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World. S

null 2.2k Dec 2, 2022
Stealthy way to hijack the existing game process handle within the game launcher (currently supports Steam and Battle.net). Achieve external game process read/write with minimum footprint.

Launcher Abuser Stealthy way to hijack the existing game process handle within the game launcher (currently supports Steam and Battle.net). Achieve ex

Ricardo Nacif 79 Nov 23, 2022
Game Boy, Game Boy Color, and Game Boy Advanced Emulator

SkyEmu SkyEmu is low level cycle accurate GameBoy, GameBoy Color and Game Boy Advance emulator that I have been developing in my spare time. Its prima

Sky 287 Dec 3, 2022
A game made for the Game (Engineless) Jam using Raylib

Fastest Pizza Delivery A fun little 3D game made for the Game (Engineless) Jam. It is still is development but the basic gameplay is something l

Ryuzaki 2 Apr 3, 2022
A simple game framework written in C++ using SDL

SGF SGF (Simple Game Framework) is, as the name implies; a very simple and easy to use game framework written in C++ using SDL. Currently the project

Cam K. 1 Nov 4, 2021
Using Astar 2d simple console game

Journey-to-a-astar About this game Astar 알고리즘을 변형하여 이용한 2D맵 게임입니다. 게임의 목표는 ★(a star)에 도달하는 것 입니다. 별을 지키는 적이 플레이어를 쫓아옵니다. 적에게 잡히지 않고 최대한 빠른시간안에 별에 도달하면

Minseob Kim 1 Dec 10, 2021
A simple 2d snake game made using opengl in c++

opengl-snakegame A simple 2d snake game made using opengl in c++ Demo Keyboard Controls P - To resume/start or pause the game R - To restart the game

Dhruv Sawarkar 3 Dec 1, 2022
A very simple 2D game engine written in C++, using SDL and Lua.

2D Game Engine written in C++, SDL, and Lua. This is a simple 2D game engine written in C++ and using SDL and Lua scripting

Gustavo Pezzi 22 Oct 31, 2022
Simple Ball-Based Game, made using SFML.

Ball Ball is a basic windows-only, ball-based game, made using C++ SFML. The goal of the game is to claim 5 balls every 10 seconds. Ball can never be

orlando 2 Dec 20, 2021