Skip to content

Commit b8222bb

Browse files
committed
能力使用後の画像
1 parent 0f72354 commit b8222bb

File tree

6 files changed

+32
-9
lines changed

6 files changed

+32
-9
lines changed
26.2 KB
Loading

src/ability.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export function copy(cx: Context) {
7474
});
7575

7676
History.record(cx);
77+
78+
cx.dynamic.player.activated = true;
7779
}
7880
export function paste(cx: Context) {
7981
const state = get(cx.state);
@@ -98,6 +100,8 @@ export function paste(cx: Context) {
98100

99101
printCells(createSnapshot(cx).game.cells, "paste");
100102
History.record(cx);
103+
104+
cx.dynamic.player.activated = true;
101105
}
102106
export function cut(cx: Context) {
103107
const { focus } = cx.dynamic;
@@ -126,6 +130,8 @@ export function cut(cx: Context) {
126130

127131
printCells(createSnapshot(cx).game.cells, "cut");
128132
History.record(cx);
133+
134+
cx.dynamic.player.activated = true;
129135
}
130136

131137
// 左向きのときにブロックを配置する位置を変更するのに使用

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export async function setup(
102102
vy: 0,
103103
onGround: false,
104104
jumpingBegin: null,
105+
activated: false,
105106
holdingKeys: {},
106107
facing: Facing.right,
107108
},

src/player.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import * as consts from "./constants.ts";
55
import { Inputs } from "./constants.ts";
66
import { Block } from "./constants.ts";
77
import type { AbilityInit, Context } from "./public-types.ts";
8-
import { bunnyTexture, characterCtrlTexture, highlightHoldTexture, highlightTexture } from "./resources.ts";
8+
import {
9+
bunnyTexture,
10+
characterActivatedTexture,
11+
characterCtrlTexture,
12+
highlightHoldTexture,
13+
highlightTexture,
14+
} from "./resources.ts";
915

1016
export function init(
1117
cx: Context,
@@ -58,6 +64,7 @@ export function init(
5864
vy: 0,
5965
onGround: false,
6066
jumpingBegin: null,
67+
activated: false,
6168
holdingKeys: {},
6269
facing: consts.Facing.right,
6370
};
@@ -284,14 +291,22 @@ export function tick(cx: Context, ticker: Ticker) {
284291
player.sprite.scale.x = Math.abs(player.sprite.scale.x);
285292
}
286293

287-
if (player.holdingKeys[Inputs.Ctrl]) {
288-
player.sprite.texture = characterCtrlTexture;
289-
player.sprite.width = consts.playerWidth * blockSize;
290-
player.sprite.height = (32 / 27) * consts.playerHeight * blockSize;
294+
// プレイヤーの能力使用状況を反映
295+
if (player.activated && player.holdingKeys[Inputs.Ctrl] && player.onGround) {
296+
player.sprite.texture = characterActivatedTexture;
297+
player.sprite.width = (29 / 26) * consts.playerWidth * blockSize;
298+
player.sprite.height = (24 / 27) * consts.playerHeight * blockSize;
291299
} else {
292-
player.sprite.texture = bunnyTexture;
293-
player.sprite.width = consts.playerWidth * blockSize;
294-
player.sprite.height = consts.playerHeight * blockSize;
300+
player.activated = false;
301+
if (player.holdingKeys[Inputs.Ctrl]) {
302+
player.sprite.texture = characterCtrlTexture;
303+
player.sprite.width = consts.playerWidth * blockSize;
304+
player.sprite.height = (32 / 27) * consts.playerHeight * blockSize;
305+
} else {
306+
player.sprite.texture = bunnyTexture;
307+
player.sprite.width = consts.playerWidth * blockSize;
308+
player.sprite.height = consts.playerHeight * blockSize;
309+
}
295310
}
296311

297312
// 当たり判定結果を反映する

src/public-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export type Context = {
7979
onGround: boolean;
8080
vx: number;
8181
vy: number;
82+
activated: boolean;
8283
};
8384
};
8485
// about time

src/resources.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Assets } from "pixi.js";
33
// assets
44
export const bunnyTexture = await Assets.load("/assets/character-normal.png");
55
export const characterCtrlTexture = await Assets.load("/assets/character-ctrl.png");
6+
export const characterActivatedTexture = await Assets.load("/assets/character-activated.png");
67
export const rockTexture = await Assets.load("/assets/block.png");
7-
// export const movableTexture = await Assets.load("/assets/movable.png");
88
export const fallableTexture = await Assets.load("/assets/woodenbox.png");
99
export const switchTexture = await Assets.load("/assets/switch.png");
1010
export const switchBaseTexture = await Assets.load("/assets/switch-base.png");

0 commit comments

Comments
 (0)