Mod texture

This commit is contained in:
2021-06-24 20:53:58 +02:00
parent b423ac7b8c
commit 2617156833
8 changed files with 40 additions and 13 deletions
+19 -6
View File
@@ -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
// fall through
case ToolType::BLOCK:
break;
}
// fall through
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 );