Skip to content

Commit 84a2ee1

Browse files
committed
Fix broken new game and animation toggle after last update
Other Changes: - New Game will now spawn two blocks just like when game starts for the first time - Add network host setting to Vite config to allow for testing the game on mobile
1 parent a8237a0 commit 84a2ee1

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/game.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ export const initGame = async (_eventHandler, _spawnManager, _animationManager)
110110
export const newGame = () => {
111111
gameState = newState();
112112

113-
spawnManager = new SpawnManager(gameState);
113+
spawnManager.setGameState(gameState);
114+
animationManager.setGameState(gameState);
114115

115-
const location = spawnManager.determineNextBlockLocation();
116+
let location = spawnManager.determineNextBlockLocation();
117+
spawnBlock(location.x, location.y, spawnManager.determineNextBlockValue());
118+
119+
location = spawnManager.determineNextBlockLocation();
116120
spawnBlock(location.x, location.y, spawnManager.determineNextBlockValue());
117-
118-
animationManager = new AnimationManager(gameState);
119121

120122
eventHandler("init", { gameState });
121123

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { initGame, move, undo, DIRECTION_DOWN, DIRECTION_LEFT, DIRECTION_RIGHT, DIRECTION_UP, setStorageFuncs } from "./game";
2-
import { getPreferenceValue, initPreferences } from "./preferences";
1+
import { initGame, newGame, move, undo, DIRECTION_DOWN, DIRECTION_LEFT, DIRECTION_RIGHT, DIRECTION_UP, setStorageFuncs } from "./game";
2+
import { getPreferenceValue, initPreferences, savePreferenceValue } from "./preferences";
33
import { createDialogContentFromTemplate, renderBackRow, renderBoard, renderDialog } from "./render";
44
import feather from "feather-icons";
55
import { clearGame, gameExists, loadGame, saveGame } from "./storage/browser";

vite.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ export default defineConfig({
1616
commonjsOptions: {
1717
transformMixedEsModules: true,
1818
}
19-
}
19+
},
20+
server: {
21+
host: true,
22+
},
2023
});

0 commit comments

Comments
 (0)