Skip to content

Commit

Permalink
A lot of changes with errors, temp removed text when picking them up
Browse files Browse the repository at this point in the history
  • Loading branch information
Matqyou committed Dec 13, 2024
1 parent 590c418 commit efbc67c
Show file tree
Hide file tree
Showing 55 changed files with 986 additions and 519 deletions.
35 changes: 31 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,37 @@ set(PROJECT_FILES
"src/game/interface/SettingsMenu.h"
"src/game/interface/LevelUpMenu.cpp"
"src/game/interface/LevelUpMenu.h"
src/game/weapons/projectile/PatersonNavy.cpp
src/game/weapons/projectile/PatersonNavy.h
src/client/Particles.cpp
src/client/Particles.h)
"src/game/weapons/projectile/PatersonNavy.cpp"
"src/game/weapons/projectile/PatersonNavy.h"
"src/client/Particles.cpp"
"src/client/Particles.h"
"src/game/error/base/ErrorStatusEffect.cpp"
"src/game/error/base/ErrorStatusEffect.h"
"src/game/error/effect/ErrorHealersParadise.h"
"src/game/error/effect/ErrorHealersParadise.cpp"
"src/game/error/effect/ErrorDisoriented.h"
"src/game/error/effect/ErrorDisoriented.cpp"
"src/game/error/effect/ErrorInvincible.h"
"src/game/error/effect/ErrorInvincible.cpp"
"src/game/error/effect/ErrorDangerousRecoil.h"
"src/game/error/effect/ErrorDangerousRecoil.cpp"
"src/game/error/effect/ErrorSpiky.h"
"src/game/error/effect/ErrorSpiky.cpp"
"src/game/error/effect/ErrorBulletFrenzy.h"
"src/game/error/effect/ErrorBulletFrenzy.cpp"
"src/game/error/effect/ErrorConfusingHealth.h"
"src/game/error/effect/ErrorConfusingHealth.cpp"
"src/game/error/effect/ErrorTeleport.h"
"src/game/error/effect/ErrorTeleport.cpp"
"src/game/error/effect/ErrorSlowdown.h"
"src/game/error/effect/ErrorSlowdown.cpp"
"src/game/error/effect/ErrorCantHear.h"
"src/game/error/effect/ErrorCantHear.cpp"
"src/game/error/effect/ErrorRangedFists.h"
"src/game/error/effect/ErrorRangedFists.cpp"
src/game/error/ErrorStatuses.cpp
src/game/error/ErrorStatuses.h
)

add_executable(${PROJECT_NAME} ${BUILD_OPTIONS} ${PROJECT_FILES})

Expand Down
File renamed without changes
Binary file added bin/assets/images/icons/dangerous_recoil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/assets/images/interface/ingame/error_frame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/assets/images/interface/ingame/frame.pdn
Binary file not shown.
File renamed without changes
Binary file added bin/assets/images/particle/magic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
5 changes: 5 additions & 0 deletions src/GameReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "game/entities/Crate.h"
#include "game/entities/item/weapons/EntityGuns.h"
#include "game/entities/Projectile.h"
#include "game/entities/Error.h"
#include "game/entities/characters/character/Character.h"

LoadedSound GameReference::sQuitSound("ui.quit");

Expand Down Expand Up @@ -156,6 +158,9 @@ bool GameReference::Initialize() {
if (!m_Random) m_Random = new Randomizer();
if (!m_Draw) m_Draw = new Drawing(this);
if (!m_AssetsHandler) m_AssetsHandler = new AssetsManager();

m_Draw->SetDrawBlendMode(SDL_BLENDMODE_BLEND);

std::cout << FStringColors("&8------------------------------------------------------------------------") << std::endl;
std::cout << std::endl;
return true;
Expand Down
3 changes: 2 additions & 1 deletion src/game/entities/Crate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "characters/character/Character.h"
#include "Crate.h"
#include <iostream>

LoadedSound Crate::sHitSound[] = {
LoadedSound("entity.crate.broken.1"),
LoadedSound("entity.crate.broken.2"),
Expand Down Expand Up @@ -65,7 +66,7 @@ void Crate::Damage(double value, Entity* damager) {

void Crate::Heal(double value) {
m_HealthComponent.ChangeHealthBy(+value);
};
}

void Crate::Tick() {
TickWalls();
Expand Down
1 change: 0 additions & 1 deletion src/game/entities/Crate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "Entity.h"
#include "SDL.h"
#include "AmmoBox.h"
#include "Error.h"

enum DropType {
AMMO,
Expand Down
1 change: 0 additions & 1 deletion src/game/entities/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ const char* Entity::toString() const {
// Add some velocity to this characters
void Entity::Accelerate(const Vec2d& direction) {
m_Core.Vel += direction;
std::cout << FStringColors("Accelerate %f, %f", m_Core.Vel.x, m_Core.Vel.y) << std::endl;
}

void Entity::Tick() {
Expand Down
37 changes: 26 additions & 11 deletions src/game/entities/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

#include "Error.h"
#include "characters/character/Character.h"
#include <random>
#include <string>

Expand All @@ -14,6 +15,7 @@ LoadedTexture Error::sTextureErrorHealersParadise("entity.error.healer");
LoadedTexture Error::sTextureErrorRanged("entity.error.ranged");
LoadedTexture Error::sTextureErrorSlowDown("entity.error.slow");
LoadedTexture Error::sTextureErrorDangerousRecoil("entity.error.golden_apple");
LoadedTexture Error::sTextureMagicParticle("particle.magic");
LoadedSound Error::ms_PickupSounds[7] = {
LoadedSound("entity.error.pickup"),
LoadedSound("entity.error.pickup"),
Expand Down Expand Up @@ -60,47 +62,60 @@ void Error::TickPickup(double x, double y) {
ms_PickupSounds[rand() % 7].GetSound()->PlaySound();

if (m_Type == DISORIANTED) {
if (Char->IsNPC()) { Char->ReverseMovement(); }
if (Char->IsNPC()) { Char->GetErrorStatuses().Disoriented.Activate(); }
else {
auto Plr = m_World->FirstCharacter();
for (; Plr; Plr = (Character*)(Plr->NextType())) {
if (!Plr->IsNPC()) continue;
Plr->ReverseMovement();
Plr->GetErrorStatuses().Disoriented.Activate();
}
}
} else if (m_Type == CONFUSING_HP) {
auto Plr = m_World->FirstCharacter();
for (; Plr; Plr = (Character*)(Plr->NextType()))
Plr->ConfuseHP();
} else if (m_Type == INVINCIBLE) { Char->MakeInvincible(); }
else if (m_Type == SPIKY) { Char->MakeSpiky(); }
Plr->GetErrorStatuses().ConfusingHealth.Activate();
} else if (m_Type == INVINCIBLE) { Char->GetErrorStatuses().Invincible.Activate(); }
else if (m_Type == SPIKY) { Char->GetErrorStatuses().Spiky.Activate(); }
else if (m_Type == HEALERS_PARADISE) {
if (Char->IsNPC()) { Char->MakeHealer(); }
if (Char->IsNPC()) { Char->GetErrorStatuses().HealersParadise.Activate(); }
else {
auto Plr = m_World->FirstCharacter();
for (; Plr; Plr = (Character*)(Plr->NextType())) {
if (Plr->IsNPC()) continue;
Plr->MakeHealer();
Plr->GetErrorStatuses().HealersParadise.Activate();
}
}
} else if (m_Type == RANGED) { Char->MakeRanged(); }
} else if (m_Type == RANGED) { Char->GetErrorStatuses().RangedFists.Activate(); }
else if (m_Type == SLOW_DOWN) {
if (Char->IsNPC()) { Char->SlowDown(); }
if (Char->IsNPC()) { Char->GetErrorStatuses().Slowdown.Activate(); }
else {
auto Plr = m_World->FirstCharacter();
for (; Plr; Plr = (Character*)(Plr->NextType())) {
if (!Plr->IsNPC()) continue;
Plr->SlowDown();
Plr->GetErrorStatuses().Slowdown.Activate();
}
}
} else if (m_Type == DANGEROUS_RECOIL) { Char->ActivateDangerousRecoil(); }
} else if (m_Type == DANGEROUS_RECOIL) { Char->GetErrorStatuses().DangerousRecoil.Activate(); }
m_Alive = false;
}
}

void Error::Tick() {
TickPickup(m_Core.Pos.x, m_Core.Pos.y);
TickWalls();

if (m_World->GetTick() % (30 + rand() % 30) != 0)
return;

m_World->GetParticles()->PlayParticle(Particle(sTextureMagicParticle.GetTexture(),
m_Core.Pos,
Vec2d(5.0, 5.0),
Vec2d((double)(rand() % 10 - 5) / 10.0, -1.0),
1.0,
0.0,
0.0,
1.0,
60));
}

void Error::Draw() {
Expand Down
2 changes: 1 addition & 1 deletion src/game/entities/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "Entity.h"
#include "../weapons/projectile/ProjectileWeapon.h"
#include "characters/character/Character.h"

enum ErrorType {
HEALERS_PARADISE,
Expand Down Expand Up @@ -39,6 +38,7 @@ class Error : public Entity {
static LoadedTexture sTextureErrorRanged;
static LoadedTexture sTextureErrorSlowDown;
static LoadedTexture sTextureErrorDangerousRecoil;
static LoadedTexture sTextureMagicParticle;
static LoadedSound ms_PickupSounds[7];

Error(GameWorld* world, const Vec2d& start_pos, int typeID);
Expand Down
16 changes: 12 additions & 4 deletions src/game/entities/Projectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LoadedTexture Projectile::sTextureBurst("entity.projectile.burst");
LoadedTexture Projectile::sTextureShotgun("entity.projectile.shotgun");
LoadedTexture Projectile::sTextureSniper("entity.projectile.sniper");
LoadedTexture Projectile::sTextureMinigun("entity.projectile.minigun");
LoadedTexture Projectile::sTextureSpark("entity.projectile.spark");
LoadedTexture Projectile::sTextureSpark("particle.spark");
LoadedSound Projectile::sMetalImpactSounds[2] = {
LoadedSound("entity.projectile.impact.metal.1"),
LoadedSound("entity.projectile.impact.metal.2"),
Expand Down Expand Up @@ -99,18 +99,26 @@ void Projectile::TickCollision() {
bool Collides = Entity->PointCollides(current_position);
if (IsShooter && !Collides) { m_StillCollidesShooter = false; }
else if (Collides && (!IsShooter || !m_StillCollidesShooter)) {
double victim_health;
if (Entity->GetType() == CHARACTER_ENTITY) {
auto ShootableCharacter = (Character*)Entity;
victim_health = ShootableCharacter->HealthComponent().m_Health;
ShootableCharacter->Damage(m_Damage, m_Shooter);
ShootableCharacter->Accelerate(direction * 0.5 * m_Damage);
} else if (Entity->GetType() == CRATE_ENTITY) {
auto ShootableCrate = (Crate*)Entity;
victim_health = ShootableCrate->HealthComponent().m_Health;
ShootableCrate->Damage(m_Damage, m_Shooter);
} else {
throw std::runtime_error("Unhandled projectile impact with entity that has health");
}

// The projectile has served its purpose (clear immediately on impact)
m_Alive = false;
break;
// The projectile has served its purpose (clear immediately all damage has been depleted)
m_Damage -= victim_health;
if (m_Damage <= 0.0) {
m_Alive = false;
break;
}
}
}
}
Expand Down
Loading

0 comments on commit efbc67c

Please sign in to comment.