Compare commits
2 Commits
f49f501306
...
2b448c3bda
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b448c3bda | |||
| 562c5ebc32 |
36
main.cpp
36
main.cpp
@@ -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);
|
||||
if (inside) {
|
||||
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_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 (mouse.buttons[MOUSE_BUTTON_LEFT]) {
|
||||
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