Permalink
Browse files

ticks_per_second is an int

  • Loading branch information...
1 parent 4fea5ab commit 9f6c3251b82f01fdd12edf359fec8111b060c12e @dwrensha dwrensha committed Dec 8, 2012
@@ -205,10 +205,10 @@ struct
()
end
- val ticks_per_second = 60.0
+ val ticks_per_second = 60
fun dophysics world =
- let val timestep = 1.0 / ticks_per_second
+ let val timestep = 1.0 / (Real.fromInt ticks_per_second)
val () = BDD.World.step (world, timestep, 8, 3)
in () end
View
@@ -61,7 +61,7 @@ struct
| handle_event SDL.E_Quit s = NONE
| handle_event _ s = SOME s
- val ticks_per_second = 60.0
+ val ticks_per_second = 60
fun tick {key = k, things = locs} =
let
@@ -224,10 +224,10 @@ struct
SDL.flip screen
)
- val ticks_per_second = 60.0
+ val ticks_per_second = 60
fun dophysics () =
- let val timestep = 1.0 / ticks_per_second
+ let val timestep = 1.0 / (Real.fromInt ticks_per_second)
val () = BDD.World.step (world, timestep, 10, 10)
in () end
View
@@ -196,7 +196,7 @@ struct
| handle_event SDL.E_Quit s = NONE
| handle_event _ s = SOME s
- val ticks_per_second = 60.0
+ val ticks_per_second = 60
fun tick {robotloc = r, key = k} =
let
@@ -74,7 +74,7 @@ struct
| handle_event SDL.E_Quit s = NONE
| handle_event _ s = SOME s
- val ticks_per_second = 60.0
+ val ticks_per_second = 60
fun tick {starloc = s, robotlocs = rs, key = k} =
let
@@ -21,11 +21,12 @@ struct
in
val new_observed_time = now ()
val sim_seconds = toReal (new_observed_time - (!last_simulated_time))
+ val ticks_per_second = Real64.fromInt Game.ticks_per_second
val num_ticks = Int.max(0,
- Real64.round(sim_seconds * Game.ticks_per_second))
+ Real64.round(sim_seconds * ticks_per_second))
val () = last_simulated_time :=
(!last_simulated_time) +
- fromReal(Real64.fromInt(num_ticks) / Game.ticks_per_second)
+ fromReal(Real64.fromInt(num_ticks) / ticks_per_second)
end
in
case option_iterate Game.tick s num_ticks of
View
@@ -21,5 +21,5 @@ sig
It is important that calls to tick are cheap enough
that this rate can be comfortably achieved --- otherwise
rendering will occur less and less frequently. *)
- val ticks_per_second : Real64.real
+ val ticks_per_second : int
end
View
@@ -44,7 +44,7 @@ struct
(* fun tick {xpos=x, ypos=y} = SOME {xpos=x+1, ypos=y} *)
fun tick s = SOME s
- val ticks_per_second = 60.0
+ val ticks_per_second = 60
end
structure Main =

0 comments on commit 9f6c325

Please sign in to comment.