Skip to content

Commit

Permalink
Simplified the world player class
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Oct 13, 2024
1 parent 8718191 commit 67dba19
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
2 changes: 0 additions & 2 deletions src/smw/ui/MI_World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ void MI_World::Init()
iAnimationFrame = 0;
iDrawFullRefresh = 0;

g_worldmap.InitPlayer();

iMapDrawOffsetCol = 0;
iMapDrawOffsetRow = 0;

Expand Down
16 changes: 5 additions & 11 deletions src/smw/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,12 @@ void WorldMovingObject::SetPosition(short iCol, short iRow)
* WorldPlayer
**********************************/

WorldPlayer::WorldPlayer() :
WorldMovingObject()
{}

WorldPlayer::~WorldPlayer()
WorldPlayer::WorldPlayer()
: WorldPlayer(0, 0)
{}

void WorldPlayer::Init(short iCol, short iRow)
WorldPlayer::WorldPlayer(short iCol, short iRow)
: WorldMovingObject()
{
WorldMovingObject::Init(iCol, iRow, 0, 0, 32);
}
Expand Down Expand Up @@ -553,6 +551,7 @@ bool WorldMap::Load(short tilesize)
if (tile.iType == 1) {
iStartX = iMapTileReadCol;
iStartY = iMapTileReadRow;
player.SetPosition(iStartX, iStartY);
}

tile.iCompleted = tile.iType <= 5 ? -1 : -2;
Expand Down Expand Up @@ -1057,11 +1056,6 @@ void WorldMap::Resize(short w, short h)
}
}

void WorldMap::InitPlayer()
{
player.Init(iStartX, iStartY);
}

bool WorldMap::Update(bool * fPlayerVehicleCollision)
{
bool fPlayMovingVehicleSound = false;
Expand Down
19 changes: 6 additions & 13 deletions src/smw/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class WorldMovingObject
void Init(short iCol, short iRow, short iSprite, short iInitialDirection, short tilesize);
virtual void Move(short iDirection);
virtual bool Update();
void Draw(short iWorldOffsetX, short iWorldOffsetY);
void FaceDirection(short iDirection);
void SetPosition(short iCol, short iRow);

Expand All @@ -75,19 +74,13 @@ class WorldMovingObject
friend void takescreenshot();
};

class WorldPlayer : public WorldMovingObject
{
public:

WorldPlayer();
~WorldPlayer();

void Init(short iCol, short iRow);

void SetSprite(short iPlayer);
void Draw(short iWorldOffsetX, short iWorldOffsetY) const;
class WorldPlayer : public WorldMovingObject {
public:
WorldPlayer();
WorldPlayer(short iCol, short iRow);

friend class WorldMap;
void SetSprite(short iPlayer);
void Draw(short iWorldOffsetX, short iWorldOffsetY) const;
};

class WorldVehicle : public WorldMovingObject
Expand Down

0 comments on commit 67dba19

Please sign in to comment.