forked from AbleOS/ableos
fiddling
This commit is contained in:
parent
0ebb1f200e
commit
34cbd9a5e6
|
@ -3,5 +3,6 @@ any := fn($Expr: type): Expr {
|
|||
}
|
||||
|
||||
range := fn($Expr: type, min: Expr, max: Expr): Expr {
|
||||
return @eca(3, 4) % (max - min + 1) + min
|
||||
// wtf is this
|
||||
return @intcast(@as(int, @eca(3, 4)) % @as(int, @intcast(max) - @intcast(min)) + 1 + @intcast(min))
|
||||
}
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
|
@ -4,8 +4,8 @@ render := @use("../../../../libraries/render/src/lib.hb")
|
|||
/* expected result:
|
||||
a cute image bounces around the screen */
|
||||
|
||||
bmp_1 := @embed("./able.bmp")
|
||||
bmp_2 := @embed("./mini.bmp")
|
||||
bmp_1 := @embed("./assets/able.bmp")
|
||||
bmp_2 := @embed("./assets/mini.bmp")
|
||||
|
||||
example := fn(): void {
|
||||
screen := render.init(true)
|
||||
|
|
|
@ -8,20 +8,21 @@ render := @use("../../../../libraries/render/src/lib.hb")
|
|||
example := fn(): void {
|
||||
screen := render.init(true)
|
||||
vel := Vec2(int).(1, 1)
|
||||
pos := Vec2(int).(100, 100)
|
||||
color := @as(render.Color, @intcast(random.range(int, 0, 0xFFFFFF)))
|
||||
side := screen.width / 8
|
||||
pos := Vec2(int).((screen.width - side) / 2, (screen.height - side) / 2)
|
||||
color := random.range(render.Color, render.black, render.white)
|
||||
loop {
|
||||
render.put_filled_rect(screen, pos, .(100, 100), color)
|
||||
render.put_filled_rect(screen, pos, .(side, side), color)
|
||||
render.sync(screen)
|
||||
render.clear(screen, render.black)
|
||||
|
||||
if pos.x == 0 | pos.x == screen.width - 100 {
|
||||
if pos.x == 0 | pos.x == screen.width - side {
|
||||
vel.x = -vel.x
|
||||
color = @as(render.Color, @intcast(random.range(int, 0, 0xFFFFFF)))
|
||||
color = random.range(render.Color, render.black, render.white)
|
||||
}
|
||||
if pos.y == 0 | pos.y == screen.height - 100 {
|
||||
if pos.y == 0 | pos.y == screen.height - side {
|
||||
vel.y = -vel.y
|
||||
color = @as(render.Color, @intcast(random.range(int, 0, 0xFFFFFF)))
|
||||
color = random.range(render.Color, render.black, render.white)
|
||||
}
|
||||
|
||||
pos += vel
|
||||
|
|
|
@ -8,29 +8,30 @@ render := @use("../../../../libraries/render/src/lib.hb")
|
|||
example := fn(): void {
|
||||
screen := render.init(true)
|
||||
|
||||
image := render.new_surface(341, 256)
|
||||
image := render.new_surface(screen.width / 3, screen.height / 3)
|
||||
vel := Vec2(int).(-1, -1)
|
||||
pos := Vec2(int).(100, 100)
|
||||
side := image.width / 8
|
||||
vel_inner := Vec2(int).(1, 1)
|
||||
pos_inner := Vec2(int).(10, 10)
|
||||
color := @as(render.Color, @intcast(random.range(int, 0, 0xFFFFFF)))
|
||||
pos_inner := Vec2(int).((image.width - side) / 2, (image.height - side) / 2)
|
||||
color := random.range(render.Color, render.black, render.white)
|
||||
loop {
|
||||
render.clear(image, render.black)
|
||||
render.clear(screen, render.black)
|
||||
|
||||
render.put_filled_rect(image, pos_inner, .(100, 100), color)
|
||||
render.put_filled_rect(image, pos_inner, .(side, side), color)
|
||||
render.put_rect(image, .(0, 0), .(image.width - 1, image.height - 1), render.white)
|
||||
|
||||
render.put_surface(screen, image, pos)
|
||||
render.sync(screen)
|
||||
|
||||
if pos_inner.x == 0 | pos_inner.x == image.width - 100 {
|
||||
if pos_inner.x == 0 | pos_inner.x == image.width - side {
|
||||
vel_inner.x = -vel_inner.x
|
||||
color = @as(render.Color, @intcast(random.range(int, 0, 0xFFFFFF)))
|
||||
color = random.range(render.Color, render.black, render.white)
|
||||
}
|
||||
if pos_inner.y == 0 | pos_inner.y == image.height - 100 {
|
||||
if pos_inner.y == 0 | pos_inner.y == image.height - side {
|
||||
vel_inner.y = -vel_inner.y
|
||||
color = @as(render.Color, @intcast(random.range(int, 0, 0xFFFFFF)))
|
||||
color = random.range(render.Color, render.black, render.white)
|
||||
}
|
||||
|
||||
if pos.x == 0 | pos.x == screen.width - image.width {
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
.{example} := @use("./examples/surface.hb")
|
||||
|
||||
main := fn(): void {
|
||||
@inline(example)
|
||||
return
|
||||
}
|
||||
main := example
|
Loading…
Reference in a new issue