Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[STORY] Provide clues to progress the game upon Minigame completion #38

Merged
merged 10 commits into from
Mar 25, 2024
Binary file added public/assets/select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 29 additions & 9 deletions src/game/scenes/Maze.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Scene } from "phaser";
import { MyPlayer } from "../components/MyPlayer";
import {createHomeButton} from "../components/HomeButton";
import { startSpecialistScene } from "./hospital/Hospital";
import { createHomeButton } from "../components/HomeButton";

const winText = [
"Looking at Sam's test results, his symptoms don't align with symptoms of most neurological disorders and his low response to the treatment plan indicates this as well. there may be other underlying conditions",
"It was mentioned Sam has occasional blurry vision. Some redness was also noticed in Sam's cornea.",
"Given the persistence of his visual issues, it may be prudent to consult with an ophthalmologist to rule out any underlying eye conditions contributing to Sam's symptoms.",
];

export class Maze extends Scene {
constructor() {
Expand All @@ -11,6 +16,7 @@ export class Maze extends Scene {
this.endPoint;
this.holes1;
this.holes2;
this.winText = winText;
}

create() {
Expand All @@ -26,7 +32,7 @@ export class Maze extends Scene {
"modern_exteriors_32",
"modern_exteriors_32"
);

// Create layers
map.createLayer("Ground", modernExteriors, 0, 0);
const wallLayer = map.createLayer("Walls", modernExteriors, 0, 0);
Expand All @@ -37,7 +43,7 @@ export class Maze extends Scene {
0,
0,
map.widthInPixels,
map.heightInPixels,
map.heightInPixels
);

// Get starting point
Expand Down Expand Up @@ -89,24 +95,38 @@ export class Maze extends Scene {
this.player.setActive(false);
this.cameras.main.stopFollow();

const box = this.add.graphics();
box.fillStyle(0x000000, 0.5);
box.fillRect(
this.cameras.main.worldView.x + this.cameras.main.width / 2 - 300,
this.cameras.main.worldView.y + this.cameras.main.height / 2 - 50,
600,
100
);

const message = this.add
.text(
this.cameras.main.worldView.x + this.cameras.main.width / 2,
this.cameras.main.worldView.y + this.cameras.main.height / 2,
"Congratulations!",
{
fontSize: "32px",
color: "#ffffff",
fontSize: "42px",
fill: "#ffffff",
fontStyle: "bold",
fontFamily: "Arial Black",
}
)
.setOrigin(0.5, 0.5);
.setOrigin(0.5);

this.time.delayedCall(
1000,
2000,
() => {
message.destroy();
startSpecialistScene(this, "Neurologist", "Integrity");
this.scene.start("MinigamePost", {
doctorType: "Neurologist",
winText: this.winText,
scoreType: "Integrity",
});
},
[],
this
Expand Down
79 changes: 79 additions & 0 deletions src/game/scenes/MinigamePost.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import Phaser from "phaser";
import { startSpecialistScene } from "./hospital/Hospital";

const textStyle = {
fontSize: "24px",
fill: "black",
align: "center",
fontFamily: "'Press Start 2P'",
};

export class MinigamePost extends Phaser.Scene {
constructor() {
super("MinigamePost");
}

init(data) {
this.doctorType = data.doctorType;
this.winText = data.winText;
this.scoreType = data.scoreType;
}

create() {
const background = this.add.image(
this.cameras.main.width / 2,
this.cameras.main.height / 2,
"bg"
);
background.setDisplaySize(
this.cameras.main.width,
this.cameras.main.height
);

// Title text
this.add
.text(
this.game.config.width / 2,
this.game.config.height / 4,
"Treatment results",
{ ...textStyle, fontSize: "48px" }
)
.setOrigin(0.5);

const selectButton = this.add
.sprite(
this.cameras.main.width - 64,
this.cameras.main.height - 64,
"select"
)
.setScale(0.2)
.setInteractive();
let line = this.displayString(this.winText[0]);
let clickCount = 1;
selectButton.on("pointerup", () => {
clickCount++;
line.destroy();
// Display the next string from the array
if (clickCount <= this.winText.length) {
line = this.displayString(this.winText[clickCount - 1]);
} else {
startSpecialistScene(this, this.doctorType, this.scoreType);
}
});
}

displayString(string) {
return this.add
.text(
this.game.config.width / 2,
this.game.config.height / 2,
string,
{
...textStyle,
wordWrap: { width: this.game.config.width - 100 },
}
)
.setOrigin(0.5);
}
}

42 changes: 31 additions & 11 deletions src/game/scenes/Pong.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Scene, Math } from "phaser";
import { startSpecialistScene } from "./hospital/Hospital";
import { createHomeButton } from "../components/HomeButton";

const winText = [
"Sam's lung capacity seems to be low, but it doesn't explain some of his other symptoms.",
"What's concerning is that he experiences weakness, difficulty concentrating and headaches as well.",
"These are common neurological symptoms. We can refer you to a neurologist. It may be worthwile to test for any underlying neurological conditions",
];

export class Pong extends Scene {
constructor() {
super("Pong");
Expand Down Expand Up @@ -132,7 +137,7 @@ export class Pong extends Scene {
undefined,
this
);

this.homeButton = createHomeButton(this, "Pulmonologist");

// Set Up Input
Expand All @@ -159,23 +164,33 @@ export class gameEnd extends Scene {
constructor() {
super("gameEnd");
this.gameState = "Failure";
this.winText = winText;
}

create(data) {
const background = this.add.image(
this.cameras.main.width / 2,
this.cameras.main.height / 2,
"bg"
);
background.setDisplaySize(
this.cameras.main.width,
this.cameras.main.height
);

// Game End
if (data.gameScore === data.scoreCon) {
this.gameState = "Success!";
this.add
.text(this.cameras.main.centerX, 300, this.gameState, {
fontSize: "72px",
color: "#ffffff",
fontFamily: "Arial Black",
})
.setOrigin(0.5);
}
this.add
.text(this.cameras.main.centerX, 300, this.gameState, {
fontSize: "72px",
color: "#ffffff",
fontFamily: "Arial Black",
})
.setOrigin(0.5);

// Try again or Continue

if (this.gameState === "Success!") {
const continueButton = this.add
.text(
Expand All @@ -191,7 +206,12 @@ export class gameEnd extends Scene {
.setOrigin(0.5)
.setInteractive();
continueButton.on("pointerdown", () => {
startSpecialistScene(this, "Pulmonologist", "Engagement");
this.gameState = "Failure!";
this.scene.start("MinigamePost", {
doctorType: "Pulmonologist",
winText: winText,
scoreType: "Engagement",
});
});
} else {
const playButton = this.add
Expand Down
3 changes: 3 additions & 0 deletions src/game/scenes/Preloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ export class Preloader extends Scene {
// Load find zebra images
this.load.image("zebra", "./assets/zebra.png");
this.load.image("find_zebra", "./assets/find_zebra.png");

// Load select image
this.load.image("select","./assets/select.png");
}

create() {
Expand Down
52 changes: 35 additions & 17 deletions src/game/scenes/TileJump.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import Phaser from "phaser";
import { MyPlayer } from "../components/MyPlayer";
import { startSpecialistScene } from "./hospital/Hospital";
import { createHomeButton } from "../components/HomeButton";

const winText = [
"It seems that Sam's not responding well to the common treatments. His symptoms persist.",
"His symptoms are quite varied. It is difficult to diagnose him without some specialized tests",
"His respiratory symptoms like difficulty breathing may explain his other symptoms like fatigue and headaches",
"Perhaps a starting point would be to seek a Pulmonologist appointment",
];

export class TileJump extends Phaser.Scene {
constructor() {
super("TileJump");
Expand All @@ -16,6 +22,7 @@ export class TileJump extends Phaser.Scene {
this.score = 0;
this.player;
this.isPlayerAirborne = false;
this.winText = winText;
}

create() {
Expand Down Expand Up @@ -157,30 +164,41 @@ export class TileJump extends Phaser.Scene {
if (this.score === 5) {
this.score = 0;
// Display the congratulatory message
this.add
// Create a box sprite as the background for the text
const box = this.add.graphics();
box.fillStyle(0x000000, 0.7);
box.fillRect(
this.cameras.main.centerX - 300,
this.cameras.main.centerY - 50,
600,
100
);

const message = this.add
.text(
this.game.config.width / 2,
this.game.config.height / 2,
this.cameras.main.centerX,
this.cameras.main.centerY,
"Congratulations!",
{ font: "48px Arial", fill: "#fff" }
)
.setOrigin(0.5);
this.add
.text(
this.game.config.width / 2,
this.game.config.height / 2 + 100,
"Click anywhere to continue",
{ font: "24px Arial", fill: "#fff" }
{
fontSize: "42px",
fill: "#ffffff",
fontStyle: "bold",
fontFamily: "Arial Black",
}
)
.setOrigin(0.5);

// Pause the game logic (but not the scene itself)
// Pause the game logic
this.physics.pause();
this.time.removeAllEvents();

// Make the scene listen for a click to restart
this.input.once("pointerdown", () => {
startSpecialistScene(this, "Pediatrician", "Engagement");
this.time.delayedCall(2000, () => {
message.destroy();
this.scene.start("MinigamePost", {
doctorType: "Pediatrician",
winText: this.winText,
scoreType: "Engagement",
});
});
}
}
Expand Down
Loading
Loading