Mario: prepartations for multiple moving objects
This commit is contained in:
parent
37f7bab63e
commit
bfe658618e
@ -22,7 +22,7 @@ COMMON_OBJECTS = global_vars.${OBJEXT} sprites.${OBJEXT} maploader.${OBJEXT} map
|
||||
ifneq ($(UNAME_S),Windows)
|
||||
COMMON_OBJECTS += libsdlpp.a
|
||||
endif
|
||||
MARIO_OBJECTS = main.${OBJEXT} blocks.${OBJEXT} mario_visitor.${OBJEXT} ${COMMON_OBJECTS}
|
||||
MARIO_OBJECTS = main.${OBJEXT} blocks.${OBJEXT} mario_visitor.${OBJEXT} bounce_visitor.${OBJEXT} visitor_generator.${OBJEXT} ${COMMON_OBJECTS}
|
||||
EDITOR_OBJECTS = editor.${OBJEXT} editor_blocks.${OBJEXT} edit_box.${OBJEXT} tool_box.${OBJEXT} editor_visitor.${OBJEXT} ${COMMON_OBJECTS}
|
||||
|
||||
ifeq ($(UNAME_S),Windows)
|
||||
@ -59,7 +59,11 @@ sprites.${OBJEXT}: sprites.cpp ../sdlpp/sdlpp.hpp sprites.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
maploader.${OBJEXT}: maploader.cpp ../sdlpp/sdlpp.hpp maploader.hpp sprites.hpp blocks.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
mario_visitor.${OBJEXT}: mario_visitor.cpp ../sdlpp/sdlpp.hpp mario_visitor.hpp objectids.hpp
|
||||
mario_visitor.${OBJEXT}: visitors/mario_visitor.cpp ../sdlpp/sdlpp.hpp visitors/mario_visitor.hpp objectids.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
bounce_visitor.${OBJEXT}: visitors/bounce_visitor.cpp ../sdlpp/sdlpp.hpp visitors/bounce_visitor.hpp objectids.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
visitor_generator.${OBJEXT}: visitors/visitor_generator.cpp ../sdlpp/sdlpp.hpp visitors/visitor_generator.hpp objectids.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
editor.${OBJEXT}: editor.cpp ../sdlpp/sdlpp.hpp sprites.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
|
@ -5,7 +5,8 @@
|
||||
#include "editor_visitor.hpp"
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include "mario_visitor.hpp"
|
||||
#include "visitors/mario_visitor.hpp"
|
||||
#include "visitors/bounce_visitor.hpp"
|
||||
#include "blocks/simpleblocks.hpp"
|
||||
#include "blocks/coineditorblock.hpp"
|
||||
#include "blocks/coinblock.hpp"
|
||||
@ -49,7 +50,7 @@ void MarioBlock::visit( SDLPP::Visitor &visitor ) {
|
||||
|
||||
setPos( getPos() - SDLPP::Vec2D< double >( 0, BLOCK_SIZE ) );
|
||||
if ( getCollisions().size() < 2 )
|
||||
addCollision( SDLPP::RectColider( 0.1, 0.1, 0.8, 0.8, 69 ) );
|
||||
addCollision( SDLPP::RectColider( 0.1, 0.1, 0.8, 0.8, BOUNCE_COLLISION ) );
|
||||
updateSizeAndPosition();
|
||||
g_playground->visitCollisions( *this, bv );
|
||||
setPos( getPos() + SDLPP::Vec2D< double >( 0, BLOCK_SIZE ) );
|
||||
@ -494,18 +495,22 @@ createBlockById( uint64_t id, int x, int y,
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< BackgroundModifierBlock >( x, y, renderer ) );
|
||||
break;
|
||||
#ifdef EDITOR
|
||||
case COIN_MODIFIER_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CoinEditorBlock >( x, y, renderer ) );
|
||||
break;
|
||||
#endif
|
||||
case MUSHROOM_MODIFIER_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< MushroomModifierBlock >( x, y, renderer ) );
|
||||
break;
|
||||
#ifndef EDITOR
|
||||
case COIN_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CoinBlock >( x, y, renderer ) );
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
void setTool( bool tool = true );
|
||||
void setTerrain( bool terrain = true );
|
||||
void bounce();
|
||||
virtual void custom_move( int ticks ) override;
|
||||
void custom_move( int ticks ) override;
|
||||
void setType( LandType::Value type );
|
||||
LandType::Value getType() const;
|
||||
virtual void onScrollUp() {}
|
||||
@ -27,6 +27,8 @@ public:
|
||||
return 0;
|
||||
}
|
||||
virtual void setData( uint8_t /*UNUSED*/ ) {}
|
||||
// handle own visitor
|
||||
virtual void handleVisitor(SDLPP::Visitor &visitor) {}
|
||||
bool hasCoin();
|
||||
bool hasMushroom();
|
||||
void removeCoin();
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "../sprites.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);
|
||||
bounce_speed = 0.75;
|
||||
bounce_ticks = 150;
|
||||
|
@ -5,11 +5,11 @@
|
||||
|
||||
class CoinBlock : public MarioBlock {
|
||||
public:
|
||||
CoinBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
virtual void custom_move(int ticks) override;
|
||||
CoinBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
void custom_move(int ticks) override;
|
||||
void setParent(MarioBlock *parent);
|
||||
private:
|
||||
MarioBlock *_parent;
|
||||
MarioBlock *_parent = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,7 +7,7 @@ CoinEditorBlock::CoinEditorBlock( int x, int y,
|
||||
false, false ) {
|
||||
setId( COIN_MODIFIER_ID );
|
||||
auto mypos = getDoubleRect();
|
||||
auto size = mypos.second.getX() / 1.5;
|
||||
auto size = mypos.second.getX() / size_divisor;
|
||||
_amount_text = std::make_shared< SDLPP::TextRenderer >(
|
||||
mypos.first.getX() + mypos.second.getX() - size,
|
||||
mypos.first.getY() + mypos.second.getX() - size, size, size, renderer,
|
||||
@ -18,7 +18,7 @@ CoinEditorBlock::CoinEditorBlock( int x, int y,
|
||||
|
||||
void CoinEditorBlock::render() {
|
||||
MarioBlock::render();
|
||||
if ( _amount_text != NULL && !hidden ) {
|
||||
if ( _amount_text != nullptr && !hidden ) {
|
||||
_amount_text->render();
|
||||
}
|
||||
}
|
||||
@ -26,12 +26,12 @@ void CoinEditorBlock::render() {
|
||||
void CoinEditorBlock::updateSizeAndPosition() {
|
||||
MarioBlock::updateSizeAndPosition();
|
||||
auto block_size = getDoubleRect().second;
|
||||
_amount_text->setPos( getPos() + block_size - block_size / 1.5 );
|
||||
_amount_text->setPos( getPos() + block_size - block_size / size_divisor );
|
||||
_amount_text->updateSizeAndPosition();
|
||||
}
|
||||
|
||||
void CoinEditorBlock::addOne() {
|
||||
if ( _amount < 15 ) {
|
||||
if ( _amount < max_amount ) {
|
||||
_amount++;
|
||||
updateText();
|
||||
}
|
||||
@ -47,8 +47,8 @@ void CoinEditorBlock::subtractOne() {
|
||||
void CoinEditorBlock::setAmount( int amount ) {
|
||||
if ( amount < 1 ) {
|
||||
amount = 1;
|
||||
} else if ( amount > 15 ) {
|
||||
amount = 15;
|
||||
} else if ( amount > max_amount ) {
|
||||
amount = max_amount;
|
||||
}
|
||||
_amount = amount;
|
||||
updateText();
|
||||
|
@ -10,20 +10,22 @@ class CoinEditorBlock : public MarioBlock {
|
||||
public:
|
||||
CoinEditorBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
virtual void render() override;
|
||||
virtual void updateSizeAndPosition() override;
|
||||
void render() override;
|
||||
void updateSizeAndPosition() override;
|
||||
void addOne();
|
||||
void subtractOne();
|
||||
void setAmount( int amount );
|
||||
virtual void onScrollUp() override;
|
||||
virtual void onScrollDown() override;
|
||||
virtual uint8_t getData() override;
|
||||
virtual void setData( uint8_t data ) override;
|
||||
void onScrollUp() override;
|
||||
void onScrollDown() override;
|
||||
uint8_t getData() override;
|
||||
void setData( uint8_t data ) override;
|
||||
|
||||
private:
|
||||
void updateText();
|
||||
int _amount = 1;
|
||||
std::shared_ptr< SDLPP::TextRenderer > _amount_text;
|
||||
constexpr static double size_divisor = 1.5;
|
||||
constexpr static uint8_t max_amount = 15;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -4,118 +4,118 @@
|
||||
#include "../objectids.hpp"
|
||||
|
||||
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 ) {
|
||||
ensureCollision();
|
||||
setId( FLOOR_ID );
|
||||
}
|
||||
|
||||
HillInclineBlock::HillInclineBlock(
|
||||
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, HILL_INCLINE_SRC,
|
||||
false ) {
|
||||
setId( HILL_INCLINE_ID );
|
||||
}
|
||||
|
||||
HillDeclineBlock::HillDeclineBlock(
|
||||
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, HILL_DECLINE_SRC,
|
||||
false ) {
|
||||
setId( HILL_INCLINE_ID );
|
||||
}
|
||||
|
||||
HillDotsRightBlock::HillDotsRightBlock(
|
||||
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, HILL_DOTS_RIGHT_SRC,
|
||||
false ) {
|
||||
setId( HILL_DOTS_RIGHT_ID );
|
||||
}
|
||||
|
||||
HillDotsLeftBlock::HillDotsLeftBlock(
|
||||
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, HILL_DOTS_LEFT_SRC,
|
||||
false ) {
|
||||
setId( HILL_DOTS_LEFT_ID );
|
||||
}
|
||||
|
||||
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,
|
||||
false ) {
|
||||
setId( HILL_FILL_ID );
|
||||
}
|
||||
|
||||
HillTopBlock::HillTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, HILL_TOP_SRC, false ) {
|
||||
setId( HILL_TOP_ID );
|
||||
}
|
||||
|
||||
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,
|
||||
false ) {
|
||||
setId( BUSH_LEFT_ID );
|
||||
}
|
||||
|
||||
BushMiddleBlock::BushMiddleBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, BUSH_MIDDLE_SRC,
|
||||
false ) {
|
||||
setId( BUSH_MIDDLE_ID );
|
||||
}
|
||||
|
||||
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,
|
||||
false ) {
|
||||
setId( BUSH_RIGHT_ID );
|
||||
}
|
||||
|
||||
CloudLeftBottomBlock::CloudLeftBottomBlock(
|
||||
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, CLOUD_LEFT_BOTTOM_SRC,
|
||||
false ) {
|
||||
setId( CLOUD_LEFT_BOTTOM_ID );
|
||||
}
|
||||
|
||||
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,
|
||||
CLOUD_MIDDLE_BOTTOM_SRC, false ) {
|
||||
setId( CLOUD_MIDDLE_BOTTOM_ID );
|
||||
}
|
||||
|
||||
CloudRightBottomBlock::CloudRightBottomBlock(
|
||||
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, CLOUD_RIGHT_BOTTOM_SRC,
|
||||
false ) {
|
||||
setId( CLOUD_RIGHT_BOTTOM_ID );
|
||||
}
|
||||
|
||||
CloudLeftTopBlock::CloudLeftTopBlock(
|
||||
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, CLOUD_LEFT_TOP_SRC,
|
||||
false ) {
|
||||
setId( CLOUD_LEFT_TOP_ID );
|
||||
}
|
||||
|
||||
CloudMiddleTopBlock::CloudMiddleTopBlock(
|
||||
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, CLOUD_MIDDLE_TOP_SRC,
|
||||
false ) {
|
||||
setId( CLOUD_MIDDLE_TOP_ID );
|
||||
}
|
||||
|
||||
CloudRightTopBlock::CloudRightTopBlock(
|
||||
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, CLOUD_RIGHT_TOP_SRC,
|
||||
false ) {
|
||||
setId( CLOUD_RIGHT_TOP_ID );
|
||||
}
|
||||
|
||||
PipeLeftBottomBlock::PipeLeftBottomBlock(
|
||||
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, PIPE_LEFT_BOTTOM_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -123,7 +123,7 @@ PipeLeftBottomBlock::PipeLeftBottomBlock(
|
||||
}
|
||||
|
||||
PipeRightBottomBlock::PipeRightBottomBlock(
|
||||
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, PIPE_RIGHT_BOTTOM_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -131,7 +131,7 @@ PipeRightBottomBlock::PipeRightBottomBlock(
|
||||
}
|
||||
|
||||
PipeLeftTopBlock::PipeLeftTopBlock(
|
||||
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, PIPE_LEFT_TOP_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -139,7 +139,7 @@ PipeLeftTopBlock::PipeLeftTopBlock(
|
||||
}
|
||||
|
||||
PipeRightTopBlock::PipeRightTopBlock(
|
||||
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, PIPE_RIGHT_TOP_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -147,56 +147,56 @@ PipeRightTopBlock::PipeRightTopBlock(
|
||||
}
|
||||
|
||||
CastleLeftBlock::CastleLeftBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, CASTLE_LEFT_SRC,
|
||||
false ) {
|
||||
setId( CASTLE_LEFT_ID );
|
||||
}
|
||||
|
||||
CastleRightBlock::CastleRightBlock(
|
||||
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, CASTLE_RIGHT_SRC,
|
||||
false ) {
|
||||
setId( CASTLE_RIGHT_ID );
|
||||
}
|
||||
|
||||
CastleBlackBlock::CastleBlackBlock(
|
||||
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, CASTLE_BLACK_SRC,
|
||||
false ) {
|
||||
setId( CASTLE_BLACK_ID );
|
||||
}
|
||||
|
||||
CastleEntryBlock::CastleEntryBlock(
|
||||
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, CASTLE_ENTRY_SRC,
|
||||
false ) {
|
||||
setId( CASTLE_ENTRY_ID );
|
||||
}
|
||||
|
||||
CastleTowerBlock::CastleTowerBlock(
|
||||
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, CASTLE_TOWER_SRC,
|
||||
false ) {
|
||||
setId( CASTLE_TOWER_ID );
|
||||
}
|
||||
|
||||
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,
|
||||
CASTLE_TOWER_FILLED_SRC, false ) {
|
||||
setId( CASTLE_TOWER_FILLED_ID );
|
||||
}
|
||||
|
||||
VineTopBlock::VineTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, VINE_TOP_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( VINE_TOP_ID );
|
||||
}
|
||||
|
||||
VineBottomBlock::VineBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, VINE_BOTTOM_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -204,14 +204,14 @@ VineBottomBlock::VineBottomBlock( int x, int y,
|
||||
}
|
||||
|
||||
PoleTopBlock::PoleTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, POLE_TOP_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( POLE_TOP_ID );
|
||||
}
|
||||
|
||||
PoleBottomBlock::PoleBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, POLE_BOTTOM_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -219,34 +219,34 @@ PoleBottomBlock::PoleBottomBlock( 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 ) {
|
||||
setId( FLAG_ID );
|
||||
}
|
||||
|
||||
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 ) {
|
||||
ensureCollision();
|
||||
setId( STEP_ID );
|
||||
}
|
||||
|
||||
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 ) {
|
||||
ensureCollision();
|
||||
setId( BRICK_ID );
|
||||
}
|
||||
|
||||
BrickTopBlock::BrickTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, BRICK_TOP_SRC, true ) {
|
||||
ensureCollision();
|
||||
setId( BRICK_TOP_ID );
|
||||
}
|
||||
|
||||
SidewayPipeEndTopBlock::SidewayPipeEndTopBlock(
|
||||
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,
|
||||
SIDEWAY_PIPE_END_TOP_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -254,7 +254,7 @@ SidewayPipeEndTopBlock::SidewayPipeEndTopBlock(
|
||||
}
|
||||
|
||||
SidewayPipeEndBottomBlock::SidewayPipeEndBottomBlock(
|
||||
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,
|
||||
SIDEWAY_PIPE_END_BOTTOM_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -262,7 +262,7 @@ SidewayPipeEndBottomBlock::SidewayPipeEndBottomBlock(
|
||||
}
|
||||
|
||||
SidewayPipeMiddleTopBlock::SidewayPipeMiddleTopBlock(
|
||||
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,
|
||||
SIDEWAY_PIPE_MIDDLE_TOP_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -270,7 +270,7 @@ SidewayPipeMiddleTopBlock::SidewayPipeMiddleTopBlock(
|
||||
}
|
||||
|
||||
SidewayPipeMiddleBottomBlock::SidewayPipeMiddleBottomBlock(
|
||||
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,
|
||||
SIDEWAY_PIPE_MIDDLE_BOTTOM_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -278,7 +278,7 @@ SidewayPipeMiddleBottomBlock::SidewayPipeMiddleBottomBlock(
|
||||
}
|
||||
|
||||
SidewayPipeConnectorTopBlock::SidewayPipeConnectorTopBlock(
|
||||
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,
|
||||
SIDEWAY_PIPE_CONNECTOR_TOP_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -286,7 +286,7 @@ SidewayPipeConnectorTopBlock::SidewayPipeConnectorTopBlock(
|
||||
}
|
||||
|
||||
SidewayPipeConnectorBottomBlock::SidewayPipeConnectorBottomBlock(
|
||||
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,
|
||||
SIDEWAY_PIPE_CONNECTOR_BOTTOM_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -294,7 +294,7 @@ SidewayPipeConnectorBottomBlock::SidewayPipeConnectorBottomBlock(
|
||||
}
|
||||
|
||||
TreePlatformTopLeftBlock::TreePlatformTopLeftBlock(
|
||||
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,
|
||||
TREE_PLATFORM_TOP_LEFT_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -302,7 +302,7 @@ TreePlatformTopLeftBlock::TreePlatformTopLeftBlock(
|
||||
}
|
||||
|
||||
TreePlatformTopMiddleBlock::TreePlatformTopMiddleBlock(
|
||||
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,
|
||||
TREE_PLATFORM_TOP_MIDDLE_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -310,7 +310,7 @@ TreePlatformTopMiddleBlock::TreePlatformTopMiddleBlock(
|
||||
}
|
||||
|
||||
TreePlatformTopRightBlock::TreePlatformTopRightBlock(
|
||||
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,
|
||||
TREE_PLATFORM_TOP_RIGHT_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -318,7 +318,7 @@ TreePlatformTopRightBlock::TreePlatformTopRightBlock(
|
||||
}
|
||||
|
||||
TreePlatformBarkBlock::TreePlatformBarkBlock(
|
||||
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, TREE_PLATFORM_BARK_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -326,7 +326,7 @@ TreePlatformBarkBlock::TreePlatformBarkBlock(
|
||||
}
|
||||
|
||||
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,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -334,7 +334,7 @@ WaterTopBlock::WaterTopBlock( 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,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -342,7 +342,7 @@ WaterFillBlock::WaterFillBlock( int x, int y,
|
||||
}
|
||||
|
||||
MushroomPlatformTopLeftBlock::MushroomPlatformTopLeftBlock(
|
||||
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,
|
||||
MUSHROOM_PLATFORM_TOP_LEFT_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -350,7 +350,7 @@ MushroomPlatformTopLeftBlock::MushroomPlatformTopLeftBlock(
|
||||
}
|
||||
|
||||
MushroomPlatformTopMiddleBlock::MushroomPlatformTopMiddleBlock(
|
||||
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,
|
||||
MUSHROOM_PLATFORM_TOP_MIDDLE_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -358,7 +358,7 @@ MushroomPlatformTopMiddleBlock::MushroomPlatformTopMiddleBlock(
|
||||
}
|
||||
|
||||
MushroomPlatformTopRightBlock::MushroomPlatformTopRightBlock(
|
||||
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,
|
||||
MUSHROOM_PLATFORM_TOP_RIGHT_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -366,7 +366,7 @@ MushroomPlatformTopRightBlock::MushroomPlatformTopRightBlock(
|
||||
}
|
||||
|
||||
MushroomPlatformBarkTopBlock::MushroomPlatformBarkTopBlock(
|
||||
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,
|
||||
MUSHROOM_PLATFORM_BARK_TOP_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -374,7 +374,7 @@ MushroomPlatformBarkTopBlock::MushroomPlatformBarkTopBlock(
|
||||
}
|
||||
|
||||
MushroomPlatformBarkBottomBlock::MushroomPlatformBarkBottomBlock(
|
||||
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,
|
||||
MUSHROOM_PLATFORM_BARK_BOTTOM_SRC, false ) {
|
||||
ensureCollision();
|
||||
@ -382,7 +382,7 @@ MushroomPlatformBarkBottomBlock::MushroomPlatformBarkBottomBlock(
|
||||
}
|
||||
|
||||
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,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -390,7 +390,7 @@ TreeBarkBlock::TreeBarkBlock( int x, int y,
|
||||
}
|
||||
|
||||
TreeLeavesSmallBlock::TreeLeavesSmallBlock(
|
||||
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, TREE_LEAVES_SMALL_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -398,7 +398,7 @@ TreeLeavesSmallBlock::TreeLeavesSmallBlock(
|
||||
}
|
||||
|
||||
TreeLeavesTopBlock::TreeLeavesTopBlock(
|
||||
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, TREE_LEAVES_TOP_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -406,7 +406,7 @@ TreeLeavesTopBlock::TreeLeavesTopBlock(
|
||||
}
|
||||
|
||||
TreeLeavesBottomBlock::TreeLeavesBottomBlock(
|
||||
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, TREE_LEAVES_BOTTOM_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -414,7 +414,7 @@ TreeLeavesBottomBlock::TreeLeavesBottomBlock(
|
||||
}
|
||||
|
||||
CannonTowerBlock::CannonTowerBlock(
|
||||
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, CANNON_TOWER_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -422,7 +422,7 @@ CannonTowerBlock::CannonTowerBlock(
|
||||
}
|
||||
|
||||
CannonPedestalBlock::CannonPedestalBlock(
|
||||
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, CANNON_PEDESTAL_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
@ -430,21 +430,21 @@ CannonPedestalBlock::CannonPedestalBlock(
|
||||
}
|
||||
|
||||
CannonBlock::CannonBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, CANNON_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( CANNON_ID );
|
||||
}
|
||||
|
||||
DestructibleModifierBlock::DestructibleModifierBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer ) : MarioBlock( x, y, renderer, g_mod_texture, MOD_DESTRUCTIBLE_SRC, false ) {
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer ) : MarioBlock( x, y, renderer, g_mod_texture, MOD_DESTRUCTIBLE_SRC, false ) {
|
||||
setId( DESTRUCTIBLE_MODIFIER_ID );
|
||||
}
|
||||
BackgroundModifierBlock::BackgroundModifierBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer ) : MarioBlock (x, y, renderer, g_mod_texture, MOD_BACKGROUND_SRC, false ) {
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer ) : MarioBlock (x, y, renderer, g_mod_texture, MOD_BACKGROUND_SRC, false ) {
|
||||
setId( BACKGROUND_MODIFIER_ID );
|
||||
}
|
||||
MushroomModifierBlock::MushroomModifierBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer ) : MarioBlock (x, y, renderer, g_mod_texture, MOD_MUSHROOM_SRC, false ) {
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer ) : MarioBlock (x, y, renderer, g_mod_texture, MOD_MUSHROOM_SRC, false ) {
|
||||
setId( MUSHROOM_MODIFIER_ID );
|
||||
}
|
||||
|
@ -5,295 +5,297 @@
|
||||
|
||||
class FloorBlock : public MarioBlock {
|
||||
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 {
|
||||
public:
|
||||
HillInclineBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class HillDeclineBlock : public MarioBlock {
|
||||
public:
|
||||
HillDeclineBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class HillDotsRightBlock : public MarioBlock {
|
||||
public:
|
||||
HillDotsRightBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class HillDotsLeftBlock : public MarioBlock {
|
||||
public:
|
||||
HillDotsLeftBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class HillFillBlock : public MarioBlock {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
public:
|
||||
BushMiddleBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class BushRightBlock : public MarioBlock {
|
||||
public:
|
||||
BushRightBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
BushRightBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CloudLeftBottomBlock : public MarioBlock {
|
||||
public:
|
||||
CloudLeftBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CloudMiddleBottomBlock : public MarioBlock {
|
||||
public:
|
||||
CloudMiddleBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CloudRightBottomBlock : public MarioBlock {
|
||||
public:
|
||||
CloudRightBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CloudLeftTopBlock : public MarioBlock {
|
||||
public:
|
||||
CloudLeftTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CloudMiddleTopBlock : public MarioBlock {
|
||||
public:
|
||||
CloudMiddleTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CloudRightTopBlock : public MarioBlock {
|
||||
public:
|
||||
CloudRightTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class PipeLeftBottomBlock : public MarioBlock {
|
||||
public:
|
||||
PipeLeftBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class PipeRightBottomBlock : public MarioBlock {
|
||||
public:
|
||||
PipeRightBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class PipeLeftTopBlock : public MarioBlock {
|
||||
public:
|
||||
PipeLeftTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class PipeRightTopBlock : public MarioBlock {
|
||||
public:
|
||||
PipeRightTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CastleLeftBlock : public MarioBlock {
|
||||
public:
|
||||
CastleLeftBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CastleRightBlock : public MarioBlock {
|
||||
public:
|
||||
CastleRightBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CastleBlackBlock : public MarioBlock {
|
||||
public:
|
||||
CastleBlackBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CastleEntryBlock : public MarioBlock {
|
||||
public:
|
||||
CastleEntryBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CastleTowerBlock : public MarioBlock {
|
||||
public:
|
||||
CastleTowerBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CastleTowerFilledBlock : public MarioBlock {
|
||||
public:
|
||||
CastleTowerFilledBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class VineTopBlock : public MarioBlock {
|
||||
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 {
|
||||
public:
|
||||
VineBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class PoleTopBlock : public MarioBlock {
|
||||
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 {
|
||||
public:
|
||||
PoleBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class FlagBlock : public MarioBlock {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
public:
|
||||
SidewayPipeEndTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class SidewayPipeEndBottomBlock : public MarioBlock {
|
||||
public:
|
||||
SidewayPipeEndBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class SidewayPipeMiddleTopBlock : public MarioBlock {
|
||||
public:
|
||||
SidewayPipeMiddleTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class SidewayPipeMiddleBottomBlock : public MarioBlock {
|
||||
public:
|
||||
SidewayPipeMiddleBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
SidewayPipeMiddleBottomBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class SidewayPipeConnectorTopBlock : public MarioBlock {
|
||||
public:
|
||||
SidewayPipeConnectorTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
SidewayPipeConnectorTopBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class SidewayPipeConnectorBottomBlock : public MarioBlock {
|
||||
public:
|
||||
SidewayPipeConnectorBottomBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class TreePlatformTopLeftBlock : public MarioBlock {
|
||||
public:
|
||||
TreePlatformTopLeftBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class TreePlatformTopMiddleBlock : public MarioBlock {
|
||||
public:
|
||||
TreePlatformTopMiddleBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class TreePlatformTopRightBlock : public MarioBlock {
|
||||
public:
|
||||
TreePlatformTopRightBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class TreePlatformBarkBlock : public MarioBlock {
|
||||
public:
|
||||
TreePlatformBarkBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class WaterTopBlock : public MarioBlock {
|
||||
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 {
|
||||
public:
|
||||
WaterFillBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
WaterFillBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class MushroomPlatformTopLeftBlock : public MarioBlock {
|
||||
public:
|
||||
MushroomPlatformTopLeftBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
MushroomPlatformTopLeftBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class MushroomPlatformTopMiddleBlock : public MarioBlock {
|
||||
public:
|
||||
MushroomPlatformTopMiddleBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class MushroomPlatformTopRightBlock : public MarioBlock {
|
||||
public:
|
||||
MushroomPlatformTopRightBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class MushroomPlatformBarkTopBlock : public MarioBlock {
|
||||
public:
|
||||
MushroomPlatformBarkTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
MushroomPlatformBarkTopBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class MushroomPlatformBarkBottomBlock : public MarioBlock {
|
||||
public:
|
||||
MushroomPlatformBarkBottomBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class TreeBarkBlock : public MarioBlock {
|
||||
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 {
|
||||
public:
|
||||
TreeLeavesSmallBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class TreeLeavesTopBlock : public MarioBlock {
|
||||
public:
|
||||
TreeLeavesTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class TreeLeavesBottomBlock : public MarioBlock {
|
||||
public:
|
||||
TreeLeavesBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CannonTowerBlock : public MarioBlock {
|
||||
public:
|
||||
CannonTowerBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CannonPedestalBlock : public MarioBlock {
|
||||
public:
|
||||
CannonPedestalBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class CannonBlock : public MarioBlock {
|
||||
public:
|
||||
CannonBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
CannonBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
|
||||
//------------------ MODS------------------------------------------------------
|
||||
class DestructibleModifierBlock : public MarioBlock {
|
||||
public:
|
||||
DestructibleModifierBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class BackgroundModifierBlock : public MarioBlock {
|
||||
public:
|
||||
BackgroundModifierBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
class MushroomModifierBlock : public MarioBlock {
|
||||
public:
|
||||
MushroomModifierBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -15,8 +15,8 @@
|
||||
#include "objectids.hpp"
|
||||
#include "blocks.hpp"
|
||||
#include "maploader.hpp"
|
||||
#include "mario_visitor.hpp"
|
||||
#include "mario.hpp"
|
||||
#include "visitors/visitor_generator.hpp"
|
||||
|
||||
bool quit = false;
|
||||
bool update = false;
|
||||
@ -27,6 +27,8 @@ std::shared_ptr< SDLPP::TextRenderer > fps = nullptr;
|
||||
std::shared_ptr< SDLPP::TextRenderer > coins = nullptr;
|
||||
int coin_count = 0;
|
||||
|
||||
std::vector< std::shared_ptr< MarioBlock > > moving_objects = {};
|
||||
|
||||
std::mutex render_mutex;
|
||||
|
||||
void handleKeyDown( SDL_Keycode key, SDLPP::Scene &scene ) {
|
||||
@ -51,8 +53,9 @@ void handleKeyDown( SDL_Keycode key, SDLPP::Scene &scene ) {
|
||||
!scene.getRenderer().getRenderColiders() );
|
||||
break;
|
||||
case SDLK_f:
|
||||
if(fps)
|
||||
fps->setHidden(!fps->getHidden());
|
||||
if ( fps ) {
|
||||
fps->setHidden( !fps->getHidden() );
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -82,8 +85,9 @@ void pollEvents( SDLPP::Scene &scene ) {
|
||||
quit = true;
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
if ( !event.key.repeat )
|
||||
if ( !event.key.repeat ) {
|
||||
handleKeyDown( event.key.keysym.sym, scene );
|
||||
}
|
||||
break;
|
||||
case SDL_KEYUP:
|
||||
handleKeyUp( event.key.keysym.sym );
|
||||
@ -130,24 +134,17 @@ void doInput( std::shared_ptr< SDLPP::Scene > scene ) {
|
||||
while ( true ) {
|
||||
SDL_framerateDelay( &gFPS );
|
||||
pollEvents( *scene );
|
||||
std::lock_guard<std::mutex> lock(render_mutex);
|
||||
std::lock_guard< std::mutex > lock( render_mutex );
|
||||
scene->updateScene();
|
||||
MarioVisitor mv(mario->getMovement().getY() < 0);
|
||||
scene->visitCollisions( *mario, mv );
|
||||
if ( mv.isDead() ) {
|
||||
quit = true;
|
||||
}
|
||||
mario->handleVisitor(mv);
|
||||
if ( mv.hasCoin() ) {
|
||||
coin_count++;
|
||||
coins->changeText(std::to_string(coin_count) + " COINS");
|
||||
}
|
||||
if ( mv.hasCoinBlock() ) {
|
||||
auto coin = mv.getCoinBlock();
|
||||
scene->addObject(coin);
|
||||
scene->setZIndex(coin, 1);
|
||||
}
|
||||
auto prev_coin_count = coin_count;
|
||||
// TODO visit all moving objects
|
||||
auto visitor = getVisitor(*mario, *scene, quit, coin_count, moving_objects);
|
||||
scene->visitCollisions( *mario, *visitor );
|
||||
mario->handleVisitor( *visitor );
|
||||
|
||||
if(coin_count != prev_coin_count) {
|
||||
coins->changeText( std::to_string( coin_count ) + " COINS" );
|
||||
}
|
||||
// if player is > 0.7 of playground, move everything left
|
||||
auto playerX = mario->getRect().x;
|
||||
auto width = scene->getWidth();
|
||||
@ -189,12 +186,11 @@ int main() {
|
||||
scene->addObject( bg );
|
||||
g_mario_texture = std::make_shared< SDLPP::Texture >(
|
||||
renderer, "sprites/mario.png", MARIO_OVERWORLD_COLORKEY );
|
||||
g_translucent_terrain_texture =
|
||||
std::make_shared< SDLPP::Texture >( renderer, "sprites/terrain.png",
|
||||
MARIO_OVERWORLD_COLORKEY );
|
||||
g_translucent_terrain_texture = std::make_shared< SDLPP::Texture >(
|
||||
renderer, "sprites/terrain.png", MARIO_OVERWORLD_COLORKEY );
|
||||
g_translucent_terrain_texture->setAlpha( 100 );
|
||||
mario = std::make_shared< Mario >(renderer);
|
||||
scene->addObject(mario);
|
||||
mario = std::make_shared< Mario >( renderer );
|
||||
scene->addObject( mario );
|
||||
|
||||
auto defeat =
|
||||
std::make_shared< SDLPP::RectangleRender >( 0, 1.01, 0, 0, renderer );
|
||||
@ -221,18 +217,22 @@ int main() {
|
||||
loadMap( scene, mario, "test_binary2.bin" );
|
||||
|
||||
auto font = std::make_shared< SDLPP::Font >( "testfont.ttf", 36 );
|
||||
fps = std::make_shared<SDLPP::TextRenderer>(0.2, 0, 0.78, 0.1, renderer, font, "0fps", "#FFFFFF", "#000000", 0.1, SDLPP_TEXT_RIGHT);
|
||||
fps->setAlignment(SDLPP::OBJ_END, SDLPP::OBJ_START);
|
||||
fps->setId(0);
|
||||
fps = std::make_shared< SDLPP::TextRenderer >(
|
||||
0.2, 0, 0.78, 0.1, renderer, font, "0fps", "#FFFFFF", "#000000", 0.1,
|
||||
SDLPP_TEXT_RIGHT );
|
||||
fps->setAlignment( SDLPP::OBJ_END, SDLPP::OBJ_START );
|
||||
fps->setId( 0 );
|
||||
fps->setPermanent();
|
||||
fps->setHidden(true);
|
||||
scene->addObject(fps);
|
||||
fps->setHidden( true );
|
||||
scene->addObject( fps );
|
||||
|
||||
coins = std::make_shared<SDLPP::TextRenderer>(0.2, 0, 0.78, 0.1, renderer, font, "0 COINS", "#FFFFFF", "#000000", 0.1, SDLPP_TEXT_RIGHT);
|
||||
coins->setAlignment(SDLPP::OBJ_START, SDLPP::OBJ_START);
|
||||
coins->setId(0);
|
||||
coins = std::make_shared< SDLPP::TextRenderer >(
|
||||
0.2, 0, 0.78, 0.1, renderer, font, "0 COINS", "#FFFFFF", "#000000", 0.1,
|
||||
SDLPP_TEXT_RIGHT );
|
||||
coins->setAlignment( SDLPP::OBJ_START, SDLPP::OBJ_START );
|
||||
coins->setId( 0 );
|
||||
coins->setPermanent();
|
||||
scene->addObject(coins);
|
||||
scene->addObject( coins );
|
||||
|
||||
FPSmanager gFPS;
|
||||
SDL_initFramerate( &gFPS );
|
||||
@ -247,9 +247,9 @@ int main() {
|
||||
while ( !quit ) {
|
||||
SDL_PumpEvents();
|
||||
SDL_framerateDelay( &gFPS );
|
||||
std::lock_guard<std::mutex> lock(render_mutex);
|
||||
std::lock_guard< std::mutex > lock( render_mutex );
|
||||
mario->setStanding();
|
||||
if(update) {
|
||||
if ( update ) {
|
||||
scene->updateSizeAndPosition();
|
||||
update = false;
|
||||
}
|
||||
@ -257,7 +257,7 @@ int main() {
|
||||
renderer->presentRenderer();
|
||||
frames++;
|
||||
if ( SDL_GetTicks() - base >= 1000 ) {
|
||||
fps->changeText(std::to_string(frames) + " fps");
|
||||
fps->changeText( std::to_string( frames ) + " fps" );
|
||||
frames = 0;
|
||||
base = SDL_GetTicks();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "global_vars.hpp"
|
||||
#include "objectids.hpp"
|
||||
#include "sprites.hpp"
|
||||
#include "visitors/mario_visitor.hpp"
|
||||
|
||||
Mario::Mario(int x, int y, const std::shared_ptr< SDLPP::Renderer > &renderer) : MarioBlock(x, y, renderer, g_mario_texture, MARIO_STANDING_SRC) {
|
||||
setAnimationFrames( MARIO_WALK_ANIM );
|
||||
@ -60,10 +61,12 @@ void Mario::setStanding() {
|
||||
}
|
||||
}
|
||||
|
||||
void Mario::handleVisitor(MarioVisitor &visitor) {
|
||||
void Mario::handleVisitor(SDLPP::Visitor &visitor) {
|
||||
#ifndef EDITOR
|
||||
// TODO - https://web.archive.org/web/20130807122227/http://i276.photobucket.com/albums/kk21/jdaster64/smb_playerphysics.png
|
||||
auto &m_visitor = dynamic_cast<MarioVisitor&>(visitor);
|
||||
// handle gravity
|
||||
on_ground = visitor.isOnGround();
|
||||
on_ground = m_visitor.isOnGround();
|
||||
if(!jumping && on_ground) {
|
||||
resetMovementY();
|
||||
setTextureSourceRect(MARIO_STANDING_SRC);
|
||||
@ -71,34 +74,35 @@ void Mario::handleVisitor(MarioVisitor &visitor) {
|
||||
resumeAnimation();
|
||||
// for some reason falling of the edge causes on_ground to be true, but
|
||||
// visitor ground_y is 0
|
||||
if(visitor.getGroundY() != 0) {
|
||||
setPos(getPos().getX(), visitor.getGroundY() - BLOCK_SIZE);
|
||||
if(m_visitor.getGroundY() != 0) {
|
||||
setPos(getPos().getX(), m_visitor.getGroundY() - BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
// if we just left ground gravity didn't work in custom_move
|
||||
if(!on_ground && !jumping && getMovement().getY() == 0) {
|
||||
addMovement(0, 2*gravity_add_falling);
|
||||
}
|
||||
if(visitor.topBlock() && getMovement().getY() < 0) {
|
||||
if(m_visitor.topBlock() && getMovement().getY() < 0) {
|
||||
resetMovementY();
|
||||
stop_jump = true;
|
||||
}
|
||||
// make sure Mario isn't stuck inside a wall
|
||||
// TODO more readable function names
|
||||
if ( visitor.isStopped() ) {
|
||||
setPos( visitor.getStopX(), getPos().getY());
|
||||
} else if ( visitor.canGoLeft() != visitor.canGoRight() && !(on_ground && visitor.getMovementBlockage().getY() > getPos().getY() + BLOCK_SIZE/2) ) {
|
||||
if ( m_visitor.isStopped() ) {
|
||||
setPos( m_visitor.getStopX(), getPos().getY());
|
||||
} else if ( m_visitor.canGoLeft() != m_visitor.canGoRight() && !(on_ground && m_visitor.getMovementBlockage().getY() > getPos().getY() + BLOCK_SIZE/2) ) {
|
||||
// only stop mario on ground if the block obstructs at least half of him (important for bug when mario lands from a high jump and is teleported if visitor is fired at wrong moment)
|
||||
SDLPP::Vec2D<double> next_pos = { visitor.getMovementBlockage().getX() + (visitor.canGoLeft() * -1 + visitor.canGoRight() * 1) * BLOCK_SIZE, getPos().getY() };
|
||||
SDLPP::Vec2D<double> next_pos = { m_visitor.getMovementBlockage().getX() + (m_visitor.canGoLeft() * -1 + m_visitor.canGoRight() * 1) * BLOCK_SIZE, getPos().getY() };
|
||||
setPos(next_pos);
|
||||
} else if (visitor.moveTop() && jumping && !stop_jump) {
|
||||
auto objPos = visitor.getRightLeftPos();
|
||||
} else if (m_visitor.moveTop() && jumping && !stop_jump) {
|
||||
auto objPos = m_visitor.getRightLeftPos();
|
||||
if(objPos.getX() < getPos().getX()) {
|
||||
setPos( objPos.getX() + BLOCK_SIZE, getPos().getY() );
|
||||
} else {
|
||||
setPos( objPos.getX() - BLOCK_SIZE, getPos().getY() );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Mario::jump() {
|
||||
|
@ -2,7 +2,6 @@
|
||||
#define MARIO_H
|
||||
|
||||
#include "../sdlpp/sdlpp_rectrenderer.hpp"
|
||||
#include "mario_visitor.hpp"
|
||||
#include "sprites.hpp"
|
||||
#include "blocks.hpp"
|
||||
|
||||
@ -13,10 +12,10 @@ public:
|
||||
void walkLeft();
|
||||
void walkRight();
|
||||
void setStanding();
|
||||
void handleVisitor( MarioVisitor &visitor );
|
||||
void handleVisitor( SDLPP::Visitor &visitor ) override;
|
||||
void jump();
|
||||
void stopJump();
|
||||
virtual void custom_move( int ticks ) override;
|
||||
void custom_move( int ticks ) override;
|
||||
void visit( SDLPP::Visitor &visitor ) override;
|
||||
|
||||
private:
|
||||
@ -35,7 +34,7 @@ private:
|
||||
const double gravity_add_jumping = jump_movement / 32.0;
|
||||
const double gravity_add_falling = jump_movement / ( 64.0 / 7.0 );
|
||||
std::shared_ptr< SDLPP::RectColider > top_collision = nullptr;
|
||||
virtual void setWorldTypeSrc( LandType::Value world ) override;
|
||||
void setWorldTypeSrc( LandType::Value world ) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -100,4 +100,7 @@
|
||||
#define MOUSE_VISITOR_TYPE 0xE003
|
||||
#define MARIO_VISITOR_TYPE 0xE004
|
||||
|
||||
// Collisions
|
||||
#define BOUNCE_COLLISION 0x0045
|
||||
|
||||
#endif
|
||||
|
17
mario/visitors/bounce_visitor.cpp
Normal file
17
mario/visitors/bounce_visitor.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "bounce_visitor.hpp"
|
||||
#include "../../sdlpp/sdlpp_renderobject.hpp"
|
||||
#include "../objectids.hpp"
|
||||
|
||||
void BounceVisitor::visit( const SDLPP::RenderObject &obj ) {
|
||||
auto id = obj.getId();
|
||||
switch ( id ) {
|
||||
case FLOOR_ID:
|
||||
case BRICK_ID:
|
||||
case BRICK_TOP_ID:
|
||||
if(from == BOUNCE_COLLISION) {
|
||||
hits += 1;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
34
mario/visitors/bounce_visitor.hpp
Normal file
34
mario/visitors/bounce_visitor.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef BOUNCE_VISITOR_HPP
|
||||
#define BOUNCE_VISITOR_HPP
|
||||
|
||||
#include "../../sdlpp/sdlpp_visitor.hpp"
|
||||
#include "../../sdlpp/sdlpp_geometry.hpp"
|
||||
|
||||
class BounceVisitor : public SDLPP::Visitor {
|
||||
public:
|
||||
BounceVisitor() {}
|
||||
virtual void visit( const SDLPP::RenderObject &obj ) override;
|
||||
virtual void setFromId( uint64_t id ) override {
|
||||
from = id;
|
||||
}
|
||||
virtual uint64_t getFromId() override {
|
||||
return from;
|
||||
}
|
||||
virtual void setVisitorType( uint64_t type ) override {
|
||||
_type = type;
|
||||
}
|
||||
virtual uint64_t getVisitorType() override {
|
||||
return _type;
|
||||
}
|
||||
|
||||
bool canBounce() {
|
||||
return hits < 2;
|
||||
}
|
||||
|
||||
private:
|
||||
int hits = 0;
|
||||
uint64_t from;
|
||||
uint64_t _type;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
#include "mario_visitor.hpp"
|
||||
#include "../sdlpp/sdlpp_renderobject.hpp"
|
||||
#include "objectids.hpp"
|
||||
#include "sprites.hpp"
|
||||
#include "../../sdlpp/sdlpp_renderobject.hpp"
|
||||
#include "../objectids.hpp"
|
||||
#include "../sprites.hpp"
|
||||
|
||||
void MarioVisitor::visit( const SDLPP::RenderObject &obj ) {
|
||||
auto id = obj.getId();
|
||||
@ -32,12 +32,14 @@ void MarioVisitor::visit( const SDLPP::RenderObject &obj ) {
|
||||
onGround = true;
|
||||
groundY = obj.getPos().getY();
|
||||
} else if ( from == MARIO_LEFT_SIDE_DETECT ) {
|
||||
if(!left && !right)
|
||||
if(!left && !right) {
|
||||
movement_blockage = obj.getPos();
|
||||
}
|
||||
left = true;
|
||||
} else if (from == MARIO_RIGHT_SIDE_DETECT ) {
|
||||
if(!left && !right)
|
||||
if(!left && !right) {
|
||||
movement_blockage = obj.getPos();
|
||||
}
|
||||
right = true;
|
||||
} else if (from == MARIO_TOP_DETECT) {
|
||||
top_hit = true;
|
||||
@ -47,7 +49,9 @@ void MarioVisitor::visit( const SDLPP::RenderObject &obj ) {
|
||||
}
|
||||
break;
|
||||
case DEATH_ID:
|
||||
// TODO remove death?
|
||||
death = true;
|
||||
_quit = true;
|
||||
break;
|
||||
case STOP_MOVEMENT:
|
||||
stop = true;
|
||||
@ -58,17 +62,3 @@ void MarioVisitor::visit( const SDLPP::RenderObject &obj ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BounceVisitor::visit( const SDLPP::RenderObject &obj ) {
|
||||
auto id = obj.getId();
|
||||
switch ( id ) {
|
||||
case FLOOR_ID:
|
||||
case BRICK_ID:
|
||||
case BRICK_TOP_ID:
|
||||
if(from == 69) {
|
||||
hits += 1;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,13 +1,14 @@
|
||||
#ifndef MARIO_VISITOR_H
|
||||
#define MARIO_VISITOR_H
|
||||
|
||||
#include "../sdlpp/sdlpp_visitor.hpp"
|
||||
#include "../sdlpp/sdlpp_geometry.hpp"
|
||||
#include "blocks.hpp"
|
||||
#include "../../sdlpp/sdlpp_visitor.hpp"
|
||||
#include "../../sdlpp/sdlpp_geometry.hpp"
|
||||
#include "../../sdlpp/sdlpp_scene.hpp"
|
||||
#include "../blocks.hpp"
|
||||
|
||||
class MarioVisitor : public SDLPP::Visitor {
|
||||
public:
|
||||
MarioVisitor(bool is_jumping) : jumping(is_jumping) {}
|
||||
MarioVisitor(bool is_jumping, SDLPP::Scene &scene, bool &quit, int &coin_count) : jumping(is_jumping), _scene(scene), _quit(quit), _coin_count(coin_count) {}
|
||||
virtual void visit( const SDLPP::RenderObject &obj ) override;
|
||||
bool isOnGround() {
|
||||
return onGround;
|
||||
@ -65,7 +66,9 @@ public:
|
||||
}
|
||||
|
||||
void setCoin() {
|
||||
// TODO remove coin?
|
||||
coin = true;
|
||||
_coin_count++;
|
||||
}
|
||||
|
||||
bool hasCoin() {
|
||||
@ -73,7 +76,10 @@ public:
|
||||
}
|
||||
|
||||
void setCoinBlock(std::shared_ptr<MarioBlock> &coin) {
|
||||
// TODO remove coin_block?
|
||||
coin_block = coin;
|
||||
_scene.addObject(coin);
|
||||
_scene.setZIndex(coin, 1);
|
||||
}
|
||||
|
||||
bool hasCoinBlock() {
|
||||
@ -101,33 +107,9 @@ private:
|
||||
bool coin = false;
|
||||
SDLPP::Vec2D<double> movement_blockage;
|
||||
std::shared_ptr<MarioBlock> coin_block = nullptr;
|
||||
};
|
||||
|
||||
class BounceVisitor : public SDLPP::Visitor {
|
||||
public:
|
||||
BounceVisitor() {}
|
||||
virtual void visit( const SDLPP::RenderObject &obj ) override;
|
||||
virtual void setFromId( uint64_t id ) override {
|
||||
from = id;
|
||||
}
|
||||
virtual uint64_t getFromId() override {
|
||||
return from;
|
||||
}
|
||||
virtual void setVisitorType( uint64_t type ) override {
|
||||
_type = type;
|
||||
}
|
||||
virtual uint64_t getVisitorType() override {
|
||||
return _type;
|
||||
}
|
||||
|
||||
bool canBounce() {
|
||||
return hits < 2;
|
||||
}
|
||||
|
||||
private:
|
||||
int hits = 0;
|
||||
uint64_t from;
|
||||
uint64_t _type;
|
||||
SDLPP::Scene &_scene;
|
||||
bool &_quit;
|
||||
int &_coin_count;
|
||||
};
|
||||
|
||||
#endif
|
17
mario/visitors/visitor_generator.cpp
Normal file
17
mario/visitors/visitor_generator.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "visitor_generator.hpp"
|
||||
#include "../objectids.hpp"
|
||||
#include "mario_visitor.hpp"
|
||||
|
||||
std::shared_ptr< SDLPP::Visitor >
|
||||
getVisitor( const MarioBlock &block, SDLPP::Scene &scene, bool &quit,
|
||||
int &coin_count,
|
||||
std::vector< std::shared_ptr< MarioBlock > > &moving_objects ) {
|
||||
std::shared_ptr< SDLPP::Visitor > result{};
|
||||
switch(block.getId()) {
|
||||
case MARIO_ID:
|
||||
result = std::static_pointer_cast<SDLPP::Visitor>(std::make_shared<MarioVisitor>(block.getMovement().getY() < 0, scene, quit, coin_count));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
11
mario/visitors/visitor_generator.hpp
Normal file
11
mario/visitors/visitor_generator.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef MARIO_VISITOR_GENERATOR_HPP
|
||||
#define MARIO_VISITOR_GENERATOR_HPP
|
||||
|
||||
#include "../blocks.hpp"
|
||||
|
||||
std::shared_ptr< SDLPP::Visitor >
|
||||
getVisitor( const MarioBlock &block, SDLPP::Scene &scene, bool &quit,
|
||||
int &coin_count,
|
||||
std::vector< std::shared_ptr< MarioBlock > > &moving_objects );
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user