mirror of
https://github.com/danbulant/heaventaker
synced 2026-06-24 17:21:51 +00:00
transition into dialog
This commit is contained in:
parent
44ec4195c2
commit
f4b51f6264
4 changed files with 29 additions and 9 deletions
|
|
@ -5,9 +5,7 @@
|
||||||
import { characters } from "./stores/characters.js";
|
import { characters } from "./stores/characters.js";
|
||||||
import { dialog } from "./stores/dialog.js";
|
import { dialog } from "./stores/dialog.js";
|
||||||
import Game from "./pages/game.svelte";
|
import Game from "./pages/game.svelte";
|
||||||
import { gameActive } from "./stores/gameActive";
|
import { gameActive, page } from "./stores/gameActive";
|
||||||
|
|
||||||
var current = localStorage.getItem("dialog-page") || 0;
|
|
||||||
|
|
||||||
var preloads = new Map;
|
var preloads = new Map;
|
||||||
function preload(url) {
|
function preload(url) {
|
||||||
|
|
@ -33,7 +31,7 @@
|
||||||
if(!music.playing()) music.play();
|
if(!music.playing()) music.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(dialog[current]);
|
$: console.log(dialog[$page]);
|
||||||
console.log("Pancake recipe at https://github.com/danbulant/heaventaker");
|
console.log("Pancake recipe at https://github.com/danbulant/heaventaker");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -43,10 +41,10 @@
|
||||||
<title>Heaventaker</title>
|
<title>Heaventaker</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
{#if dialog[current].map}
|
{#if dialog[$page].map}
|
||||||
<Game bind:current />
|
<Game bind:current={$page} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Overlay active={$gameActive}>
|
<Overlay active={!$gameActive}>
|
||||||
<Dialog bind:current />
|
<Dialog bind:current={$page} />
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import Phaser, { Animations } from "phaser";
|
import Phaser, { Animations } from "phaser";
|
||||||
|
import { gameActive, page } from "../stores/gameActive";
|
||||||
import { steps } from "../stores/step";
|
import { steps } from "../stores/step";
|
||||||
import { keys } from "./input";
|
import { keys } from "./input";
|
||||||
|
import { dialog } from "../stores/dialog.js";
|
||||||
|
|
||||||
const textureWidth = 100;
|
const textureWidth = 100;
|
||||||
|
|
||||||
|
|
@ -16,6 +18,7 @@ export class GameScene extends Phaser.Scene {
|
||||||
/** @type {{
|
/** @type {{
|
||||||
background: string,
|
background: string,
|
||||||
sprite: string,
|
sprite: string,
|
||||||
|
next: string,
|
||||||
offset: { x: number, y: nunber },
|
offset: { x: number, y: nunber },
|
||||||
size: { x: number, y: number },
|
size: { x: number, y: number },
|
||||||
px: number,
|
px: number,
|
||||||
|
|
@ -119,6 +122,11 @@ export class GameScene extends Phaser.Scene {
|
||||||
this.player.x = x;
|
this.player.x = x;
|
||||||
this.player.y = y;
|
this.player.y = y;
|
||||||
}
|
}
|
||||||
|
if(item.type === "angel") {
|
||||||
|
this.angel = item;
|
||||||
|
this.angel.x = x;
|
||||||
|
this.angel.y = y;
|
||||||
|
}
|
||||||
if(item.type !== "wind") {
|
if(item.type !== "wind") {
|
||||||
item.sprite.setDepth(1);
|
item.sprite.setDepth(1);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -189,10 +197,22 @@ export class GameScene extends Phaser.Scene {
|
||||||
if(this.winds[toX][toY]) {
|
if(this.winds[toX][toY]) {
|
||||||
var movement = this.getMovementFromDirection(this.winds[toX][toY].direction);
|
var movement = this.getMovementFromDirection(this.winds[toX][toY].direction);
|
||||||
this.movePlayer(movement.x, movement.y, true);
|
this.movePlayer(movement.x, movement.y, true);
|
||||||
|
} else {
|
||||||
|
this.checkAngel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkAngel() {
|
||||||
|
var xdiff = Math.abs(this.player.x - this.angel.x);
|
||||||
|
var ydiff = Math.abs(this.player.y - this.angel.y);
|
||||||
|
if((xdiff === 0 && ydiff === 1) || (xdiff === 1 && ydiff === 0)) {
|
||||||
|
var next = dialog.findIndex(t => t.name === this.map.next);
|
||||||
|
page.set(next);
|
||||||
|
gameActive.set(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
canMove = true;
|
canMove = true;
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ export const maps = {
|
||||||
uriel: {
|
uriel: {
|
||||||
background: "level1",
|
background: "level1",
|
||||||
sprite: "uriel",
|
sprite: "uriel",
|
||||||
|
next: "uriel_entrance",
|
||||||
offset: { // map offset for alignment
|
offset: { // map offset for alignment
|
||||||
x: 60,
|
x: 60,
|
||||||
y: 100
|
y: 100
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
import { writable } from "svelte/store";
|
import { writable } from "svelte/store";
|
||||||
|
|
||||||
export const gameActive = writable(false);
|
export const gameActive = writable(true);
|
||||||
|
export const page = writable(parseInt(localStorage.getItem("dialog-page")) || 0);
|
||||||
Loading…
Reference in a new issue