diff --git a/src/core/kaplay/interactions/index.js b/src/core/kaplay/interactions/index.js index 924d6618..6f696eed 100644 --- a/src/core/kaplay/interactions/index.js +++ b/src/core/kaplay/interactions/index.js @@ -11,5 +11,4 @@ export const attachInteractions = (interactions, gameObjTag) => { k.onSceneLeave((currentScene) => { saveScene(currentScene); }); - }; diff --git a/src/main.js b/src/main.js index 37fba8dc..7ea7c414 100644 --- a/src/main.js +++ b/src/main.js @@ -46,7 +46,6 @@ if (gameState) { k.go('start'); // Go to the default starting scene } - // To test different maps instead of going through each and every scene to get to yours, // Import the scene, name the scene, and then name the spawn point as an additional tag // k.go('insert_scene_name_here', 'insert_spawn_point_here'); diff --git a/src/player.controls.js b/src/player.controls.js index 130b2a53..e2244673 100644 --- a/src/player.controls.js +++ b/src/player.controls.js @@ -69,8 +69,8 @@ export const addPlayerControls = (player) => { ? player.state.speed * 1.25 : player.state.speed * 1.1 : player.state.energy >= 50 - ? player.state.speed * 0.707106781188095 * 1.25 // Dot product for diagonal movement 45% - : player.state.speed * 0.707106781188095 * 1.1; + ? player.state.speed * 0.707106781188095 * 1.25 // Dot product for diagonal movement 45% + : player.state.speed * 0.707106781188095 * 1.1; player.move(moveDir.unit().scale(speed)); }); diff --git a/src/scenes/bootstrap.js b/src/scenes/bootstrap.js index be322a24..ffb85d94 100644 --- a/src/scenes/bootstrap.js +++ b/src/scenes/bootstrap.js @@ -13,12 +13,10 @@ export async function bootstrap(bootMapCb, mapArgs) { const [map, spawnpoint, gameObjects, interactions, sounds] = await bootMapCb(); - - if (mapArgs?.enter_tag === "Player") { - player.pos.x = gameState.player.position.x - player.pos.y = gameState.player.position.y - } - else { + if (mapArgs?.enter_tag === 'Player') { + player.pos.x = gameState.player.position.x; + player.pos.y = gameState.player.position.y; + } else { player.pos = (mapArgs?.enter_tag && spawnpoint[mapArgs?.enter_tag]) || spawnpoint.player; diff --git a/src/utils/gameState.js b/src/utils/gameState.js index 937a602a..49494196 100644 --- a/src/utils/gameState.js +++ b/src/utils/gameState.js @@ -13,8 +13,8 @@ const initialState = () => ({ isInDialog: false, collectedCoins: 0, score: 0, - scene: "start", - position: { x: 32, y: 384 } + scene: 'start', + position: { x: 32, y: 384 }, }, }); @@ -23,7 +23,7 @@ let currentState = undefined; export const clearSavedGame = () => { localStorage.removeItem(LOCAL_STORAGE_GAME_STATE_KEY); - currentState = undefined + currentState = undefined; }; const syncStateProps = (stateToCheck, defaultState) => { diff --git a/src/utils/saveCurrentScene.js b/src/utils/saveCurrentScene.js index 8cd3d7ca..699e309c 100644 --- a/src/utils/saveCurrentScene.js +++ b/src/utils/saveCurrentScene.js @@ -1,4 +1,4 @@ -import { getGameState, setGameState } from "./gameState"; +import { getGameState, setGameState } from './gameState'; // Function to save current scene to local storage export const saveScene = (sceneName) => { @@ -9,10 +9,9 @@ export const saveScene = (sceneName) => { // console.log(`Scene ${sceneName} saved to local storage.`); const gameState = getGameState(); - gameState.player["scene"] = sceneName; + gameState.player['scene'] = sceneName; setGameState(gameState); - -} +}; // Function to save player's position to local storage export const savePosition = (player) => { @@ -26,10 +25,9 @@ export const savePosition = (player) => { // console.log(`Position (${player.pos.x}, ${player.pos.y}) saved to local storage.`); const gameState = getGameState(); - gameState.player["position"] = { + gameState.player['position'] = { x: player.pos.x, - y: player.pos.y - } + y: player.pos.y, + }; setGameState(gameState); -} - +};