diff --git a/include/conf.h b/include/conf.h index 9d02f55..d9a064a 100644 --- a/include/conf.h +++ b/include/conf.h @@ -14,11 +14,13 @@ static const int editor_target_fps = 60; static const int picker_target_fps = 30; static const Color unselected_tile_color = {80, 80, 80, 255}; +static const Color overring_tile_color = {255, 255, 255, 80}; -static const int editor_window_width = 396; -static const int editor_window_height = 224; -static const int draw_offset_x = -2; -static const int draw_offset_y = -8; +#define EDITOR_SCALE 1 /* don't change this yet! */ +static const int editor_window_width = 396 * EDITOR_SCALE; +static const int editor_window_height = 224 * EDITOR_SCALE; +static const int draw_offset_x = -2 * EDITOR_SCALE; +static const int draw_offset_y = -8 * EDITOR_SCALE; #define PICKER_PADDING 4 static const int picker_window_width = diff --git a/include/editing_area/draw.h b/include/editing_area/draw.h index 0fadd68..61d882f 100644 --- a/include/editing_area/draw.h +++ b/include/editing_area/draw.h @@ -6,3 +6,4 @@ #include void level_draw(struct Level level, Texture2D tileset); +void editor_mouse_draw(int x, int y); diff --git a/src/editing_area/draw.c b/src/editing_area/draw.c index 415f001..4d56237 100644 --- a/src/editing_area/draw.c +++ b/src/editing_area/draw.c @@ -27,3 +27,9 @@ void level_draw(struct Level level, Texture2D tileset) } } } + +void editor_mouse_draw(int x, int y) { + const int tx = x * TILE_WIDTH + draw_offset_x; + const int ty = y * TILE_HEIGHT + draw_offset_y; + DrawRectangle(tx, ty, TILE_WIDTH, TILE_HEIGHT, overring_tile_color); +} diff --git a/src/editing_area/main.c b/src/editing_area/main.c index 6f8858f..7424c51 100644 --- a/src/editing_area/main.c +++ b/src/editing_area/main.c @@ -11,9 +11,13 @@ #include #include +static void init_mouse(void); + int editing_area_main(int argc, char **argv, struct SharedData *shared_data) { + int mouse_x; + int mouse_y; struct Level level; level.data = NULL; @@ -21,6 +25,7 @@ int editing_area_main(int argc, char **argv, InitWindow(editor_window_width, editor_window_height, "SLE main window"); SetTargetFPS(editor_target_fps); + init_mouse(); /* load textures */ const Texture2D tileset = LoadTexture(argv[1]); @@ -31,11 +36,16 @@ int editing_area_main(int argc, char **argv, level_read(&level, argv[2]); while (!WindowShouldClose()) { + /* update */ + mouse_x = GetMouseX(); + mouse_y = GetMouseY(); + /* draw */ BeginDrawing(); ClearBackground(BLACK); level_draw(level, tileset); + editor_mouse_draw(mouse_x, mouse_y); EndDrawing(); } @@ -64,3 +74,8 @@ int editing_area_main(int argc, char **argv, return EXIT_SUCCESS; } + +static void init_mouse(void) { + SetMouseOffset(-draw_offset_x, -draw_offset_y); + SetMouseScale(1.0 / (TILE_WIDTH * EDITOR_SCALE), 1.0 / (TILE_HEIGHT * EDITOR_SCALE)); +}