Skip to content

Commit

Permalink
Split objecthazard into smaller files
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Apr 10, 2024
1 parent 586db6f commit c0d2352
Show file tree
Hide file tree
Showing 18 changed files with 1,130 additions and 1,015 deletions.
844 changes: 0 additions & 844 deletions src/smw/objecthazard.cpp

Large diffs are not rendered by default.

179 changes: 8 additions & 171 deletions src/smw/objecthazard.h
Original file line number Diff line number Diff line change
@@ -1,173 +1,10 @@
#ifndef OBJECTHAZARD_H
#define OBJECTHAZARD_H
#pragma once

#include "gfx.h"
#include "object.h"
#include "PlayerKillStyles.h"

class CPlayer;
class IO_MovingObject;

class OMO_OrbitHazard : public IO_OverMapObject
{
public:
OMO_OrbitHazard(gfxSprite *nspr, short x, short y, float radius, float vel, float angle, short iNumSpr, short aniSpeed, short iCollisionWidth, short iCollisionHeight, short iCollisionOffsetX, short iCollisionOffsetY, short iAnimationOffsetX, short iAnimationOffsetY, short iAnimationHeight, short iAnimationWidth);
~OMO_OrbitHazard() {}

void update();

bool collide(CPlayer *);

private:
void CalculatePosition();

float dAngle, dVel, dRadius;
float dCenterX, dCenterY;
};

class OMO_StraightPathHazard : public IO_OverMapObject
{
public:
OMO_StraightPathHazard(gfxSprite *nspr, short x, short y, float angle, float vel, short iNumSpr, short aniSpeed, short iCollisionWidth, short iCollisionHeight, short iCollisionOffsetX, short iCollisionOffsetY, short iAnimationOffsetX, short iAnimationOffsetY, short iAnimationHeight, short iAnimationWidth);
~OMO_StraightPathHazard() {}

void update();

bool collide(CPlayer *);

private:

float dAngle, dVel;
};

class MO_BulletBill : public IO_MovingObject
{
public:
MO_BulletBill(gfxSprite *nspr, gfxSprite *nsprdead, short x, short y, float nspeed, short playerID, bool isspawned);
~MO_BulletBill(){};

void update();
void draw();
void draw(short iOffsetX, short iOffsetY);
bool collide(CPlayer * player);
void collide(IO_MovingObject * object);

bool hittop(CPlayer * player);
bool hitother(CPlayer * player);

void Die();
void SetDirectionOffset();

private:
gfxSprite * spr_dead;

short iColorID;

short iColorOffsetY;
short iDirectionOffsetY;

bool fIsSpawned;
short iHiddenDirection;
short iHiddenPlane;

friend class MO_Podobo;
};

class IO_BulletBillCannon : public CObject
{
public:
IO_BulletBillCannon(short x, short y, short freq, float vel, bool preview);
~IO_BulletBillCannon() {}

void draw() {}
void update();

bool collide(CPlayer *) {
return false;
}
void collide(IO_MovingObject *) {}

private:
void SetNewTimer();

short iFreq, iTimer;
float dVel;
bool fPreview;
};


class MO_Explosion : public IO_MovingObject
{
public:
MO_Explosion(gfxSprite *nspr, short x, short y, short iNumSpr, short aniSpeed, short id, short iTeamID, KillStyle style);
~MO_Explosion(){};

void update();
bool collide(CPlayer * player);

private:

short timer;
KillStyle iStyle;
};


class IO_FlameCannon : public CObject
{
public:
IO_FlameCannon(short x, short y, short freq, short direction);
~IO_FlameCannon() {}

void draw();
void draw(short iOffsetX, short iOffsetY);
void update();

bool collide(CPlayer * player);
void collide(IO_MovingObject *) {}

private:
void SetNewTimer();

short iFreq, iTimer, iCycle;
short iFrame;

short iDirection;

friend class CPlayerAI;
};


class MO_PirhanaPlant : public IO_MovingObject
{
public:
MO_PirhanaPlant(short x, short y, short type, short freq, short direction, bool preview);
~MO_PirhanaPlant() {}

void draw();
void draw(short iOffsetX, short iOffsetY);
void update();

bool collide(CPlayer * player);
void collide(IO_MovingObject *);

void KillPlant();

private:
void SetNewTimer();

float GetFireballAngle();

short iType, iDirection;
short iFreq, iTimer;
//short iHiddenPlane, iHiddenDirection;
//short iSrcX, iSrcY;
short iAnimationTimer;
short iFrame;
short iActionTimer;

bool fPreview;

friend class CPlayerAI;
};

#endif // OBJECTHAZARD_H
#include "objects/IO_BulletBillCannon.h"
#include "objects/IO_FlameCannon.h"
#include "objects/moving/MO_BulletBill.h"
#include "objects/moving/MO_Explosion.h"
#include "objects/moving/MO_PirhanaPlant.h"
#include "objects/overmap/WO_OrbitHazard.h"
#include "objects/overmap/WO_StraightPathHazard.h"
14 changes: 14 additions & 0 deletions src/smw/objects/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
target_sources(smw PRIVATE
IO_BulletBillCannon.cpp
IO_BulletBillCannon.h
IO_FlameCannon.cpp
IO_FlameCannon.h
MysteryMushroomTempPlayer.h
MysteryMushroomTempPlayer.cpp

Expand Down Expand Up @@ -55,6 +59,8 @@ target_sources(smw PRIVATE
moving/MO_BonusHouseChest.h
moving/MO_Boomerang.cpp
moving/MO_Boomerang.h
moving/MO_BulletBill.cpp
moving/MO_BulletBill.h
moving/MO_BuzzyBeetle.cpp
moving/MO_BuzzyBeetle.h
moving/MO_CarriedObject.cpp
Expand All @@ -65,6 +71,8 @@ target_sources(smw PRIVATE
moving/MO_Coin.h
moving/MO_CollectionCard.cpp
moving/MO_CollectionCard.h
moving/MO_Explosion.cpp
moving/MO_Explosion.h
moving/MO_Fireball.cpp
moving/MO_Fireball.h
moving/MO_FlagBase.cpp
Expand All @@ -79,6 +87,8 @@ target_sources(smw PRIVATE
moving/MO_IceBlast.h
moving/MO_Koopa.cpp
moving/MO_Koopa.h
moving/MO_PirhanaPlant.cpp
moving/MO_PirhanaPlant.h
moving/MO_Podobo.cpp
moving/MO_Podobo.h
moving/MO_SledgeBrother.cpp
Expand Down Expand Up @@ -108,6 +118,8 @@ target_sources(smw PRIVATE
overmap/WO_BowserFire.h
overmap/WO_KingOfTheHillZone.cpp
overmap/WO_KingOfTheHillZone.h
overmap/WO_OrbitHazard.cpp
overmap/WO_OrbitHazard.h
overmap/WO_Phanto.cpp
overmap/WO_Phanto.h
overmap/WO_PipeBonus.cpp
Expand All @@ -116,6 +128,8 @@ target_sources(smw PRIVATE
overmap/WO_PipeCoin.h
overmap/WO_RaceGoal.cpp
overmap/WO_RaceGoal.h
overmap/WO_StraightPathHazard.cpp
overmap/WO_StraightPathHazard.h
overmap/WO_Thwomp.cpp
overmap/WO_Thwomp.h

Expand Down
41 changes: 41 additions & 0 deletions src/smw/objects/IO_BulletBillCannon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "IO_BulletBillCannon.h"

#include "GameValues.h"
#include "ObjectContainer.h"
#include "RandomNumberGenerator.h"
#include "ResourceManager.h"
#include "objects/moving/MO_BulletBill.h"

extern CObjectContainer objectcontainer[3];
extern CResourceManager* rm;

//------------------------------------------------------------------------------
// class IO_BulletBillCannon - gets update calls and shoots bullet bills based on timer
//------------------------------------------------------------------------------

IO_BulletBillCannon::IO_BulletBillCannon(short x, short y, short freq, float vel, bool preview) :
CObject(NULL, x, y)
{
iFreq = freq;
dVel = vel;
fPreview = preview;

objectType = object_bulletbillcannon;

SetNewTimer();
}

void IO_BulletBillCannon::update()
{
if (--iTimer <= 0) {
SetNewTimer();

objectcontainer[1].add(new MO_BulletBill(&rm->spr_hazard_bulletbill[fPreview ? 1 : 0], &rm->spr_hazard_bulletbilldead, ix + (dVel < 0.0f ? 32 : -32), iy, dVel, 0, true));
ifSoundOnPlay(rm->sfx_bulletbillsound);
}
}

void IO_BulletBillCannon::SetNewTimer()
{
iTimer = iFreq + RANDOM_INT(iFreq);
}
28 changes: 28 additions & 0 deletions src/smw/objects/IO_BulletBillCannon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "object.h"


class IO_BulletBillCannon : public CObject
{
public:
IO_BulletBillCannon(short x, short y, short freq, float vel, bool preview);
~IO_BulletBillCannon() {}

void draw() {}
void update();

bool collide(CPlayer *) {
return false;
}
void collide(IO_MovingObject *) {}

private:
void SetNewTimer();

short iFreq, iTimer;
float dVel;
bool fPreview;
};


Loading

0 comments on commit c0d2352

Please sign in to comment.