Compare commits

...

2 Commits

View File

@@ -303,7 +303,7 @@ void Print(int x, int y, const char* text) {
} }
} }
bool Button(int x, int y, char* text) { bool Button(int x, int y, const char* text) {
bool inside = (mouse.x >= x) && (mouse.y >= y) && (mouse.x < x + 55) && (mouse.y < y + 12); bool inside = (mouse.x >= x) && (mouse.y >= y) && (mouse.x < x + 55) && (mouse.y < y + 12);
if (inside) { if (inside) {
FillRect(x, y, 55, 13, 128, 64, 64, 255); FillRect(x, y, 55, 13, 128, 64, 64, 255);
@@ -483,19 +483,33 @@ void DoTileMap() {
if (keyJustPressed == SDL_SCANCODE_F) { Undo_Op(); FloodFill(); } if (keyJustPressed == SDL_SCANCODE_F) { Undo_Op(); FloodFill(); }
if (keyJustPressed == SDL_SCANCODE_R) { Undo_Op(); ReplaceTile(); } if (keyJustPressed == SDL_SCANCODE_R) { Undo_Op(); ReplaceTile(); }
static int scroll_x = 0;
static int scroll_y = 0;
static int old_map_x = 0;
static int old_map_y = 0;
if (mouse.mouse_down[MOUSE_BUTTON_LEFT] || mouse.mouse_down[MOUSE_BUTTON_RIGHT]) { Undo_Op(); } if (mouse.mouse_down[MOUSE_BUTTON_LEFT] || mouse.mouse_down[MOUSE_BUTTON_RIGHT]) { Undo_Op(); }
if (mouse.mouse_down[MOUSE_BUTTON_LEFT]) {
old_map_x = map_x; old_map_y = map_y;
scroll_x = cur_x; scroll_y = cur_y;
}
if (mouse.buttons[MOUSE_BUTTON_RIGHT]) { if (tile_back < sprites) map[(map_x + cur_x) + (map_y + cur_y)*map_width] = tile_back; } if (mouse.buttons[MOUSE_BUTTON_RIGHT]) { if (tile_back < sprites) map[(map_x + cur_x) + (map_y + cur_y)*map_width] = tile_back; }
if (mouse.buttons[MOUSE_BUTTON_LEFT]) { if (mouse.buttons[MOUSE_BUTTON_LEFT]) {
const int pos = (map_x + cur_x) + (map_y + cur_y)*map_width; if (keyboard[SDL_SCANCODE_SPACE]) {
if (tile_sel >= sprites) { map_x = old_map_x - (cur_x - scroll_x);
ignoreMouse = true; map_y = old_map_y - (cur_y - scroll_y);
if (map[pos + (map_width*map_height)] == 0) {
map[pos + (map_width*map_height)] = tile_sel;
} else {
map[pos + (map_width*map_height)] = 0;
}
} else { } else {
map[pos] = tile_sel; const int pos = (map_x + cur_x) + (map_y + cur_y)*map_width;
if (tile_sel >= sprites) {
ignoreMouse = true;
if (map[pos + (map_width*map_height)] == 0) {
map[pos + (map_width*map_height)] = tile_sel;
} else {
map[pos + (map_width*map_height)] = 0;
}
} else {
map[pos] = tile_sel;
}
} }
} }
if (mouse.buttons[MOUSE_BUTTON_MIDDLE]) { tile_sel = map[(map_x + cur_x) + (map_y + cur_y)*map_width]; } if (mouse.buttons[MOUSE_BUTTON_MIDDLE]) { tile_sel = map[(map_x + cur_x) + (map_y + cur_y)*map_width]; }