@@ -5,7 +5,13 @@ import * as consts from "./constants.ts";
55import { Inputs } from "./constants.ts" ;
66import { Block } from "./constants.ts" ;
77import 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
1016export 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 // 当たり判定結果を反映する
0 commit comments