structSheet
struct Sheet
image: Image
frame_width: int
frame_height: int
columns: int
count: int
endsprite: sprite sheets and animations, for characters that walk, jump and blink. use "sprite.jamo"
A sheet is one image cut into frames of the same size, counted from 0, left to right and then down. An animation is a list of frame numbers played at so many frames a second, looping or stopping at its last one.
var hero = sheet(screen.load_pixel_image("hero.png"), 16, 16)
var walk = animation([0, 1, 2, 3], 8.0, true)
...each frame:
walk.update(window.frame_time())
screen.sprite(hero, walk.frame(), x, y, 4.0, facing_left)
struct Sheet
image: Image
frame_width: int
frame_height: int
columns: int
count: int
endstruct Animation
frames: [int]
seconds_each: float
time: float
looping: bool
endfunc sheet(image: Image, frame_width: int, frame_height: int): Sheet
Cuts an image into frames frame_width by frame_height pixels. Any part left over at the right or bottom is skipped
func Gfx.sprite(sheet: Sheet, frame: int, x: float, y: float, scale: float, flipped: bool)
Draws one frame with its top left corner at x, y, scale times its size, mirrored left to right when flipped
func Gfx.sprite_turned(sheet: Sheet, frame: int, center_x: float, center_y: float, scale: float, angle: float, flipped: bool)
Draws one frame around its middle at center_x, center_y, turned by angle in radians
func animation(frames: [int], frames_a_second: float, looping: bool): Animation
Plays these frame numbers in order, frames_a_second of them each second
func Animation.update(seconds: float)
Moves the animation on by seconds, usually window.frame_time()
func Animation.frame(): int
The frame number to draw now
func Animation.done(): bool
True once an animation that doesn't loop has shown its last frame for its full time
func Animation.restart()
Back to the first frame