ableos/sysdata/programs/render_example/src/examples/image.hb
koniifer 96c2bd5cd5 bitmap image support & better mem opts
restructure render lib
add peony's render api additions and example
add image example
fix some dubious bugs i had made in unused code in mem_serve.rs
remove tetris stub (now in peony's fork)
update hblang
2024-10-13 23:38:43 +01:00

31 lines
670 B
Plaintext

.{Vec2} := @use("../../../../libraries/stn/src/lib.hb").math;
render := @use("../../../../libraries/render/src/lib.hb")
/* expected result:
a cute image bounces around the screen */
mini_bmp := @embed("./mini.bmp")
example := fn(): void {
render.init()
mini := render.image.from_bmp(@bitcast(&mini_bmp))
vel := Vec2(int).(1, 1)
pos := Vec2(int).(100, 100)
width := render.width()
height := render.height()
loop {
render.put_image(mini, pos)
render.sync()
render.clear(render.black)
if pos.x == 0 | pos.x == width - mini.width {
vel.x = -vel.x
}
if pos.y == 0 | pos.y == height - mini.height {
vel.y = -vel.y
}
pos += vel
}
return
}