     { tick-interval-micros $[ 60 fps ] }
 } ;
 
-MAIN: fluids
-
 fluids-world H{
     { T{ button-down } [ [
-        hand-loc get { 1024 768 } v/ 2 v*n 1 v-n { 1 -1 } v* first2 float2_t <struct-boa>
-        dup 2.0 particle_t <struct-boa> suffix
+        hand-loc get >float-array
+        world get dim>> >float-array v/ 2 v*n 1 v-n { 1 -1 } v*
+        float-array{ 0 0.2 } 2.0 particle_t <struct-boa> suffix
     ] change-particles drop ] }
 } set-gestures


M:: fluids-world draw-world* ( world -- )
    world particles>> [
        [ p>> [ x>> , ] [ y>> , ] bi ] each
    ] curry float-array{ } make :> verts
    
    [ 
        verts world texture>> 50.0 { 320 240 } blended-point-sprite-batch &dispose
        
        blend-state new set-gpu-state
        
        gaussian-blur &dispose world ramp>> { 1024 768 } step-texture &dispose
        { 1024 768 } draw-texture
    ] with-destructors
    ;

GAME: fluids {
    { world-class fluids-world }

SPECIALIZED-ARRAY: float
IN: fluids

STRUCT: particle_t
    { p float[2] }
    { v float[2] }
    { m float    } ;
SPECIALIZED-ARRAY: particle_t

CONSTANT: gravity { 0.0 -0.1 }

:: verlet-integrate-particle ( particle dt -- particle' )
    particle [ p>> ] [ v>> ] bi dt v*n v+
    gravity dt dt * particle m>> 2 * / v*n v+ :> p'
    p' particle p>> v- dt v/n :> v'
    p' v' particle m>> particle_t <struct-boa> ; inline

CONSTANT: initial-particles
particle_t-array{
    S{ particle_t f float-array{ 0.5 0.6 } float-array{ 0 0.1 } 1.0 }
    S{ particle_t f float-array{ 0.5 0.6 } float-array{ 0.1 0 } 3.0 }
    
    S{ particle_t f float-array{ 0.5 0.5 } float-array{ 0.1 0.1 } 2.0 }
    S{ particle_t f float-array{ 0.5 0.6 } float-array{ -0.1 0 } 1.0 }
    S{ particle_t f float-array{ 0.6 0.5 } float-array{ 0 -0.1 } 3.0 }
    S{ particle_t f float-array{ 0.7 0.5 } float-array{ 0.1 0.1 } 1.0 }
    S{ particle_t f float-array{ 0.1 0.5 } float-array{ -0.1 -0.1 } 5.0 }
    S{ particle_t f float-array{ 0.2 0.5 } float-array{ 0 0 } 1.0 }
    S{ particle_t f float-array{ 0.3 0.3 } float-array{ 0 0 } 4.0 }
    S{ particle_t f float-array{ 0.5 0.15 } float-array{ 0 0 } 1.0 }
    S{ particle_t f float-array{ 0.5 0.1 } float-array{ 0 0 } 9.0 }
}

: integrate-particles! ( particles dt -- particles )
