#ifndef JNR_SPRITES_H
#define JNR_SPRITES_H

#include <SDL2/SDL.h>
#include "engine/animation.h"

/* Sprite sheet layout:
 * Each sprite cell is 16x16 pixels.
 * The sheet is organized in rows:
 *
 * Row 0: Player idle (2), run (4), jump (1), fall (1)
 * Row 1: Grunt idle (2), walk (4), death (1)
 * Row 2: Flyer idle (2), fly (4), death (1)
 * Row 3: Projectiles: bullet (2), impact (3), enemy bullet (2)
 * Row 4: Turret (2), platform (1), flame vent (3), force field (2)
 * Row 5: Force field off (1), powerups: health (2), jetpack (2), drone (2)
 * Row 6: Drone companion (2), gun powerup (2), asteroid (2), fuel (2)
 * Row 7: Charger idle (2), walk (4), death (1)
 * Row 8: Spawner idle (2), death (1), laser turret idle (1), fire (1)
 */

#define SPRITE_CELL  16

/* Generate the spritesheet texture (call after renderer is ready) */
SDL_Texture *sprites_generate(SDL_Renderer *renderer);

/* ── Player animations ─────────────────────────── */
extern AnimDef anim_player_idle;
extern AnimDef anim_player_run;
extern AnimDef anim_player_jump;
extern AnimDef anim_player_fall;

/* ── Grunt animations ──────────────────────────── */
extern AnimDef anim_grunt_idle;
extern AnimDef anim_grunt_walk;
extern AnimDef anim_grunt_death;

/* ── Flyer animations ──────────────────────────── */
extern AnimDef anim_flyer_idle;
extern AnimDef anim_flyer_fly;
extern AnimDef anim_flyer_death;

/* ── Projectile animations ─────────────────────── */
extern AnimDef anim_bullet;
extern AnimDef anim_bullet_impact;
extern AnimDef anim_enemy_bullet;

/* ── Hazard animations ─────────────────────────── */
extern AnimDef anim_turret_idle;
extern AnimDef anim_turret_fire;
extern AnimDef anim_platform;
extern AnimDef anim_flame_vent_idle;
extern AnimDef anim_flame_vent_active;
extern AnimDef anim_force_field_on;
extern AnimDef anim_force_field_off;

/* ── Powerup animations ────────────────────────── */
extern AnimDef anim_powerup_health;
extern AnimDef anim_powerup_jetpack;
extern AnimDef anim_powerup_fuel;
extern AnimDef anim_powerup_drone;
extern AnimDef anim_powerup_gun;

/* ── Asteroid animation ─────────────────────────── */
extern AnimDef anim_asteroid;

/* ── Drone animation ───────────────────────────── */
extern AnimDef anim_drone;

/* ── Charger animations ────────────────────────── */
extern AnimDef anim_charger_idle;
extern AnimDef anim_charger_walk;
extern AnimDef anim_charger_death;

/* ── Spawner animations ────────────────────────── */
extern AnimDef anim_spawner_idle;
extern AnimDef anim_spawner_death;

/* ── Laser turret animations ───────────────────── */
extern AnimDef anim_laser_turret_idle;
extern AnimDef anim_laser_turret_fire;

/* Initialize all animation definitions */
void sprites_init_anims(void);

/* The global spritesheet texture */
extern SDL_Texture *g_spritesheet;

#endif /* JNR_SPRITES_H */
