Install Raspberry Pi OS (64-bit) f.e. via Raspberry Pi Imager on your SD-Card.
Boot with the SD-Card inside Raspberry Pi OS. Open a Terminal.
| export abstract class PizzaFactory { | |
| protected abstract create(): Pizza; | |
| } | |
| export class ProsciuttoFactory extends PizzaFactory { | |
| public create(): Pizza { | |
| let pizza = new Pizza(); | |
| pizza.addIngredients([ tomatoes, mozzarella, ham, salt, oliveOil ]); | |
| return pizza; | |
| } |
| export class SimpleEnemyFactory { | |
| public create(enemyType: string): Enemy { | |
| switch (enemyType) { | |
| case "bobbie": | |
| return new Bobbie(); | |
| case "wallace": | |
| return new Wallace(); |
| this.treeInstance = new Tree({ | |
| map: { | |
| width: this.game.canvas.width, | |
| height: this.game.canvas.height, | |
| tileSize: 8 | |
| }, | |
| nodes: { size: { min: 10, max: 20 } } | |
| }); |
| this.treeInstance = new Tree({ | |
| width: this.game.canvas.width, | |
| height: this.game.canvas.height, | |
| tileSize: 8, | |
| leafSize: { min: 10, max: 20 } | |
| }); |
| update(): void { | |
| // handle angle change | |
| if (this.angle < 30) { | |
| this.angle += 2; | |
| } | |
| // handle input | |
| if (this.jumpKey.isDown && !this.isFlapping) { | |
| // flap | |
| this.isFlapping = true; |
| private addNewRowOfPipes(): void { | |
| // update the score | |
| this.registry.values.score += 1; | |
| this.scoreText.setText(this.registry.values.score); | |
| // randomly pick a number between 1 and 5 | |
| let hole = Math.floor(Math.random() * 5) + 1; | |
| // add 6 pipes with one big hole at position hole and hole + 1 | |
| for (let i = 0; i < 10; i++) { |
| preload(): void { | |
| this.load.pack( | |
| "flappyBirdPack", | |
| "./src/assets/pack.json", | |
| "flappyBirdPack" | |
| ); | |
| } |
| init(): void { | |
| this.registry.set("score", -1); | |
| } |
| export class GameScene extends Phaser.Scene { | |
| constructor() { | |
| super({ | |
| key: "GameScene" | |
| }); | |
| } | |
| } |