]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/fluids/fluids.factor
factor: trim using lists
[factor.git] / extra / fluids / fluids.factor
index f76ee063cd964642ea0dd1bb659849534ebe96ae..b7875ab0de60600ed825bdd22262d139afd9c2bb 100644 (file)
@@ -1,12 +1,10 @@
 ! Copyright (C) 2010 Erik Charlebois.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays classes.struct destructors game.loop
-game.worlds gpu gpu.buffers gpu.effects.blur gpu.framebuffers
-gpu.render gpu.shaders gpu.state gpu.textures gpu.util images
-images.loader kernel literals locals make math math.rectangles
-math.vectors namespaces opengl.gl sequences specialized-arrays
-ui.gadgets.worlds ui.gestures ui.pixel-formats gpu.effects.step
-images.pgm images.ppm ;
+USING: accessors alien.data classes.struct destructors game.loop
+game.worlds gpu gpu.effects.blur gpu.effects.step gpu.state
+gpu.textures gpu.util images.loader kernel literals make math
+math.vectors namespaces sequences specialized-arrays
+ui.gadgets.worlds ui.gestures ui.pixel-formats ;
 FROM: alien.c-types => float ;
 SPECIALIZED-ARRAY: float
 IN: fluids
@@ -23,13 +21,13 @@ CONSTANT: gravity { 0.0 -0.1 }
     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
+    p' v' particle m>> particle_t 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 }
@@ -60,7 +58,7 @@ TUPLE: fluids-world < game-world
         <texture-2d>
     ]
     [
-        0 swap [ allocate-texture-image ] 3keep 2drop
+        0 swap [ allocate-texture-image ] keepdd
     ] bi ;
 
 SYMBOL: fluid
@@ -92,8 +90,8 @@ M:: fluids-world draw-world* ( world -- )
     world particles>> [
         [ p>> [ first , ] [ second , ] bi ] each
     ] curry float-array{ } make :> verts
-    
-    [ 
+
+    [
         verts world texture>> 30.0 world dim>> { 4 4 } v/
         blended-point-sprite-batch &dispose
         blend-state new set-gpu-state
@@ -113,8 +111,8 @@ GAME: fluids {
 
 fluids-world H{
     { T{ button-down } [ [
-        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
+        hand-loc get float >c-array
+        world get dim>> float >c-array v/ 2 v*n 1 v-n { 1 -1 } v*
+        float-array{ 0 0.2 } 2.0 particle_t boa suffix
     ] change-particles drop ] }
 } set-gestures