Skip to content

Commit

Permalink
Merge pull request #34 from owencooke/spacebar
Browse files Browse the repository at this point in the history
spacebar
  • Loading branch information
Sami-Jagirdar authored Mar 25, 2024
2 parents fa4e827 + 62b0b4e commit fa9dd00
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Binary file added public/assets/space.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/game/scenes/Preloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class Preloader extends Scene {

// Load minigame assets
this.load.image("bg", "./assets/balancebg.jpg");
this.load.image("spacebar", "./assets/space.png");
this.load.image("tile1", "./assets/tile1.png");

// Load building icons for each doctor
Expand Down
27 changes: 27 additions & 0 deletions src/game/scenes/hospital/Hospital.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,29 @@ class Hospital extends Scene {
map.heightInPixels / 2
);

// Overlay

this.overlay = this.physics.add.sprite(
this.doctor.x,
this.doctor.y + 70,
"spacebar"
)

this.overlay.setScale(0.1)
this.overlay.setVisible(false)
this.time.addEvent({callback: ()=>
{
if (this.physics.overlap(this.player, triggerDialogueZone) === false) {
this.overlay.setVisible(false)
}
},
delay: 5,
callbackScope:
this,
loop: true
})


// Enable keyboard input
this.cursors = this.input.keyboard.createCursorKeys();
}
Expand All @@ -191,7 +214,11 @@ class Hospital extends Scene {
}

handleDoctorCollision() {
if (!this.dialogueInProgess) {
this.overlay.setVisible(true)
}
if (this.cursors.space.isDown && !this.dialogueInProgess) {
this.overlay.setVisible(false)
this.allowMovement = false;
this.dialogueInProgess = true;
startDialogue(this, this.dialogue, () => {
Expand Down

0 comments on commit fa9dd00

Please sign in to comment.