Prevent input handling, if it is over ImGui
This commit is contained in:
22
game/main.c
22
game/main.c
@@ -239,15 +239,21 @@ void deinit(Game *game) {
|
||||
void render(float dt, Game *game) {
|
||||
Camera2D *camera = &game->camera;
|
||||
|
||||
if (IsKeyDown(KEY_W)) camera->target.y -= 20;
|
||||
if (IsKeyDown(KEY_S)) camera->target.y += 20;
|
||||
if (IsKeyDown(KEY_A)) camera->target.x -= 20;
|
||||
if (IsKeyDown(KEY_D)) camera->target.x += 20;
|
||||
ImGuiIO *io = igGetIO();
|
||||
|
||||
if (!io->WantCaptureMouse && !io->WantCaptureKeyboard) {
|
||||
if (IsKeyDown(KEY_W)) camera->target.y -= 20;
|
||||
if (IsKeyDown(KEY_S)) camera->target.y += 20;
|
||||
if (IsKeyDown(KEY_A)) camera->target.x -= 20;
|
||||
if (IsKeyDown(KEY_D)) camera->target.x += 20;
|
||||
|
||||
if (IsKeyDown(KEY_Q)) camera->rotation--;
|
||||
if (IsKeyDown(KEY_E)) camera->rotation++;
|
||||
|
||||
camera->zoom += ((float) GetMouseWheelMove() * 0.05f);
|
||||
}
|
||||
|
||||
if (IsKeyDown(KEY_Q)) camera->rotation--;
|
||||
if (IsKeyDown(KEY_E)) camera->rotation++;
|
||||
|
||||
camera->zoom += ((float) GetMouseWheelMove() * 0.05f);
|
||||
|
||||
BeginMode2D(*camera);
|
||||
ClearBackground(RAYWHITE);
|
||||
@@ -270,7 +276,7 @@ void render(float dt, Game *game) {
|
||||
|
||||
DrawRectangleLines(tileX * 16, tileY * 16, sizeX * 16, sizeY * 16, placeColor);
|
||||
|
||||
if (canPlace && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
|
||||
if (canPlace && IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
|
||||
placeBuilding(&game->map, selectedBuilding, tileX, tileY, sizeX, sizeY);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user