Mario: formatting
Some checks reported errors
continuous-integration/drone/push Build is passing
continuous-integration/drone Build was killed

This commit is contained in:
zv0n 2021-10-18 10:10:43 +02:00
parent 303490a619
commit 0d855ed218
20 changed files with 541 additions and 490 deletions

View File

@ -2,7 +2,8 @@
#include "../sprites.hpp" #include "../sprites.hpp"
#include "../global_vars.hpp" #include "../global_vars.hpp"
CoinBlock::CoinBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) : MarioBlock(x, y, renderer, g_terrain_texture, COIN_SRC, true, true) { CoinBlock::CoinBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, COIN_SRC, true, true) {
setHidden(true); setHidden(true);
bounce_speed = 0.75; bounce_speed = 0.75;
bounce_ticks = 150; bounce_ticks = 150;

View File

@ -8,6 +8,7 @@ public:
CoinBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); CoinBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
void custom_move(int ticks) override; void custom_move(int ticks) override;
void setParent(MarioBlock *parent); void setParent(MarioBlock *parent);
private: private:
MarioBlock *_parent = nullptr; MarioBlock *_parent = nullptr;
}; };

View File

@ -8,8 +8,7 @@
class CoinEditorBlock : public MarioBlock { class CoinEditorBlock : public MarioBlock {
public: public:
CoinEditorBlock( int x, int y, CoinEditorBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> renderer);
std::shared_ptr< SDLPP::Renderer > renderer );
void render() override; void render() override;
void updateSizeAndPosition() override; void updateSizeAndPosition() override;
void addOne(); void addOne();

View File

@ -4,7 +4,10 @@
#include "../objectids.hpp" #include "../objectids.hpp"
#include "../visitors/goomba_visitor.hpp" #include "../visitors/goomba_visitor.hpp"
GoombaBlock::GoombaBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) : MarioBlock(x, y, renderer, g_enemies_texture, GOOMBA_WALK_ANIM[0], true, true) { GoombaBlock::GoombaBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_enemies_texture, GOOMBA_WALK_ANIM[0],
true, true) {
#ifndef EDITOR #ifndef EDITOR
setAnimationFrames(GOOMBA_WALK_ANIM); setAnimationFrames(GOOMBA_WALK_ANIM);
setAnimationSpeed(12.5); setAnimationSpeed(12.5);
@ -14,11 +17,11 @@ GoombaBlock::GoombaBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > &rend
auto bottom_detect = SDLPP::RectColider(0.2, 1, 0.6, 0, NPC_FLOOR_DETECT); auto bottom_detect = SDLPP::RectColider(0.2, 1, 0.6, 0, NPC_FLOOR_DETECT);
bottom_detect.setMinHeight(1); bottom_detect.setMinHeight(1);
addCollision(bottom_detect); addCollision(bottom_detect);
addCollision( addCollision(SDLPP::RectColider(0, 0.25, 0.1, 0.6, NPC_LEFT_SIDE_DETECT));
SDLPP::RectColider( 0, 0.25, 0.1, 0.6, NPC_LEFT_SIDE_DETECT ) );
addCollision( addCollision(
SDLPP::RectColider(0.9, 0.25, 0.1, 0.6, NPC_RIGHT_SIDE_DETECT)); SDLPP::RectColider(0.9, 0.25, 0.1, 0.6, NPC_RIGHT_SIDE_DETECT));
addCollision( std::make_shared<SDLPP::RectColider>( 0.5, 0, 0.2, 0.15, NPC_TOP_DETECT ) ); addCollision(std::make_shared<SDLPP::RectColider>(0.5, 0, 0.2, 0.15,
NPC_TOP_DETECT));
#ifndef EDITOR #ifndef EDITOR
setMovement(-0.19, 0); setMovement(-0.19, 0);
#endif #endif

View File

@ -9,6 +9,7 @@ public:
void custom_move(int ticks) override; void custom_move(int ticks) override;
void move(int ticks) override; void move(int ticks) override;
void handleVisitor(SDLPP::Visitor &visitor) override; void handleVisitor(SDLPP::Visitor &visitor) override;
private: private:
void startDeath(); void startDeath();
int death_countdown = 100; int death_countdown = 100;

View File

@ -4,7 +4,10 @@
#include "../objectids.hpp" #include "../objectids.hpp"
#include "../visitors/mushroom_visitor.hpp" #include "../visitors/mushroom_visitor.hpp"
MushroomBlock::MushroomBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) : MarioBlock(x, y, renderer, g_terrain_texture, MUSHROOM_SRC, true, true) { MushroomBlock::MushroomBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, MUSHROOM_SRC, true,
true) {
setHidden(true); setHidden(true);
ensureCollision(); ensureCollision();
setId(MUSHROOM_ID); setId(MUSHROOM_ID);
@ -13,8 +16,7 @@ MushroomBlock::MushroomBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > &
bottom_detect.setOutlineColor("#FF0000"); bottom_detect.setOutlineColor("#FF0000");
bottom_detect.setMinHeight(1); bottom_detect.setMinHeight(1);
addCollision(bottom_detect); addCollision(bottom_detect);
addCollision( addCollision(SDLPP::RectColider(0, 0.25, 0.1, 0.6, NPC_LEFT_SIDE_DETECT));
SDLPP::RectColider( 0, 0.25, 0.1, 0.6, NPC_LEFT_SIDE_DETECT ) );
addCollision( addCollision(
SDLPP::RectColider(0.9, 0.25, 0.1, 0.6, NPC_RIGHT_SIDE_DETECT)); SDLPP::RectColider(0.9, 0.25, 0.1, 0.6, NPC_RIGHT_SIDE_DETECT));
} }

View File

@ -9,6 +9,7 @@ public:
void custom_move(int ticks) override; void custom_move(int ticks) override;
void setParent(MarioBlock *parent); void setParent(MarioBlock *parent);
void handleVisitor(SDLPP::Visitor &visitor) override; void handleVisitor(SDLPP::Visitor &visitor) override;
private: private:
MarioBlock *_parent = nullptr; MarioBlock *_parent = nullptr;
bool _started_movement = false; bool _started_movement = false;

View File

@ -3,22 +3,21 @@
#include "../sprites.hpp" #include "../sprites.hpp"
#include "../objectids.hpp" #include "../objectids.hpp"
FloorBlock::FloorBlock( int x, int y, FloorBlock::FloorBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer)
std::shared_ptr< SDLPP::Renderer > &renderer )
: MarioBlock(x, y, renderer, g_terrain_texture, FLOOR_SRC, true) { : MarioBlock(x, y, renderer, g_terrain_texture, FLOOR_SRC, true) {
ensureCollision(); ensureCollision();
setId(FLOOR_ID); setId(FLOOR_ID);
} }
HillInclineBlock::HillInclineBlock( HillInclineBlock::HillInclineBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, HILL_INCLINE_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, HILL_INCLINE_SRC,
false) { false) {
setId(HILL_INCLINE_ID); setId(HILL_INCLINE_ID);
} }
HillDeclineBlock::HillDeclineBlock( HillDeclineBlock::HillDeclineBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, HILL_DECLINE_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, HILL_DECLINE_SRC,
false) { false) {
setId(HILL_INCLINE_ID); setId(HILL_INCLINE_ID);
@ -31,8 +30,8 @@ HillDotsRightBlock::HillDotsRightBlock(
setId(HILL_DOTS_RIGHT_ID); setId(HILL_DOTS_RIGHT_ID);
} }
HillDotsLeftBlock::HillDotsLeftBlock( HillDotsLeftBlock::HillDotsLeftBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, HILL_DOTS_LEFT_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, HILL_DOTS_LEFT_SRC,
false) { false) {
setId(HILL_DOTS_LEFT_ID); setId(HILL_DOTS_LEFT_ID);
@ -40,8 +39,7 @@ HillDotsLeftBlock::HillDotsLeftBlock(
HillFillBlock::HillFillBlock(int x, int y, HillFillBlock::HillFillBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock( x, y, renderer, g_terrain_texture, HILL_FILL_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, HILL_FILL_SRC, false) {
false ) {
setId(HILL_FILL_ID); setId(HILL_FILL_ID);
} }
@ -53,8 +51,7 @@ HillTopBlock::HillTopBlock( int x, int y,
BushLeftBlock::BushLeftBlock(int x, int y, BushLeftBlock::BushLeftBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock( x, y, renderer, g_terrain_texture, BUSH_LEFT_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, BUSH_LEFT_SRC, false) {
false ) {
setId(BUSH_LEFT_ID); setId(BUSH_LEFT_ID);
} }
@ -67,8 +64,7 @@ BushMiddleBlock::BushMiddleBlock( int x, int y,
BushRightBlock::BushRightBlock(int x, int y, BushRightBlock::BushRightBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock( x, y, renderer, g_terrain_texture, BUSH_RIGHT_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, BUSH_RIGHT_SRC, false) {
false ) {
setId(BUSH_RIGHT_ID); setId(BUSH_RIGHT_ID);
} }
@ -81,8 +77,8 @@ CloudLeftBottomBlock::CloudLeftBottomBlock(
CloudMiddleBottomBlock::CloudMiddleBottomBlock( CloudMiddleBottomBlock::CloudMiddleBottomBlock(
int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer) int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock( x, y, renderer, g_terrain_texture, : MarioBlock(x, y, renderer, g_terrain_texture, CLOUD_MIDDLE_BOTTOM_SRC,
CLOUD_MIDDLE_BOTTOM_SRC, false ) { false) {
setId(CLOUD_MIDDLE_BOTTOM_ID); setId(CLOUD_MIDDLE_BOTTOM_ID);
} }
@ -93,8 +89,8 @@ CloudRightBottomBlock::CloudRightBottomBlock(
setId(CLOUD_RIGHT_BOTTOM_ID); setId(CLOUD_RIGHT_BOTTOM_ID);
} }
CloudLeftTopBlock::CloudLeftTopBlock( CloudLeftTopBlock::CloudLeftTopBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, CLOUD_LEFT_TOP_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, CLOUD_LEFT_TOP_SRC,
false) { false) {
setId(CLOUD_LEFT_TOP_ID); setId(CLOUD_LEFT_TOP_ID);
@ -130,16 +126,16 @@ PipeRightBottomBlock::PipeRightBottomBlock(
setId(PIPE_RIGHT_BOTTOM_ID); setId(PIPE_RIGHT_BOTTOM_ID);
} }
PipeLeftTopBlock::PipeLeftTopBlock( PipeLeftTopBlock::PipeLeftTopBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, PIPE_LEFT_TOP_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, PIPE_LEFT_TOP_SRC,
false) { false) {
ensureCollision(); ensureCollision();
setId(PIPE_LEFT_TOP_ID); setId(PIPE_LEFT_TOP_ID);
} }
PipeRightTopBlock::PipeRightTopBlock( PipeRightTopBlock::PipeRightTopBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, PIPE_RIGHT_TOP_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, PIPE_RIGHT_TOP_SRC,
false) { false) {
ensureCollision(); ensureCollision();
@ -153,29 +149,29 @@ CastleLeftBlock::CastleLeftBlock( int x, int y,
setId(CASTLE_LEFT_ID); setId(CASTLE_LEFT_ID);
} }
CastleRightBlock::CastleRightBlock( CastleRightBlock::CastleRightBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, CASTLE_RIGHT_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, CASTLE_RIGHT_SRC,
false) { false) {
setId(CASTLE_RIGHT_ID); setId(CASTLE_RIGHT_ID);
} }
CastleBlackBlock::CastleBlackBlock( CastleBlackBlock::CastleBlackBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, CASTLE_BLACK_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, CASTLE_BLACK_SRC,
false) { false) {
setId(CASTLE_BLACK_ID); setId(CASTLE_BLACK_ID);
} }
CastleEntryBlock::CastleEntryBlock( CastleEntryBlock::CastleEntryBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, CASTLE_ENTRY_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, CASTLE_ENTRY_SRC,
false) { false) {
setId(CASTLE_ENTRY_ID); setId(CASTLE_ENTRY_ID);
} }
CastleTowerBlock::CastleTowerBlock( CastleTowerBlock::CastleTowerBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, CASTLE_TOWER_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, CASTLE_TOWER_SRC,
false) { false) {
setId(CASTLE_TOWER_ID); setId(CASTLE_TOWER_ID);
@ -183,8 +179,8 @@ CastleTowerBlock::CastleTowerBlock(
CastleTowerFilledBlock::CastleTowerFilledBlock( CastleTowerFilledBlock::CastleTowerFilledBlock(
int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer) int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock( x, y, renderer, g_terrain_texture, : MarioBlock(x, y, renderer, g_terrain_texture, CASTLE_TOWER_FILLED_SRC,
CASTLE_TOWER_FILLED_SRC, false ) { false) {
setId(CASTLE_TOWER_FILLED_ID); setId(CASTLE_TOWER_FILLED_ID);
} }
@ -218,21 +214,18 @@ PoleBottomBlock::PoleBottomBlock( int x, int y,
setId(POLE_BOTTOM_ID); setId(POLE_BOTTOM_ID);
} }
FlagBlock::FlagBlock( int x, int y, FlagBlock::FlagBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer)
std::shared_ptr< SDLPP::Renderer > &renderer )
: MarioBlock(x, y, renderer, g_terrain_texture, FLAG_SRC, false) { : MarioBlock(x, y, renderer, g_terrain_texture, FLAG_SRC, false) {
setId(FLAG_ID); setId(FLAG_ID);
} }
StepBlock::StepBlock( int x, int y, StepBlock::StepBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer)
std::shared_ptr< SDLPP::Renderer > &renderer )
: MarioBlock(x, y, renderer, g_terrain_texture, STEP_SRC, true) { : MarioBlock(x, y, renderer, g_terrain_texture, STEP_SRC, true) {
ensureCollision(); ensureCollision();
setId(STEP_ID); setId(STEP_ID);
} }
BrickBlock::BrickBlock( int x, int y, BrickBlock::BrickBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer)
std::shared_ptr< SDLPP::Renderer > &renderer )
: MarioBlock(x, y, renderer, g_terrain_texture, BRICK_SRC, true) { : MarioBlock(x, y, renderer, g_terrain_texture, BRICK_SRC, true) {
ensureCollision(); ensureCollision();
setId(BRICK_ID); setId(BRICK_ID);
@ -327,16 +320,14 @@ TreePlatformBarkBlock::TreePlatformBarkBlock(
WaterTopBlock::WaterTopBlock(int x, int y, WaterTopBlock::WaterTopBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock( x, y, renderer, g_terrain_texture, WATER_TOP_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, WATER_TOP_SRC, false) {
false ) {
ensureCollision(); ensureCollision();
setId(WATER_TOP_ID); setId(WATER_TOP_ID);
} }
WaterFillBlock::WaterFillBlock(int x, int y, WaterFillBlock::WaterFillBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock( x, y, renderer, g_terrain_texture, WATER_FILL_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, WATER_FILL_SRC, false) {
false ) {
ensureCollision(); ensureCollision();
setId(WATER_FILL_ID); setId(WATER_FILL_ID);
} }
@ -383,8 +374,7 @@ MushroomPlatformBarkBottomBlock::MushroomPlatformBarkBottomBlock(
TreeBarkBlock::TreeBarkBlock(int x, int y, TreeBarkBlock::TreeBarkBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock( x, y, renderer, g_terrain_texture, TREE_BARK_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, TREE_BARK_SRC, false) {
false ) {
ensureCollision(); ensureCollision();
setId(TREE_BARK_ID); setId(TREE_BARK_ID);
} }
@ -413,8 +403,8 @@ TreeLeavesBottomBlock::TreeLeavesBottomBlock(
setId(TREE_LEAVES_BOTTOM_ID); setId(TREE_LEAVES_BOTTOM_ID);
} }
CannonTowerBlock::CannonTowerBlock( CannonTowerBlock::CannonTowerBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ) std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, CANNON_TOWER_SRC, : MarioBlock(x, y, renderer, g_terrain_texture, CANNON_TOWER_SRC,
false) { false) {
ensureCollision(); ensureCollision();
@ -442,12 +432,13 @@ DestructibleModifierBlock::DestructibleModifierBlock(
false) { false) {
setId(DESTRUCTIBLE_MODIFIER_ID); setId(DESTRUCTIBLE_MODIFIER_ID);
} }
BackgroundModifierBlock::BackgroundModifierBlock( BackgroundModifierBlock::BackgroundModifierBlock(
int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer) int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock( x, y, renderer, g_mod_texture, MOD_BACKGROUND_SRC, : MarioBlock(x, y, renderer, g_mod_texture, MOD_BACKGROUND_SRC, false) {
false ) {
setId(BACKGROUND_MODIFIER_ID); setId(BACKGROUND_MODIFIER_ID);
} }
MushroomModifierBlock::MushroomModifierBlock( MushroomModifierBlock::MushroomModifierBlock(
int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer) int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_mod_texture, MOD_MUSHROOM_SRC, false) { : MarioBlock(x, y, renderer, g_mod_texture, MOD_MUSHROOM_SRC, false) {

View File

@ -7,275 +7,315 @@ class FloorBlock : public MarioBlock {
public: public:
FloorBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); FloorBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class HillInclineBlock : public MarioBlock { class HillInclineBlock : public MarioBlock {
public: public:
HillInclineBlock( int x, int y, HillInclineBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class HillDeclineBlock : public MarioBlock { class HillDeclineBlock : public MarioBlock {
public: public:
HillDeclineBlock( int x, int y, HillDeclineBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class HillDotsRightBlock : public MarioBlock { class HillDotsRightBlock : public MarioBlock {
public: public:
HillDotsRightBlock(int x, int y, HillDotsRightBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class HillDotsLeftBlock : public MarioBlock { class HillDotsLeftBlock : public MarioBlock {
public: public:
HillDotsLeftBlock( int x, int y, HillDotsLeftBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class HillFillBlock : public MarioBlock { class HillFillBlock : public MarioBlock {
public: public:
HillFillBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); HillFillBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class HillTopBlock : public MarioBlock { class HillTopBlock : public MarioBlock {
public: public:
HillTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); HillTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class BushLeftBlock : public MarioBlock { class BushLeftBlock : public MarioBlock {
public: public:
BushLeftBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); BushLeftBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class BushMiddleBlock : public MarioBlock { class BushMiddleBlock : public MarioBlock {
public: public:
BushMiddleBlock( int x, int y, BushMiddleBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class BushRightBlock : public MarioBlock { class BushRightBlock : public MarioBlock {
public: public:
BushRightBlock( int x, int y, BushRightBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class CloudLeftBottomBlock : public MarioBlock { class CloudLeftBottomBlock : public MarioBlock {
public: public:
CloudLeftBottomBlock(int x, int y, CloudLeftBottomBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class CloudMiddleBottomBlock : public MarioBlock { class CloudMiddleBottomBlock : public MarioBlock {
public: public:
CloudMiddleBottomBlock(int x, int y, CloudMiddleBottomBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class CloudRightBottomBlock : public MarioBlock { class CloudRightBottomBlock : public MarioBlock {
public: public:
CloudRightBottomBlock(int x, int y, CloudRightBottomBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class CloudLeftTopBlock : public MarioBlock { class CloudLeftTopBlock : public MarioBlock {
public: public:
CloudLeftTopBlock( int x, int y, CloudLeftTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class CloudMiddleTopBlock : public MarioBlock { class CloudMiddleTopBlock : public MarioBlock {
public: public:
CloudMiddleTopBlock(int x, int y, CloudMiddleTopBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class CloudRightTopBlock : public MarioBlock { class CloudRightTopBlock : public MarioBlock {
public: public:
CloudRightTopBlock(int x, int y, CloudRightTopBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class PipeLeftBottomBlock : public MarioBlock { class PipeLeftBottomBlock : public MarioBlock {
public: public:
PipeLeftBottomBlock(int x, int y, PipeLeftBottomBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class PipeRightBottomBlock : public MarioBlock { class PipeRightBottomBlock : public MarioBlock {
public: public:
PipeRightBottomBlock(int x, int y, PipeRightBottomBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class PipeLeftTopBlock : public MarioBlock { class PipeLeftTopBlock : public MarioBlock {
public: public:
PipeLeftTopBlock( int x, int y, PipeLeftTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class PipeRightTopBlock : public MarioBlock { class PipeRightTopBlock : public MarioBlock {
public: public:
PipeRightTopBlock( int x, int y, PipeRightTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class CastleLeftBlock : public MarioBlock { class CastleLeftBlock : public MarioBlock {
public: public:
CastleLeftBlock( int x, int y, CastleLeftBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class CastleRightBlock : public MarioBlock { class CastleRightBlock : public MarioBlock {
public: public:
CastleRightBlock( int x, int y, CastleRightBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class CastleBlackBlock : public MarioBlock { class CastleBlackBlock : public MarioBlock {
public: public:
CastleBlackBlock( int x, int y, CastleBlackBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class CastleEntryBlock : public MarioBlock { class CastleEntryBlock : public MarioBlock {
public: public:
CastleEntryBlock( int x, int y, CastleEntryBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class CastleTowerBlock : public MarioBlock { class CastleTowerBlock : public MarioBlock {
public: public:
CastleTowerBlock( int x, int y, CastleTowerBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class CastleTowerFilledBlock : public MarioBlock { class CastleTowerFilledBlock : public MarioBlock {
public: public:
CastleTowerFilledBlock(int x, int y, CastleTowerFilledBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class VineTopBlock : public MarioBlock { class VineTopBlock : public MarioBlock {
public: public:
VineTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); VineTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class VineBottomBlock : public MarioBlock { class VineBottomBlock : public MarioBlock {
public: public:
VineBottomBlock( int x, int y, VineBottomBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class PoleTopBlock : public MarioBlock { class PoleTopBlock : public MarioBlock {
public: public:
PoleTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); PoleTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class PoleBottomBlock : public MarioBlock { class PoleBottomBlock : public MarioBlock {
public: public:
PoleBottomBlock( int x, int y, PoleBottomBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class FlagBlock : public MarioBlock { class FlagBlock : public MarioBlock {
public: public:
FlagBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); FlagBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class StepBlock : public MarioBlock { class StepBlock : public MarioBlock {
public: public:
StepBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); StepBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class BrickBlock : public MarioBlock { class BrickBlock : public MarioBlock {
public: public:
BrickBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); BrickBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class BrickTopBlock : public MarioBlock { class BrickTopBlock : public MarioBlock {
public: public:
BrickTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); BrickTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class SidewayPipeEndTopBlock : public MarioBlock { class SidewayPipeEndTopBlock : public MarioBlock {
public: public:
SidewayPipeEndTopBlock(int x, int y, SidewayPipeEndTopBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class SidewayPipeEndBottomBlock : public MarioBlock { class SidewayPipeEndBottomBlock : public MarioBlock {
public: public:
SidewayPipeEndBottomBlock(int x, int y, SidewayPipeEndBottomBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class SidewayPipeMiddleTopBlock : public MarioBlock { class SidewayPipeMiddleTopBlock : public MarioBlock {
public: public:
SidewayPipeMiddleTopBlock(int x, int y, SidewayPipeMiddleTopBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class SidewayPipeMiddleBottomBlock : public MarioBlock { class SidewayPipeMiddleBottomBlock : public MarioBlock {
public: public:
SidewayPipeMiddleBottomBlock( SidewayPipeMiddleBottomBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class SidewayPipeConnectorTopBlock : public MarioBlock { class SidewayPipeConnectorTopBlock : public MarioBlock {
public: public:
SidewayPipeConnectorTopBlock( SidewayPipeConnectorTopBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class SidewayPipeConnectorBottomBlock : public MarioBlock { class SidewayPipeConnectorBottomBlock : public MarioBlock {
public: public:
SidewayPipeConnectorBottomBlock( SidewayPipeConnectorBottomBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class TreePlatformTopLeftBlock : public MarioBlock { class TreePlatformTopLeftBlock : public MarioBlock {
public: public:
TreePlatformTopLeftBlock(int x, int y, TreePlatformTopLeftBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class TreePlatformTopMiddleBlock : public MarioBlock { class TreePlatformTopMiddleBlock : public MarioBlock {
public: public:
TreePlatformTopMiddleBlock(int x, int y, TreePlatformTopMiddleBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class TreePlatformTopRightBlock : public MarioBlock { class TreePlatformTopRightBlock : public MarioBlock {
public: public:
TreePlatformTopRightBlock(int x, int y, TreePlatformTopRightBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class TreePlatformBarkBlock : public MarioBlock { class TreePlatformBarkBlock : public MarioBlock {
public: public:
TreePlatformBarkBlock(int x, int y, TreePlatformBarkBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class WaterTopBlock : public MarioBlock { class WaterTopBlock : public MarioBlock {
public: public:
WaterTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); WaterTopBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class WaterFillBlock : public MarioBlock { class WaterFillBlock : public MarioBlock {
public: public:
WaterFillBlock( int x, int y, WaterFillBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class MushroomPlatformTopLeftBlock : public MarioBlock { class MushroomPlatformTopLeftBlock : public MarioBlock {
public: public:
MushroomPlatformTopLeftBlock( MushroomPlatformTopLeftBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class MushroomPlatformTopMiddleBlock : public MarioBlock { class MushroomPlatformTopMiddleBlock : public MarioBlock {
public: public:
MushroomPlatformTopMiddleBlock( MushroomPlatformTopMiddleBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class MushroomPlatformTopRightBlock : public MarioBlock { class MushroomPlatformTopRightBlock : public MarioBlock {
public: public:
MushroomPlatformTopRightBlock( MushroomPlatformTopRightBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class MushroomPlatformBarkTopBlock : public MarioBlock { class MushroomPlatformBarkTopBlock : public MarioBlock {
public: public:
MushroomPlatformBarkTopBlock( MushroomPlatformBarkTopBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class MushroomPlatformBarkBottomBlock : public MarioBlock { class MushroomPlatformBarkBottomBlock : public MarioBlock {
public: public:
MushroomPlatformBarkBottomBlock( MushroomPlatformBarkBottomBlock(int x, int y,
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer ); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class TreeBarkBlock : public MarioBlock { class TreeBarkBlock : public MarioBlock {
public: public:
TreeBarkBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); TreeBarkBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class TreeLeavesSmallBlock : public MarioBlock { class TreeLeavesSmallBlock : public MarioBlock {
public: public:
TreeLeavesSmallBlock(int x, int y, TreeLeavesSmallBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class TreeLeavesTopBlock : public MarioBlock { class TreeLeavesTopBlock : public MarioBlock {
public: public:
TreeLeavesTopBlock(int x, int y, TreeLeavesTopBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class TreeLeavesBottomBlock : public MarioBlock { class TreeLeavesBottomBlock : public MarioBlock {
public: public:
TreeLeavesBottomBlock(int x, int y, TreeLeavesBottomBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class CannonTowerBlock : public MarioBlock { class CannonTowerBlock : public MarioBlock {
public: public:
CannonTowerBlock( int x, int y, CannonTowerBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
std::shared_ptr< SDLPP::Renderer > &renderer );
}; };
class CannonPedestalBlock : public MarioBlock { class CannonPedestalBlock : public MarioBlock {
public: public:
CannonPedestalBlock(int x, int y, CannonPedestalBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class CannonBlock : public MarioBlock { class CannonBlock : public MarioBlock {
public: public:
CannonBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer); CannonBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer);
@ -287,11 +327,13 @@ public:
DestructibleModifierBlock(int x, int y, DestructibleModifierBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class BackgroundModifierBlock : public MarioBlock { class BackgroundModifierBlock : public MarioBlock {
public: public:
BackgroundModifierBlock(int x, int y, BackgroundModifierBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer); std::shared_ptr<SDLPP::Renderer> &renderer);
}; };
class MushroomModifierBlock : public MarioBlock { class MushroomModifierBlock : public MarioBlock {
public: public:
MushroomModifierBlock(int x, int y, MushroomModifierBlock(int x, int y,

View File

@ -43,7 +43,8 @@ void MarioVisitor::visit( const SDLPP::RenderObject &obj ) {
right = true; right = true;
} else if (from == MARIO_TOP_DETECT) { } else if (from == MARIO_TOP_DETECT) {
top_hit = true; top_hit = true;
} else if (from == MARIO_TOP_LEFT_DETECT || from == MARIO_TOP_RIGHT_DETECT) { } else if (from == MARIO_TOP_LEFT_DETECT ||
from == MARIO_TOP_RIGHT_DETECT) {
rightleftpos = obj.getPos(); rightleftpos = obj.getPos();
top_left_right = true; top_left_right = true;
} }

View File

@ -8,7 +8,11 @@
class MarioVisitor : public SDLPP::Visitor { class MarioVisitor : public SDLPP::Visitor {
public: public:
MarioVisitor(bool is_jumping, SDLPP::Scene &scene, bool &quit, int &coin_count, std::vector< std::shared_ptr< MarioBlock > > &moving_objects) : jumping(is_jumping), _scene(scene), _quit(quit), _coin_count(coin_count), _moving_objects(moving_objects) {} MarioVisitor(bool is_jumping, SDLPP::Scene &scene, bool &quit,
int &coin_count,
std::vector<std::shared_ptr<MarioBlock>> &moving_objects)
: jumping(is_jumping), _scene(scene), _quit(quit),
_coin_count(coin_count), _moving_objects(moving_objects) {}
void visit(const SDLPP::RenderObject &obj) override; void visit(const SDLPP::RenderObject &obj) override;
bool isOnGround() const { bool isOnGround() const {
return onGround; return onGround;

View File

@ -11,13 +11,18 @@ getVisitor( const MarioBlock &block, SDLPP::Scene &scene, bool &quit,
std::shared_ptr<SDLPP::Visitor> result{}; std::shared_ptr<SDLPP::Visitor> result{};
switch (block.getId()) { switch (block.getId()) {
case MARIO_ID: case MARIO_ID:
result = std::static_pointer_cast<SDLPP::Visitor>(std::make_shared<MarioVisitor>(block.getMovement().getY() < 0, scene, quit, coin_count, moving_objects)); result = std::static_pointer_cast<SDLPP::Visitor>(
std::make_shared<MarioVisitor>(block.getMovement().getY() < 0,
scene, quit, coin_count,
moving_objects));
break; break;
case MUSHROOM_ID: case MUSHROOM_ID:
result = std::static_pointer_cast<SDLPP::Visitor>(std::make_shared<MushroomVisitor>()); result = std::static_pointer_cast<SDLPP::Visitor>(
std::make_shared<MushroomVisitor>());
break; break;
case GOOMBA_ID: case GOOMBA_ID:
result = std::static_pointer_cast<SDLPP::Visitor>(std::make_shared<GoombaVisitor>()); result = std::static_pointer_cast<SDLPP::Visitor>(
std::make_shared<GoombaVisitor>());
break; break;
default: default:
break; break;