Add Particles (basic)
78
.idea/.idea.Motherload/.idea/workspace.xml
generated
@@ -11,28 +11,12 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="26a0623a-44d5-441c-8048-32ff1dab3479" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/Game/Particle/Particle.cpp" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Game/Particle/Particle.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/BaseGame.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/BaseGame.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Animations/Animation.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Animations/Animation.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Animations/Animation.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Animations/Animation.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Game.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Game.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Game.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.vcxproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GroundTileTypeManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GroundTileTypeManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Gui/GuiMeter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/GuiMeter.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Gui/GuiMeter.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/GuiMeter.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/Level.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/Level.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/Level.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/Level.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/World/Building.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/Building.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Particle/Particle.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Particle/Particle.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Particle/Particle.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Particle/Particle.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Player.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Player.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/TextureManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/TextureManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/TextureManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/TextureManager.h" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -50,7 +34,8 @@
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="cidr-memory-view://1" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/algorithm" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/vector" root0="SKIP_HIGHLIGHTING" />
|
||||
@@ -59,6 +44,7 @@
|
||||
<setting file="file://$PROJECT_DIR$/Engine/Texture.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Engine/utils.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Engine/utils.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/Animations/Animation.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/Camera.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/Player.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/Player.h" root0="FORCE_HIGHLIGHTING" />
|
||||
@@ -86,28 +72,28 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"C++ Project.Game.executor": "Debug",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.sourceCode.C++",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"C++ Project.Game.executor": "Debug",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.sourceCode.C++",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"rider.external.source.directories": [
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\DecompilerCache",
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache",
|
||||
"C:\\Users\\Bram\\AppData\\Local\\Symbols\\src"
|
||||
"keyToStringList": {
|
||||
"rider.external.source.directories": [
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\DecompilerCache",
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache",
|
||||
"C:\\Users\\Bram\\AppData\\Local\\Symbols\\src"
|
||||
]
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="Game" type="CppProject" factoryName="C++ Project">
|
||||
<configuration_1>
|
||||
@@ -249,7 +235,8 @@
|
||||
<workItem from="1715031948901" duration="46000" />
|
||||
<workItem from="1715063584283" duration="11702000" />
|
||||
<workItem from="1715170674144" duration="2320000" />
|
||||
<workItem from="1715206284291" duration="2013000" />
|
||||
<workItem from="1715206284291" duration="5406000" />
|
||||
<workItem from="1715254613428" duration="787000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Rework Tile detection system">
|
||||
<option name="closed" value="true" />
|
||||
@@ -379,7 +366,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1715070920513</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="17" />
|
||||
<task id="LOCAL-00017" summary="Started on GuiIcon, General fixes">
|
||||
<option name="closed" value="true" />
|
||||
<created>1715208368790</created>
|
||||
<option name="number" value="00017" />
|
||||
<option name="presentableId" value="LOCAL-00017" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1715208368790</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="18" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -404,7 +399,8 @@
|
||||
<MESSAGE value="Update gitignore" />
|
||||
<MESSAGE value="Remove All Memory leaks" />
|
||||
<MESSAGE value="Fix digging" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Fix digging" />
|
||||
<MESSAGE value="Started on GuiIcon, General fixes" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Started on GuiIcon, General fixes" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
||||
@@ -61,8 +61,8 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {700, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {750, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {800, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
|
||||
m_Meter = new GuiMeter("gui/main/fuel_guage.png", Vector2f{100, 100}, Vector2f{336, 146}, 100, TextureManager::GetInstance());
|
||||
Texture* test = new Texture("gui/main/fuel_guage.png");
|
||||
// m_Meter = new GuiMeter("gui/main/fuel_guage.png", Vector2f{100, 100}, Vector2f{336, 146}, 100, TextureManager::GetInstance());
|
||||
// Texture* test = new Texture("gui/main/fuel_guage.png");
|
||||
}
|
||||
WorldLevel::~WorldLevel() {
|
||||
delete m_RefeulBuilding;
|
||||
@@ -73,7 +73,7 @@ WorldLevel::~WorldLevel() {
|
||||
}
|
||||
void WorldLevel::Update(float elapsedSec) {
|
||||
m_Fps = 1 / elapsedSec;
|
||||
m_Meter->Update(elapsedSec);
|
||||
// m_Meter->Update(elapsedSec);
|
||||
|
||||
int mouseX, mouseY;
|
||||
SDL_GetMouseState(&mouseX, &mouseY);
|
||||
@@ -95,6 +95,23 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
}
|
||||
}
|
||||
}
|
||||
testCounter++;
|
||||
std::vector<Particle*> ToDelete{};
|
||||
for(Particle* p : m_Particles) {
|
||||
p->Update(elapsedSec);
|
||||
if(p->IsDead()) {
|
||||
ToDelete.emplace_back(p);
|
||||
}
|
||||
}
|
||||
for (Particle* p : ToDelete) {
|
||||
m_Particles.erase(std::remove(m_Particles.begin(), m_Particles.end(), p), m_Particles.end());
|
||||
delete p;
|
||||
}
|
||||
if(testCounter % 100 == 0) {
|
||||
m_Particles.emplace_back(new Particle(Vector2f{100, 100}, Vector2f{float(utils::randRange(-200, 200)), 10},100, TextureManager::GetInstance()->GetTexture("particles/dirt_" + std::to_string(utils::randRange(1, 8)) + ".png")));
|
||||
}
|
||||
|
||||
|
||||
if (m_pSelectedTile != nullptr) {
|
||||
if (utils::isMouseDown(SDL_BUTTON_LEFT)) {
|
||||
m_pSelectedTile->SetTileType(GroundTileTypeManager::GetInstance()->AIR);
|
||||
@@ -180,6 +197,10 @@ void WorldLevel::Draw() const {
|
||||
m_RepairBuilding->Draw();
|
||||
m_Player.Draw();
|
||||
|
||||
for(Particle* p : m_Particles) {
|
||||
p->Draw();
|
||||
}
|
||||
|
||||
utils::SetColor(Colors::GREEN);
|
||||
utils::DrawArrow(Vector2f{0, 0}, m_MousePos);
|
||||
|
||||
@@ -194,7 +215,7 @@ void WorldLevel::Draw() const {
|
||||
screen->Draw();
|
||||
}
|
||||
|
||||
m_Meter->Draw();
|
||||
// m_Meter->Draw();
|
||||
}
|
||||
void WorldLevel::MouseMove(const Vector2f& mousePos) {
|
||||
m_MousePos = mousePos;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Gui/Screens/ScreenManager.h"
|
||||
#include "Camera.h"
|
||||
#include "Gui/GuiMeter.h"
|
||||
#include "Particle/Particle.h"
|
||||
|
||||
class WorldLevel : public Level
|
||||
{
|
||||
@@ -27,6 +28,9 @@ public:
|
||||
|
||||
std::vector<Collision::CollisionRect> m_Rects;
|
||||
|
||||
std::vector<Particle*> m_Particles;
|
||||
int testCounter{ 0 };
|
||||
|
||||
private:
|
||||
double m_Fps{ 0.0f };
|
||||
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
#include "pch.h"
|
||||
#include "Particle.h"
|
||||
Particle::Particle(const Vector2f& pos, const Vector2f& velocity, Texture* pTexture): m_Position{ pos }, m_Velocity{ velocity }, m_pTexture{ pTexture }
|
||||
{}
|
||||
Particle::Particle(const Vector2f& pos, const Vector2f& velocity, float lifetime, Texture* pTexture): m_Position { pos }, m_Velocity { velocity }, m_LifeTime { lifetime },
|
||||
m_pTexture { pTexture } {
|
||||
}
|
||||
void Particle::Update(float elapsedSec) {
|
||||
|
||||
m_Acceleration = Vector2f { 0.0f, -9.81f * 20};
|
||||
m_Velocity += m_Acceleration * elapsedSec;
|
||||
m_Position += m_Velocity * elapsedSec;
|
||||
m_LifeTime -= elapsedSec;
|
||||
m_Acceleration = Vector2f { 0.0f, 0.0f };
|
||||
|
||||
}
|
||||
void Particle::Draw() const {
|
||||
|
||||
m_pTexture->Draw(m_Position);
|
||||
}
|
||||
bool Particle::IsDead() const {
|
||||
return m_LifeTime <= 0.0f;
|
||||
}
|
||||
|
||||
@@ -4,13 +4,17 @@
|
||||
class Particle {
|
||||
public:
|
||||
Particle() = default;
|
||||
Particle(const Vector2f& pos, const Vector2f& velocity, Texture* pTexture);
|
||||
Particle(const Vector2f& pos, const Vector2f& velocity,float lifetime, Texture* pTexture);
|
||||
void Update(float elapsedSec);
|
||||
void Draw() const;
|
||||
bool IsDead() const;
|
||||
|
||||
private:
|
||||
Vector2f m_Position;
|
||||
Vector2f m_Velocity;
|
||||
Vector2f m_Acceleration;
|
||||
|
||||
float m_LifeTime;
|
||||
|
||||
Texture* m_pTexture;
|
||||
};
|
||||
|
||||
@@ -166,6 +166,9 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
m_BobTimer = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//check for keys
|
||||
if (m_State != PlayerState::Digging) {
|
||||
if (utils::isKeyDown(SDL_SCANCODE_W)) {
|
||||
|
||||
BIN
Resources/particles/dirt_1.png
Normal file
|
After Width: | Height: | Size: 364 B |
BIN
Resources/particles/dirt_2.png
Normal file
|
After Width: | Height: | Size: 422 B |
BIN
Resources/particles/dirt_3.png
Normal file
|
After Width: | Height: | Size: 340 B |
BIN
Resources/particles/dirt_4.png
Normal file
|
After Width: | Height: | Size: 419 B |
BIN
Resources/particles/dirt_5.png
Normal file
|
After Width: | Height: | Size: 368 B |
BIN
Resources/particles/dirt_6.png
Normal file
|
After Width: | Height: | Size: 430 B |
BIN
Resources/particles/dirt_7.png
Normal file
|
After Width: | Height: | Size: 426 B |
BIN
Resources/particles/dirt_8.png
Normal file
|
After Width: | Height: | Size: 402 B |