[FEAT] Added support to scroll tile by tile
This commit is contained in:
32
main.cpp
32
main.cpp
@@ -483,19 +483,33 @@ void DoTileMap() {
|
||||
if (keyJustPressed == SDL_SCANCODE_F) { Undo_Op(); FloodFill(); }
|
||||
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]) {
|
||||
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_LEFT]) {
|
||||
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;
|
||||
}
|
||||
if (keyboard[SDL_SCANCODE_SPACE]) {
|
||||
map_x = old_map_x - (cur_x - scroll_x);
|
||||
map_y = old_map_y - (cur_y - scroll_y);
|
||||
} 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]; }
|
||||
|
||||
Reference in New Issue
Block a user