summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop/Game.fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/LivingVillage.Desktop/Game.fs')
-rw-r--r--src/LivingVillage.Desktop/Game.fs43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/LivingVillage.Desktop/Game.fs b/src/LivingVillage.Desktop/Game.fs
index 79c6fec..ab9b628 100644
--- a/src/LivingVillage.Desktop/Game.fs
+++ b/src/LivingVillage.Desktop/Game.fs
@@ -149,8 +149,25 @@ type LivingVillageGame() as this =
let mutable pauseHelpControl: SimulationControl option = None
let recordMode = Environment.GetEnvironmentVariable("LV_AUTOPLAY_RECORD") = "1"
let mutable recordIndex = 0
+ let mutable scale = int (
+ match Environment.GetEnvironmentVariable("LV_MAP_SCALE") with
+ | null | "" -> 1
+ | v -> match Int32.TryParse v with (true, value) -> max 1 value | _ -> 1)
+ let mapTourMode = Environment.GetEnvironmentVariable("LV_MAP_TOUR") = "1"
+ let mutable tourWaypoints =
+ [ (1, 1); (255, 191); (509, 381); (256, 60); (256, 300); (80, 200); (430, 300) ]
+ let mutable tourIndex = 0
+ let mutable tourFrame = 0
do
+ if scale > 1 then
+ Sim.configureBounds (64 * scale) (48 * scale)
+ ProceduralMap.activate (uint64 4242)
+ if mapTourMode then
+ tourWaypoints <-
+ [ (1, 1); (Sim.mapWidthTiles / 2, Sim.mapHeightTiles / 2); (Sim.mapWidthTiles - 3, Sim.mapHeightTiles - 3)
+ (Sim.mapWidthTiles / 2, 60); (Sim.mapWidthTiles / 2, Sim.mapHeightTiles - 60)
+ (80, 200); (430, 300) ]
graphics.PreferredBackBufferWidth <- 1280
graphics.PreferredBackBufferHeight <- 720
graphics.SynchronizeWithVerticalRetrace <- true
@@ -272,8 +289,32 @@ type LivingVillageGame() as this =
printfn (if nextState.TimedOut then "sample result=timeout" else "sample result=ok")
this.Exit()
+ member private this.RunMapTour () =
+ let (tileX, tileY) = tourWaypoints.[tourIndex % tourWaypoints.Length]
+ let position : Vec2 =
+ { X = float32 (tileX * Sim.tilePixels + Sim.tilePixels / 2)
+ Y = float32 (tileY * Sim.tilePixels + Sim.tilePixels / 2) }
+ world <- { world with Avatar = { world.Avatar with Pos = position } }
+ // give NPCs active ticks so the town stays alive between waypoints
+ for _ in 0 .. 7 do
+ world <- Sim.step { Input = { MoveX = 0.0f; MoveY = 0.0f } } world
+ avatarFacing <- VillageArt.SouthFacing
+ m5View <- M5Interaction.refreshPrompt world m5View
+ this.CenterCamera()
+ tourFrame <- tourFrame + 1
+ if tourFrame >= 45 then
+ tourFrame <- 0
+ tourIndex <- tourIndex + 1
+ if tourIndex >= tourWaypoints.Length then
+ printfn "map tour=complete frames={recordIndex}"
+ this.Exit()
+ else
+ printfn $"map tour={tourIndex} at tile=({tileX},{tileY})"
+
member private this.UpdatePlaying (gameTime: GameTime) (kb: KeyboardState) (pressed: Keys -> bool) (pressedAny: Keys list -> bool) =
- if sampleMode then
+ if mapTourMode then
+ this.RunMapTour()
+ elif sampleMode then
this.RunSampleMode()
else
this.UpdatePlayingManual gameTime kb pressed pressedAny