From 557eb3316e02d8b0d2dbca38307da9a237757bb3 Mon Sep 17 00:00:00 2001 From: mehbark Date: Sun, 24 Dec 2023 13:27:27 -0500 Subject: [PATCH] done enough! flaked --- flake.nix | 8 ++++++++ main.scm | 23 ++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 5352a7b..8df3f04 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,14 @@ in { schemas = flake-schemas.schemas; + packages = forEachSupportedSystem ({ pkgs }: { + default = pkgs.writeShellScriptBin "mineschemer" '' + ${pkgs.chez}/bin/scheme --script ${ + pkgs.writeText "main.scm" (builtins.readFile ./main.scm) + } $@ + ''; + }); + devShells = forEachSupportedSystem ({ pkgs }: { default = pkgs.mkShell { diff --git a/main.scm b/main.scm index b52abc0..abe441f 100644 --- a/main.scm +++ b/main.scm @@ -690,13 +690,14 @@ ; draw-game-over as a separate thing would be nice ; the game shows -99 when (- num-mines num-flagged) is less than -99 -(define (run-game mines width height) +(define (run-game mines width height seed) (init-window (* width square-width) (* height square-width) "mineschemer") (set-target-fps 60) - (let ([seed (time-nanosecond (current-time))]) - (display "seed: ") (display seed) - (newline) - (random-seed seed)) + + (display "seed: ") (display seed) + (newline) + (random-seed seed) + (let ([skin (load-skin "xp-flowers.bmp")] [game (new-game mines width height)]) ;; (display skin) @@ -728,3 +729,15 @@ ; let's save playing with shaders for later ; seems like minesweeper.online doesn't need middle-clicking to be separate (left-clicking performs the same function) + +(define (get-nano-seed) + (time-nanosecond (current-time))) + +(unless (and + (>= 4 (length (command-line-arguments)) 3) + (for-all number? (map string->number (command-line-arguments)))) + (display "i need 3-4 numbers (MINES WIDTH HEIGHT SEED)") + (exit 1)) + +(apply run-game (append (map string->number (command-line-arguments)) + (list (get-nano-seed))))