From 4367068ba60d2899f062a03c96f1bf8723863d31 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Sat, 9 May 2009 14:31:33 -0500
Subject: [PATCH 1/5] save off the tick-slice when draw*-ing a game-world

---
 extra/game-worlds/game-worlds.factor | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/extra/game-worlds/game-worlds.factor b/extra/game-worlds/game-worlds.factor
index 864bd28fc1..fa6b326fa9 100644
--- a/extra/game-worlds/game-worlds.factor
+++ b/extra/game-worlds/game-worlds.factor
@@ -1,14 +1,15 @@
-USING: accessors game-input game-loop kernel ui.gadgets
+USING: accessors game-input game-loop kernel math ui.gadgets
 ui.gadgets.worlds ui.gestures ;
 IN: game-worlds
 
 TUPLE: game-world < world
-    game-loop ;
+    game-loop
+    { tick-slice float initial: 0.0 } ;
 
 GENERIC: tick-length ( world -- millis )
 
 M: game-world draw*
-    nip draw-world ;
+    swap >>tick-slice draw-world ;
 
 M: game-world begin-world
     dup [ tick-length ] [ ] bi <game-loop> [ >>game-loop ] keep start-loop

From 8cbcb87152cef62bd8719f0f4f41f424de88fc4c Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Sat, 9 May 2009 14:33:17 -0500
Subject: [PATCH 2/5] don't mess with the orphaned nodes when pop-front-ing or
 pop-back-ing a dlist. add a dlist-filter word that drops off all nodes that
 don't satisfy a predicate

---
 basis/dlists/dlists-tests.factor | 5 +++++
 basis/dlists/dlists.factor       | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/basis/dlists/dlists-tests.factor b/basis/dlists/dlists-tests.factor
index 3689680157..8072c93753 100755
--- a/basis/dlists/dlists-tests.factor
+++ b/basis/dlists/dlists-tests.factor
@@ -79,3 +79,8 @@ IN: dlists.tests
 [ V{ f 3 1 f } ] [ <dlist> 1 over push-front 3 over push-front f over push-front f over push-back dlist>seq ] unit-test
 
 [ V{ } ] [ <dlist> dlist>seq ] unit-test
+
+[ V{ 0 2 4 } ] [ <dlist> { 0 1 2 3 4 } over push-all-back [ even? ] dlist-filter dlist>seq ] unit-test
+[ V{ 2 4 } ] [ <dlist> { 1 2 3 4 } over push-all-back [ even? ] dlist-filter dlist>seq ] unit-test
+[ V{ 2 4 } ] [ <dlist> { 1 2 3 4 5 } over push-all-back [ even? ] dlist-filter dlist>seq ] unit-test
+[ V{ 0 2 4 } ] [ <dlist> { 0 1 2 3 4 5 } over push-all-back [ even? ] dlist-filter dlist>seq ] unit-test
diff --git a/basis/dlists/dlists.factor b/basis/dlists/dlists.factor
index 3d7224ed16..89675c6469 100755
--- a/basis/dlists/dlists.factor
+++ b/basis/dlists/dlists.factor
@@ -95,7 +95,7 @@ M: dlist pop-front* ( dlist -- )
     [
         [
             [ empty-dlist ] unless*
-            [ f ] change-next drop
+            next>>
             f over set-prev-when
         ] change-front drop
     ] keep
@@ -108,7 +108,7 @@ M: dlist pop-back* ( dlist -- )
     [
         [
             [ empty-dlist ] unless*
-            [ f ] change-prev drop
+            prev>>
             f over set-next-when
         ] change-back drop
     ] keep
@@ -157,6 +157,9 @@ M: dlist clear-deque ( dlist -- )
 
 : 1dlist ( obj -- dlist ) <dlist> [ push-front ] keep ;
 
+: dlist-filter ( dlist quot -- dlist )
+    over [ '[ dup obj>> @ [ drop ] [ _ delete-node ] if ] dlist-each-node ] keep ; inline
+
 M: dlist clone
     <dlist> [ '[ _ push-back ] dlist-each ] keep ;
 

From cbb1f1c60b3f224cf8c9e9913818b5afeee4a596 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Sat, 9 May 2009 20:15:03 -0500
Subject: [PATCH 3/5] docs for dlist-filter

---
 basis/dlists/dlists-docs.factor | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/basis/dlists/dlists-docs.factor b/basis/dlists/dlists-docs.factor
index 12e39746c7..e210ad35ce 100755
--- a/basis/dlists/dlists-docs.factor
+++ b/basis/dlists/dlists-docs.factor
@@ -15,6 +15,7 @@ $nl
 "Iterating over elements:"
 { $subsection dlist-each }
 { $subsection dlist-find }
+{ $subsection dlist-filter }
 { $subsection dlist-any? }
 "Deleting a node matching a predicate:"
 { $subsection delete-node-if* }
@@ -40,6 +41,11 @@ HELP: dlist-find
     "This operation is O(n)."
 } ;
 
+HELP: dlist-filter
+{ $values { "dlist" { $link dlist } } { "quot" quotation } { "dlist" { $link dlist } } }
+{ $description "Applies the quotation to each element of the " { $link dlist } " in turn, removing the corresponding nodes if the quotation returns " { $link f } "." }
+{ $side-effects { "dlist" } } ;
+
 HELP: dlist-any?
 { $values { "dlist" { $link dlist } } { "quot" quotation } { "?" "a boolean" } }
 { $description "Just like " { $link dlist-find } " except it doesn't return the object." }

From e4059d8393c81efe4ff7ebdb01e630d492ffbe19 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Sat, 9 May 2009 20:15:55 -0500
Subject: [PATCH 4/5] clamp coordinates when doing terrain collision detection
 past the edge of the segment

---
 extra/terrain/terrain.factor | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/extra/terrain/terrain.factor b/extra/terrain/terrain.factor
index fe105b2e52..590244ca6a 100644
--- a/extra/terrain/terrain.factor
+++ b/extra/terrain/terrain.factor
@@ -138,8 +138,11 @@ M: terrain-world tick-length
 : apply-gravity ( velocity -- velocity' )
     1 over [ GRAVITY - ] change-nth ;
 
+: clamp-coords ( coords dim -- coords' )
+    [ { 0 0 } vmax ] dip { 2 2 } v- vmin ;
+
 :: pixel-indices ( coords dim -- indices )
-    coords vfloor [ >integer ] map :> floor-coords
+    coords vfloor [ >integer ] map dim clamp-coords :> floor-coords
     floor-coords first2 dim first * + :> base-index
     base-index dim first + :> next-row-index
 

From 7584b3075593b95689df75c2d69ebec261157db6 Mon Sep 17 00:00:00 2001
From: Joe Groff <arcata@gmail.com>
Date: Sat, 9 May 2009 20:23:56 -0500
Subject: [PATCH 5/5] "math" help-lint

---
 core/math/math-docs.factor | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor
index 75370d6cfd..e5f68a511c 100644
--- a/core/math/math-docs.factor
+++ b/core/math/math-docs.factor
@@ -274,7 +274,7 @@ HELP: fp-nan-payload
 { $description "If " { $snippet "x" } " is an IEEE Not-a-Number value, returns the payload encoded in the value. Returns " { $link f } " if " { $snippet "x" } " is not a " { $link float } "." } ;
 
 HELP: <fp-nan>
-{ $values { "payload" integer } { "float" float } }
+{ $values { "payload" integer } { "nan" float } }
 { $description "Constructs an IEEE Not-a-Number value with a payload of " { $snippet "payload" } "." }
 { $notes "A " { $snippet "payload" } " of " { $snippet "0" } " will construct an Infinity value." } ;