aboutsummaryrefslogtreecommitdiff
path: root/src/gunner
diff options
context:
space:
mode:
Diffstat (limited to 'src/gunner')
-rw-r--r--src/gunner/controller.c88
-rw-r--r--src/gunner/text.c14
2 files changed, 19 insertions, 83 deletions
diff --git a/src/gunner/controller.c b/src/gunner/controller.c
index 4e56a27..1ac76ff 100644
--- a/src/gunner/controller.c
+++ b/src/gunner/controller.c
@@ -1,86 +1,14 @@
-// Keyboard things
-
-b32 is_key_pressed(i32 btn)
-{
- return IsKeyPressed(btn);
-}
-
-b32 is_key_held(i32 btn)
-{
- return IsKeyDown(btn);
-}
-
-b32 is_key_released(i32 btn)
-{
- return IsKeyReleased(btn);
-}
-
-// Mouse things
-
-b32 is_mouse_pressed(i32 btn)
-{
- return IsMouseButtonPressed(btn);
-}
-
-b32 is_mouse_held(i32 btn)
-{
- return IsMouseButtonDown(btn);
-}
-
-b32 is_mouse_released(i32 btn)
-{
- return IsMouseButtonReleased(btn);
-}
-
-void set_mouse_scale(f32 x, f32 y)
-{
- SetMouseScale(x, y);
-}
-
-vec2 get_mouse_pos(void)
-{
- Vector2 pos = GetMousePosition();
- return (vec2){FP_TO_FIXED(pos.x), FP_TO_FIXED(pos.y)};
-}
-
-fx32 get_wheel_movement(void)
-{
- return FP_TO_FIXED(GetMouseWheelMove());
-}
-
-// Gamepad things
-
-b32 is_button_pressed(i32 btn)
-{
- return IsGamepadButtonPressed(0, btn);
-}
-
-b32 is_button_held(i32 btn)
-{
- return IsGamepadButtonDown(0, btn);
-}
-
-b32 is_button_released(i32 btn)
-{
- return IsGamepadButtonReleased(0, btn);
-}
-
-i32 last_button_press(void)
-{
- return GetGamepadButtonPressed();
-}
-
// Movement things
-vec2 get_dir_input(void)
+Vector2 get_dir_input(void)
{
- fx32 cont_x = FP_TO_FIXED(GetGamepadAxisMovement(0, 0));
- fx32 cont_y = FP_TO_FIXED(GetGamepadAxisMovement(0, 1));
+ f32 cont_x = GetGamepadAxisMovement(0, 0);
+ f32 cont_y = GetGamepadAxisMovement(0, 1);
- fx32 key_w = IsKeyDown(KEY_W) ? FIXED_POINT_ONE : 0;
- fx32 key_s = IsKeyDown(KEY_S) ? FIXED_POINT_ONE : 0;
- fx32 key_a = IsKeyDown(KEY_A) ? FIXED_POINT_ONE : 0;
- fx32 key_d = IsKeyDown(KEY_D) ? FIXED_POINT_ONE : 0;
+ f32 key_w = IsKeyDown(KEY_W) ? 1.f: 0.f;
+ f32 key_s = IsKeyDown(KEY_S) ? 1.f: 0.f;
+ f32 key_a = IsKeyDown(KEY_A) ? 1.f: 0.f;
+ f32 key_d = IsKeyDown(KEY_D) ? 1.f: 0.f;
// Either Gamepad or Keyboard control, not both!
if(key_w != 0 || key_s != 0 || key_a != 0 || key_d != 0){
@@ -88,5 +16,5 @@ vec2 get_dir_input(void)
cont_y = key_s - key_w;
}
- return (vec2){cont_x, cont_y};
+ return (Vector2){cont_x, cont_y};
}
diff --git a/src/gunner/text.c b/src/gunner/text.c
index 0812ff1..d7f1e23 100644
--- a/src/gunner/text.c
+++ b/src/gunner/text.c
@@ -94,10 +94,18 @@ i32 load_font(const char* path)
return current_idx;
}
-void draw_text_font(i32 idx, const char* text, vec2 pos, i32 size, Color col)
+void draw_text_font(i32 idx, const char* text, Vector2 pos, f32 size, Color col)
{
- Vector2 position = (Vector2){FROM_FIXED(pos.x), FROM_FIXED(pos.y)};
- DrawTextEx(font_slots[idx], text, position, (f32)size, 1.0f, col);
+ DrawTextEx(font_slots[idx], text, pos, size, 0.5f, col);
+}
+
+void draw_text_font_centered(i32 idx, const char* text, f32 y_offset, f32 size, Color col)
+{
+ Vector2 vec = MeasureTextEx(font_slots[idx], text, size, 0.5f);
+ Vector2 final_pos = (Vector2){(320.0f - vec.x) / 2.f, y_offset};
+
+ DrawTextEx(font_slots[idx], text, final_pos, size, 0.5f, col);
+ DrawLineV((Vector2){final_pos.x, y_offset + vec.y - 2.f}, (Vector2){final_pos.x + vec.x, y_offset + vec.y - 2.f}, col);
}
void unload_font(i32 idx)