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