From de93637d9af3444ca07861f2d34a3ca9de17a196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Sat, 8 May 2021 18:38:33 +0200 Subject: [PATCH] fix mouse movement speed --- code/apps/client/source/game.c | 2 +- code/apps/client/source/platform_raylib.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/code/apps/client/source/game.c b/code/apps/client/source/game.c index 875b4b3..f7477f5 100644 --- a/code/apps/client/source/game.c +++ b/code/apps/client/source/game.c @@ -127,7 +127,7 @@ void game_init(int8_t play_mode, uint32_t num_viewers, int32_t seed, uint16_t bl ECS_IMPORT(world_ecs(), Controllers); ECS_IMPORT(world_ecs(), Physics); uint16_t half_world_dim = world_dim() / 2; - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100; i++) { uint64_t e = entity_spawn(NULL); ecs_add(world_ecs(), e, EcsDemoNPC); Position *pos = ecs_get_mut(world_ecs(), e, Position, NULL); diff --git a/code/apps/client/source/platform_raylib.c b/code/apps/client/source/platform_raylib.c index 689419f..3f2d115 100644 --- a/code/apps/client/source/platform_raylib.c +++ b/code/apps/client/source/platform_raylib.c @@ -7,8 +7,8 @@ #include "camera.h" #include "math.h" -const uint16_t screenWidth = 1600; -const uint16_t screenHeight = 900; +uint16_t screenWidth = 1600; +uint16_t screenHeight = 900; #define GFX_WORLD_SCALE 20.0f @@ -51,8 +51,12 @@ void DrawRectangleEco(int posX, int posY, int width, int height, Color color) void platform_init() { InitWindow(screenWidth, screenHeight, "eco2d - client"); + SetWindowState(FLAG_WINDOW_UNDECORATED|FLAG_WINDOW_HIGHDPI|FLAG_WINDOW_MAXIMIZED|FLAG_WINDOW_RESIZABLE); SetTargetFPS(60); + screenWidth = GetScreenWidth(); + screenHeight = GetScreenHeight(); + render_camera.target = (Vector2){0.0f,0.0f}; render_camera.offset = (Vector2){screenWidth/2.0f, screenHeight/2.0f}; render_camera.rotation = 0.0f; @@ -91,8 +95,11 @@ void platform_input() { Vector2 mouse_pos = GetMousePosition(); mouse_pos.x /= screenWidth; mouse_pos.y /= screenHeight; - x = mouse_pos.x-0.5f; - y = mouse_pos.y-0.5f; + mouse_pos.x -= 0.5f; + mouse_pos.y -= 0.5f; + mouse_pos = Vector2Normalize(mouse_pos); + x = mouse_pos.x; + y = mouse_pos.y; }