#pragma once

#include <stdbool.h>

#include "../lib/raylib.h"

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

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

#include "game.h"

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

fz_timer_t *fz_timer_create(int frames, int step);
bool fz_timer_check(fz_timer_t *timer);
void fz_timer_update(fz_timer_t *timer);
void fz_timer_reset(fz_timer_t *timer);
int fz_timer_get(fz_timer_t *timer);
void fz_timer_free(fz_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);
bool rect_collide_threshold(rect_t a, rect_t b, float threshold);

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

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);
