From 0483a5044a26ae48224116e1502c06deb30ed39c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 13 May 2009 19:31:58 -0500 Subject: [PATCH 1/3] rotate-circular word --- basis/circular/circular-docs.factor | 6 ++++++ basis/circular/circular-tests.factor | 1 + basis/circular/circular.factor | 3 +++ 3 files changed, 10 insertions(+) diff --git a/basis/circular/circular-docs.factor b/basis/circular/circular-docs.factor index c7af57c1fe..235d5db2c7 100644 --- a/basis/circular/circular-docs.factor +++ b/basis/circular/circular-docs.factor @@ -43,6 +43,11 @@ HELP: push-growing-circular { "elt" object } { "circular" circular } } { $description "Pushes an element onto a " { $link growing-circular } " object." } ; +HELP: rotate-circular +{ $values + { "circular" circular } } +{ $description "Advances the start index of a circular object by one." } ; + ARTICLE: "circular" "Circular sequences" "The " { $vocab-link "circular" } " vocabulary implements the " { $link "sequence-protocol" } " to allow an arbitrary start index and wrap-around indexing." $nl "Creating a new circular object:" @@ -51,6 +56,7 @@ ARTICLE: "circular" "Circular sequences" { $subsection } "Changing the start index:" { $subsection change-circular-start } +{ $subsection rotate-circular } "Pushing new elements:" { $subsection push-circular } { $subsection push-growing-circular } ; diff --git a/basis/circular/circular-tests.factor b/basis/circular/circular-tests.factor index 105e3790aa..3a94e14640 100644 --- a/basis/circular/circular-tests.factor +++ b/basis/circular/circular-tests.factor @@ -12,6 +12,7 @@ circular strings ; [ CHAR: e ] [ "test" 5 swap nth-unsafe ] unit-test [ [ 1 2 3 ] ] [ { 1 2 3 } [ ] like ] unit-test +[ [ 2 3 1 ] ] [ { 1 2 3 } [ rotate-circular ] keep [ ] like ] unit-test [ [ 2 3 1 ] ] [ { 1 2 3 } 1 over change-circular-start [ ] like ] unit-test [ [ 3 1 2 ] ] [ { 1 2 3 } 1 over change-circular-start 1 over change-circular-start [ ] like ] unit-test [ [ 3 1 2 ] ] [ { 1 2 3 } -100 over change-circular-start [ ] like ] unit-test diff --git a/basis/circular/circular.factor b/basis/circular/circular.factor index 9f3a71f2a8..909b2ed713 100644 --- a/basis/circular/circular.factor +++ b/basis/circular/circular.factor @@ -27,6 +27,9 @@ M: circular virtual-seq seq>> ; #! change start to (start + n) mod length circular-wrap (>>start) ; +: rotate-circular ( circular -- ) + [ start>> 1 + ] keep circular-wrap (>>start) ; + : push-circular ( elt circular -- ) [ set-first ] [ 1 swap change-circular-start ] bi ; From 575b0645a39e2b49121597f9d8ba77e4649be161 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 13 May 2009 19:35:46 -0500 Subject: [PATCH 2/3] in game-worlds, open game-input before starting game-loop and close after. otherwise there's a chance the game-loop might tick without game-input available --- extra/game-worlds/game-worlds.factor | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/extra/game-worlds/game-worlds.factor b/extra/game-worlds/game-worlds.factor index c9ea03e333..2fb115b5d0 100644 --- a/extra/game-worlds/game-worlds.factor +++ b/extra/game-worlds/game-worlds.factor @@ -12,12 +12,12 @@ M: game-world draw* swap >>tick-slice draw-world ; M: game-world begin-world + open-game-input dup [ tick-length ] [ ] bi [ >>game-loop ] keep start-loop - drop - open-game-input ; - -M: game-world end-world - close-game-input - [ [ stop-loop ] when* f ] change-game-loop + drop ; + +M: game-world end-world + [ [ stop-loop ] when* f ] change-game-loop + close-game-input drop ; From 96e8006eb323f0e252031d640b138b66caa86a7b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 13 May 2009 19:36:06 -0500 Subject: [PATCH 3/3] redundant math is redundant --- extra/terrain/shaders/shaders.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/terrain/shaders/shaders.factor b/extra/terrain/shaders/shaders.factor index e5b517ad59..108856e1dd 100644 --- a/extra/terrain/shaders/shaders.factor +++ b/extra/terrain/shaders/shaders.factor @@ -8,10 +8,10 @@ varying vec3 direction; void main() { - vec4 v = vec4(gl_Vertex.xy, 1.0, 1.0); + vec4 v = vec4(gl_Vertex.xy, -1.0, 1.0); gl_Position = v; - vec4 p = (gl_ProjectionMatrixInverse * v) * vec4(1,1,-1,1); + vec4 p = gl_ProjectionMatrixInverse * v; float s = sin(sky_theta), c = cos(sky_theta); direction = mat3(1, 0, 0, 0, c, s, 0, -s, c)