forked from AbleOS/ableos
26 lines
894 B
Plaintext
26 lines
894 B
Plaintext
|
.{rect_line} := @use("../draw.hb");
|
||
|
.{present, create_buffer, clear} := @use("../lib.hb")
|
||
|
|
||
|
/* expected result:
|
||
|
the impostor travels left and loops around the screen */
|
||
|
|
||
|
example := fn(): void {
|
||
|
// Creates a back buffer, which we write to, to avoid screen flickering
|
||
|
buffer := create_buffer()
|
||
|
x := 0
|
||
|
loop {
|
||
|
// draw all our shapes to the back buffer
|
||
|
rect_line(buffer, .(200 - x, 80), .(430, 380), .(0, 0, 255, 0), 1)
|
||
|
rect_line(buffer, .(630 - x, 120), .(120, 300), .(0, 0, 255, 0), 1)
|
||
|
rect_line(buffer, .(200 - x, 460), .(160, 270), .(0, 0, 255, 0), 1)
|
||
|
rect_line(buffer, .(470 - x, 460), .(160, 270), .(0, 0, 255, 0), 1)
|
||
|
rect_line(buffer, .(140 - x, 140), .(340, 250), .(255, 255, 0, 0), 1)
|
||
|
/* push the back buffer to the front buffer
|
||
|
this displays our image to the screen */
|
||
|
present(buffer)
|
||
|
// erase our old image
|
||
|
clear(buffer, .(0, 0, 0, 0))
|
||
|
x += 1
|
||
|
}
|
||
|
return
|
||
|
}
|