package main

import eng "pkg:engine"

// Clip switcher: 1 = idle, 2 = walk. No movement — animation policy only.
main :: proc() {
	app: eng.App
	if !eng.init(&app, "clips", 800, 600) do return
	defer eng.shutdown(&app)

	data, ok := eng.load_character_data(&app, "assets_baked/characters/toad/toad.char.json")
	if !ok do return
	defer eng.destroy_character_data(&app, &data)

	toad := eng.spawn_sprite(&data, {400, 500}, "idle", 0)
	app.camera.position = toad.position - {0, 100}

	last := eng.now_seconds()

	for eng.events() {
		now := eng.now_seconds()
		dt := f32(now - last)
		last = now

		if eng.key_down(.N1) {
			eng.set_sprite_clip(&toad, "idle")
		}
		if eng.key_down(.N2) {
			eng.set_sprite_clip(&toad, "walk")
		}

		eng.update_sprite(&toad, dt)

		eng.begin_frame(&app)
		eng.draw_sprite(&app, &toad)
		eng.end_frame(&app)
	}
}
