Skip to content

Commit

Permalink
Replaced the raw shell type number with an enum
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Apr 18, 2024
1 parent a781c75 commit 8a9e46b
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/smw/GSGameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2146,28 +2146,28 @@ void GameplayState::handleInput()
if (event.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL))
objectcontainer[0].add(new PU_Tanooki(list_players[0]->leftX() + 32, list_players[0]->topY()));
else if (event.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT))
objectcontainer[1].add(new CO_Shell(0, list_players[0]->leftX() + 32, list_players[0]->topY(), true, true, true, false));
objectcontainer[1].add(new CO_Shell(ShellType::Green, list_players[0]->leftX() + 32, list_players[0]->topY(), true, true, true, false));
else
objectcontainer[0].add(new PU_ExtraGuyPowerup(&rm->spr_3uppowerup, list_players[0]->leftX() + 32, list_players[0]->topY(), 1, true, 0, 30, 30, 1, 1, 3));
} else if (event.key.keysym.sym == SDLK_5) {
if (event.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL))
objectcontainer[0].add(new PU_PWingsPowerup(&rm->spr_pwingspowerup, list_players[0]->leftX() + 32, list_players[0]->topY()));
else if (event.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT))
objectcontainer[1].add(new CO_Shell(1, list_players[0]->leftX() + 32, list_players[0]->topY(), false, true, true, false));
objectcontainer[1].add(new CO_Shell(ShellType::Red, list_players[0]->leftX() + 32, list_players[0]->topY(), false, true, true, false));
else
objectcontainer[0].add(new PU_ExtraGuyPowerup(&rm->spr_5uppowerup, list_players[0]->leftX() + 32, list_players[0]->topY(), 1, true, 0, 30, 30, 1, 1, 5));
} else if (event.key.keysym.sym == SDLK_6) {
if (event.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL))
objectcontainer[1].add(new CO_Spring(&rm->spr_spring, list_players[0]->leftX() + 32, list_players[0]->topY(), true));
else if (event.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT))
objectcontainer[1].add(new CO_Shell(2, list_players[0]->leftX() + 32, list_players[0]->topY(), false, false, true, true));
objectcontainer[1].add(new CO_Shell(ShellType::Spiny, list_players[0]->leftX() + 32, list_players[0]->topY(), false, false, true, true));
else
objectcontainer[0].add(new PU_FirePowerup(&rm->spr_firepowerup, list_players[0]->leftX() + 32, list_players[0]->topY(), 1, true, 0, 30, 30, 1, 1));
} else if (event.key.keysym.sym == SDLK_7) {
if (event.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL))
objectcontainer[1].add(new CO_ThrowBox(&rm->spr_throwbox, list_players[0]->leftX() + 32, list_players[0]->topY(), (RANDOM_INT(NUM_POWERUPS) + 3) - 3));
else if (event.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT))
objectcontainer[1].add(new CO_Shell(3, list_players[0]->leftX() + 32, list_players[0]->topY(), false, true, false, false));
objectcontainer[1].add(new CO_Shell(ShellType::Buzzy, list_players[0]->leftX() + 32, list_players[0]->topY(), false, true, false, false));
else
objectcontainer[0].add(new PU_HammerPowerup(&rm->spr_hammerpowerup, list_players[0]->leftX() + 32, list_players[0]->topY(), 1, true, 0, 30, 30, 1, 1));
} else if (event.key.keysym.sym == SDLK_8) {
Expand Down
8 changes: 4 additions & 4 deletions src/smw/objectgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,19 @@ IO_MovingObject * createpowerup(short iType, short ix, short iy, bool side, bool
break;
}
case 12: {
shell = new CO_Shell(0, iSpawnX, iSpawnY, true, true, true, false);
shell = new CO_Shell(ShellType::Green, iSpawnX, iSpawnY, true, true, true, false);
break;
}
case 13: {
shell = new CO_Shell(1, iSpawnX, iSpawnY, false, true, true, false);
shell = new CO_Shell(ShellType::Red, iSpawnX, iSpawnY, false, true, true, false);
break;
}
case 14: {
shell = new CO_Shell(2, iSpawnX, iSpawnY, false, false, true, true);
shell = new CO_Shell(ShellType::Spiny, iSpawnX, iSpawnY, false, false, true, true);
break;
}
case 15: {
shell = new CO_Shell(3, iSpawnX, iSpawnY, false, true, false, false);
shell = new CO_Shell(ShellType::Buzzy, iSpawnX, iSpawnY, false, true, false, false);
break;
}
case 16: {
Expand Down
8 changes: 4 additions & 4 deletions src/smw/objects/carriable/CO_Shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ extern CResourceManager* rm;
// state 1: Shell is moving
// state 2: Shell is waiting to be picked up
// state 3: Shell is being held
CO_Shell::CO_Shell(short type, short x, short y, bool dieOnMovingPlayerCollision, bool dieOnHoldingPlayerCollision, bool dieOnFire, bool killBouncePlayer)
: MO_CarriedObject(&rm->spr_shell, x, y, 4, 4, 30, 20, 1, 11, 0, type * 32, 32, 32)
CO_Shell::CO_Shell(ShellType type, short x, short y, bool dieOnMovingPlayerCollision, bool dieOnHoldingPlayerCollision, bool dieOnFire, bool killBouncePlayer)
: MO_CarriedObject(&rm->spr_shell, x, y, 4, 4, 30, 20, 1, 11, 0, static_cast<int>(type) * 32, 32, 32)
{
iShellType = type;

Expand All @@ -48,7 +48,7 @@ CO_Shell::CO_Shell(short type, short x, short y, bool dieOnMovingPlayerCollision

iDestY = iy - collisionHeight;
fy = iDestY + 32.0f;
iColorOffsetY = type * 32;
iColorOffsetY = static_cast<int>(type) * 32;

iKillCounter = 0;
iNoOwnerKillTime = 0;
Expand Down Expand Up @@ -474,7 +474,7 @@ void CO_Shell::Die()
return;
}

eyecandy[2].add(new EC_FallingObject(&rm->spr_shelldead, ix, iy, -velx / 4.0f, -VELJUMP / 2.0f, 1, 0, iShellType * 32, 0, 32, 32));
eyecandy[2].add(new EC_FallingObject(&rm->spr_shelldead, ix, iy, -velx / 4.0f, -VELJUMP / 2.0f, 1, 0, static_cast<int>(iShellType) * 32, 0, 32, 32));
dead = true;
ifSoundOnPlay(rm->sfx_kicksound);
iKillCounter = 0;
Expand Down
13 changes: 11 additions & 2 deletions src/smw/objects/carriable/CO_Shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ class CPlayer;
class gfxSprite;
class Spotlight;


enum class ShellType : unsigned char {
Green,
Red,
Spiny,
Buzzy,
};


class CO_Shell : public MO_CarriedObject {
public:
CO_Shell(short type, short x, short y, bool dieOnMovingPlayerCollision, bool dieOnHoldingPlayerCollision, bool dieOnFire, bool killBouncePlayer);
CO_Shell(ShellType type, short x, short y, bool dieOnMovingPlayerCollision, bool dieOnHoldingPlayerCollision, bool dieOnFire, bool killBouncePlayer);

void update() override;
void draw() override;
Expand Down Expand Up @@ -43,7 +52,7 @@ class CO_Shell : public MO_CarriedObject {
private:
void Stop();

short iShellType;
ShellType iShellType;

short iIgnoreBounceTimer;
short iDestY;
Expand Down
2 changes: 1 addition & 1 deletion src/smw/objects/moving/MO_BuzzyBeetle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void MO_BuzzyBeetle::Die()
void MO_BuzzyBeetle::DropShell(bool fBounce, bool fFlip)
{
// Give the shell a state 2 so it is already spawned but sitting
CO_Shell* shell = new CO_Shell(3, ix - 1, iy, false, true, false, false);
CO_Shell* shell = new CO_Shell(ShellType::Buzzy, ix - 1, iy, false, true, false, false);
shell->nospawn(iy, fBounce);

if (fFlip)
Expand Down
8 changes: 4 additions & 4 deletions src/smw/objects/moving/MO_FrenzyCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@ bool MO_FrenzyCard::collide(CPlayer* player)
} else {
switch (type) {
case 14: {
CO_Shell* shell = new CO_Shell(0, 0, 0, true, true, true, false);
CO_Shell* shell = new CO_Shell(ShellType::Green, 0, 0, true, true, true, false);
if (objectcontainer[1].add(shell))
shell->UsedAsStoredPowerup(player);
break;
}
case 15: {
CO_Shell* shell = new CO_Shell(1, 0, 0, false, true, true, false);
CO_Shell* shell = new CO_Shell(ShellType::Red, 0, 0, false, true, true, false);
if (objectcontainer[1].add(shell))
shell->UsedAsStoredPowerup(player);
break;
}
case 16: {
CO_Shell* shell = new CO_Shell(2, 0, 0, false, false, true, true);
CO_Shell* shell = new CO_Shell(ShellType::Spiny, 0, 0, false, false, true, true);
if (objectcontainer[1].add(shell))
shell->UsedAsStoredPowerup(player);
break;
}
case 17: {
CO_Shell* shell = new CO_Shell(3, 0, 0, false, true, false, false);
CO_Shell* shell = new CO_Shell(ShellType::Buzzy, 0, 0, false, true, false, false);
if (objectcontainer[1].add(shell))
shell->UsedAsStoredPowerup(player);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/smw/objects/moving/MO_Koopa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ void MO_Koopa::DropShell(bool fBounce, bool fFlip)
CO_Shell* shell;

if (fRed)
shell = new CO_Shell(1, ix - 1, iy + 8, false, true, true, false);
shell = new CO_Shell(ShellType::Red, ix - 1, iy + 8, false, true, true, false);
else
shell = new CO_Shell(0, ix - 1, iy + 8, true, true, true, false);
shell = new CO_Shell(ShellType::Green, ix - 1, iy + 8, true, true, true, false);

shell->nospawn(iy + 8, fBounce);

Expand Down
2 changes: 1 addition & 1 deletion src/smw/objects/moving/MO_Spiny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void MO_Spiny::Die()
void MO_Spiny::DropShell(bool fBounce, bool fFlip)
{
// Give the shell a state 2 so it is already spawned but sitting
CO_Shell* shell = new CO_Shell(2, ix - 1, iy, false, true, false, false);
CO_Shell* shell = new CO_Shell(ShellType::Spiny, ix - 1, iy, false, true, false, false);
shell->nospawn(iy, fBounce);

if (fFlip)
Expand Down
8 changes: 4 additions & 4 deletions src/smw/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,25 +758,25 @@ void CPlayer::triggerPowerup()
break;
}
case 12: {
CO_Shell * shell = new CO_Shell(0, 0, 0, true, true, true, false);
CO_Shell * shell = new CO_Shell(ShellType::Green, 0, 0, true, true, true, false);
if (objectcontainer[1].add(shell))
shell->UsedAsStoredPowerup(this);
break;
}
case 13: {
CO_Shell * shell = new CO_Shell(1, 0, 0, false, true, true, false);
CO_Shell * shell = new CO_Shell(ShellType::Red, 0, 0, false, true, true, false);
if (objectcontainer[1].add(shell))
shell->UsedAsStoredPowerup(this);
break;
}
case 14: {
CO_Shell * shell = new CO_Shell(2, 0, 0, false, false, true, true);
CO_Shell * shell = new CO_Shell(ShellType::Spiny, 0, 0, false, false, true, true);
if (objectcontainer[1].add(shell))
shell->UsedAsStoredPowerup(this);
break;
}
case 15: {
CO_Shell * shell = new CO_Shell(3, 0, 0, false, true, false, false);
CO_Shell * shell = new CO_Shell(ShellType::Buzzy, 0, 0, false, true, false, false);
if (objectcontainer[1].add(shell))
shell->UsedAsStoredPowerup(this);
break;
Expand Down

0 comments on commit 8a9e46b

Please sign in to comment.