-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 370f108
Showing
182 changed files
with
5,078 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake-build-debug | ||
build | ||
.idea | ||
*.dll | ||
!allegro_monolith-5.2.dll | ||
log.txt | ||
Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Win32", | ||
"includePath": [ | ||
"${workspaceFolder}/**", | ||
"C:\\allegro\\include" | ||
], | ||
"defines": [ | ||
"_DEBUG", | ||
"UNICODE", | ||
"_UNICODE" | ||
], | ||
"windowsSdkVersion": "10.0.22621.0", | ||
"compilerPath": "C:/msys64/ucrt64/bin/g++.exe", | ||
"cStandard": "c17", | ||
"cppStandard": "c++17", | ||
"intelliSenseMode": "windows-gcc-x64" | ||
} | ||
], | ||
"version": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "(gdb) Launch", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "enter program name, for example ${workspaceFolder}/a.exe", | ||
"args": [], | ||
"stopAtEntry": false, | ||
"cwd": "${fileDirname}", | ||
"environment": [], | ||
"externalConsole": false, | ||
"MIMode": "gdb", | ||
"miDebuggerPath": "/path/to/gdb", | ||
"setupCommands": [ | ||
{ | ||
"description": "Enable pretty-printing for gdb", | ||
"text": "-enable-pretty-printing", | ||
"ignoreFailures": true | ||
}, | ||
{ | ||
"description": "Set Disassembly Flavor to Intel", | ||
"text": "-gdb-set disassembly-flavor intel", | ||
"ignoreFailures": true | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "C/C++: g++.exe build and debug active file", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe", | ||
"args": [], | ||
"stopAtEntry": false, | ||
"cwd": "${fileDirname}", | ||
"environment": [], | ||
"externalConsole": false, | ||
"MIMode": "gdb", | ||
"miDebuggerPath": "C:\\msys64\\ucrt64\\bin\\gdb.exe", | ||
"setupCommands": [ | ||
{ | ||
"description": "Enable pretty-printing for gdb", | ||
"text": "-enable-pretty-printing", | ||
"ignoreFailures": true | ||
}, | ||
{ | ||
"description": "Set Disassembly Flavor to Intel", | ||
"text": "-gdb-set disassembly-flavor intel", | ||
"ignoreFailures": true | ||
} | ||
], | ||
"preLaunchTask": "C/C++: g++.exe build active file" | ||
} | ||
], | ||
"version": "2.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"files.associations": { | ||
"iosfwd": "cpp", | ||
"xutility": "cpp", | ||
"xstring": "cpp", | ||
"algorithm": "cpp", | ||
"array": "cpp", | ||
"atomic": "cpp", | ||
"bit": "cpp", | ||
"bitset": "cpp", | ||
"cctype": "cpp", | ||
"cfenv": "cpp", | ||
"charconv": "cpp", | ||
"chrono": "cpp", | ||
"cinttypes": "cpp", | ||
"clocale": "cpp", | ||
"cmath": "cpp", | ||
"compare": "cpp", | ||
"complex": "cpp", | ||
"concepts": "cpp", | ||
"condition_variable": "cpp", | ||
"csetjmp": "cpp", | ||
"csignal": "cpp", | ||
"cstdarg": "cpp", | ||
"cstddef": "cpp", | ||
"cstdint": "cpp", | ||
"cstdio": "cpp", | ||
"cstdlib": "cpp", | ||
"cstring": "cpp", | ||
"ctime": "cpp", | ||
"cwchar": "cpp", | ||
"cwctype": "cpp", | ||
"deque": "cpp", | ||
"exception": "cpp", | ||
"format": "cpp", | ||
"forward_list": "cpp", | ||
"fstream": "cpp", | ||
"functional": "cpp", | ||
"future": "cpp", | ||
"initializer_list": "cpp", | ||
"iomanip": "cpp", | ||
"ios": "cpp", | ||
"iostream": "cpp", | ||
"istream": "cpp", | ||
"iterator": "cpp", | ||
"limits": "cpp", | ||
"list": "cpp", | ||
"locale": "cpp", | ||
"map": "cpp", | ||
"memory": "cpp", | ||
"mutex": "cpp", | ||
"new": "cpp", | ||
"numeric": "cpp", | ||
"optional": "cpp", | ||
"ostream": "cpp", | ||
"queue": "cpp", | ||
"random": "cpp", | ||
"ranges": "cpp", | ||
"ratio": "cpp", | ||
"regex": "cpp", | ||
"scoped_allocator": "cpp", | ||
"set": "cpp", | ||
"span": "cpp", | ||
"sstream": "cpp", | ||
"stack": "cpp", | ||
"stdexcept": "cpp", | ||
"stop_token": "cpp", | ||
"streambuf": "cpp", | ||
"string": "cpp", | ||
"system_error": "cpp", | ||
"thread": "cpp", | ||
"tuple": "cpp", | ||
"type_traits": "cpp", | ||
"typeindex": "cpp", | ||
"typeinfo": "cpp", | ||
"unordered_map": "cpp", | ||
"unordered_set": "cpp", | ||
"utility": "cpp", | ||
"valarray": "cpp", | ||
"vector": "cpp", | ||
"xfacet": "cpp", | ||
"xhash": "cpp", | ||
"xiosbase": "cpp", | ||
"xlocale": "cpp", | ||
"xlocbuf": "cpp", | ||
"xlocinfo": "cpp", | ||
"xlocmes": "cpp", | ||
"xlocmon": "cpp", | ||
"xlocnum": "cpp", | ||
"xloctime": "cpp", | ||
"xmemory": "cpp", | ||
"xtr1common": "cpp", | ||
"xtree": "cpp", | ||
"*.tcc": "cpp", | ||
"memory_resource": "cpp", | ||
"string_view": "cpp", | ||
"numbers": "cpp", | ||
"semaphore": "cpp", | ||
"variant": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"tasks": [ | ||
{ | ||
"type": "cppbuild", | ||
"label": "C/C++: g++.exe build active file", | ||
"command": "C:\\msys64\\ucrt64\\bin\\g++.exe", | ||
"args": [ | ||
"-fdiagnostics-color=always", | ||
"-g", | ||
"${file}", | ||
"-o", | ||
"${fileDirname}\\${fileBasenameNoExtension}.exe" | ||
], | ||
"options": { | ||
"cwd": "${fileDirname}" | ||
}, | ||
"problemMatcher": [ | ||
"$gcc" | ||
], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"detail": "Task generated by Debugger." | ||
} | ||
], | ||
"version": "2.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "Bullet.hpp" | ||
#include "Engine/Collider.hpp" | ||
#include "Enemy/Enemy.hpp" | ||
#include "Engine/GameEngine.hpp" | ||
#include "Engine/Group.hpp" | ||
#include "Engine/IObject.hpp" | ||
#include "Engine/IScene.hpp" | ||
#include "Scene/PlayScene.hpp" | ||
#include "Engine/Point.hpp" | ||
#include "Engine/Sprite.hpp" | ||
|
||
PlayScene* Bullet::getPlayScene() { | ||
return dynamic_cast<PlayScene*>(Engine::GameEngine::GetInstance().GetActiveScene()); | ||
} | ||
void Bullet::OnExplode(Enemy* enemy) { | ||
} | ||
Bullet::Bullet(std::string img, float speed, float damage, Engine::Point position, Engine::Point forwardDirection, float rotation, Turret* parent) : | ||
Sprite(img, position.x, position.y), speed(speed), damage(damage), parent(parent) { | ||
Velocity = forwardDirection.Normalize() * speed; | ||
Rotation = rotation; | ||
CollisionRadius = 4; | ||
} | ||
void Bullet::Update(float deltaTime) { | ||
Sprite::Update(deltaTime); | ||
PlayScene* scene = getPlayScene(); | ||
// Can be improved by Spatial Hash, Quad Tree, ... | ||
// However simply loop through all enemies is enough for this program. | ||
for (auto& it : scene->EnemyGroup->GetObjects()) { | ||
Enemy* enemy = dynamic_cast<Enemy*>(it); | ||
if (!enemy->Visible) | ||
continue; | ||
if (Engine::Collider::IsCircleOverlap(Position, CollisionRadius, enemy->Position, enemy->CollisionRadius)) { | ||
OnExplode(enemy); | ||
enemy->Hit(damage); | ||
getPlayScene()->BulletGroup->RemoveObject(objectIterator); | ||
return; | ||
} | ||
} | ||
// Check if out of boundary. | ||
if (!Engine::Collider::IsRectOverlap(Position - Size / 2, Position + Size / 2, Engine::Point(0, 0), PlayScene::GetClientSize())) | ||
getPlayScene()->BulletGroup->RemoveObject(objectIterator); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef BULLET_HPP | ||
#define BULLET_HPP | ||
#include <string> | ||
|
||
#include "Engine/Sprite.hpp" | ||
|
||
class Enemy; | ||
class PlayScene; | ||
class Turret; | ||
namespace Engine { | ||
struct Point; | ||
} // namespace Engine | ||
|
||
class Bullet : public Engine::Sprite { | ||
protected: | ||
float speed; | ||
float damage; | ||
Turret* parent; | ||
PlayScene* getPlayScene(); | ||
virtual void OnExplode(Enemy* enemy); | ||
public: | ||
Enemy* Target = nullptr; | ||
explicit Bullet(std::string img, float speed, float damage, Engine::Point position, Engine::Point forwardDirection, float rotation, Turret* parent); | ||
void Update(float deltaTime) override; | ||
}; | ||
#endif // BULLET_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <allegro5/base.h> | ||
#include <random> | ||
#include <string> | ||
|
||
#include "UI/Animation/DirtyEffect.hpp" | ||
#include "Enemy/Enemy.hpp" | ||
#include "FireBullet.hpp" | ||
#include "Engine/Group.hpp" | ||
#include "Scene/PlayScene.hpp" | ||
#include "Engine/Point.hpp" | ||
|
||
class Turret; | ||
|
||
FireBullet::FireBullet(Engine::Point position, Engine::Point forwardDirection, float rotation, Turret* parent) : | ||
Bullet("play/bullet-1.png", 500, 1, position, forwardDirection, rotation - ALLEGRO_PI / 2, parent) { | ||
// TODO: [CUSTOM-TOOL] You can imitate the 2 files: 'FireBullet.hpp', 'FireBullet.cpp' to create a new bullet. | ||
} | ||
void FireBullet::OnExplode(Enemy* enemy) { | ||
std::random_device dev; | ||
std::mt19937 rng(dev()); | ||
std::uniform_int_distribution<std::mt19937::result_type> dist(2, 5); | ||
getPlayScene()->GroundEffectGroup->AddNewObject(new DirtyEffect("play/dirty-1.png", dist(rng), enemy->Position.x, enemy->Position.y)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef FIREBULLET_HPP | ||
#define FIREBULLET_HPP | ||
#include "Bullet.hpp" | ||
|
||
class Enemy; | ||
class Turret; | ||
namespace Engine { | ||
struct Point; | ||
} // namespace Engine | ||
|
||
class FireBullet : public Bullet { | ||
public: | ||
explicit FireBullet(Engine::Point position, Engine::Point forwardDirection, float rotation, Turret* parent); | ||
void OnExplode(Enemy* enemy) override; | ||
}; | ||
#endif // FIREBULLET_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <allegro5/base.h> | ||
#include <random> | ||
#include <string> | ||
|
||
#include "UI/Animation/DirtyEffect.hpp" | ||
#include "Enemy/Enemy.hpp" | ||
#include "Engine/Group.hpp" | ||
#include "LaserBullet.hpp" | ||
#include "Scene/PlayScene.hpp" | ||
#include "Engine/Point.hpp" | ||
|
||
class Turret; | ||
|
||
LaserBullet::LaserBullet(Engine::Point position, Engine::Point forwardDirection, float rotation, Turret* parent) : | ||
Bullet("play/bullet-2.png", 800, 2, position, forwardDirection, rotation - ALLEGRO_PI / 2, parent) { | ||
} | ||
void LaserBullet::OnExplode(Enemy* enemy) { | ||
std::random_device dev; | ||
std::mt19937 rng(dev()); | ||
std::uniform_int_distribution<std::mt19937::result_type> dist(2, 10); | ||
getPlayScene()->GroundEffectGroup->AddNewObject(new DirtyEffect("play/dirty-2.png", dist(rng), enemy->Position.x, enemy->Position.y)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef LASERBULLET_HPP | ||
#define LASERBULLET_HPP | ||
#include "Bullet.hpp" | ||
|
||
class Enemy; | ||
class Turret; | ||
namespace Engine { | ||
struct Point; | ||
} // namespace Engine | ||
|
||
class LaserBullet : public Bullet { | ||
public: | ||
explicit LaserBullet(Engine::Point position, Engine::Point forwardDirection, float rotation, Turret* parent); | ||
void OnExplode(Enemy* enemy) override; | ||
}; | ||
#endif // LASERBULLET_HPP |
Oops, something went wrong.