LightYears
No description available
Install / Use
/learn @TutLeeUdemy/LightYearsREADME
Light Years
Introduction to the Game
Light Years is a 2D scrolling shooter spaceship fighting game, the player controls the hero spaceship and defeat the alien invation.
The Game is written in C++ and with the following library:
The Game Support Windows, MacOS, and Linux.
Screen Captures
<image src="doc/assets/capture01.png" width=200> <image src="doc/assets/capture02.png" width=200> <image src="doc/assets/capture03.png" width=200> <image src="doc/assets/capture04.png" width=200>
How to Build
The project uses cmake to configure the project and dependencies. Make sure your system have cmake and gcc/g++ installed:
|Build Tools |Version|
|---------------------|------|
|cmake version: |3.27.7|
|C++ version: |C++ 14|
|Generator: |Ninja |
The build process is very generic:
1, Open the folder with command prompt, and configure with cmake:
cmake -S . -B build -G Ninja
2, Build with cmake:
cmake --build build
3, open the game:
./build/LightYearsGame/LightYearsGame.exe
You can also run buildAndRun.bat to do all the above steps in one go.
Technical Details
The game is broken down to 2 major projects:
- LightYearsEngine
- LightYearsGame
The LightYearsEngine is a minimal game engine build on top of SFML that has the following implementations:
-
Appliation
the
Applicationclass is the top level object of the game that handles:- window creation
- game loop
- rendering
- level loading
- event dispatching
- Input
-
World
The
Worldclass represent a game level, it handles:- Actor Spawning
- HUD Spawning
- Object Lifetime Management
- Game Stage Management
-
Actor
The
Actorrepresent a game object than can be place in the level, they have facilities to change theirlocation,rotation, andvisuals. -
Asset Manager
The
AssetManagerclass is the core object to manageFontsandTextures, allowing easy loading, and memeory management of the resources. -
Physics System
The
PhysicsSystemuses Box2D as the Physics Engine, enabling Actors to trigger overlapping events. -
Timer Manager
The
TimerManagerprovide easy timer creation, manages life time, looping, and callbacks. -
Delegates
The
Delegateclass allows easy object member function binding and callbacks which helps creating event driven code. -
Widgets
The
Widgetclasses are used for UI elements, and currently have:- Button
- Image
- Text
- Value Gauge (progress bar)
-
Memory Management
The game uses reference counting to do garbage collection, adapting a peoridical sweeping system.
The LightYearsGame is the actual game build on top of LightYearsEngine, and it has the following major components:
-
Player
The
Playerrepresent the player, and it holdslife count,scoreand the reference of thePlayerSpaceShipit currently posess. -
Spaceship
The
Spaceshipclass is the based class for the player placeship, and various enemy spaceships, it has basic move and shooting capabilities, and has a health component to track it's health, as well as a healbar display. -
Player Spaceship
The
PlayerSpaceshipclass represent the player's spaceship, it handles player input, and unique player spaceship capabilies like picking up pickup and upgrade weapons. -
Health Component
The
HealthComponentclass manages health and damage related events, and fire up delegates to signal these events. -
Shooter
The
Shooterclass is the base class for all weapons, able to shoot bullets, weapons uses composition of Shooters to create more complex shooters.Weapons based on shooter are:
- FrontalWiper
- ThreeWayShooter
-
Bullet
The
Bulletclass represent the bullet that will cause damage to theHealthComponentof theActorit hits. -
Enemy
The
EnemySpaceshipclass is the based class for all enemy variants, and is based on Spaceship. Handles basic shooting, and reward spawning.There are many enemy classes based on enemy:
- Vanguard
- TwinBlade
- Hexagon
- UFO
- Boss
-
Reward
The
Rewardclass represents rewards the player can pick up, it uses factory function to spawn specific rewards:- HealthReward
- ThreewayShooterReward
- FrontalWiperReward
- LifeReward
Each of these rewards holds a function pointer that performs the actuall reward:
void RewardHealth(PlayerSpaceship* player);
void RewardThreewayShooter(PlayerSpaceship* player);
void RewardFrontalWiper(PlayerSpaceship* player);
void RewardLife(PlayerSpaceship* player);
Hope you have fun playing or extending this game!
