11import { Container , Graphics , HTMLText } from "pixi.js" ;
22import { HEIGHT , TEXT_FONT , theme , WIDTH } from "../constants" ;
33import GameNode from "./GameNode" ;
4- import { inputs } from "../inputs" ;
4+ import { type PlayerInput } from "../inputs" ;
55import { getScores , setScores , type Score } from "../storage" ;
66import { playSound } from "../audio" ;
77import { container } from "../util" ;
@@ -18,11 +18,13 @@ export default class ScoreScreen extends GameNode {
1818 nameEnter = new Container ( ) ;
1919 arrows = new Container ( ) ;
2020 state : State = "enter_name" ;
21+ inputMap : PlayerInput ;
2122 onFinish ?: ( ) => void ;
2223
23- constructor ( score : number ) {
24+ constructor ( score : number , inputMap : PlayerInput ) {
2425 super ( ) ;
2526 this . score = score ;
27+ this . inputMap = inputMap ;
2628 this . view . position = { x : WIDTH / 2 , y : HEIGHT / 2 } ;
2729
2830 const containerSize = HEIGHT * 0.75 ;
@@ -167,15 +169,15 @@ export default class ScoreScreen extends GameNode {
167169 if ( this . state === "enter_name" ) {
168170 switch ( e . key ) {
169171 // up/down: change letter
170- case inputs . player1 . up : {
172+ case this . inputMap . up : {
171173 const currentLetter = this . letters [ this . #activeIndex] ;
172174 const letterIndex = LETTERS . indexOf ( currentLetter . text ) ;
173175 currentLetter . text = LETTERS [ ( letterIndex || LETTERS . length ) - 1 ] ;
174176 pulse ( currentLetter , 1.1 ) ;
175177 playSound ( "move" ) ;
176178 break ;
177179 }
178- case inputs . player1 . down : {
180+ case this . inputMap . down : {
179181 const currentLetter = this . letters [ this . #activeIndex] ;
180182 const letterIndex = LETTERS . indexOf ( currentLetter . text ) ;
181183 currentLetter . text = LETTERS [ ( letterIndex + 1 ) % LETTERS . length ] ;
@@ -184,17 +186,17 @@ export default class ScoreScreen extends GameNode {
184186 break ;
185187 }
186188 // left/right: change active index
187- case inputs . player1 . left : {
189+ case this . inputMap . left : {
188190 this . activeIndex = ( this . activeIndex || this . letters . length ) - 1 ;
189191 playSound ( "move" ) ;
190192 break ;
191193 }
192- case inputs . player1 . right : {
194+ case this . inputMap . right : {
193195 this . activeIndex = ( this . activeIndex + 1 ) % this . letters . length ;
194196 playSound ( "move" ) ;
195197 break ;
196198 }
197- case inputs . player1 . flip : {
199+ case this . inputMap . flip : {
198200 playSound ( "clear" ) ;
199201 this . showHighScores ( ) ;
200202 break ;
0 commit comments