mouse pan and reset offset
This commit is contained in:
parent
7189f28c00
commit
2026f8ac8d
5 changed files with 32 additions and 1 deletions
|
|
@ -22,6 +22,8 @@ static void window_render(struct kubo_context *context);
|
|||
static void window_left_mouse(struct kubo_context *context);
|
||||
static void window_right_mouse(struct kubo_context *context);
|
||||
|
||||
static void pan(struct kubo_context *context);
|
||||
|
||||
static void new_wall_click(struct kubo_context *context);
|
||||
static void new_wall_end(struct kubo_context *context);
|
||||
|
||||
|
|
@ -30,7 +32,7 @@ void kubo_window_init() {
|
|||
InitWindow(KUBO_WINDOW_WIDTH, KUBO_WINDOW_HEIGHT, "Kubo");
|
||||
EnableEventWaiting();
|
||||
SetExitKey(0);
|
||||
SetTargetFPS(60);
|
||||
SetTargetFPS(KUBO_TARGET_FPS);
|
||||
}
|
||||
|
||||
void kubo_window_cleanup() { CloseWindow(); }
|
||||
|
|
@ -41,6 +43,7 @@ bool kubo_window_should_close(struct kubo_context *context) {
|
|||
|
||||
void kubo_window_tick(struct kubo_context *context) {
|
||||
window_render(context);
|
||||
pan(context);
|
||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
|
||||
window_left_mouse(context);
|
||||
}
|
||||
|
|
@ -91,6 +94,15 @@ static void window_right_mouse(struct kubo_context *context) {
|
|||
}
|
||||
}
|
||||
|
||||
static void pan(struct kubo_context *context) {
|
||||
if (context->state.id == KUBO_CONTEXT_NORMAL &&
|
||||
IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
|
||||
Vector2 delta = GetMouseDelta();
|
||||
context->offset_x += delta.x;
|
||||
context->offset_y += delta.y;
|
||||
}
|
||||
}
|
||||
|
||||
static void new_wall_click(struct kubo_context *context) {
|
||||
struct kubo_wall *current_wall = kubo_context_get_pending_wall(context);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue