From d233fd1062e3330101c0299ae1ee8f35de0890e2 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Wed, 10 Aug 2022 19:07:58 +0000 Subject: [PATCH] Make puzzleWidth and puzzleHeight variable --- .../source/HabitModel.hx | 4 +++- .../source/HabitModel.kiss | 10 ++++++---- .../source/HabitState.kiss | 9 +++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx b/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx index a52125bc..0e1fe571 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx @@ -29,7 +29,9 @@ typedef Entry = { typedef RewardFile = { path: String, - startingPoints: Int + startingPoints: Int, + puzzleWidth: Int, + puzzleHeight: Int }; typedef Puzzle = { diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.kiss index 3b8154db..1487b770 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.kiss @@ -30,9 +30,11 @@ ((when (= lastHeader "FILES") (Some line)) (rewardFiles.push (let [parts (line.split " ") + puzzleHeight (Std.parseInt (parts.pop)) + puzzleWidth (Std.parseInt (parts.pop)) startingPoints (Std.parseInt (parts.pop)) path (parts.join " ")] - (objectWith path startingPoints)))) + (objectWith path startingPoints puzzleWidth puzzleHeight)))) ((Some line) (.push (case lastHeader @@ -138,7 +140,7 @@ "${label.label} $(* "|" label.points)") "/")") (function :String stringifyRewardFile [:RewardFile rewardFile] - "${rewardFile.path} ${rewardFile.startingPoints}") + "${rewardFile.path} ${rewardFile.startingPoints} ${rewardFile.puzzleWidth} ${rewardFile.puzzleHeight}") (method :Void save [] (localVar &mut content "DAILY\n-----\n") @@ -217,6 +219,6 @@ (objectWith [labels (for label labels (objectWith [points 0] label))] type)) (save)) -(method addRewardFile [path startingPoints] - (rewardFiles.push (objectWith path startingPoints)) +(method addRewardFile [path startingPoints puzzleWidth puzzleHeight] + (rewardFiles.push (objectWith path startingPoints puzzleWidth puzzleHeight)) (save)) \ No newline at end of file diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss index 96b2ee4c..96b9d0c1 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss @@ -111,9 +111,9 @@ (defAlias &ident EDGE_LEEWAY 25) (defAlias &ident BUBBLE_SIZE 15) -(var PUZZLE_WIDTH 6) -(var PUZZLE_HEIGHT 5) -(var TOTAL_PIECES (* PUZZLE_WIDTH PUZZLE_HEIGHT)) +(defAlias &ident PUZZLE_WIDTH .puzzleWidth (nth model.rewardFiles rewardFileIndex)) +(defAlias &ident PUZZLE_HEIGHT .puzzleHeight (nth model.rewardFiles rewardFileIndex)) +(defAlias &ident TOTAL_PIECES (* PUZZLE_WIDTH PUZZLE_HEIGHT)) (prop &mut :FlxSprite rewardSprite null) (prop &mut :FlxTypedGroup rewardSprites null) (prop &mut :Map matchingPiecesLeft (new Map)) @@ -467,7 +467,8 @@ (nextPuzzleChoiceGroup.add (new FlxButton (+ x text.width) y "CHOOSE" ->:Void { (remove nextPuzzleChoiceGroup) (set nextPuzzleChoiceGroup null) - (model.addRewardFile np.path nextStartingPoints) + // TODO generate a good width and height while respecting user settings + (model.addRewardFile np.path nextStartingPoints 6 5) (setModel model) }))))