Mario Editor: smaller block size
This commit is contained in:
parent
243c1d9d04
commit
0475f4967b
@ -3,7 +3,7 @@
|
|||||||
#include "blocks.hpp"
|
#include "blocks.hpp"
|
||||||
#include "sprites.hpp"
|
#include "sprites.hpp"
|
||||||
|
|
||||||
EditBox::EditBox(int x, int y, int map_width, int map_height, std::shared_ptr<SDLPP::Renderer> renderer) : SDLPP::RectangleRender(BLOCK_SIZE + x*BLOCK_SIZE, (map_width - map_height + 2)*BLOCK_SIZE + y*BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE, renderer) {
|
EditBox::EditBox(int x, int y, float start_x, float start_y, int map_width, int map_height, std::shared_ptr<SDLPP::Renderer> renderer) : SDLPP::RectangleRender(start_x + x*BLOCK_SIZE, start_y + y*BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE, renderer) {
|
||||||
_x = x;
|
_x = x;
|
||||||
_y = y;
|
_y = y;
|
||||||
setId(EDITOR_EDIT_SQUARE);
|
setId(EDITOR_EDIT_SQUARE);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class EditBox : public SDLPP::RectangleRender {
|
class EditBox : public SDLPP::RectangleRender {
|
||||||
public:
|
public:
|
||||||
EditBox(int x, int y, int map_width, int map_height, std::shared_ptr<SDLPP::Renderer> renderer);
|
EditBox(int x, int y, float start_x, float start_y, int map_width, int map_height, std::shared_ptr<SDLPP::Renderer> renderer);
|
||||||
virtual SDLPP::Vec2D<int> getIndexes() const;
|
virtual SDLPP::Vec2D<int> getIndexes() const;
|
||||||
virtual void visit( SDLPP::Visitor &visitor ) override;
|
virtual void visit( SDLPP::Visitor &visitor ) override;
|
||||||
private:
|
private:
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "editor_visitor.hpp"
|
#include "editor_visitor.hpp"
|
||||||
#include "tool_box.hpp"
|
#include "tool_box.hpp"
|
||||||
|
|
||||||
#define MAP_WIDTH 18
|
#define MAP_WIDTH 24
|
||||||
#define MAP_HEIGHT 16
|
#define MAP_HEIGHT 16
|
||||||
|
|
||||||
#define QUIT_FLAG 0x00000001
|
#define QUIT_FLAG 0x00000001
|
||||||
@ -36,7 +36,7 @@
|
|||||||
#define CHARACTER_RIGHT_ENABLED_FLAG 0x00000200
|
#define CHARACTER_RIGHT_ENABLED_FLAG 0x00000200
|
||||||
|
|
||||||
#define TOOLS_WIDTH 4
|
#define TOOLS_WIDTH 4
|
||||||
#define CHARACTER_WIDTH 2
|
#define CHARACTER_WIDTH 3
|
||||||
#define MOD_WIDTH 2
|
#define MOD_WIDTH 2
|
||||||
#define OVERWORLD_WIDTH 2
|
#define OVERWORLD_WIDTH 2
|
||||||
|
|
||||||
@ -475,8 +475,7 @@ void getMousePositionFlags( SDLPP::Scene &scene ) {
|
|||||||
if ( visitor.foundEditBox() ) {
|
if ( visitor.foundEditBox() ) {
|
||||||
const auto &box = global_vars.mouse.edit_box;
|
const auto &box = global_vars.mouse.edit_box;
|
||||||
global_vars.current_tool->setPos( box.getX() * BLOCK_SIZE,
|
global_vars.current_tool->setPos( box.getX() * BLOCK_SIZE,
|
||||||
( MAP_WIDTH - MAP_HEIGHT + 2 ) *
|
1 - MAP_HEIGHT * BLOCK_SIZE +
|
||||||
BLOCK_SIZE +
|
|
||||||
box.getY() * BLOCK_SIZE );
|
box.getY() * BLOCK_SIZE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -920,7 +919,7 @@ int main() {
|
|||||||
SDLPP::init();
|
SDLPP::init();
|
||||||
SDLPP::Window w( "Mario editor!" );
|
SDLPP::Window w( "Mario editor!" );
|
||||||
w.setResizable( true );
|
w.setResizable( true );
|
||||||
BLOCK_SIZE = 1.0 / ( MAP_WIDTH + 2 );
|
BLOCK_SIZE = 1.0 / 26;
|
||||||
|
|
||||||
auto renderer = std::make_shared< SDLPP::Renderer >( w );
|
auto renderer = std::make_shared< SDLPP::Renderer >( w );
|
||||||
renderer->setBlendMode( SDL_BLENDMODE_BLEND );
|
renderer->setBlendMode( SDL_BLENDMODE_BLEND );
|
||||||
@ -955,7 +954,7 @@ int main() {
|
|||||||
// map
|
// map
|
||||||
auto arrows = createArrowControls(
|
auto arrows = createArrowControls(
|
||||||
0, ( MAP_WIDTH + 1 ) * BLOCK_SIZE,
|
0, ( MAP_WIDTH + 1 ) * BLOCK_SIZE,
|
||||||
( MAP_WIDTH + 2 - MAP_HEIGHT ) * BLOCK_SIZE, MAP_HEIGHT * BLOCK_SIZE,
|
1 - MAP_HEIGHT * BLOCK_SIZE, MAP_HEIGHT * BLOCK_SIZE,
|
||||||
EDITOR_LEFT_MAP_ID, EDITOR_RIGHT_MAP_ID, scene, font_config );
|
EDITOR_LEFT_MAP_ID, EDITOR_RIGHT_MAP_ID, scene, font_config );
|
||||||
auto left_map_arrow = arrows.first;
|
auto left_map_arrow = arrows.first;
|
||||||
auto right_map_arrow = arrows.second;
|
auto right_map_arrow = arrows.second;
|
||||||
@ -965,53 +964,53 @@ int main() {
|
|||||||
for ( int i = 0; i < MAP_WIDTH; i++ ) {
|
for ( int i = 0; i < MAP_WIDTH; i++ ) {
|
||||||
for ( int j = 0; j < MAP_HEIGHT; j++ ) {
|
for ( int j = 0; j < MAP_HEIGHT; j++ ) {
|
||||||
scene->addObject( std::make_shared< EditBox >(
|
scene->addObject( std::make_shared< EditBox >(
|
||||||
i, j, MAP_WIDTH, MAP_HEIGHT, renderer ) );
|
i, j, BLOCK_SIZE, 1 - MAP_HEIGHT * BLOCK_SIZE, MAP_WIDTH, MAP_HEIGHT, renderer ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tools
|
// tools
|
||||||
populateToolGrid( TOOLS_WIDTH, 2, ( MAP_WIDTH - TOOLS_WIDTH ) * BLOCK_SIZE,
|
populateToolGrid( TOOLS_WIDTH, 2, ( MAP_WIDTH - TOOLS_WIDTH ) * BLOCK_SIZE,
|
||||||
BLOCK_SIZE, ToolType::BLOCK, possibleBlocks,
|
1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, ToolType::BLOCK, possibleBlocks,
|
||||||
global_vars.tools, global_vars.tool_boxes, scene,
|
global_vars.tools, global_vars.tool_boxes, scene,
|
||||||
"TERRAIN", font_config );
|
"TERRAIN", font_config );
|
||||||
arrows = createArrowControls( ( MAP_WIDTH - TOOLS_WIDTH - 1 ) * BLOCK_SIZE,
|
arrows = createArrowControls( ( MAP_WIDTH - TOOLS_WIDTH - 1 ) * BLOCK_SIZE,
|
||||||
MAP_WIDTH * BLOCK_SIZE, BLOCK_SIZE,
|
MAP_WIDTH * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE,
|
||||||
2 * BLOCK_SIZE, EDITOR_LEFT_TOOL_ID,
|
2 * BLOCK_SIZE, EDITOR_LEFT_TOOL_ID,
|
||||||
EDITOR_RIGHT_TOOL_ID, scene, font_config );
|
EDITOR_RIGHT_TOOL_ID, scene, font_config );
|
||||||
auto left_tool_arrow = arrows.first;
|
auto left_tool_arrow = arrows.first;
|
||||||
auto right_tool_arrow = arrows.second;
|
auto right_tool_arrow = arrows.second;
|
||||||
createGrid( ( MAP_WIDTH - TOOLS_WIDTH ) * BLOCK_SIZE, BLOCK_SIZE,
|
createGrid( ( MAP_WIDTH - TOOLS_WIDTH ) * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE,
|
||||||
TOOLS_WIDTH, 2, scene );
|
TOOLS_WIDTH, 2, scene );
|
||||||
// mods
|
// mods
|
||||||
populateToolGrid( MOD_WIDTH, 2, 4 * BLOCK_SIZE, BLOCK_SIZE, ToolType::MOD,
|
populateToolGrid( MOD_WIDTH, 2, 5 * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, ToolType::MOD,
|
||||||
possibleMods, global_vars.mods, global_vars.mod_boxes,
|
possibleMods, global_vars.mods, global_vars.mod_boxes,
|
||||||
scene, "MODS", font_config );
|
scene, "MODS", font_config );
|
||||||
arrows =
|
arrows =
|
||||||
createArrowControls( 3 * BLOCK_SIZE, ( MOD_WIDTH + 4 ) * BLOCK_SIZE,
|
createArrowControls( 4 * BLOCK_SIZE, ( MOD_WIDTH + 5 ) * BLOCK_SIZE,
|
||||||
BLOCK_SIZE, 2 * BLOCK_SIZE, EDITOR_LEFT_MOD_ID,
|
1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, 2 * BLOCK_SIZE, EDITOR_LEFT_MOD_ID,
|
||||||
EDITOR_RIGHT_MOD_ID, scene, font_config );
|
EDITOR_RIGHT_MOD_ID, scene, font_config );
|
||||||
auto left_mod_arrow = arrows.first;
|
auto left_mod_arrow = arrows.first;
|
||||||
auto right_mod_arrow = arrows.second;
|
auto right_mod_arrow = arrows.second;
|
||||||
createGrid( 4 * BLOCK_SIZE, BLOCK_SIZE, MOD_WIDTH, 2, scene );
|
createGrid( 5 * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, MOD_WIDTH, 2, scene );
|
||||||
// characters
|
// characters
|
||||||
populateToolGrid( CHARACTER_WIDTH, 2, ( MOD_WIDTH + 7 ) * BLOCK_SIZE,
|
populateToolGrid( CHARACTER_WIDTH, 2, ( MOD_WIDTH + 8 ) * BLOCK_SIZE,
|
||||||
BLOCK_SIZE, ToolType::CHARACTER, possibleCharacters,
|
1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, ToolType::CHARACTER, possibleCharacters,
|
||||||
global_vars.characters, global_vars.character_boxes,
|
global_vars.characters, global_vars.character_boxes,
|
||||||
scene, "CHARACTERS", font_config );
|
scene, "CHARACTERS", font_config );
|
||||||
arrows = createArrowControls(
|
arrows = createArrowControls(
|
||||||
( MOD_WIDTH + 6 ) * BLOCK_SIZE,
|
( MOD_WIDTH + 7 ) * BLOCK_SIZE,
|
||||||
( MOD_WIDTH + 7 + CHARACTER_WIDTH ) * BLOCK_SIZE, BLOCK_SIZE,
|
( MOD_WIDTH + 8 + CHARACTER_WIDTH ) * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE,
|
||||||
2 * BLOCK_SIZE, EDITOR_LEFT_CHARACTER_ID, EDITOR_RIGHT_CHARACTER_ID,
|
2 * BLOCK_SIZE, EDITOR_LEFT_CHARACTER_ID, EDITOR_RIGHT_CHARACTER_ID,
|
||||||
scene, font_config );
|
scene, font_config );
|
||||||
auto left_char_arrow = arrows.first;
|
auto left_char_arrow = arrows.first;
|
||||||
auto right_char_arrow = arrows.second;
|
auto right_char_arrow = arrows.second;
|
||||||
createGrid( ( MOD_WIDTH + 7 ) * BLOCK_SIZE, BLOCK_SIZE, CHARACTER_WIDTH, 2,
|
createGrid( ( MOD_WIDTH + 8 ) * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, CHARACTER_WIDTH, 2,
|
||||||
scene );
|
scene );
|
||||||
|
|
||||||
// world type
|
// world type
|
||||||
populateWorldType( OVERWORLD_WIDTH, 2, 0, BLOCK_SIZE, scene, "WORLD",
|
populateWorldType( OVERWORLD_WIDTH, 2, BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, scene, "WORLD",
|
||||||
font_config );
|
font_config );
|
||||||
createGrid( 0, BLOCK_SIZE, OVERWORLD_WIDTH, 2, scene );
|
createGrid( BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, OVERWORLD_WIDTH, 2, scene );
|
||||||
|
|
||||||
global_vars.map.max_page = global_vars.objects.size() - MAP_WIDTH;
|
global_vars.map.max_page = global_vars.objects.size() - MAP_WIDTH;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user