Refactor to use objects for terrain/mod creation, added coin modifier
This commit is contained in:
parent
79d9f266b4
commit
3be728843a
@ -18,11 +18,11 @@ LDFLAGS ?= -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_ttf -pthread
|
||||
OUTPUTFLAG = -o
|
||||
endif
|
||||
|
||||
COMMON_OBJECTS = global_vars.${OBJEXT} sprites.${OBJEXT} maploader.${OBJEXT} mapobject.${OBJEXT}
|
||||
COMMON_OBJECTS = global_vars.${OBJEXT} sprites.${OBJEXT} maploader.${OBJEXT} mapobject.${OBJEXT} coinblock.${OBJEXT} simpleblocks.${OBJEXT} mario.${OBJEXT}
|
||||
ifneq ($(UNAME_S),Windows)
|
||||
COMMON_OBJECTS += libsdlpp.a
|
||||
endif
|
||||
MARIO_OBJECTS = main.${OBJEXT} blocks.${OBJEXT} mario_visitor.${OBJEXT} mario.${OBJEXT} ${COMMON_OBJECTS}
|
||||
MARIO_OBJECTS = main.${OBJEXT} blocks.${OBJEXT} mario_visitor.${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)
|
||||
@ -69,6 +69,10 @@ tool_box.${OBJEXT}: tool_box.cpp ../sdlpp/sdlpp.hpp sprites.hpp tool_box.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
editor_visitor.${OBJEXT}: editor_visitor.cpp ../sdlpp/sdlpp.hpp sprites.hpp editor_visitor.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
coinblock.${OBJEXT}: blocks/coinblock.cpp ../sdlpp/sdlpp.hpp sprites.hpp global_vars.hpp blocks.hpp blocks/coinblock.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
simpleblocks.${OBJEXT}: blocks/simpleblocks.cpp ../sdlpp/sdlpp.hpp sprites.hpp global_vars.hpp blocks.hpp blocks/simpleblocks.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
mapobject.${OBJEXT}: mapobject.cpp ../sdlpp/sdlpp.hpp objectids.hpp
|
||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||
mario.${OBJEXT}: mario.cpp ../sdlpp/sdlpp.hpp mario.hpp global_vars.hpp objectids.hpp sprites.hpp ../sdlpp/sdlpp_rectrenderer.hpp
|
||||
|
467
mario/blocks.cpp
467
mario/blocks.cpp
@ -1,23 +1,29 @@
|
||||
#include "blocks.hpp"
|
||||
#include "blocks/coinblock.hpp"
|
||||
#include "global_vars.hpp"
|
||||
#include "objectids.hpp"
|
||||
#include "sprites.hpp"
|
||||
#include "editor_visitor.hpp"
|
||||
#include <unordered_map>
|
||||
#include "mario_visitor.hpp"
|
||||
#include "blocks/simpleblocks.hpp"
|
||||
#include "blocks/coinblock.hpp"
|
||||
#include "mario.hpp"
|
||||
|
||||
#define CAN_BE_DESTROYED_FLAG 0x0000000000000001
|
||||
#define HAS_COLLISION 0x0000000000000002
|
||||
#define HAS_COLLISION 0x0000000000000002
|
||||
|
||||
MarioBlock::MarioBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer,
|
||||
std::shared_ptr< SDLPP::Texture > texture,
|
||||
SDL_Rect src, bool can_be_destroyed, bool destructible )
|
||||
const std::shared_ptr< SDLPP::Renderer > &renderer,
|
||||
std::shared_ptr< SDLPP::Texture > texture, SDL_Rect src,
|
||||
bool can_be_destroyed, bool destructible )
|
||||
: RectangleRender( x * BLOCK_SIZE, 1 - ( 16 - y ) * BLOCK_SIZE,
|
||||
BLOCK_SIZE, BLOCK_SIZE, renderer, texture, src ) {
|
||||
_can_be_destroyed = can_be_destroyed;
|
||||
_destructible = can_be_destroyed && destructible;
|
||||
setMovementSpeed(1);
|
||||
_can_be_destroyed = can_be_destroyed;
|
||||
_destructible = can_be_destroyed && destructible;
|
||||
setMovementSpeed( 1 );
|
||||
_coins = 0;
|
||||
_mushroom = false;
|
||||
}
|
||||
void MarioBlock::visit( SDLPP::Visitor &visitor ) {
|
||||
#ifdef EDITOR
|
||||
@ -30,24 +36,29 @@ void MarioBlock::visit( SDLPP::Visitor &visitor ) {
|
||||
destroy();
|
||||
}
|
||||
#else
|
||||
if(visitor.getFromId() == MARIO_TOP_DETECT && dynamic_cast<MarioVisitor&>(visitor).canDestroy()) {
|
||||
if ( visitor.getFromId() == MARIO_TOP_DETECT &&
|
||||
dynamic_cast< MarioVisitor & >( visitor ).canDestroy() ) {
|
||||
// TODO if big mario and _can_be_destroyed
|
||||
if( _destructible ) {
|
||||
if ( _destructible && !hasCoin() ) {
|
||||
destroy();
|
||||
} else {
|
||||
BounceVisitor bv;
|
||||
bv.setVisitorType(VisitorType::Terrain);
|
||||
bv.setVisitorType( VisitorType::Terrain );
|
||||
|
||||
setPos(getPos() - SDLPP::Vec2D<double>(0, BLOCK_SIZE));
|
||||
if(getCollisions().size() < 2)
|
||||
addCollision(SDLPP::RectColider(0.1, 0.1, 0.8, 0.8, 69));
|
||||
setPos( getPos() - SDLPP::Vec2D< double >( 0, BLOCK_SIZE ) );
|
||||
if ( getCollisions().size() < 2 )
|
||||
addCollision( SDLPP::RectColider( 0.1, 0.1, 0.8, 0.8, 69 ) );
|
||||
updateSizeAndPosition();
|
||||
g_playground->visitCollisions(*this, bv);
|
||||
setPos(getPos() + SDLPP::Vec2D<double>(0, BLOCK_SIZE));
|
||||
g_playground->visitCollisions( *this, bv );
|
||||
setPos( getPos() + SDLPP::Vec2D< double >( 0, BLOCK_SIZE ) );
|
||||
updateSizeAndPosition();
|
||||
if(bv.canBounce())
|
||||
if ( bv.canBounce() )
|
||||
bounce();
|
||||
}
|
||||
if ( hasCoin() ) {
|
||||
removeCoin();
|
||||
dynamic_cast< MarioVisitor & >( visitor ).setCoin();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
visitor.visit( *this );
|
||||
@ -60,38 +71,85 @@ void MarioBlock::setTerrain( bool terrain ) {
|
||||
}
|
||||
|
||||
void MarioBlock::bounce() {
|
||||
if(_bouncing)
|
||||
if ( _bouncing )
|
||||
return;
|
||||
_bouncing = true;
|
||||
og_pos = getPos();
|
||||
setMovement(0, -0.5);
|
||||
setMovement( 0, -0.5 );
|
||||
}
|
||||
|
||||
void MarioBlock::custom_move(int ticks) {
|
||||
if(!_bouncing)
|
||||
void MarioBlock::custom_move( int ticks ) {
|
||||
if ( !_bouncing )
|
||||
return;
|
||||
if(getMovement().getY() < 0) {
|
||||
if ( getMovement().getY() < 0 ) {
|
||||
ticks_to_bounce -= ticks;
|
||||
if(ticks_to_bounce < 0) {
|
||||
setMovement(0, 0.5);
|
||||
if ( ticks_to_bounce < 0 ) {
|
||||
setMovement( 0, 0.5 );
|
||||
ticks_to_bounce = bounce_ticks;
|
||||
}
|
||||
} else {
|
||||
if(getPos().getY() >= og_pos.getY()) {
|
||||
setMovement(0, 0);
|
||||
setPos(getPos().getX(), og_pos.getY());
|
||||
if ( getPos().getY() >= og_pos.getY() ) {
|
||||
setMovement( 0, 0 );
|
||||
setPos( getPos().getX(), og_pos.getY() );
|
||||
_bouncing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MarioBlock::setType(LandType::Value type) {
|
||||
void MarioBlock::setType( LandType::Value type ) {
|
||||
_type = type;
|
||||
setWorldTypeSrc( _type );
|
||||
}
|
||||
LandType::Value MarioBlock::getType() const {
|
||||
return _type;
|
||||
}
|
||||
|
||||
bool MarioBlock::hasCoin() {
|
||||
return _coins > 0;
|
||||
}
|
||||
bool MarioBlock::hasMushroom() {
|
||||
return _mushroom;
|
||||
}
|
||||
void MarioBlock::removeCoin() {
|
||||
_coins--;
|
||||
}
|
||||
void MarioBlock::removeMushroom() {
|
||||
_mushroom = false;
|
||||
}
|
||||
void MarioBlock::setCoinCount( int coins ) {
|
||||
_coins = coins;
|
||||
}
|
||||
void MarioBlock::setDestructible( bool destructible ) {
|
||||
_destructible = destructible;
|
||||
}
|
||||
void MarioBlock::ensureCollision() {
|
||||
if ( getCollisions().size() == 0 ) {
|
||||
addCollision( SDLPP::RectColider( 0, 0, 1, 1 ) );
|
||||
}
|
||||
}
|
||||
void MarioBlock::setWorldTypeSrc( LandType::Value world ) {
|
||||
auto rect = getTextureSourceRect();
|
||||
switch ( world ) {
|
||||
case LandType::OVERWORLD:
|
||||
rect.x += OVERWORLD_SHIFT.getX();
|
||||
rect.y += OVERWORLD_SHIFT.getY();
|
||||
break;
|
||||
case LandType::UNDERWORLD:
|
||||
rect.x += UNDERWORLD_SHIFT.getX();
|
||||
rect.y += UNDERWORLD_SHIFT.getY();
|
||||
break;
|
||||
case LandType::WATER:
|
||||
rect.x += WATER_SHIFT.getX();
|
||||
rect.y += WATER_SHIFT.getY();
|
||||
break;
|
||||
case LandType::BOWSER:
|
||||
rect.x += BOWSER_SHIFT.getX();
|
||||
rect.y += BOWSER_SHIFT.getY();
|
||||
break;
|
||||
}
|
||||
setTextureSourceRect( rect );
|
||||
}
|
||||
|
||||
const std::vector< uint64_t > possibleBlocks = {
|
||||
FLOOR_ID,
|
||||
STEP_ID,
|
||||
@ -165,10 +223,7 @@ const std::vector< uint64_t > possibleCharacters = {
|
||||
};
|
||||
|
||||
const std::vector< LandType::Value > possibleLands = {
|
||||
LandType::OVERWORLD,
|
||||
LandType::UNDERWORLD,
|
||||
LandType::WATER,
|
||||
LandType::BOWSER
|
||||
LandType::OVERWORLD, LandType::UNDERWORLD, LandType::WATER, LandType::BOWSER
|
||||
};
|
||||
|
||||
const std::unordered_map< uint64_t, const SDL_Rect * > block_mapping = {
|
||||
@ -301,37 +356,306 @@ const std::unordered_map< uint64_t, uint64_t > block_flags = {
|
||||
{ BACKGROUND_MODIFIER_ID, 0 },
|
||||
};
|
||||
|
||||
bool blockCanBeDestroyed(uint64_t id) {
|
||||
auto it = block_flags.find(id);
|
||||
if(it == block_flags.end())
|
||||
bool blockCanBeDestroyed( uint64_t id ) {
|
||||
auto it = block_flags.find( id );
|
||||
if ( it == block_flags.end() )
|
||||
return false;
|
||||
return it->second & CAN_BE_DESTROYED_FLAG;
|
||||
}
|
||||
|
||||
bool blockHasCollision(uint64_t id) {
|
||||
auto it = block_flags.find(id);
|
||||
if(it == block_flags.end()) {
|
||||
bool blockHasCollision( uint64_t id ) {
|
||||
auto it = block_flags.find( id );
|
||||
if ( it == block_flags.end() ) {
|
||||
return false;
|
||||
}
|
||||
return it->second & HAS_COLLISION;
|
||||
}
|
||||
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
createBlock( std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
||||
std::shared_ptr< SDLPP::Texture > &texture, const SDL_Rect &src,
|
||||
uint64_t id, LandType::Value land_type, bool destructible, bool editor ) {
|
||||
auto can_destroy = blockCanBeDestroyed(id);
|
||||
auto collision = blockHasCollision(id);
|
||||
if(editor) {
|
||||
collision = true;
|
||||
std::shared_ptr< MarioBlock >
|
||||
createBlockById( uint64_t id, int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer ) {
|
||||
std::shared_ptr< MarioBlock > result = nullptr;
|
||||
switch ( id ) {
|
||||
case FLOOR_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< FloorBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case HILL_INCLINE_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< HillInclineBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case HILL_DECLINE_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< HillDeclineBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case HILL_DOTS_RIGHT_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< HillDotsRightBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case HILL_DOTS_LEFT_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< HillDotsLeftBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case HILL_FILL_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< HillFillBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case HILL_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< HillTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case BUSH_LEFT_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< BushLeftBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case BUSH_MIDDLE_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< BushMiddleBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case BUSH_RIGHT_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< BushRightBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CLOUD_LEFT_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CloudLeftBottomBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CLOUD_MIDDLE_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CloudMiddleBottomBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CLOUD_RIGHT_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CloudRightBottomBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CLOUD_LEFT_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CloudLeftTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CLOUD_MIDDLE_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CloudMiddleTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CLOUD_RIGHT_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CloudRightTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case PIPE_LEFT_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< PipeLeftBottomBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case PIPE_RIGHT_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< PipeRightBottomBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case PIPE_LEFT_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< PipeLeftTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case PIPE_RIGHT_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< PipeRightTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CASTLE_LEFT_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CastleLeftBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CASTLE_RIGHT_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CastleRightBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CASTLE_BLACK_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CastleBlackBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CASTLE_ENTRY_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CastleEntryBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CASTLE_TOWER_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CastleTowerBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CASTLE_TOWER_FILLED_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CastleTowerFilledBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case VINE_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< VineTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case VINE_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< VineBottomBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case POLE_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< PoleTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case POLE_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< PoleBottomBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case FLAG_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< FlagBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case STEP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< StepBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case BRICK_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< BrickBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case BRICK_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< BrickTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case SIDEWAY_PIPE_END_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< SidewayPipeEndTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case SIDEWAY_PIPE_END_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< SidewayPipeEndBottomBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case SIDEWAY_PIPE_MIDDLE_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< SidewayPipeMiddleTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case SIDEWAY_PIPE_MIDDLE_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< SidewayPipeMiddleBottomBlock >( x, y,
|
||||
renderer ) );
|
||||
break;
|
||||
case SIDEWAY_PIPE_CONNECTOR_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< SidewayPipeConnectorTopBlock >( x, y,
|
||||
renderer ) );
|
||||
break;
|
||||
case SIDEWAY_PIPE_CONNECTOR_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< SidewayPipeConnectorBottomBlock >( x, y,
|
||||
renderer ) );
|
||||
break;
|
||||
case TREE_PLATFORM_TOP_LEFT_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< TreePlatformTopLeftBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case TREE_PLATFORM_TOP_MIDDLE_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< TreePlatformTopMiddleBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case TREE_PLATFORM_TOP_RIGHT_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< TreePlatformTopRightBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case TREE_PLATFORM_BARK_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< TreePlatformBarkBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case WATER_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< WaterTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case WATER_FILL_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< WaterFillBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case MUSHROOM_PLATFORM_TOP_LEFT_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< MushroomPlatformTopLeftBlock >( x, y,
|
||||
renderer ) );
|
||||
break;
|
||||
case MUSHROOM_PLATFORM_TOP_MIDDLE_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< MushroomPlatformTopMiddleBlock >( x, y,
|
||||
renderer ) );
|
||||
break;
|
||||
case MUSHROOM_PLATFORM_TOP_RIGHT_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< MushroomPlatformTopRightBlock >( x, y,
|
||||
renderer ) );
|
||||
break;
|
||||
case MUSHROOM_PLATFORM_BARK_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< MushroomPlatformBarkTopBlock >( x, y,
|
||||
renderer ) );
|
||||
break;
|
||||
case MUSHROOM_PLATFORM_BARK_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< MushroomPlatformBarkBottomBlock >( x, y,
|
||||
renderer ) );
|
||||
break;
|
||||
case TREE_BARK_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< TreeBarkBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case TREE_LEAVES_SMALL_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< TreeLeavesSmallBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case TREE_LEAVES_TOP_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< TreeLeavesTopBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case TREE_LEAVES_BOTTOM_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< TreeLeavesBottomBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CANNON_TOWER_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CannonTowerBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CANNON_PEDESTAL_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CannonPedestalBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case CANNON_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CannonBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case MARIO_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared<Mario>(x,y,renderer));
|
||||
break;
|
||||
case DESTRUCTIBLE_MODIFIER_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared<DestructibleModifierBlock>(x,y,renderer));
|
||||
break;
|
||||
case BACKGROUND_MODIFIER_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared<BackgroundModifierBlock>(x,y,renderer));
|
||||
break;
|
||||
case COIN_MODIFIER_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared<CoinEditorBlock>(x,y,renderer));
|
||||
break;
|
||||
case MUSHROOM_MODIFIER_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared<MushroomModifierBlock>(x,y,renderer));
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr< MarioBlock >
|
||||
createBlock( std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
||||
uint64_t id, LandType::Value land_type, bool destructible,
|
||||
bool editor ) {
|
||||
auto block = createBlockById( id, x, y, renderer );
|
||||
if(block == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
auto block = std::make_shared< MarioBlock >( x, y, renderer, texture, src, can_destroy, destructible );
|
||||
block->setId( id );
|
||||
block->setAlignment( SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER );
|
||||
block->setStatic();
|
||||
block->setType(land_type);
|
||||
if ( collision ) {
|
||||
block->addCollision( SDLPP::RectColider( 0, 0, 1, 1 ) );
|
||||
block->setType( land_type );
|
||||
if(destructible) {
|
||||
block->setDestructible();
|
||||
}
|
||||
if ( editor ) {
|
||||
block->ensureCollision();
|
||||
}
|
||||
return block;
|
||||
}
|
||||
@ -361,47 +685,32 @@ SDL_Rect getSourceRectByID( uint64_t id, LandType::Value type ) {
|
||||
}
|
||||
return ret_src;
|
||||
}
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
||||
std::shared_ptr< SDLPP::Texture > texture,
|
||||
bool destructible, bool editor ) {
|
||||
return createBlock( renderer, x, y, texture,
|
||||
getSourceRectByID( block_id, type ), block_id, type,
|
||||
destructible, editor );
|
||||
}
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer,
|
||||
std::shared_ptr< SDLPP::Texture > texture,
|
||||
bool destructible, bool editor ) {
|
||||
return createTerrainBlock( block_id, type, renderer, 0, 0, texture,
|
||||
destructible, editor );
|
||||
}
|
||||
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
// TODO coin count
|
||||
std::shared_ptr< MarioBlock >
|
||||
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
||||
bool destructible, bool editor ) {
|
||||
return createTerrainBlock( block_id, type, renderer, x, y,
|
||||
g_terrain_texture, destructible, editor );
|
||||
return createBlock( renderer, x, y, block_id, type, destructible, editor );
|
||||
}
|
||||
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
std::shared_ptr< MarioBlock >
|
||||
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer,
|
||||
bool destructible, bool editor ) {
|
||||
return createTerrainBlock( block_id, type, renderer, g_terrain_texture,
|
||||
destructible, editor );
|
||||
return createTerrainBlock( block_id, type, renderer, 0, 0, destructible,
|
||||
editor );
|
||||
}
|
||||
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
std::shared_ptr< MarioBlock >
|
||||
createMario( LandType::Value type, std::shared_ptr< SDLPP::Renderer > &renderer,
|
||||
int x, int y ) {
|
||||
int x, int y, bool editor ) {
|
||||
// TODO add type additions
|
||||
auto mario = createBlock( renderer, x, y, g_mario_texture,
|
||||
MARIO_STANDING_SRC, MARIO_ID, type, false, true );
|
||||
dynamic_cast< MarioBlock & >( *mario ).setTerrain( false );
|
||||
auto mario = createBlock(renderer, x, y, MARIO_ID, type, false, true);
|
||||
if(editor) {
|
||||
mario->setTerrain( false );
|
||||
mario->removeCollisions();
|
||||
mario->ensureCollision();
|
||||
}
|
||||
return mario;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define BLOCKS_H
|
||||
|
||||
#include "../sdlpp/sdlpp_rectrenderer.hpp"
|
||||
#include "../sdlpp/sdlpp_fontconfiguration.hpp"
|
||||
#include <memory>
|
||||
|
||||
struct LandType {
|
||||
@ -10,7 +11,7 @@ struct LandType {
|
||||
|
||||
class MarioBlock : public SDLPP::RectangleRender {
|
||||
public:
|
||||
MarioBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > renderer,
|
||||
MarioBlock( int x, int y, const std::shared_ptr< SDLPP::Renderer > &renderer,
|
||||
std::shared_ptr< SDLPP::Texture > texture, SDL_Rect src, bool can_be_destroyed = false, bool destructible = false );
|
||||
void visit( SDLPP::Visitor &visitor ) override;
|
||||
void setTool( bool tool = true );
|
||||
@ -19,6 +20,17 @@ public:
|
||||
virtual void custom_move(int ticks) override;
|
||||
void setType(LandType::Value type);
|
||||
LandType::Value getType() const;
|
||||
virtual void onScrollUp() {}
|
||||
virtual void onScrollDown() {}
|
||||
virtual uint8_t getData() {return 0;}
|
||||
virtual void setData(uint8_t /*UNUSED*/) {}
|
||||
bool hasCoin();
|
||||
bool hasMushroom();
|
||||
void removeCoin();
|
||||
void removeMushroom();
|
||||
void setCoinCount(int coins);
|
||||
void setDestructible(bool destructible = true);
|
||||
void ensureCollision();
|
||||
|
||||
private:
|
||||
bool _tool = false;
|
||||
@ -26,10 +38,14 @@ private:
|
||||
bool _destructible = false;
|
||||
bool _can_be_destroyed = false;
|
||||
bool _bouncing = false;
|
||||
int _coins = 0;
|
||||
bool _mushroom = false;
|
||||
const int bounce_ticks = 100;
|
||||
int ticks_to_bounce = bounce_ticks;
|
||||
SDLPP::Vec2D<double> og_pos = {};
|
||||
LandType::Value _type;
|
||||
|
||||
virtual void setWorldTypeSrc(LandType::Value world);
|
||||
};
|
||||
|
||||
extern const std::vector< uint64_t > possibleBlocks;
|
||||
@ -46,30 +62,20 @@ struct BlockRole {
|
||||
};
|
||||
};
|
||||
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
std::shared_ptr< MarioBlock >
|
||||
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer,
|
||||
bool destructible = false, bool editor = false );
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
std::shared_ptr< MarioBlock >
|
||||
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
||||
bool destructible = false, bool editor = false );
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer,
|
||||
std::shared_ptr< SDLPP::Texture > texture,
|
||||
bool destructible = false, bool editor = false );
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
||||
std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
||||
std::shared_ptr< SDLPP::Texture > texture,
|
||||
bool destructible = false, bool editor = false );
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
std::shared_ptr< MarioBlock >
|
||||
createMario( LandType::Value type, std::shared_ptr< SDLPP::Renderer > &renderer,
|
||||
int x, int y );
|
||||
|
||||
SDL_Rect getSourceRectByID( uint64_t id, LandType::Value type );
|
||||
int x, int y, bool editor = false );
|
||||
|
||||
enum BlockRole::Value getBlockRole( uint64_t id );
|
||||
|
||||
SDL_Rect getSourceRectByID( uint64_t id, LandType::Value type );
|
||||
|
||||
#endif
|
||||
|
70
mario/blocks/coinblock.cpp
Normal file
70
mario/blocks/coinblock.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#include "coinblock.hpp"
|
||||
#include "../objectids.hpp"
|
||||
|
||||
CoinEditorBlock::CoinEditorBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > renderer ) :
|
||||
MarioBlock( x, y, renderer, g_translucent_mod_texture, MOD_COIN_SRC, false, false ) {
|
||||
setId(COIN_MODIFIER_ID);
|
||||
auto mypos = getDoubleRect();
|
||||
auto size = mypos.second.getX() / 1.5;
|
||||
_amount_text = std::make_shared<SDLPP::TextRenderer>( mypos.first.getX() + mypos.second.getX() - size, mypos.first.getY() + mypos.second.getX() - size, size, size, renderer, "1", g_text_config );
|
||||
setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||
_amount_text->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||
}
|
||||
|
||||
void CoinEditorBlock::render() {
|
||||
MarioBlock::render();
|
||||
if ( _amount_text != NULL ) {
|
||||
_amount_text->render();
|
||||
}
|
||||
}
|
||||
|
||||
void CoinEditorBlock::updateSizeAndPosition() {
|
||||
MarioBlock::updateSizeAndPosition();
|
||||
auto block_size = getDoubleRect().second;
|
||||
_amount_text->setPos( getPos() + block_size - block_size / 1.5 );
|
||||
_amount_text->updateSizeAndPosition();
|
||||
}
|
||||
|
||||
void CoinEditorBlock::addOne() {
|
||||
if(_amount < 15) {
|
||||
_amount++;
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
void CoinEditorBlock::subtractOne() {
|
||||
if(_amount > 1) {
|
||||
_amount--;
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
void CoinEditorBlock::setAmount(int amount) {
|
||||
if(amount < 1) {
|
||||
amount = 1;
|
||||
} else if(amount > 15) {
|
||||
amount = 15;
|
||||
}
|
||||
_amount = amount;
|
||||
updateText();
|
||||
}
|
||||
|
||||
void CoinEditorBlock::updateText() {
|
||||
_amount_text->changeText(std::to_string(_amount));
|
||||
}
|
||||
|
||||
void CoinEditorBlock::onScrollUp() {
|
||||
addOne();
|
||||
}
|
||||
|
||||
void CoinEditorBlock::onScrollDown() {
|
||||
subtractOne();
|
||||
}
|
||||
|
||||
uint8_t CoinEditorBlock::getData() {
|
||||
return _amount;
|
||||
}
|
||||
|
||||
void CoinEditorBlock::setData(uint8_t data) {
|
||||
setAmount(data);
|
||||
}
|
27
mario/blocks/coinblock.hpp
Normal file
27
mario/blocks/coinblock.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef COIN_BLOCK_H
|
||||
#define COIN_BLOCK_H
|
||||
|
||||
#include "../blocks.hpp"
|
||||
#include "../global_vars.hpp"
|
||||
#include "../sprites.hpp"
|
||||
#include "../../sdlpp/sdlpp_textrenderer.hpp"
|
||||
|
||||
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 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;
|
||||
private:
|
||||
void updateText();
|
||||
int _amount = 1;
|
||||
std::shared_ptr<SDLPP::TextRenderer> _amount_text;
|
||||
};
|
||||
|
||||
#endif
|
454
mario/blocks/simpleblocks.cpp
Normal file
454
mario/blocks/simpleblocks.cpp
Normal file
@ -0,0 +1,454 @@
|
||||
#include "simpleblocks.hpp"
|
||||
#include "../global_vars.hpp"
|
||||
#include "../sprites.hpp"
|
||||
#include "../objectids.hpp"
|
||||
|
||||
FloorBlock::FloorBlock( int x, int y,
|
||||
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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, PIPE_LEFT_BOTTOM_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( PIPE_LEFT_BOTTOM_ID );
|
||||
}
|
||||
|
||||
PipeRightBottomBlock::PipeRightBottomBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, PIPE_RIGHT_BOTTOM_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( PIPE_RIGHT_BOTTOM_ID );
|
||||
}
|
||||
|
||||
PipeLeftTopBlock::PipeLeftTopBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, PIPE_LEFT_TOP_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( PIPE_LEFT_TOP_ID );
|
||||
}
|
||||
|
||||
PipeRightTopBlock::PipeRightTopBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, PIPE_RIGHT_TOP_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( PIPE_RIGHT_TOP_ID );
|
||||
}
|
||||
|
||||
CastleLeftBlock::CastleLeftBlock( int x, int y,
|
||||
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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, VINE_BOTTOM_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( VINE_BOTTOM_ID );
|
||||
}
|
||||
|
||||
PoleTopBlock::PoleTopBlock( int x, int y,
|
||||
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 )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, POLE_BOTTOM_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( POLE_BOTTOM_ID );
|
||||
}
|
||||
|
||||
FlagBlock::FlagBlock( int x, int y,
|
||||
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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: 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 )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
SIDEWAY_PIPE_END_TOP_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( SIDEWAY_PIPE_END_TOP_ID );
|
||||
}
|
||||
|
||||
SidewayPipeEndBottomBlock::SidewayPipeEndBottomBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
SIDEWAY_PIPE_END_BOTTOM_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( SIDEWAY_PIPE_END_BOTTOM_ID );
|
||||
}
|
||||
|
||||
SidewayPipeMiddleTopBlock::SidewayPipeMiddleTopBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
SIDEWAY_PIPE_MIDDLE_TOP_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( SIDEWAY_PIPE_MIDDLE_TOP_ID );
|
||||
}
|
||||
|
||||
SidewayPipeMiddleBottomBlock::SidewayPipeMiddleBottomBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
SIDEWAY_PIPE_MIDDLE_BOTTOM_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( SIDEWAY_PIPE_MIDDLE_BOTTOM_ID );
|
||||
}
|
||||
|
||||
SidewayPipeConnectorTopBlock::SidewayPipeConnectorTopBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
SIDEWAY_PIPE_CONNECTOR_TOP_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( SIDEWAY_PIPE_CONNECTOR_TOP_ID );
|
||||
}
|
||||
|
||||
SidewayPipeConnectorBottomBlock::SidewayPipeConnectorBottomBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
SIDEWAY_PIPE_CONNECTOR_BOTTOM_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( SIDEWAY_PIPE_CONNECTOR_BOTTOM_ID );
|
||||
}
|
||||
|
||||
TreePlatformTopLeftBlock::TreePlatformTopLeftBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
TREE_PLATFORM_TOP_LEFT_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( TREE_PLATFORM_TOP_LEFT_ID );
|
||||
}
|
||||
|
||||
TreePlatformTopMiddleBlock::TreePlatformTopMiddleBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
TREE_PLATFORM_TOP_MIDDLE_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( TREE_PLATFORM_TOP_MIDDLE_ID );
|
||||
}
|
||||
|
||||
TreePlatformTopRightBlock::TreePlatformTopRightBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
TREE_PLATFORM_TOP_RIGHT_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( TREE_PLATFORM_TOP_RIGHT_ID );
|
||||
}
|
||||
|
||||
TreePlatformBarkBlock::TreePlatformBarkBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, TREE_PLATFORM_BARK_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( TREE_PLATFORM_BARK_ID );
|
||||
}
|
||||
|
||||
WaterTopBlock::WaterTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, WATER_TOP_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( WATER_TOP_ID );
|
||||
}
|
||||
|
||||
WaterFillBlock::WaterFillBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, WATER_FILL_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( WATER_FILL_ID );
|
||||
}
|
||||
|
||||
MushroomPlatformTopLeftBlock::MushroomPlatformTopLeftBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
MUSHROOM_PLATFORM_TOP_LEFT_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( MUSHROOM_PLATFORM_TOP_LEFT_ID );
|
||||
}
|
||||
|
||||
MushroomPlatformTopMiddleBlock::MushroomPlatformTopMiddleBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
MUSHROOM_PLATFORM_TOP_MIDDLE_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( MUSHROOM_PLATFORM_TOP_MIDDLE_ID );
|
||||
}
|
||||
|
||||
MushroomPlatformTopRightBlock::MushroomPlatformTopRightBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
MUSHROOM_PLATFORM_TOP_RIGHT_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( MUSHROOM_PLATFORM_TOP_RIGHT_ID );
|
||||
}
|
||||
|
||||
MushroomPlatformBarkTopBlock::MushroomPlatformBarkTopBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
MUSHROOM_PLATFORM_BARK_TOP_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( MUSHROOM_PLATFORM_BARK_TOP_ID );
|
||||
}
|
||||
|
||||
MushroomPlatformBarkBottomBlock::MushroomPlatformBarkBottomBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture,
|
||||
MUSHROOM_PLATFORM_BARK_BOTTOM_SRC, false ) {
|
||||
ensureCollision();
|
||||
setId( MUSHROOM_PLATFORM_BARK_BOTTOM_ID );
|
||||
}
|
||||
|
||||
TreeBarkBlock::TreeBarkBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, TREE_BARK_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( TREE_BARK_ID );
|
||||
}
|
||||
|
||||
TreeLeavesSmallBlock::TreeLeavesSmallBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, TREE_LEAVES_SMALL_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( TREE_LEAVES_SMALL_ID );
|
||||
}
|
||||
|
||||
TreeLeavesTopBlock::TreeLeavesTopBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, TREE_LEAVES_TOP_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( TREE_LEAVES_TOP_ID );
|
||||
}
|
||||
|
||||
TreeLeavesBottomBlock::TreeLeavesBottomBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, TREE_LEAVES_BOTTOM_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( TREE_LEAVES_BOTTOM_ID );
|
||||
}
|
||||
|
||||
CannonTowerBlock::CannonTowerBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, CANNON_TOWER_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( CANNON_TOWER_ID );
|
||||
}
|
||||
|
||||
CannonPedestalBlock::CannonPedestalBlock(
|
||||
int x, int y, std::shared_ptr< SDLPP::Renderer > renderer )
|
||||
: MarioBlock( x, y, renderer, g_terrain_texture, CANNON_PEDESTAL_SRC,
|
||||
false ) {
|
||||
ensureCollision();
|
||||
setId( CANNON_PEDESTAL_ID );
|
||||
}
|
||||
|
||||
CannonBlock::CannonBlock( int x, int y,
|
||||
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 ) {
|
||||
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 ) {
|
||||
setId( BACKGROUND_MODIFIER_ID );
|
||||
}
|
||||
CoinModifierBlock::CoinModifierBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer ) : MarioBlock (x, y, renderer, g_mod_texture, MOD_COIN_SRC, false ) {
|
||||
setId( COIN_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 ) {
|
||||
setId( MUSHROOM_MODIFIER_ID );
|
||||
}
|
304
mario/blocks/simpleblocks.hpp
Normal file
304
mario/blocks/simpleblocks.hpp
Normal file
@ -0,0 +1,304 @@
|
||||
#ifndef SIMPLE_BLOCKS_HPP
|
||||
#define SIMPLE_BLOCKS_HPP
|
||||
|
||||
#include "../blocks.hpp"
|
||||
|
||||
class FloorBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class HillDeclineBlock : public MarioBlock {
|
||||
public:
|
||||
HillDeclineBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class HillDotsRightBlock : public MarioBlock {
|
||||
public:
|
||||
HillDotsRightBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class HillDotsLeftBlock : public MarioBlock {
|
||||
public:
|
||||
HillDotsLeftBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class HillFillBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class BushLeftBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class BushRightBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class CloudMiddleBottomBlock : public MarioBlock {
|
||||
public:
|
||||
CloudMiddleBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CloudRightBottomBlock : public MarioBlock {
|
||||
public:
|
||||
CloudRightBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CloudLeftTopBlock : public MarioBlock {
|
||||
public:
|
||||
CloudLeftTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CloudMiddleTopBlock : public MarioBlock {
|
||||
public:
|
||||
CloudMiddleTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CloudRightTopBlock : public MarioBlock {
|
||||
public:
|
||||
CloudRightTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class PipeLeftBottomBlock : public MarioBlock {
|
||||
public:
|
||||
PipeLeftBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class PipeRightBottomBlock : public MarioBlock {
|
||||
public:
|
||||
PipeRightBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class PipeLeftTopBlock : public MarioBlock {
|
||||
public:
|
||||
PipeLeftTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class PipeRightTopBlock : public MarioBlock {
|
||||
public:
|
||||
PipeRightTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CastleLeftBlock : public MarioBlock {
|
||||
public:
|
||||
CastleLeftBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CastleRightBlock : public MarioBlock {
|
||||
public:
|
||||
CastleRightBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CastleBlackBlock : public MarioBlock {
|
||||
public:
|
||||
CastleBlackBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CastleEntryBlock : public MarioBlock {
|
||||
public:
|
||||
CastleEntryBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CastleTowerBlock : public MarioBlock {
|
||||
public:
|
||||
CastleTowerBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CastleTowerFilledBlock : public MarioBlock {
|
||||
public:
|
||||
CastleTowerFilledBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class VineTopBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class PoleTopBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class FlagBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class BrickBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class SidewayPipeEndTopBlock : public MarioBlock {
|
||||
public:
|
||||
SidewayPipeEndTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class SidewayPipeEndBottomBlock : public MarioBlock {
|
||||
public:
|
||||
SidewayPipeEndBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class SidewayPipeMiddleTopBlock : public MarioBlock {
|
||||
public:
|
||||
SidewayPipeMiddleTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class SidewayPipeMiddleBottomBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class SidewayPipeConnectorBottomBlock : public MarioBlock {
|
||||
public:
|
||||
SidewayPipeConnectorBottomBlock(
|
||||
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 );
|
||||
};
|
||||
class TreePlatformTopMiddleBlock : public MarioBlock {
|
||||
public:
|
||||
TreePlatformTopMiddleBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class TreePlatformTopRightBlock : public MarioBlock {
|
||||
public:
|
||||
TreePlatformTopRightBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class TreePlatformBarkBlock : public MarioBlock {
|
||||
public:
|
||||
TreePlatformBarkBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class WaterTopBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class MushroomPlatformTopLeftBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class MushroomPlatformTopRightBlock : public MarioBlock {
|
||||
public:
|
||||
MushroomPlatformTopRightBlock(
|
||||
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 );
|
||||
};
|
||||
class MushroomPlatformBarkBottomBlock : public MarioBlock {
|
||||
public:
|
||||
MushroomPlatformBarkBottomBlock(
|
||||
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 );
|
||||
};
|
||||
class TreeLeavesSmallBlock : public MarioBlock {
|
||||
public:
|
||||
TreeLeavesSmallBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class TreeLeavesTopBlock : public MarioBlock {
|
||||
public:
|
||||
TreeLeavesTopBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class TreeLeavesBottomBlock : public MarioBlock {
|
||||
public:
|
||||
TreeLeavesBottomBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CannonTowerBlock : public MarioBlock {
|
||||
public:
|
||||
CannonTowerBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CannonPedestalBlock : public MarioBlock {
|
||||
public:
|
||||
CannonPedestalBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CannonBlock : public MarioBlock {
|
||||
public:
|
||||
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 );
|
||||
};
|
||||
class BackgroundModifierBlock : public MarioBlock {
|
||||
public:
|
||||
BackgroundModifierBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class CoinModifierBlock : public MarioBlock {
|
||||
public:
|
||||
CoinModifierBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
class MushroomModifierBlock : public MarioBlock {
|
||||
public:
|
||||
MushroomModifierBlock( int x, int y,
|
||||
std::shared_ptr< SDLPP::Renderer > renderer );
|
||||
};
|
||||
|
||||
#endif
|
@ -20,6 +20,7 @@
|
||||
#include "edit_box.hpp"
|
||||
#include "editor_visitor.hpp"
|
||||
#include "tool_box.hpp"
|
||||
#include "blocks/coinblock.hpp"
|
||||
|
||||
#define MAP_WIDTH 24
|
||||
#define MAP_HEIGHT 16
|
||||
@ -86,7 +87,9 @@ struct GlobalVars {
|
||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > mod_boxes;
|
||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > character_boxes;
|
||||
enum LandType::Value current_world_type;
|
||||
std::shared_ptr< SDLPP::RenderObject > current_tool;
|
||||
std::shared_ptr< MarioBlock > coin_tool;
|
||||
std::shared_ptr< MarioBlock > generic_tool;
|
||||
std::shared_ptr< MarioBlock > current_tool;
|
||||
std::shared_ptr< SDLPP::Texture > translucent_terrain_texture;
|
||||
std::shared_ptr< SDLPP::Texture > translucent_mario_texture;
|
||||
std::shared_ptr< SDLPP::Texture > translucent_mod_texture;
|
||||
@ -127,11 +130,20 @@ void updateTool() {
|
||||
case BlockRole::CHARACTER:
|
||||
break;
|
||||
}
|
||||
global_vars.current_tool->setTexture(
|
||||
target_texture,
|
||||
getSourceRectByID( tool_id, global_vars.current_world_type ) );
|
||||
global_vars.current_tool->setId( tool_id );
|
||||
global_vars.current_tool->getCollisions()[0]->setId( tool_id );
|
||||
global_vars.current_tool->setHidden(true);
|
||||
if(tool_id == COIN_MODIFIER_ID) {
|
||||
global_vars.coin_tool->setPos(global_vars.current_tool->getPos());
|
||||
global_vars.current_tool = global_vars.coin_tool;
|
||||
} else {
|
||||
global_vars.generic_tool->setPos(global_vars.current_tool->getPos());
|
||||
global_vars.current_tool = global_vars.generic_tool;
|
||||
global_vars.current_tool->setTexture(
|
||||
target_texture,
|
||||
getSourceRectByID( tool_id, global_vars.current_world_type ) );
|
||||
global_vars.current_tool->setId( tool_id );
|
||||
global_vars.current_tool->getCollisions()[0]->setId( tool_id );
|
||||
}
|
||||
global_vars.current_tool->setHidden(false);
|
||||
}
|
||||
|
||||
void removeMario() {
|
||||
@ -415,10 +427,11 @@ void updateWorld() {
|
||||
dynamic_cast< MarioBlock * >( block.get() )
|
||||
->setType( global_vars.current_world_type );
|
||||
}
|
||||
global_vars.current_tool->setTextureSourceRect( getSourceRectByID(
|
||||
global_vars.current_tool->getId(), global_vars.current_world_type ) );
|
||||
dynamic_cast< MarioBlock * >( global_vars.current_tool.get() )
|
||||
->setType( global_vars.current_world_type );
|
||||
if(getBlockRole(global_vars.current_tool->getId()) != BlockRole::MODIFIER) {
|
||||
global_vars.current_tool->setTextureSourceRect( getSourceRectByID(
|
||||
global_vars.current_tool->getId(), global_vars.current_world_type ) );
|
||||
global_vars.current_tool->setType( global_vars.current_world_type );
|
||||
}
|
||||
}
|
||||
|
||||
// TODO add mouse wheel control for modifiers
|
||||
@ -569,6 +582,7 @@ void placeTool( SDLPP::Scene &scene ) {
|
||||
scene.visitCollisions( *global_vars.current_tool, visitor );
|
||||
auto &obj = getSelectedObject();
|
||||
if ( visitor.removeBlock() && !visitor.addBlock() ) {
|
||||
std::cout << "DO NOT ADD" << std::endl;
|
||||
switch ( visitor.getVisitorType() ) {
|
||||
case VisitorType::Terrain:
|
||||
obj.unsetTerrain();
|
||||
@ -580,9 +594,10 @@ void placeTool( SDLPP::Scene &scene ) {
|
||||
break;
|
||||
}
|
||||
} else if ( visitor.addBlock() ) {
|
||||
std::cout << "ADD" << std::endl;
|
||||
auto renderer = scene.getRendererShared();
|
||||
int z_index = 1;
|
||||
std::shared_ptr< SDLPP::RenderObject > new_obj = nullptr;
|
||||
std::shared_ptr< MarioBlock > new_obj = nullptr;
|
||||
switch ( visitor.getVisitorType() ) {
|
||||
case VisitorType::Terrain:
|
||||
obj.setTerrain( global_vars.current_tool->getId(),
|
||||
@ -599,7 +614,7 @@ void placeTool( SDLPP::Scene &scene ) {
|
||||
obj.setCharacter(MARIO_ID, global_vars.current_world_type);
|
||||
new_obj = createMario( global_vars.current_world_type, renderer,
|
||||
global_vars.mouse.edit_box.getX(),
|
||||
global_vars.mouse.edit_box.getY() );
|
||||
global_vars.mouse.edit_box.getY(), true );
|
||||
// remove mario if exists
|
||||
removeMario();
|
||||
global_vars.mario = new_obj;
|
||||
@ -608,14 +623,15 @@ void placeTool( SDLPP::Scene &scene ) {
|
||||
z_index = scene.getObjects().size() - 1;
|
||||
// TODO BlockRole::Character
|
||||
} else {
|
||||
// TODO data
|
||||
obj.setModifier(global_vars.current_tool->getId(), 0);
|
||||
obj.setModifier(global_vars.current_tool->getId(), global_vars.current_tool->getData());
|
||||
new_obj = createTerrainBlock(
|
||||
obj.getModifierId(),
|
||||
LandType::OVERWORLD, renderer,
|
||||
global_vars.mouse.edit_box.getX(),
|
||||
global_vars.mouse.edit_box.getY(),
|
||||
global_vars.translucent_mod_texture, false, true );
|
||||
false, true );
|
||||
new_obj->setTextureKeepSRC(global_vars.translucent_mod_texture);
|
||||
new_obj->setData(global_vars.current_tool->getData());
|
||||
new_obj->getCollisions()[0]->setId( EDITOR_TERRAIN_ID );
|
||||
// TODO createModifierBlock
|
||||
dynamic_cast< MarioBlock * >( new_obj.get() )
|
||||
@ -697,6 +713,13 @@ void pollEvents( SDLPP::Scene &scene ) {
|
||||
// store current mouse flags in previous mouse flags
|
||||
global_vars.mouse.prev_flags = global_vars.mouse.cur_flags;
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
if(event.wheel.y > 0) {
|
||||
global_vars.current_tool->onScrollUp();
|
||||
} else if (event.wheel.y < 0) {
|
||||
global_vars.current_tool->onScrollDown();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -799,14 +822,14 @@ void populateToolGrid(
|
||||
case ToolType::CHARACTER:
|
||||
if ( block == MARIO_ID ) {
|
||||
tool_store.push_back( createMario(
|
||||
global_vars.current_world_type, renderer, 0, 0 ) );
|
||||
global_vars.current_world_type, renderer, 0, 0, true ) );
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
case ToolType::MOD:
|
||||
tool_store.push_back(
|
||||
createTerrainBlock( block, global_vars.current_world_type,
|
||||
renderer, g_mod_texture, false, true ) );
|
||||
renderer, false, true ) );
|
||||
break;
|
||||
case ToolType::BLOCK:
|
||||
tool_store.push_back(
|
||||
@ -921,6 +944,12 @@ int main() {
|
||||
w.setResizable( true );
|
||||
BLOCK_SIZE = 1.0 / 26;
|
||||
|
||||
auto font = std::make_shared< SDLPP::Font >( "testfont.ttf", 36 );
|
||||
auto font_config = std::make_shared< SDLPP::FontConfiguration >(
|
||||
font, "#000000", "#282828", 0.05 );
|
||||
g_text_config = std::make_shared< SDLPP::FontConfiguration >(
|
||||
font, "#FFFFFF", "#000000", 0.15 );
|
||||
|
||||
auto renderer = std::make_shared< SDLPP::Renderer >( w );
|
||||
renderer->setBlendMode( SDL_BLENDMODE_BLEND );
|
||||
|
||||
@ -951,10 +980,6 @@ int main() {
|
||||
loadMap( scene, global_vars.mario, "test_binary.bin",
|
||||
global_vars.objects, true, MAP_WIDTH );
|
||||
|
||||
auto font = std::make_shared< SDLPP::Font >( "testfont.ttf", 36 );
|
||||
auto font_config = std::make_shared< SDLPP::FontConfiguration >(
|
||||
font, "#000000", "#282828", 0.05 );
|
||||
|
||||
// create grids and arrow controls
|
||||
// map
|
||||
auto arrows = createArrowControls(
|
||||
@ -1051,16 +1076,27 @@ int main() {
|
||||
global_vars.translucent_mario_texture = std::make_shared< SDLPP::Texture >(
|
||||
renderer, "sprites/mario.png", MARIO_OVERWORLD_COLORKEY );
|
||||
global_vars.translucent_mario_texture->setAlpha( 100 );
|
||||
global_vars.current_tool = createTerrainBlock(
|
||||
global_vars.generic_tool = createTerrainBlock(
|
||||
possibleBlocks[global_vars.tool.index], global_vars.current_world_type,
|
||||
renderer, global_vars.translucent_terrain_texture, false );
|
||||
global_vars.current_tool->removeCollisions();
|
||||
global_vars.current_tool->addCollision(
|
||||
renderer, false );
|
||||
global_vars.generic_tool->setTextureKeepSRC(global_vars.translucent_terrain_texture);
|
||||
global_vars.generic_tool->removeCollisions();
|
||||
global_vars.generic_tool->addCollision(
|
||||
SDLPP::RectColider( 0.1, 0.1, 0.8, 0.8 ) );
|
||||
global_vars.current_tool = global_vars.generic_tool;
|
||||
|
||||
global_vars.coin_tool = createTerrainBlock(COIN_MODIFIER_ID, LandType::OVERWORLD, renderer, 0, 0, false, true );
|
||||
global_vars.coin_tool->setData(1);
|
||||
global_vars.coin_tool->removeCollisions();
|
||||
global_vars.coin_tool->addCollision(
|
||||
SDLPP::RectColider( 0.1, 0.1, 0.8, 0.8 ) );
|
||||
global_vars.translucent_mod_texture = g_translucent_mod_texture;
|
||||
dynamic_cast< MarioBlock & >( *global_vars.current_tool ).setTool();
|
||||
scene->addObject( global_vars.current_tool );
|
||||
scene->addObject( global_vars.coin_tool );
|
||||
global_vars.coin_tool->setHidden(true);
|
||||
scene->moveZTop( global_vars.current_tool );
|
||||
scene->moveZTop( global_vars.coin_tool );
|
||||
|
||||
scene->moveEverything( BLOCK_SIZE, 0 );
|
||||
FPSmanager gFPS;
|
||||
|
@ -7,3 +7,4 @@ std::shared_ptr< SDLPP::Texture > g_mod_texture{};
|
||||
std::shared_ptr< SDLPP::Texture > g_translucent_terrain_texture{};
|
||||
std::shared_ptr< SDLPP::Texture > g_translucent_mod_texture{};
|
||||
std::shared_ptr< SDLPP::Scene > g_playground{};
|
||||
std::shared_ptr< SDLPP::FontConfiguration > g_text_config{};
|
||||
|
@ -9,5 +9,6 @@ extern std::shared_ptr< SDLPP::Texture > g_mod_texture;
|
||||
extern std::shared_ptr< SDLPP::Texture > g_translucent_terrain_texture;
|
||||
extern std::shared_ptr< SDLPP::Texture > g_translucent_mod_texture;
|
||||
extern std::shared_ptr< SDLPP::Scene > g_playground;
|
||||
extern std::shared_ptr< SDLPP::FontConfiguration > g_text_config;
|
||||
|
||||
#endif
|
||||
|
@ -24,6 +24,8 @@ std::shared_ptr< Mario > mario = nullptr;
|
||||
std::shared_ptr< SDLPP::RectangleRender > leftStop = nullptr;
|
||||
std::shared_ptr< SDLPP::Renderer > renderer = nullptr;
|
||||
std::shared_ptr< SDLPP::TextRenderer > fps = nullptr;
|
||||
std::shared_ptr< SDLPP::TextRenderer > coins = nullptr;
|
||||
int coin_count = 0;
|
||||
|
||||
std::mutex render_mutex;
|
||||
|
||||
@ -136,6 +138,10 @@ void doInput( std::shared_ptr< SDLPP::Scene > scene ) {
|
||||
quit = true;
|
||||
}
|
||||
mario->handleVisitor(mv);
|
||||
if ( mv.hasCoin() ) {
|
||||
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;
|
||||
@ -217,6 +223,12 @@ int main() {
|
||||
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->setPermanent();
|
||||
scene->addObject(coins);
|
||||
|
||||
FPSmanager gFPS;
|
||||
SDL_initFramerate( &gFPS );
|
||||
SDL_setFramerate( &gFPS, 60 );
|
||||
|
@ -112,6 +112,7 @@ void loadMap( std::shared_ptr< SDLPP::Scene > &scene,
|
||||
}
|
||||
bool destructible = false;
|
||||
bool removeCollisions = false;
|
||||
int coinCount = 0;
|
||||
if ( !editor &&
|
||||
block.getModifierId() == DESTRUCTIBLE_MODIFIER_ID ) {
|
||||
destructible = true;
|
||||
@ -121,11 +122,18 @@ void loadMap( std::shared_ptr< SDLPP::Scene > &scene,
|
||||
destructible = false;
|
||||
removeCollisions = true;
|
||||
}
|
||||
if ( !editor &&
|
||||
block.getModifierId() == COIN_MODIFIER_ID ) {
|
||||
coinCount = block.getModifierData();
|
||||
}
|
||||
// TODO add modifiers to createTerrainBlock
|
||||
if(block.getTerrainId() != 0) {
|
||||
auto obj = createTerrainBlock(
|
||||
block.getTerrainId(), block.getTerrainType(),
|
||||
renderer, i, j, destructible, editor );
|
||||
if(obj == nullptr)
|
||||
continue;
|
||||
obj->setCoinCount(coinCount);
|
||||
if(removeCollisions) {
|
||||
obj->removeCollisions();
|
||||
}
|
||||
@ -141,7 +149,7 @@ void loadMap( std::shared_ptr< SDLPP::Scene > &scene,
|
||||
if ( editor ) {
|
||||
scene->addObject( createMario(
|
||||
block.getCharacterType(),
|
||||
renderer, i, j ) );
|
||||
renderer, i, j, true ) );
|
||||
mario =
|
||||
scene->getObject( scene->getObjects().size() - 1 );
|
||||
} else {
|
||||
@ -154,7 +162,9 @@ void loadMap( std::shared_ptr< SDLPP::Scene > &scene,
|
||||
// TODO createModifierBlock with data
|
||||
auto mod = createTerrainBlock(
|
||||
block.getModifierId(), LandType::OVERWORLD, renderer, i, j,
|
||||
g_translucent_mod_texture, false, editor );
|
||||
false, editor );
|
||||
mod->setData(block.getModifierData());
|
||||
mod->setTextureKeepSRC(g_translucent_mod_texture);
|
||||
mod->getCollisions()[0]->setId( EDITOR_TERRAIN_ID );
|
||||
dynamic_cast< MarioBlock * >( mod.get() )->setTerrain( false );
|
||||
scene->addObject( mod );
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "objectids.hpp"
|
||||
#include "sprites.hpp"
|
||||
|
||||
Mario::Mario(const std::shared_ptr< SDLPP::Renderer > &renderer) : SDLPP::RectangleRender(0, 0, BLOCK_SIZE, BLOCK_SIZE, renderer, g_mario_texture, MARIO_STANDING_SRC) {
|
||||
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 );
|
||||
setId( MARIO_ID );
|
||||
setAlignment( SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER );
|
||||
@ -29,6 +29,7 @@ Mario::Mario(const std::shared_ptr< SDLPP::Renderer > &renderer) : SDLPP::Rectan
|
||||
setColiderColor("#FF0000");
|
||||
setStatic( false );
|
||||
}
|
||||
Mario::Mario(const std::shared_ptr< SDLPP::Renderer > &renderer) : Mario(0, 0, renderer) {}
|
||||
void Mario::walkLeft() {
|
||||
if(on_ground)
|
||||
resumeAnimation();
|
||||
@ -138,3 +139,11 @@ void Mario::custom_move( int ticks ) {
|
||||
ticks_till_gravity += base_gravity_ticks;
|
||||
}
|
||||
}
|
||||
|
||||
void Mario::visit(SDLPP::Visitor &/*UNUSED*/) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Mario::setWorldTypeSrc(LandType::Value /*UNUSED*/) {
|
||||
// TODO
|
||||
}
|
||||
|
@ -4,9 +4,12 @@
|
||||
#include "../sdlpp/sdlpp_rectrenderer.hpp"
|
||||
#include "mario_visitor.hpp"
|
||||
#include "sprites.hpp"
|
||||
#include "blocks.hpp"
|
||||
|
||||
class Mario : public SDLPP::RectangleRender {
|
||||
// TODO change to MarioBlock instead of RectangleRender
|
||||
class Mario : public MarioBlock {
|
||||
public:
|
||||
Mario(int x, int y, const std::shared_ptr< SDLPP::Renderer > &renderer);
|
||||
Mario(const std::shared_ptr< SDLPP::Renderer > &renderer);
|
||||
void walkLeft();
|
||||
void walkRight();
|
||||
@ -15,6 +18,7 @@ public:
|
||||
void jump();
|
||||
void stopJump();
|
||||
virtual void custom_move( int ticks ) override;
|
||||
void visit(SDLPP::Visitor &visitor) override;
|
||||
private:
|
||||
bool faces_right = true;
|
||||
double side_movement = 0.39;
|
||||
@ -31,6 +35,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;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -63,6 +63,14 @@ public:
|
||||
return newX;
|
||||
}
|
||||
|
||||
void setCoin() {
|
||||
coin = true;
|
||||
}
|
||||
|
||||
bool hasCoin() {
|
||||
return coin;
|
||||
}
|
||||
|
||||
private:
|
||||
bool onGround = false;
|
||||
double groundY = 0;
|
||||
@ -77,6 +85,7 @@ private:
|
||||
SDLPP::Vec2D<double> rightleftpos;
|
||||
bool top_left_right = false;
|
||||
bool jumping;
|
||||
bool coin = false;
|
||||
SDLPP::Vec2D<double> movement_blockage;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user