All files / games/roguelike/src/game/screens start.ts

100% Statements 12/12
100% Branches 4/4
100% Functions 3/3
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  12x 12x 12x 12x     18x       9x 9x     8x   8x 6x   8x     12x      
import { Keys } from "jga-games-commands";
import { DisplayInterface } from "jga-games-display";
import { Engine } from "jga-games-engine";
import { InputDataInterface, Screen } from "jga-games-screens";
 
export class StartScreen extends Screen {
    public constructor(engine: Engine, display: DisplayInterface) {
        super("Start", engine, display);
    }
 
    public render(): void {
        // Render our prompt to the screen
        this.display.drawText({ x: 1, y: 1 }, "%c{yellow}Space Roguelike");
        this.display.drawText({ x: 1, y: 2 }, "Press [Enter] to start!");
    }
 
    public handleInput(inputType: string, inputData: InputDataInterface): string | null {
        let result = null;
        // When [Enter] is pressed, go to the play screen
        if (inputType === "keydown" && inputData.code === Keys.RETURN) {
            result = "play";
        }
 
        return result;
    }
}