mirror of https://git.sr.ht/~kikoodx/sle
EDITOR_SCALE + mouse cursor
This commit is contained in:
parent
f5863dc820
commit
28f40ac97e
|
@ -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 =
|
||||
|
|
|
@ -6,3 +6,4 @@
|
|||
#include <raylib.h>
|
||||
|
||||
void level_draw(struct Level level, Texture2D tileset);
|
||||
void editor_mouse_draw(int x, int y);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -11,9 +11,13 @@
|
|||
#include <stdlib.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue