.{Vec2} := @use("../../../../libraries/stn/src/lib.hb").math render := @use("../../../../libraries/render/src/lib.hb") /* expected result: a cute image bounces around the screen */ bmp_1 := @embed("./assets/able.bmp") bmp_2 := @embed("./assets/mini.bmp") example := fn(): void { images := [render.Surface].( render.image.surface_from_bmp(@bitcast(&bmp_1)), render.image.surface_from_bmp(@bitcast(&bmp_2)), ) screen := render.init(true) vel := Vec2(int).(1, 1) pos := Vec2(uint).(100, 100) n := 0 loop { image := images[n] render.put_surface(screen, image, pos, false) render.sync(screen) render.clear(screen, render.black) if pos.x == 0 | pos.x == screen.width - image.width { vel.x = -vel.x n = 1 - n } if pos.y == 0 | pos.y == screen.height - image.height { vel.y = -vel.y n = 1 - n } pos += @bitcast(vel) } return }