Skip to content
This repository
Browse code

Remove ViewPort parameter from simulations.

  • Loading branch information...
commit 3a40249e04255d082821ff3e6f904e92c6de5f9a 1 parent c62f1d6
Chris Smith authored February 27, 2012
14  gloss-web-adapters/GlossAdapters.hs
@@ -10,17 +10,16 @@ import Graphics.Gloss.Interface.Game
10 10
 
11 11
 data Simulation = forall a. Simulation
12 12
     a
13  
-    (ViewPort -> Float -> a -> a)
  13
+    (Float -> a -> a)
14 14
     (a -> Picture)
15 15
 
16 16
 
17 17
 advanceSimulation :: Float -> Simulation -> Simulation
18  
-advanceSimulation t (Simulation c s p) = Simulation (s v t c) s p
19  
-    where v = ViewPort (0,0) 0 1
  18
+advanceSimulation dt (Simulation w s d) = Simulation (s dt w) s d
20 19
 
21 20
 
22 21
 simulationToPicture :: Simulation -> Picture
23  
-simulationToPicture (Simulation c s p) = p c
  22
+simulationToPicture (Simulation w s d) = d w
24 23
 
25 24
 
26 25
 data Game = forall a. Game
@@ -31,13 +30,12 @@ data Game = forall a. Game
31 30
 
32 31
 
33 32
 advanceGame :: Float -> Game -> Game
34  
-advanceGame t (Game w e a d) = Game (a t w) e a d
  33
+advanceGame dt (Game w e s d) = Game (s dt w) e s d
35 34
 
36 35
 
37 36
 signalGame :: Event -> Game -> Game
38  
-signalGame ev (Game w e a d) = Game (e ev w) e a d
  37
+signalGame ev (Game w e s d) = Game (e ev w) e s d
39 38
 
40 39
 
41 40
 gameToPicture :: Game -> Picture
42  
-gameToPicture (Game w e a d) = d w
43  
-
  41
+gameToPicture (Game w e s d) = d w
6  src/Main.hs
@@ -137,9 +137,9 @@ sim app = do
137 137
         TextNode "var sourceCookie = 'simulateSource';",
138 138
         TextNode "var initialSource = 'import Graphics.Gloss\\n\\n",
139 139
         TextNode "data BallState = BallAt Float Float\\n",
140  
-        TextNode "initial _ = BallAt 100 0\\n",
141  
-        TextNode "step _ t (BallAt x v) = BallAt (x+v*t) (0.99*v-x*t)\\n",
142  
-        TextNode "draw     (BallAt x v) = translate x x (circle 20)';"
  140
+        TextNode "initial _           = BallAt 100 0\\n",
  141
+        TextNode "step t (BallAt x v) = BallAt (x+v*t) (0.99*v-x*t)\\n",
  142
+        TextNode "draw   (BallAt x v) = translate x x (circle 20)';"
143 143
         ]]
144 144
 
145 145
 

0 notes on commit 3a40249

Please sign in to comment.
Something went wrong with that request. Please try again.