Mod texture
This commit is contained in:
parent
b423ac7b8c
commit
2617156833
@ -156,6 +156,8 @@ const std::vector< uint64_t > possibleBlocks = {
|
||||
const std::vector< uint64_t > possibleMods = {
|
||||
DESTRUCTIBLE_MODIFIER_ID,
|
||||
BACKGROUND_MODIFIER_ID,
|
||||
COIN_MODIFIER_ID,
|
||||
MUSHROOM_MODIFIER_ID,
|
||||
};
|
||||
|
||||
const std::vector< uint64_t > possibleCharacters = {
|
||||
@ -229,8 +231,10 @@ const std::unordered_map< uint64_t, const SDL_Rect * > block_mapping = {
|
||||
{ CANNON_PEDESTAL_ID, &CANNON_PEDESTAL_SRC },
|
||||
{ CANNON_ID, &CANNON_SRC },
|
||||
{ MARIO_ID, &MARIO_STANDING_SRC },
|
||||
{ DESTRUCTIBLE_MODIFIER_ID, &DESTRUCTIBLE_SRC },
|
||||
{ BACKGROUND_MODIFIER_ID, &BACKGROUND_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 = {
|
||||
|
@ -89,6 +89,7 @@ struct GlobalVars {
|
||||
std::shared_ptr< SDLPP::RenderObject > 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;
|
||||
std::shared_ptr< SDLPP::RenderObject > mario;
|
||||
SDLPP::Vec2D< int > mario_pos;
|
||||
};
|
||||
@ -121,7 +122,7 @@ void updateTool() {
|
||||
target_texture = global_vars.translucent_mario_texture;
|
||||
break;
|
||||
case BlockRole::MODIFIER:
|
||||
target_texture = global_vars.translucent_terrain_texture;
|
||||
target_texture = global_vars.translucent_mod_texture;
|
||||
break;
|
||||
case BlockRole::CHARACTER:
|
||||
break;
|
||||
@ -614,7 +615,7 @@ void placeTool( SDLPP::Scene &scene ) {
|
||||
LandType::OVERWORLD, renderer,
|
||||
global_vars.mouse.edit_box.getX(),
|
||||
global_vars.mouse.edit_box.getY(),
|
||||
global_vars.translucent_terrain_texture, false, true );
|
||||
global_vars.translucent_mod_texture, false, true );
|
||||
new_obj->getCollisions()[0]->setId( EDITOR_TERRAIN_ID );
|
||||
// TODO createModifierBlock
|
||||
dynamic_cast< MarioBlock * >( new_obj.get() )
|
||||
@ -796,16 +797,22 @@ void populateToolGrid(
|
||||
for ( auto &block : blocks ) {
|
||||
switch ( type ) {
|
||||
case ToolType::CHARACTER:
|
||||
if ( block == MARIO_ID )
|
||||
if ( block == MARIO_ID ) {
|
||||
tool_store.push_back( createMario(
|
||||
global_vars.current_world_type, renderer, 0, 0 ) );
|
||||
else
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
case ToolType::BLOCK:
|
||||
case ToolType::MOD:
|
||||
tool_store.push_back(
|
||||
createTerrainBlock( block, global_vars.current_world_type,
|
||||
renderer, g_mod_texture, false, true ) );
|
||||
break;
|
||||
case ToolType::BLOCK:
|
||||
tool_store.push_back(
|
||||
createTerrainBlock( block, global_vars.current_world_type,
|
||||
renderer, false, true ) );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -922,9 +929,14 @@ int main() {
|
||||
renderer, "sprites/terrain.png", MARIO_OVERWORLD_COLORKEY );
|
||||
g_mario_texture = std::make_shared< SDLPP::Texture >(
|
||||
renderer, "sprites/mario.png", MARIO_OVERWORLD_COLORKEY );
|
||||
g_mod_texture = std::make_shared<SDLPP::Texture>(
|
||||
renderer, "sprites/mods.png");
|
||||
g_translucent_terrain_texture = std::make_shared< SDLPP::Texture >(
|
||||
renderer, "sprites/terrain.png", MARIO_OVERWORLD_COLORKEY );
|
||||
g_translucent_terrain_texture->setAlpha( 100 );
|
||||
g_translucent_mod_texture = std::make_shared<SDLPP::Texture>(
|
||||
renderer, "sprites/mods.png");
|
||||
g_translucent_mod_texture->setAlpha( 100 );
|
||||
|
||||
auto scene = std::make_shared< SDLPP::Scene >( renderer );
|
||||
auto bg = std::make_shared< SDLPP::RectangleRender >(
|
||||
@ -1045,6 +1057,7 @@ int main() {
|
||||
global_vars.current_tool->removeCollisions();
|
||||
global_vars.current_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->moveZTop( global_vars.current_tool );
|
||||
|
@ -3,5 +3,7 @@
|
||||
|
||||
std::shared_ptr< SDLPP::Texture > g_terrain_texture{};
|
||||
std::shared_ptr< SDLPP::Texture > g_mario_texture{};
|
||||
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{};
|
||||
|
@ -5,7 +5,9 @@
|
||||
|
||||
extern std::shared_ptr< SDLPP::Texture > g_terrain_texture;
|
||||
extern std::shared_ptr< SDLPP::Texture > g_mario_texture;
|
||||
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;
|
||||
|
||||
#endif
|
||||
|
@ -154,7 +154,7 @@ void loadMap( std::shared_ptr< SDLPP::Scene > &scene,
|
||||
// TODO createModifierBlock with data
|
||||
auto mod = createTerrainBlock(
|
||||
block.getModifierId(), LandType::OVERWORLD, renderer, i, j,
|
||||
g_translucent_terrain_texture, false, editor );
|
||||
g_translucent_mod_texture, false, editor );
|
||||
mod->getCollisions()[0]->setId( EDITOR_TERRAIN_ID );
|
||||
dynamic_cast< MarioBlock * >( mod.get() )->setTerrain( false );
|
||||
scene->addObject( mod );
|
||||
|
@ -65,6 +65,8 @@
|
||||
// modifiers
|
||||
#define DESTRUCTIBLE_MODIFIER_ID 0x01
|
||||
#define BACKGROUND_MODIFIER_ID 0x02
|
||||
#define COIN_MODIFIER_ID 0x03
|
||||
#define MUSHROOM_MODIFIER_ID 0x04
|
||||
|
||||
// character IDs
|
||||
#define MARIO_ID 0x0F
|
||||
|
@ -79,8 +79,10 @@ const SDL_Rect CANNON_TOWER_SRC = {256, 46, 16, 16};
|
||||
const SDL_Rect CANNON_PEDESTAL_SRC = {256, 29, 16, 16};
|
||||
const SDL_Rect CANNON_SRC = {256, 12, 16, 16};
|
||||
|
||||
extern const SDL_Rect DESTRUCTIBLE_SRC = {0, 0, 16, 16};
|
||||
extern const SDL_Rect BACKGROUND_SRC = {16, 0, 16, 16};
|
||||
extern const SDL_Rect MOD_DESTRUCTIBLE_SRC = {0, 0, 16, 16};
|
||||
extern const SDL_Rect MOD_BACKGROUND_SRC = {16, 0, 16, 16};
|
||||
extern const SDL_Rect MOD_COIN_SRC = {32, 0, 16, 16};
|
||||
extern const SDL_Rect MOD_MUSHROOM_SRC = {48, 0, 16, 16};
|
||||
|
||||
const SDLPP::Vec2D<uint64_t> OVERWORLD_SHIFT = {0, 0};
|
||||
const SDLPP::Vec2D<uint64_t> UNDERWORLD_SHIFT = {274, 0};
|
||||
|
@ -87,8 +87,10 @@ extern const SDL_Rect CANNON_TOWER_SRC;
|
||||
extern const SDL_Rect CANNON_PEDESTAL_SRC;
|
||||
extern const SDL_Rect CANNON_SRC;
|
||||
//------------------ MODIFIERS ----------------------
|
||||
extern const SDL_Rect DESTRUCTIBLE_SRC;
|
||||
extern const SDL_Rect BACKGROUND_SRC;
|
||||
extern const SDL_Rect MOD_DESTRUCTIBLE_SRC;
|
||||
extern const SDL_Rect MOD_BACKGROUND_SRC;
|
||||
extern const SDL_Rect MOD_COIN_SRC;
|
||||
extern const SDL_Rect MOD_MUSHROOM_SRC;
|
||||
|
||||
extern const SDLPP::Vec2D<uint64_t> OVERWORLD_SHIFT;
|
||||
extern const SDLPP::Vec2D<uint64_t> UNDERWORLD_SHIFT;
|
||||
|
Loading…
Reference in New Issue
Block a user