1
0
Fork 0
forked from AbleOS/ableos
ableos/sysdata/programs/render_example/src/examples/square.hb

27 lines
550 B
Plaintext

render := @use("../../../../libraries/render/src/lib.hb")
/* expected result:
the white outline of a square bounces around the screen */
example := fn(): void {
render.init()
vel := render.IVec2.(1, 1)
pos := render.IVec2.(100, 100)
width := render.width()
height := render.height()
loop {
render.put_rect(pos, .(100, 100), render.white)
render.sync()
render.clear(render.black)
if pos.x == 0 | pos.x == width - 100 {
vel.x = -vel.x
}
if pos.y == 0 | pos.y == height - 100 {
vel.y = -vel.y
}
pos += vel
}
return
}