Skip to content

anim.um

Marek Maskarinec edited this page Oct 9, 2022 · 2 revisions

anim.um

 Module for frame based image animation.
 TODO: Rework this module to use atlases.

struct Anim*

type Anim* = struct {
	anim: []image.Image
	rot: th.fu
	scale: th.fu
	fps: th.uu
	looping: bool

	pos: th.Vf2

	zeroTime: int

	frame: int
}

Anim is able to animate an array of images. As opposed to ent.Ent.animate, it starts from the first frame.

fn mk*

fn mk*(pos: th.Vf2, anm: []image.Image, fps: th.uu): Anim {

Anim's constructor.

fn start*

fn (a: ^Anim) start*(t: int) {

Starts animation with start_time of t.

fn handle*

fn (a: ^Anim) handle*(t: uint, cam: rect.Rect): bool {

This draws the animation. Returns true, if the animation ended.

Clone this wiki locally