#pragma once

#include <stdbool.h>

#include "libs/raylib.h"

#define UNUSED(x) (void)(x)

typedef Vector2 pos_t;
typedef Rectangle rect_t;
typedef struct Timer timer_t;

#include "game.h"

struct Timer {
  int frames;
  int count;
  int step;
};

timer_t *timer_create(int frames, int step);
bool timer_check(timer_t *timer);
void timer_update(timer_t *timer);
void timer_reset(timer_t *timer);
int timer_get(timer_t *timer);
void timer_free(timer_t *timer);

pos_t pos_snap(pos_t vec);

rect_t rect_from_pos(pos_t pos, int width, int height);
bool rect_collide(rect_t a, rect_t b);

Texture texture_load(char *filename, int scale);
Rectangle texture_rect(int x, int y, int width, int height);

typedef enum {
  TEXT_ALIGNMENT_LEFT,
  TEXT_ALIGNMENT_RIGHT,
  TEXT_ALIGNMENT_CENTER,
} text_alignment_e;

void text_draw(pos_t pos, char *text, text_alignment_e alignment, game_t *game);
