: AyaanScript+ — Hardware-accelerated 3D via OpenGL.
: Same scene as cube3d_smooth.ayaan but rendered on the GPU.
: Way faster — even with hundreds of cubes you should hit 60fps easily.

const W = 800
const H = 800
gl_init W H "AyaanScript+ - OpenGL Cubes"

set ay = 0
set running = 1
set frame = 0
set tstart = {time()}

while running == 1
    gl_open running
    if running == 0
        break
    endif

    gl_clear "#0a0a2a"

    set ay = {ay + 0.015}
    gl_rotate 0.5 ay 0
    gl_camera 7

    : draw a 3x3 grid of cubes
    set i = 0
    repeat 3 i
        set j = 0
        repeat 3 j
            set x = {(i - 2) * 2.0}
            set y = {(j - 2) * 2.0}
            set hue = {(i + j * 3) * 40}
            hsv_to_rgb hue 0.8 1.0 -> col
            gl_cube x y 0 1.4 col
        endrepeat
    endrepeat

    gl_swap

    set frame = {frame + 1}
    if frame > 600
        set running = 0
    endif
endwhile

gl_close
set now = {time()}
set elapsed = {now - tstart}
psyska -/ "rendered {frame} frames in {elapsed}s"
