Skip to content

Commit a785a91

Browse files
committed
feat: Tutorial Image (wip)
1 parent ac2bb44 commit a785a91

File tree

6 files changed

+45
-1
lines changed

6 files changed

+45
-1
lines changed

public/assets/tutorial1.png

147 KB
Loading

public/assets/tutorial2.png

190 KB
Loading

public/assets/tutorial3.png

191 KB
Loading

src/grid.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {
1313
switchBaseTexture,
1414
switchPressedTexture,
1515
switchTexture,
16+
tutorialImg1,
17+
tutorialImg2,
18+
tutorialImg3,
1619
} from "./resources.ts";
1720
import type { StageDefinition } from "./stages.ts";
1821

@@ -793,6 +796,27 @@ function updateSprite(
793796
sprite.y = y * blockSize + marginY;
794797
}
795798

799+
export function createTutorialSprite(
800+
cx: { _stage_container: Container },
801+
order: number,
802+
) {
803+
let sprite = new Sprite(tutorialImg1);
804+
switch (order) {
805+
case 2:
806+
sprite = new Sprite(tutorialImg2);
807+
break;
808+
case 3:
809+
sprite = new Sprite(tutorialImg3);
810+
break;
811+
}
812+
sprite.width = 200;
813+
sprite.height = 200;
814+
sprite.x = 500;
815+
sprite.y = 100;
816+
cx._stage_container.addChild(sprite);
817+
}
818+
//ToDo: 現在の仕様では、Escメニュー表示状態でも動き続ける。
819+
796820
export function printCells(cells: GridCell[][], context?: string) {
797821
console.log(
798822
`${context ? context : "Grid"}:

src/main.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { Application, Container, type Ticker } from "pixi.js";
22
import { derived, get, writable } from "svelte/store";
33
import { Facing } from "./constants.ts";
4-
import { Grid, createCellsFromStageDefinition } from "./grid.ts";
4+
import {
5+
Grid,
6+
createCellsFromStageDefinition,
7+
createTutorialSprite,
8+
} from "./grid.ts";
59
import * as Player from "./player.ts";
610
import type { Context, GameState, UIInfo } from "./public-types.ts";
711
import { bunnyTexture } from "./resources.ts";
@@ -138,6 +142,19 @@ export async function setup(
138142
}),
139143
);
140144

145+
// Stage 1,2のチュートリアル表示実装機構
146+
// Frm stands for Frames
147+
let tutorialFrm = 0;
148+
app.ticker.add((ticker) => {
149+
tutorialFrm += ticker.deltaTime;
150+
// 1秒ごとにチュートリアルの画像が変わる
151+
createTutorialSprite(cx, Math.floor(tutorialFrm / 60 + 1));
152+
if (tutorialFrm >= 180) {
153+
tutorialFrm = 0;
154+
//Todo: Stage 1,2のみにする
155+
}
156+
});
157+
141158
cx.dynamic.player = Player.init(cx, bunnyTexture);
142159
app.ticker.add(unlessPaused((ticker) => Player.tick(cx, ticker)));
143160

src/resources.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ export const highlightTexture = await Assets.load("/assets/highlight.svg");
1212
export const highlightHoldTexture = await Assets.load(
1313
"/assets/highlight-hold.webp",
1414
);
15+
export const tutorialImg1 = await Assets.load("/assets/tutorial1.png");
16+
export const tutorialImg2 = await Assets.load("/assets/tutorial2.png");
17+
export const tutorialImg3 = await Assets.load("/assets/tutorial3.png");

0 commit comments

Comments
 (0)