Remove redundant functions from blocks.cpp, fix editor problem with pagination
This commit is contained in:
parent
3be728843a
commit
d638108223
@ -18,7 +18,7 @@ LDFLAGS ?= -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_ttf -pthread
|
|||||||
OUTPUTFLAG = -o
|
OUTPUTFLAG = -o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
COMMON_OBJECTS = global_vars.${OBJEXT} sprites.${OBJEXT} maploader.${OBJEXT} mapobject.${OBJEXT} coinblock.${OBJEXT} simpleblocks.${OBJEXT} mario.${OBJEXT}
|
COMMON_OBJECTS = global_vars.${OBJEXT} sprites.${OBJEXT} maploader.${OBJEXT} mapobject.${OBJEXT} coineditorblock.${OBJEXT} simpleblocks.${OBJEXT} mario.${OBJEXT}
|
||||||
ifneq ($(UNAME_S),Windows)
|
ifneq ($(UNAME_S),Windows)
|
||||||
COMMON_OBJECTS += libsdlpp.a
|
COMMON_OBJECTS += libsdlpp.a
|
||||||
endif
|
endif
|
||||||
@ -69,7 +69,7 @@ tool_box.${OBJEXT}: tool_box.cpp ../sdlpp/sdlpp.hpp sprites.hpp tool_box.hpp
|
|||||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||||
editor_visitor.${OBJEXT}: editor_visitor.cpp ../sdlpp/sdlpp.hpp sprites.hpp editor_visitor.hpp
|
editor_visitor.${OBJEXT}: editor_visitor.cpp ../sdlpp/sdlpp.hpp sprites.hpp editor_visitor.hpp
|
||||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||||
coinblock.${OBJEXT}: blocks/coinblock.cpp ../sdlpp/sdlpp.hpp sprites.hpp global_vars.hpp blocks.hpp blocks/coinblock.hpp
|
coineditorblock.${OBJEXT}: blocks/coineditorblock.cpp ../sdlpp/sdlpp.hpp sprites.hpp global_vars.hpp blocks.hpp blocks/coineditorblock.hpp
|
||||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||||
simpleblocks.${OBJEXT}: blocks/simpleblocks.cpp ../sdlpp/sdlpp.hpp sprites.hpp global_vars.hpp blocks.hpp blocks/simpleblocks.hpp
|
simpleblocks.${OBJEXT}: blocks/simpleblocks.cpp ../sdlpp/sdlpp.hpp sprites.hpp global_vars.hpp blocks.hpp blocks/simpleblocks.hpp
|
||||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||||
|
176
mario/blocks.cpp
176
mario/blocks.cpp
@ -1,5 +1,4 @@
|
|||||||
#include "blocks.hpp"
|
#include "blocks.hpp"
|
||||||
#include "blocks/coinblock.hpp"
|
|
||||||
#include "global_vars.hpp"
|
#include "global_vars.hpp"
|
||||||
#include "objectids.hpp"
|
#include "objectids.hpp"
|
||||||
#include "sprites.hpp"
|
#include "sprites.hpp"
|
||||||
@ -7,7 +6,7 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "mario_visitor.hpp"
|
#include "mario_visitor.hpp"
|
||||||
#include "blocks/simpleblocks.hpp"
|
#include "blocks/simpleblocks.hpp"
|
||||||
#include "blocks/coinblock.hpp"
|
#include "blocks/coineditorblock.hpp"
|
||||||
#include "mario.hpp"
|
#include "mario.hpp"
|
||||||
|
|
||||||
#define CAN_BE_DESTROYED_FLAG 0x0000000000000001
|
#define CAN_BE_DESTROYED_FLAG 0x0000000000000001
|
||||||
@ -24,6 +23,7 @@ MarioBlock::MarioBlock( int x, int y,
|
|||||||
setMovementSpeed( 1 );
|
setMovementSpeed( 1 );
|
||||||
_coins = 0;
|
_coins = 0;
|
||||||
_mushroom = false;
|
_mushroom = false;
|
||||||
|
_base_src = src;
|
||||||
}
|
}
|
||||||
void MarioBlock::visit( SDLPP::Visitor &visitor ) {
|
void MarioBlock::visit( SDLPP::Visitor &visitor ) {
|
||||||
#ifdef EDITOR
|
#ifdef EDITOR
|
||||||
@ -128,7 +128,7 @@ void MarioBlock::ensureCollision() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void MarioBlock::setWorldTypeSrc( LandType::Value world ) {
|
void MarioBlock::setWorldTypeSrc( LandType::Value world ) {
|
||||||
auto rect = getTextureSourceRect();
|
auto rect = _base_src;
|
||||||
switch ( world ) {
|
switch ( world ) {
|
||||||
case LandType::OVERWORLD:
|
case LandType::OVERWORLD:
|
||||||
rect.x += OVERWORLD_SHIFT.getX();
|
rect.x += OVERWORLD_SHIFT.getX();
|
||||||
@ -226,151 +226,6 @@ 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 = {
|
|
||||||
{ FLOOR_ID, &FLOOR_SRC },
|
|
||||||
{ HILL_INCLINE_ID, &HILL_INCLINE_SRC },
|
|
||||||
{ HILL_DECLINE_ID, &HILL_DECLINE_SRC },
|
|
||||||
{ HILL_DOTS_RIGHT_ID, &HILL_DOTS_RIGHT_SRC },
|
|
||||||
{ HILL_DOTS_LEFT_ID, &HILL_DOTS_LEFT_SRC },
|
|
||||||
{ HILL_FILL_ID, &HILL_FILL_SRC },
|
|
||||||
{ HILL_TOP_ID, &HILL_TOP_SRC },
|
|
||||||
{ BUSH_LEFT_ID, &BUSH_LEFT_SRC },
|
|
||||||
{ BUSH_MIDDLE_ID, &BUSH_MIDDLE_SRC },
|
|
||||||
{ BUSH_RIGHT_ID, &BUSH_RIGHT_SRC },
|
|
||||||
{ CLOUD_LEFT_BOTTOM_ID, &CLOUD_LEFT_BOTTOM_SRC },
|
|
||||||
{ CLOUD_MIDDLE_BOTTOM_ID, &CLOUD_MIDDLE_BOTTOM_SRC },
|
|
||||||
{ CLOUD_RIGHT_BOTTOM_ID, &CLOUD_RIGHT_BOTTOM_SRC },
|
|
||||||
{ CLOUD_LEFT_TOP_ID, &CLOUD_LEFT_TOP_SRC },
|
|
||||||
{ CLOUD_MIDDLE_TOP_ID, &CLOUD_MIDDLE_TOP_SRC },
|
|
||||||
{ CLOUD_RIGHT_TOP_ID, &CLOUD_RIGHT_TOP_SRC },
|
|
||||||
{ PIPE_LEFT_BOTTOM_ID, &PIPE_LEFT_BOTTOM_SRC },
|
|
||||||
{ PIPE_LEFT_TOP_ID, &PIPE_LEFT_TOP_SRC },
|
|
||||||
{ PIPE_RIGHT_BOTTOM_ID, &PIPE_RIGHT_BOTTOM_SRC },
|
|
||||||
{ PIPE_RIGHT_TOP_ID, &PIPE_RIGHT_TOP_SRC },
|
|
||||||
{ CASTLE_LEFT_ID, &CASTLE_LEFT_SRC },
|
|
||||||
{ CASTLE_RIGHT_ID, &CASTLE_RIGHT_SRC },
|
|
||||||
{ CASTLE_BLACK_ID, &CASTLE_BLACK_SRC },
|
|
||||||
{ CASTLE_ENTRY_ID, &CASTLE_ENTRY_SRC },
|
|
||||||
{ CASTLE_TOWER_ID, &CASTLE_TOWER_SRC },
|
|
||||||
{ CASTLE_TOWER_FILLED_ID, &CASTLE_TOWER_FILLED_SRC },
|
|
||||||
{ VINE_TOP_ID, &VINE_TOP_SRC },
|
|
||||||
{ VINE_BOTTOM_ID, &VINE_BOTTOM_SRC },
|
|
||||||
{ POLE_TOP_ID, &POLE_TOP_SRC },
|
|
||||||
{ POLE_BOTTOM_ID, &POLE_BOTTOM_SRC },
|
|
||||||
{ FLAG_ID, &FLAG_SRC },
|
|
||||||
{ STEP_ID, &STEP_SRC },
|
|
||||||
{ BRICK_ID, &BRICK_SRC },
|
|
||||||
{ BRICK_TOP_ID, &BRICK_TOP_SRC },
|
|
||||||
{ SIDEWAY_PIPE_END_TOP_ID, &SIDEWAY_PIPE_END_TOP_SRC },
|
|
||||||
{ SIDEWAY_PIPE_END_BOTTOM_ID, &SIDEWAY_PIPE_END_BOTTOM_SRC },
|
|
||||||
{ SIDEWAY_PIPE_MIDDLE_TOP_ID, &SIDEWAY_PIPE_MIDDLE_TOP_SRC },
|
|
||||||
{ SIDEWAY_PIPE_MIDDLE_BOTTOM_ID, &SIDEWAY_PIPE_MIDDLE_BOTTOM_SRC },
|
|
||||||
{ SIDEWAY_PIPE_CONNECTOR_TOP_ID, &SIDEWAY_PIPE_CONNECTOR_TOP_SRC },
|
|
||||||
{ SIDEWAY_PIPE_CONNECTOR_BOTTOM_ID, &SIDEWAY_PIPE_CONNECTOR_BOTTOM_SRC },
|
|
||||||
{ TREE_PLATFORM_TOP_LEFT_ID, &TREE_PLATFORM_TOP_LEFT_SRC },
|
|
||||||
{ TREE_PLATFORM_TOP_MIDDLE_ID, &TREE_PLATFORM_TOP_MIDDLE_SRC },
|
|
||||||
{ TREE_PLATFORM_TOP_RIGHT_ID, &TREE_PLATFORM_TOP_RIGHT_SRC },
|
|
||||||
{ TREE_PLATFORM_BARK_ID, &TREE_PLATFORM_BARK_SRC },
|
|
||||||
{ WATER_TOP_ID, &WATER_TOP_SRC },
|
|
||||||
{ WATER_FILL_ID, &WATER_FILL_SRC },
|
|
||||||
{ MUSHROOM_PLATFORM_TOP_LEFT_ID, &MUSHROOM_PLATFORM_TOP_LEFT_SRC },
|
|
||||||
{ MUSHROOM_PLATFORM_TOP_MIDDLE_ID, &MUSHROOM_PLATFORM_TOP_MIDDLE_SRC },
|
|
||||||
{ MUSHROOM_PLATFORM_TOP_RIGHT_ID, &MUSHROOM_PLATFORM_TOP_RIGHT_SRC },
|
|
||||||
{ MUSHROOM_PLATFORM_BARK_TOP_ID, &MUSHROOM_PLATFORM_BARK_TOP_SRC },
|
|
||||||
{ MUSHROOM_PLATFORM_BARK_BOTTOM_ID, &MUSHROOM_PLATFORM_BARK_BOTTOM_SRC },
|
|
||||||
{ TREE_BARK_ID, &TREE_BARK_SRC },
|
|
||||||
{ TREE_LEAVES_SMALL_ID, &TREE_LEAVES_SMALL_SRC },
|
|
||||||
{ TREE_LEAVES_TOP_ID, &TREE_LEAVES_TOP_SRC },
|
|
||||||
{ TREE_LEAVES_BOTTOM_ID, &TREE_LEAVES_BOTTOM_SRC },
|
|
||||||
{ CANNON_TOWER_ID, &CANNON_TOWER_SRC },
|
|
||||||
{ CANNON_PEDESTAL_ID, &CANNON_PEDESTAL_SRC },
|
|
||||||
{ CANNON_ID, &CANNON_SRC },
|
|
||||||
{ MARIO_ID, &MARIO_STANDING_SRC },
|
|
||||||
{ DESTRUCTIBLE_MODIFIER_ID, &MOD_DESTRUCTIBLE_SRC },
|
|
||||||
{ BACKGROUND_MODIFIER_ID, &MOD_BACKGROUND_SRC },
|
|
||||||
{ COIN_MODIFIER_ID, &MOD_COIN_SRC },
|
|
||||||
{ MUSHROOM_MODIFIER_ID, &MOD_MUSHROOM_SRC },
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::unordered_map< uint64_t, uint64_t > block_flags = {
|
|
||||||
{ FLOOR_ID, CAN_BE_DESTROYED_FLAG | HAS_COLLISION },
|
|
||||||
{ HILL_INCLINE_ID, 0 },
|
|
||||||
{ HILL_DECLINE_ID, 0 },
|
|
||||||
{ HILL_DOTS_RIGHT_ID, 0 },
|
|
||||||
{ HILL_DOTS_LEFT_ID, 0 },
|
|
||||||
{ HILL_FILL_ID, 0 },
|
|
||||||
{ HILL_TOP_ID, 0 },
|
|
||||||
{ BUSH_LEFT_ID, 0 },
|
|
||||||
{ BUSH_MIDDLE_ID, 0 },
|
|
||||||
{ BUSH_RIGHT_ID, 0 },
|
|
||||||
{ CLOUD_LEFT_BOTTOM_ID, 0 },
|
|
||||||
{ CLOUD_MIDDLE_BOTTOM_ID, 0 },
|
|
||||||
{ CLOUD_RIGHT_BOTTOM_ID, 0 },
|
|
||||||
{ CLOUD_LEFT_TOP_ID, 0 },
|
|
||||||
{ CLOUD_MIDDLE_TOP_ID, 0 },
|
|
||||||
{ CLOUD_RIGHT_TOP_ID, 0 },
|
|
||||||
{ PIPE_LEFT_BOTTOM_ID, HAS_COLLISION },
|
|
||||||
{ PIPE_LEFT_TOP_ID, HAS_COLLISION },
|
|
||||||
{ PIPE_RIGHT_BOTTOM_ID, HAS_COLLISION },
|
|
||||||
{ PIPE_RIGHT_TOP_ID, HAS_COLLISION },
|
|
||||||
{ CASTLE_LEFT_ID, 0 },
|
|
||||||
{ CASTLE_RIGHT_ID, 0 },
|
|
||||||
{ CASTLE_BLACK_ID, 0 },
|
|
||||||
{ CASTLE_ENTRY_ID, 0 },
|
|
||||||
{ CASTLE_TOWER_ID, 0 },
|
|
||||||
{ CASTLE_TOWER_FILLED_ID, 0 },
|
|
||||||
{ VINE_TOP_ID, HAS_COLLISION },
|
|
||||||
{ VINE_BOTTOM_ID, HAS_COLLISION },
|
|
||||||
{ POLE_TOP_ID, HAS_COLLISION },
|
|
||||||
{ POLE_BOTTOM_ID, HAS_COLLISION },
|
|
||||||
{ FLAG_ID, 0 },
|
|
||||||
{ STEP_ID, CAN_BE_DESTROYED_FLAG | HAS_COLLISION },
|
|
||||||
{ BRICK_ID, CAN_BE_DESTROYED_FLAG | HAS_COLLISION },
|
|
||||||
{ BRICK_TOP_ID, CAN_BE_DESTROYED_FLAG | HAS_COLLISION },
|
|
||||||
{ SIDEWAY_PIPE_END_TOP_ID, HAS_COLLISION },
|
|
||||||
{ SIDEWAY_PIPE_END_BOTTOM_ID, HAS_COLLISION },
|
|
||||||
{ SIDEWAY_PIPE_MIDDLE_TOP_ID, HAS_COLLISION },
|
|
||||||
{ SIDEWAY_PIPE_MIDDLE_BOTTOM_ID, HAS_COLLISION },
|
|
||||||
{ SIDEWAY_PIPE_CONNECTOR_TOP_ID, HAS_COLLISION },
|
|
||||||
{ SIDEWAY_PIPE_CONNECTOR_BOTTOM_ID, HAS_COLLISION },
|
|
||||||
{ TREE_PLATFORM_TOP_LEFT_ID, HAS_COLLISION },
|
|
||||||
{ TREE_PLATFORM_TOP_MIDDLE_ID, HAS_COLLISION },
|
|
||||||
{ TREE_PLATFORM_TOP_RIGHT_ID, HAS_COLLISION },
|
|
||||||
{ TREE_PLATFORM_BARK_ID, HAS_COLLISION },
|
|
||||||
{ WATER_TOP_ID, HAS_COLLISION },
|
|
||||||
{ WATER_FILL_ID, HAS_COLLISION },
|
|
||||||
{ MUSHROOM_PLATFORM_TOP_LEFT_ID, HAS_COLLISION },
|
|
||||||
{ MUSHROOM_PLATFORM_TOP_MIDDLE_ID, HAS_COLLISION },
|
|
||||||
{ MUSHROOM_PLATFORM_TOP_RIGHT_ID, HAS_COLLISION },
|
|
||||||
{ MUSHROOM_PLATFORM_BARK_TOP_ID, HAS_COLLISION },
|
|
||||||
{ MUSHROOM_PLATFORM_BARK_BOTTOM_ID, HAS_COLLISION },
|
|
||||||
{ TREE_BARK_ID, HAS_COLLISION },
|
|
||||||
{ TREE_LEAVES_SMALL_ID, HAS_COLLISION },
|
|
||||||
{ TREE_LEAVES_TOP_ID, HAS_COLLISION },
|
|
||||||
{ TREE_LEAVES_BOTTOM_ID, HAS_COLLISION },
|
|
||||||
{ CANNON_TOWER_ID, HAS_COLLISION },
|
|
||||||
{ CANNON_PEDESTAL_ID, HAS_COLLISION },
|
|
||||||
{ CANNON_ID, HAS_COLLISION },
|
|
||||||
{ MARIO_ID, 0 },
|
|
||||||
{ DESTRUCTIBLE_MODIFIER_ID, 0 },
|
|
||||||
{ BACKGROUND_MODIFIER_ID, 0 },
|
|
||||||
};
|
|
||||||
|
|
||||||
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() ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return it->second & HAS_COLLISION;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr< MarioBlock >
|
std::shared_ptr< MarioBlock >
|
||||||
createBlockById( uint64_t id, int x, int y,
|
createBlockById( uint64_t id, int x, int y,
|
||||||
std::shared_ptr< SDLPP::Renderer > &renderer ) {
|
std::shared_ptr< SDLPP::Renderer > &renderer ) {
|
||||||
@ -660,31 +515,6 @@ createBlock( std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Rect getSourceRectByID( uint64_t id, LandType::Value type ) {
|
|
||||||
auto mapping = block_mapping.find( id );
|
|
||||||
if ( mapping == block_mapping.end() )
|
|
||||||
return {};
|
|
||||||
SDL_Rect ret_src = *mapping->second;
|
|
||||||
switch ( type ) {
|
|
||||||
case LandType::OVERWORLD:
|
|
||||||
ret_src.x += OVERWORLD_SHIFT.getX();
|
|
||||||
ret_src.y += OVERWORLD_SHIFT.getY();
|
|
||||||
break;
|
|
||||||
case LandType::UNDERWORLD:
|
|
||||||
ret_src.x += UNDERWORLD_SHIFT.getX();
|
|
||||||
ret_src.y += UNDERWORLD_SHIFT.getY();
|
|
||||||
break;
|
|
||||||
case LandType::WATER:
|
|
||||||
ret_src.x += WATER_SHIFT.getX();
|
|
||||||
ret_src.y += WATER_SHIFT.getY();
|
|
||||||
break;
|
|
||||||
case LandType::BOWSER:
|
|
||||||
ret_src.x += BOWSER_SHIFT.getX();
|
|
||||||
ret_src.y += BOWSER_SHIFT.getY();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ret_src;
|
|
||||||
}
|
|
||||||
// TODO coin count
|
// TODO coin count
|
||||||
std::shared_ptr< MarioBlock >
|
std::shared_ptr< MarioBlock >
|
||||||
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define BLOCKS_H
|
#define BLOCKS_H
|
||||||
|
|
||||||
#include "../sdlpp/sdlpp_rectrenderer.hpp"
|
#include "../sdlpp/sdlpp_rectrenderer.hpp"
|
||||||
#include "../sdlpp/sdlpp_fontconfiguration.hpp"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
struct LandType {
|
struct LandType {
|
||||||
@ -11,8 +10,10 @@ struct LandType {
|
|||||||
|
|
||||||
class MarioBlock : public SDLPP::RectangleRender {
|
class MarioBlock : public SDLPP::RectangleRender {
|
||||||
public:
|
public:
|
||||||
MarioBlock( int x, int y, const std::shared_ptr< SDLPP::Renderer > &renderer,
|
MarioBlock( int x, int y,
|
||||||
std::shared_ptr< SDLPP::Texture > texture, SDL_Rect src, bool can_be_destroyed = false, bool destructible = false );
|
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 visit( SDLPP::Visitor &visitor ) override;
|
||||||
void setTool( bool tool = true );
|
void setTool( bool tool = true );
|
||||||
void setTerrain( bool terrain = true );
|
void setTerrain( bool terrain = true );
|
||||||
@ -22,7 +23,9 @@ public:
|
|||||||
LandType::Value getType() const;
|
LandType::Value getType() const;
|
||||||
virtual void onScrollUp() {}
|
virtual void onScrollUp() {}
|
||||||
virtual void onScrollDown() {}
|
virtual void onScrollDown() {}
|
||||||
virtual uint8_t getData() {return 0;}
|
virtual uint8_t getData() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
virtual void setData( uint8_t /*UNUSED*/ ) {}
|
virtual void setData( uint8_t /*UNUSED*/ ) {}
|
||||||
bool hasCoin();
|
bool hasCoin();
|
||||||
bool hasMushroom();
|
bool hasMushroom();
|
||||||
@ -44,6 +47,7 @@ private:
|
|||||||
int ticks_to_bounce = bounce_ticks;
|
int ticks_to_bounce = bounce_ticks;
|
||||||
SDLPP::Vec2D< double > og_pos = {};
|
SDLPP::Vec2D< double > og_pos = {};
|
||||||
LandType::Value _type;
|
LandType::Value _type;
|
||||||
|
SDL_Rect _base_src;
|
||||||
|
|
||||||
virtual void setWorldTypeSrc( LandType::Value world );
|
virtual void setWorldTypeSrc( LandType::Value world );
|
||||||
};
|
};
|
||||||
@ -76,6 +80,4 @@ createMario( LandType::Value type, std::shared_ptr< SDLPP::Renderer > &renderer,
|
|||||||
|
|
||||||
enum BlockRole::Value getBlockRole( uint64_t id );
|
enum BlockRole::Value getBlockRole( uint64_t id );
|
||||||
|
|
||||||
SDL_Rect getSourceRectByID( uint64_t id, LandType::Value type );
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
#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
|
|
@ -20,7 +20,7 @@
|
|||||||
#include "edit_box.hpp"
|
#include "edit_box.hpp"
|
||||||
#include "editor_visitor.hpp"
|
#include "editor_visitor.hpp"
|
||||||
#include "tool_box.hpp"
|
#include "tool_box.hpp"
|
||||||
#include "blocks/coinblock.hpp"
|
#include "blocks/coineditorblock.hpp"
|
||||||
|
|
||||||
#define MAP_WIDTH 24
|
#define MAP_WIDTH 24
|
||||||
#define MAP_HEIGHT 16
|
#define MAP_HEIGHT 16
|
||||||
@ -66,6 +66,7 @@ struct MapInfo {
|
|||||||
struct ToolInfo {
|
struct ToolInfo {
|
||||||
ToolType::Value type;
|
ToolType::Value type;
|
||||||
uint64_t index;
|
uint64_t index;
|
||||||
|
SDL_Rect texture_src;
|
||||||
int cur_page_tools;
|
int cur_page_tools;
|
||||||
int max_page_tools;
|
int max_page_tools;
|
||||||
int cur_page_mods;
|
int cur_page_mods;
|
||||||
@ -80,9 +81,9 @@ struct GlobalVars {
|
|||||||
ToolInfo tool;
|
ToolInfo tool;
|
||||||
uint64_t flags;
|
uint64_t flags;
|
||||||
std::vector< mapColumnType > objects;
|
std::vector< mapColumnType > objects;
|
||||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > tools;
|
std::vector< std::shared_ptr< MarioBlock > > tools;
|
||||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > mods;
|
std::vector< std::shared_ptr< MarioBlock > > mods;
|
||||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > characters;
|
std::vector< std::shared_ptr< MarioBlock > > characters;
|
||||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > tool_boxes;
|
std::vector< std::shared_ptr< SDLPP::RenderObject > > tool_boxes;
|
||||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > mod_boxes;
|
std::vector< std::shared_ptr< SDLPP::RenderObject > > mod_boxes;
|
||||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > character_boxes;
|
std::vector< std::shared_ptr< SDLPP::RenderObject > > character_boxes;
|
||||||
@ -117,17 +118,22 @@ void updateTool() {
|
|||||||
}
|
}
|
||||||
auto tool_role = getBlockRole( tool_id );
|
auto tool_role = getBlockRole( tool_id );
|
||||||
std::shared_ptr< SDLPP::Texture > target_texture = nullptr;
|
std::shared_ptr< SDLPP::Texture > target_texture = nullptr;
|
||||||
|
SDL_Rect target_src;
|
||||||
switch ( tool_role ) {
|
switch ( tool_role ) {
|
||||||
case BlockRole::TERRAIN:
|
case BlockRole::TERRAIN:
|
||||||
target_texture = global_vars.translucent_terrain_texture;
|
target_texture = global_vars.translucent_terrain_texture;
|
||||||
|
target_src = global_vars.tools[global_vars.tool.index]->getTextureSourceRect();
|
||||||
break;
|
break;
|
||||||
case BlockRole::MARIO:
|
case BlockRole::MARIO:
|
||||||
target_texture = global_vars.translucent_mario_texture;
|
target_texture = global_vars.translucent_mario_texture;
|
||||||
|
target_src = global_vars.characters[global_vars.tool.index]->getTextureSourceRect();
|
||||||
break;
|
break;
|
||||||
case BlockRole::MODIFIER:
|
case BlockRole::MODIFIER:
|
||||||
target_texture = global_vars.translucent_mod_texture;
|
target_texture = global_vars.translucent_mod_texture;
|
||||||
|
target_src = global_vars.mods[global_vars.tool.index]->getTextureSourceRect();
|
||||||
break;
|
break;
|
||||||
case BlockRole::CHARACTER:
|
case BlockRole::CHARACTER:
|
||||||
|
target_src = global_vars.characters[global_vars.tool.index]->getTextureSourceRect();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
global_vars.current_tool->setHidden( true );
|
global_vars.current_tool->setHidden( true );
|
||||||
@ -137,9 +143,7 @@ void updateTool() {
|
|||||||
} else {
|
} else {
|
||||||
global_vars.generic_tool->setPos( global_vars.current_tool->getPos() );
|
global_vars.generic_tool->setPos( global_vars.current_tool->getPos() );
|
||||||
global_vars.current_tool = global_vars.generic_tool;
|
global_vars.current_tool = global_vars.generic_tool;
|
||||||
global_vars.current_tool->setTexture(
|
global_vars.current_tool->setTexture( target_texture, target_src );
|
||||||
target_texture,
|
|
||||||
getSourceRectByID( tool_id, global_vars.current_world_type ) );
|
|
||||||
global_vars.current_tool->setId( tool_id );
|
global_vars.current_tool->setId( tool_id );
|
||||||
global_vars.current_tool->getCollisions()[0]->setId( tool_id );
|
global_vars.current_tool->getCollisions()[0]->setId( tool_id );
|
||||||
}
|
}
|
||||||
@ -193,7 +197,7 @@ void updateToolSelection( int prev_index, ToolType::Value type ) {
|
|||||||
unsetToolColor();
|
unsetToolColor();
|
||||||
size_t cur_page = 0;
|
size_t cur_page = 0;
|
||||||
size_t multiplier = 0;
|
size_t multiplier = 0;
|
||||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > *tool_vec = nullptr;
|
std::vector< std::shared_ptr< MarioBlock > > *tool_vec = nullptr;
|
||||||
switch ( type ) {
|
switch ( type ) {
|
||||||
case ToolType::BLOCK:
|
case ToolType::BLOCK:
|
||||||
cur_page = global_vars.tool.cur_page_tools;
|
cur_page = global_vars.tool.cur_page_tools;
|
||||||
@ -272,7 +276,7 @@ void moveToolsRight( ToolType::Value type ) {
|
|||||||
void updateToolIndex( uint64_t new_index, ToolType::Value new_type ) {
|
void updateToolIndex( uint64_t new_index, ToolType::Value new_type ) {
|
||||||
int multiplier = 0;
|
int multiplier = 0;
|
||||||
int *page = nullptr;
|
int *page = nullptr;
|
||||||
switch ( global_vars.tool.type ) {
|
switch ( new_type ) {
|
||||||
case ToolType::BLOCK:
|
case ToolType::BLOCK:
|
||||||
multiplier = 2 * TOOLS_WIDTH;
|
multiplier = 2 * TOOLS_WIDTH;
|
||||||
page = &global_vars.tool.cur_page_tools;
|
page = &global_vars.tool.cur_page_tools;
|
||||||
@ -416,20 +420,13 @@ bool getFlag( uint64_t flag ) {
|
|||||||
|
|
||||||
void updateWorld() {
|
void updateWorld() {
|
||||||
for ( auto &block : global_vars.tools ) {
|
for ( auto &block : global_vars.tools ) {
|
||||||
block->setTextureSourceRect( getSourceRectByID(
|
block->setType( global_vars.current_world_type );
|
||||||
block->getId(), global_vars.current_world_type ) );
|
|
||||||
dynamic_cast< MarioBlock * >( block.get() )
|
|
||||||
->setType( global_vars.current_world_type );
|
|
||||||
}
|
}
|
||||||
for ( auto &block : global_vars.characters ) {
|
for ( auto &block : global_vars.characters ) {
|
||||||
block->setTextureSourceRect( getSourceRectByID(
|
block->setType( global_vars.current_world_type );
|
||||||
block->getId(), global_vars.current_world_type ) );
|
|
||||||
dynamic_cast< MarioBlock * >( block.get() )
|
|
||||||
->setType( global_vars.current_world_type );
|
|
||||||
}
|
}
|
||||||
if(getBlockRole(global_vars.current_tool->getId()) != BlockRole::MODIFIER) {
|
if ( getBlockRole( global_vars.current_tool->getId() ) !=
|
||||||
global_vars.current_tool->setTextureSourceRect( getSourceRectByID(
|
BlockRole::MODIFIER ) {
|
||||||
global_vars.current_tool->getId(), global_vars.current_world_type ) );
|
|
||||||
global_vars.current_tool->setType( global_vars.current_world_type );
|
global_vars.current_tool->setType( global_vars.current_world_type );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -582,7 +579,6 @@ void placeTool( SDLPP::Scene &scene ) {
|
|||||||
scene.visitCollisions( *global_vars.current_tool, visitor );
|
scene.visitCollisions( *global_vars.current_tool, visitor );
|
||||||
auto &obj = getSelectedObject();
|
auto &obj = getSelectedObject();
|
||||||
if ( visitor.removeBlock() && !visitor.addBlock() ) {
|
if ( visitor.removeBlock() && !visitor.addBlock() ) {
|
||||||
std::cout << "DO NOT ADD" << std::endl;
|
|
||||||
switch ( visitor.getVisitorType() ) {
|
switch ( visitor.getVisitorType() ) {
|
||||||
case VisitorType::Terrain:
|
case VisitorType::Terrain:
|
||||||
obj.unsetTerrain();
|
obj.unsetTerrain();
|
||||||
@ -594,7 +590,6 @@ void placeTool( SDLPP::Scene &scene ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if ( visitor.addBlock() ) {
|
} else if ( visitor.addBlock() ) {
|
||||||
std::cout << "ADD" << std::endl;
|
|
||||||
auto renderer = scene.getRendererShared();
|
auto renderer = scene.getRendererShared();
|
||||||
int z_index = 1;
|
int z_index = 1;
|
||||||
std::shared_ptr< MarioBlock > new_obj = nullptr;
|
std::shared_ptr< MarioBlock > new_obj = nullptr;
|
||||||
@ -603,8 +598,7 @@ void placeTool( SDLPP::Scene &scene ) {
|
|||||||
obj.setTerrain( global_vars.current_tool->getId(),
|
obj.setTerrain( global_vars.current_tool->getId(),
|
||||||
global_vars.current_world_type );
|
global_vars.current_world_type );
|
||||||
new_obj = createTerrainBlock(
|
new_obj = createTerrainBlock(
|
||||||
obj.getTerrainId(),
|
obj.getTerrainId(), obj.getTerrainType(), renderer,
|
||||||
obj.getTerrainType(), renderer,
|
|
||||||
global_vars.mouse.edit_box.getX(),
|
global_vars.mouse.edit_box.getX(),
|
||||||
global_vars.mouse.edit_box.getY(), false, true );
|
global_vars.mouse.edit_box.getY(), false, true );
|
||||||
new_obj->getCollisions()[0]->setId( EDITOR_TERRAIN_ID );
|
new_obj->getCollisions()[0]->setId( EDITOR_TERRAIN_ID );
|
||||||
@ -612,7 +606,8 @@ void placeTool( SDLPP::Scene &scene ) {
|
|||||||
case VisitorType::Modifier:
|
case VisitorType::Modifier:
|
||||||
if ( tool_type == BlockRole::MARIO ) {
|
if ( tool_type == BlockRole::MARIO ) {
|
||||||
obj.setCharacter( MARIO_ID, global_vars.current_world_type );
|
obj.setCharacter( MARIO_ID, global_vars.current_world_type );
|
||||||
new_obj = createMario( global_vars.current_world_type, renderer,
|
new_obj =
|
||||||
|
createMario( global_vars.current_world_type, renderer,
|
||||||
global_vars.mouse.edit_box.getX(),
|
global_vars.mouse.edit_box.getX(),
|
||||||
global_vars.mouse.edit_box.getY(), true );
|
global_vars.mouse.edit_box.getY(), true );
|
||||||
// remove mario if exists
|
// remove mario if exists
|
||||||
@ -623,14 +618,14 @@ void placeTool( SDLPP::Scene &scene ) {
|
|||||||
z_index = scene.getObjects().size() - 1;
|
z_index = scene.getObjects().size() - 1;
|
||||||
// TODO BlockRole::Character
|
// TODO BlockRole::Character
|
||||||
} else {
|
} else {
|
||||||
obj.setModifier(global_vars.current_tool->getId(), global_vars.current_tool->getData());
|
obj.setModifier( global_vars.current_tool->getId(),
|
||||||
|
global_vars.current_tool->getData() );
|
||||||
new_obj = createTerrainBlock(
|
new_obj = createTerrainBlock(
|
||||||
obj.getModifierId(),
|
obj.getModifierId(), LandType::OVERWORLD, renderer,
|
||||||
LandType::OVERWORLD, renderer,
|
|
||||||
global_vars.mouse.edit_box.getX(),
|
global_vars.mouse.edit_box.getX(),
|
||||||
global_vars.mouse.edit_box.getY(),
|
global_vars.mouse.edit_box.getY(), false, true );
|
||||||
false, true );
|
new_obj->setTextureKeepSRC(
|
||||||
new_obj->setTextureKeepSRC(global_vars.translucent_mod_texture);
|
global_vars.translucent_mod_texture );
|
||||||
new_obj->setData( global_vars.current_tool->getData() );
|
new_obj->setData( global_vars.current_tool->getData() );
|
||||||
new_obj->getCollisions()[0]->setId( EDITOR_TERRAIN_ID );
|
new_obj->getCollisions()[0]->setId( EDITOR_TERRAIN_ID );
|
||||||
// TODO createModifierBlock
|
// TODO createModifierBlock
|
||||||
@ -804,7 +799,7 @@ createArrowControls(
|
|||||||
void populateToolGrid(
|
void populateToolGrid(
|
||||||
int count_x, int count_y, float start_x, float start_y,
|
int count_x, int count_y, float start_x, float start_y,
|
||||||
ToolType::Value type, const std::vector< uint64_t > &blocks,
|
ToolType::Value type, const std::vector< uint64_t > &blocks,
|
||||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > &tool_store,
|
std::vector< std::shared_ptr< MarioBlock > > &tool_store,
|
||||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > &tool_box_store,
|
std::vector< std::shared_ptr< SDLPP::RenderObject > > &tool_box_store,
|
||||||
std::shared_ptr< SDLPP::Scene > &scene, const std::string &title,
|
std::shared_ptr< SDLPP::Scene > &scene, const std::string &title,
|
||||||
const std::shared_ptr< SDLPP::FontConfiguration > &font_config ) {
|
const std::shared_ptr< SDLPP::FontConfiguration > &font_config ) {
|
||||||
@ -958,13 +953,13 @@ int main() {
|
|||||||
renderer, "sprites/terrain.png", MARIO_OVERWORLD_COLORKEY );
|
renderer, "sprites/terrain.png", MARIO_OVERWORLD_COLORKEY );
|
||||||
g_mario_texture = std::make_shared< SDLPP::Texture >(
|
g_mario_texture = std::make_shared< SDLPP::Texture >(
|
||||||
renderer, "sprites/mario.png", MARIO_OVERWORLD_COLORKEY );
|
renderer, "sprites/mario.png", MARIO_OVERWORLD_COLORKEY );
|
||||||
g_mod_texture = std::make_shared<SDLPP::Texture>(
|
g_mod_texture =
|
||||||
renderer, "sprites/mods.png");
|
std::make_shared< SDLPP::Texture >( renderer, "sprites/mods.png" );
|
||||||
g_translucent_terrain_texture = std::make_shared< SDLPP::Texture >(
|
g_translucent_terrain_texture = std::make_shared< SDLPP::Texture >(
|
||||||
renderer, "sprites/terrain.png", MARIO_OVERWORLD_COLORKEY );
|
renderer, "sprites/terrain.png", MARIO_OVERWORLD_COLORKEY );
|
||||||
g_translucent_terrain_texture->setAlpha( 100 );
|
g_translucent_terrain_texture->setAlpha( 100 );
|
||||||
g_translucent_mod_texture = std::make_shared<SDLPP::Texture>(
|
g_translucent_mod_texture =
|
||||||
renderer, "sprites/mods.png");
|
std::make_shared< SDLPP::Texture >( renderer, "sprites/mods.png" );
|
||||||
g_translucent_mod_texture->setAlpha( 100 );
|
g_translucent_mod_texture->setAlpha( 100 );
|
||||||
|
|
||||||
auto scene = std::make_shared< SDLPP::Scene >( renderer );
|
auto scene = std::make_shared< SDLPP::Scene >( renderer );
|
||||||
@ -977,8 +972,8 @@ int main() {
|
|||||||
global_vars.current_world_type = LandType::OVERWORLD;
|
global_vars.current_world_type = LandType::OVERWORLD;
|
||||||
|
|
||||||
// TODO file name
|
// TODO file name
|
||||||
loadMap( scene, global_vars.mario, "test_binary.bin",
|
loadMap( scene, global_vars.mario, "test_binary.bin", global_vars.objects,
|
||||||
global_vars.objects, true, MAP_WIDTH );
|
true, MAP_WIDTH );
|
||||||
|
|
||||||
// create grids and arrow controls
|
// create grids and arrow controls
|
||||||
// map
|
// map
|
||||||
@ -1076,16 +1071,18 @@ int main() {
|
|||||||
global_vars.translucent_mario_texture = std::make_shared< SDLPP::Texture >(
|
global_vars.translucent_mario_texture = std::make_shared< SDLPP::Texture >(
|
||||||
renderer, "sprites/mario.png", MARIO_OVERWORLD_COLORKEY );
|
renderer, "sprites/mario.png", MARIO_OVERWORLD_COLORKEY );
|
||||||
global_vars.translucent_mario_texture->setAlpha( 100 );
|
global_vars.translucent_mario_texture->setAlpha( 100 );
|
||||||
global_vars.generic_tool = createTerrainBlock(
|
global_vars.generic_tool =
|
||||||
possibleBlocks[global_vars.tool.index], global_vars.current_world_type,
|
createTerrainBlock( possibleBlocks[global_vars.tool.index],
|
||||||
renderer, false );
|
global_vars.current_world_type, renderer, false );
|
||||||
global_vars.generic_tool->setTextureKeepSRC(global_vars.translucent_terrain_texture);
|
global_vars.generic_tool->setTextureKeepSRC(
|
||||||
|
global_vars.translucent_terrain_texture );
|
||||||
global_vars.generic_tool->removeCollisions();
|
global_vars.generic_tool->removeCollisions();
|
||||||
global_vars.generic_tool->addCollision(
|
global_vars.generic_tool->addCollision(
|
||||||
SDLPP::RectColider( 0.1, 0.1, 0.8, 0.8 ) );
|
SDLPP::RectColider( 0.1, 0.1, 0.8, 0.8 ) );
|
||||||
global_vars.current_tool = global_vars.generic_tool;
|
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 = createTerrainBlock(
|
||||||
|
COIN_MODIFIER_ID, LandType::OVERWORLD, renderer, 0, 0, false, true );
|
||||||
global_vars.coin_tool->setData( 1 );
|
global_vars.coin_tool->setData( 1 );
|
||||||
global_vars.coin_tool->removeCollisions();
|
global_vars.coin_tool->removeCollisions();
|
||||||
global_vars.coin_tool->addCollision(
|
global_vars.coin_tool->addCollision(
|
||||||
|
@ -131,8 +131,7 @@ void loadMap( std::shared_ptr< SDLPP::Scene > &scene,
|
|||||||
auto obj = createTerrainBlock(
|
auto obj = createTerrainBlock(
|
||||||
block.getTerrainId(), block.getTerrainType(),
|
block.getTerrainId(), block.getTerrainType(),
|
||||||
renderer, i, j, destructible, editor );
|
renderer, i, j, destructible, editor );
|
||||||
if(obj == nullptr)
|
if(obj != nullptr) {
|
||||||
continue;
|
|
||||||
obj->setCoinCount(coinCount);
|
obj->setCoinCount(coinCount);
|
||||||
if(removeCollisions) {
|
if(removeCollisions) {
|
||||||
obj->removeCollisions();
|
obj->removeCollisions();
|
||||||
@ -144,6 +143,7 @@ void loadMap( std::shared_ptr< SDLPP::Scene > &scene,
|
|||||||
scene->addObject( obj );
|
scene->addObject( obj );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ( block.hasCharacter() ) {
|
if ( block.hasCharacter() ) {
|
||||||
if ( block.getCharacterId() == MARIO_ID ) {
|
if ( block.getCharacterId() == MARIO_ID ) {
|
||||||
if ( editor ) {
|
if ( editor ) {
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "sprites.hpp"
|
#include "sprites.hpp"
|
||||||
#include "blocks.hpp"
|
#include "blocks.hpp"
|
||||||
|
|
||||||
// TODO change to MarioBlock instead of RectangleRender
|
|
||||||
class Mario : public MarioBlock {
|
class Mario : public MarioBlock {
|
||||||
public:
|
public:
|
||||||
Mario( int x, int y, const std::shared_ptr< SDLPP::Renderer > &renderer );
|
Mario( int x, int y, const std::shared_ptr< SDLPP::Renderer > &renderer );
|
||||||
@ -19,6 +18,7 @@ public:
|
|||||||
void stopJump();
|
void stopJump();
|
||||||
virtual void custom_move( int ticks ) override;
|
virtual void custom_move( int ticks ) override;
|
||||||
void visit( SDLPP::Visitor &visitor ) override;
|
void visit( SDLPP::Visitor &visitor ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool faces_right = true;
|
bool faces_right = true;
|
||||||
double side_movement = 0.39;
|
double side_movement = 0.39;
|
||||||
|
Loading…
Reference in New Issue
Block a user