diff --git a/README.md b/README.md index d06e59b..96ef38f 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,26 @@ -This is a point-and-click horror story game. - -Prerequisites -git 2 -maven 3 -JDK 21 -OpenJavaFX 21 (Find OS Specific Downloads Here) -How to compile -mvn clean install - -How to run with maven -mvn javafx:run - -How to run with just Java -Replace /path/to/openjavafx to your actual install location of Open JavaFX: - -java --module-path /path/to/openjavafx/lib --add-modules javafx.controls -jar .\target\FinalProject-0.0.1.jar - -How to run with IntelliJ -Open src/main/java/edu/sdccd/cisc190/Main.java -Press the green play button on Current File on the upper right. -A run configuration should automatically be generated for Main. -Click the run configuration drop down on the upper right and click Edit Configurations... -In the Run/Debug Configurations popup, select Main on the left nav. -Click the Modify options dropdown and select Add VM Options. -Add --module-path /path/to/openjavafx/lib --add-modules javafx.controls, changing /path/to/openjavafx to the location you have it installed on your machine +This is a point-and-click horror story game. + +Prerequisites +git 2 +maven 3 +JDK 21 +OpenJavaFX 21 (Find OS Specific Downloads Here) +How to compile +mvn clean install + +How to run with maven +mvn javafx:run + +How to run with just Java +Replace /path/to/openjavafx to your actual install location of Open JavaFX: + +java --module-path /path/to/openjavafx/lib --add-modules javafx.controls -jar .\target\FinalProject-0.0.1.jar + +How to run with IntelliJ +Open src/main/java/edu/sdccd/cisc190/Main.java +Press the green play button on Current File on the upper right. +A run configuration should automatically be generated for Main. +Click the run configuration drop down on the upper right and click Edit Configurations... +In the Run/Debug Configurations popup, select Main on the left nav. +Click the Modify options dropdown and select Add VM Options. +Add --module-path /path/to/openjavafx/lib --add-modules javafx.controls, changing /path/to/openjavafx to the location you have it installed on your machine diff --git a/pom.xml b/pom.xml index 8e106cf..b1d57a8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,130 +1,130 @@ - - - 4.0.0 - - edu.sdccd.cisc190 - EngineOfDesolation - 1.0-SNAPSHOT - - - 21 - 21 - UTF-8 - 5.11.2 - 22 - - - - org.openjfx - javafx-fxml - ${javafx.version} - - - org.openjfx - javafx-web - ${javafx.version} - - - com.google.api-client - google-api-client - 1.25.0 - - - com.google.oauth-client - google-oauth-client-jetty - 1.25.0 - - - com.google.apis - google-api-services-sheets - v4-rev612-1.25.0 - - - org.junit.jupiter - junit-jupiter-api - ${junit.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.version} - test - - - org.mockito - mockito-core - 5.5.0 - test - - - org.testfx - testfx-core - 4.0.16-alpha - test - - - org.testfx - testfx-junit5 - 4.0.16-alpha - test - - - org.testfx - testfx-core - 4.0.18 - compile - - - org.testfx - testfx-junit5 - 4.0.18 - compile - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - 21 - 21 - - - - org.openjfx - javafx-maven-plugin - 0.0.8 - - - - default-cli - - app - app - app - true - true - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.5.0 - - --add-opens=javafx.graphics/com.sun.javafx.application=org.testfx - - - - - - - + + + 4.0.0 + + edu.sdccd.cisc190 + EngineOfDesolation + 1.0-SNAPSHOT + + + 21 + 21 + UTF-8 + 5.11.2 + 22 + + + + org.openjfx + javafx-fxml + ${javafx.version} + + + org.openjfx + javafx-web + ${javafx.version} + + + com.google.api-client + google-api-client + 1.25.0 + + + com.google.oauth-client + google-oauth-client-jetty + 1.25.0 + + + com.google.apis + google-api-services-sheets + v4-rev612-1.25.0 + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + org.mockito + mockito-core + 5.5.0 + test + + + org.testfx + testfx-core + 4.0.16-alpha + test + + + org.testfx + testfx-junit5 + 4.0.16-alpha + test + + + org.testfx + testfx-core + 4.0.18 + compile + + + org.testfx + testfx-junit5 + 4.0.18 + compile + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 21 + 21 + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + + + default-cli + + app + app + app + true + true + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.0 + + --add-opens=javafx.graphics/com.sun.javafx.application=org.testfx + + + + + + + diff --git a/src/main/java/event/Event01.java b/src/main/java/event/Event01.java index bf4147d..10c1f6b 100644 --- a/src/main/java/event/Event01.java +++ b/src/main/java/event/Event01.java @@ -1,70 +1,70 @@ -package event; - -/** - * This and all the other event classes handle specific scenes and buttons - */ - -import main.GameManager; - -public class Event01 { - - GameManager gm; - - public Event01(GameManager gm) { - this.gm = gm; - } - - public void lookJeramiah() { - gm.ui.messageText.setText("This is your tall handsome roommate Jeramiah. (He works on cars. Specifically Hondas)"); - } - public void talkJeramiah() { - gm.ui.messageText.setText("Did you hear that noise outside son?"); - gm.playSE(gm.engineNoise); - } - public void restJeramiah() { - - if(gm.player.playerLife != gm.player.playerMaxLife) { - gm.ui.messageText.setText("Come here my baka! \n*You lay in Jeramiah's strong arms*\n(Your life has been recovered)"); - gm.player.playerLife++; - gm.player.updatePlayerStatus(); - gm.playSE(gm.heal); - gm.playSE(gm.awSound); - } - else{ - gm.ui.messageText.setText("(Your life is full)"); - gm.playSE(gm.cannotSound); - - } - - } - public void lookFlashlight() { - gm.ui.messageText.setText("This is a flashlight"); - } - public void grabFlashlight() { - if(gm.player.hasFlashlight == 0) { - gm.player.hasFlashlight = 1; - gm.ui.messageText.setText("(You obtained a flashlight)"); - - gm.player.updatePlayerStatus(); - gm.playSE(gm.flashlightSwitch); - } - else{ - gm.ui.messageText.setText("(You already have a flashlight)"); - gm.playSE(gm.cannotSound); - } - - } - public void restFlashlight() { - if(gm.player.hasFlashlight == 1) { - gm.player.hasFlashlight = 0; - gm.ui.messageText.setText("*You rest the flashlight back on the bed*"); - - gm.player.updatePlayerStatus(); - } - else{ - gm.ui.messageText.setText("(You don't have a flashlight)"); - gm.playSE(gm.cannotSound); - } - - } -} +package event; + +/** + * This and all the other event classes handle specific scenes and buttons + */ + +import main.GameManager; + +public class Event01 { + + GameManager gm; + + public Event01(GameManager gm) { + this.gm = gm; + } + + public void lookJeramiah() { + gm.ui.messageText.setText("This is your tall handsome roommate Jeramiah. (He works on cars. Specifically Hondas)"); + } + public void talkJeramiah() { + gm.ui.messageText.setText("Did you hear that noise outside son?"); + gm.playSE(gm.engineNoise); + } + public void restJeramiah() { + + if(gm.player.playerLife != gm.player.playerMaxLife) { + gm.ui.messageText.setText("Come here my baka! \n*You lay in Jeramiah's strong arms*\n(Your life has been recovered)"); + gm.player.playerLife++; + gm.player.updatePlayerStatus(); + gm.playSE(gm.heal); + gm.playSE(gm.awSound); + } + else{ + gm.ui.messageText.setText("(Your life is full)"); + gm.playSE(gm.cannotSound); + + } + + } + public void lookFlashlight() { + gm.ui.messageText.setText("This is a flashlight"); + } + public void grabFlashlight() { + if(gm.player.hasFlashlight == 0) { + gm.player.hasFlashlight = 1; + gm.ui.messageText.setText("(You obtained a flashlight)"); + + gm.player.updatePlayerStatus(); + gm.playSE(gm.flashlightSwitch); + } + else{ + gm.ui.messageText.setText("(You already have a flashlight)"); + gm.playSE(gm.cannotSound); + } + + } + public void restFlashlight() { + if(gm.player.hasFlashlight == 1) { + gm.player.hasFlashlight = 0; + gm.ui.messageText.setText("*You rest the flashlight back on the bed*"); + + gm.player.updatePlayerStatus(); + } + else{ + gm.ui.messageText.setText("(You don't have a flashlight)"); + gm.playSE(gm.cannotSound); + } + + } +} diff --git a/src/main/java/event/Event02.java b/src/main/java/event/Event02.java index ae445fb..c208420 100644 --- a/src/main/java/event/Event02.java +++ b/src/main/java/event/Event02.java @@ -1,32 +1,34 @@ -package event; - -import main.GameManager; - -public class Event02 { - - GameManager gm; - - public Event02(GameManager gm) { - - this.gm = gm; - } - public void search1Honda() { - gm.ui.messageText.setText("Nothing sus here"); - } - public void search2Honda() { - gm.ui.messageText.setText("OH MY GYAT MY ENGINE IS MISSING"); - } - public void restHonda() { - if(gm.player.playerLife != gm.player.playerMaxLife) { - gm.ui.messageText.setText("*You rest on the hood of your car*\n(Your life has been recovered)"); - gm.player.playerLife++; - gm.player.updatePlayerStatus(); - gm.playSE(gm.heal); - } - else{ - gm.ui.messageText.setText("(Your life is full)"); - gm.playSE(gm.cannotSound); - - } - } -} +package event; + +import main.GameManager; + +//Add java dox here and to the rest of the events + +public class Event02 { + + GameManager gm; + + public Event02(GameManager gm) { + + this.gm = gm; + } + public void search1Honda() { + gm.ui.messageText.setText("Nothing sus here"); + } + public void search2Honda() { + gm.ui.messageText.setText("OH MY GYAT MY ENGINE IS MISSING"); + } + public void restHonda() { + if(gm.player.playerLife != gm.player.playerMaxLife) { + gm.ui.messageText.setText("*You rest on the hood of your car*\n(Your life has been recovered)"); + gm.player.playerLife++; + gm.player.updatePlayerStatus(); + gm.playSE(gm.heal); + } + else{ + gm.ui.messageText.setText("(Your life is full)"); + gm.playSE(gm.cannotSound); + + } + } +} diff --git a/src/main/java/event/Event03.java b/src/main/java/event/Event03.java index d0d0de4..674d71e 100644 --- a/src/main/java/event/Event03.java +++ b/src/main/java/event/Event03.java @@ -1,23 +1,23 @@ -package event; - -import main.GameManager; - -public class Event03 { - - GameManager gm; - - public Event03(GameManager gm) { - - this.gm = gm; - } - public void lookHondaur() { - gm.ui.messageText.setText("Its a Hondaur"); - } - public void talkHondaur() { - gm.ui.messageText.setText("The Hondaur growls at you and revs his engine "); - } - public void attackHondaur() { - gm.ui.messageText.setText("*You start beating the shit out of the poor Hondaur*"); - - } -} +package event; + +import main.GameManager; + +public class Event03 { + + GameManager gm; + + public Event03(GameManager gm) { + + this.gm = gm; + } + public void lookHondaur() { + gm.ui.messageText.setText("Its a Hondaur"); + } + public void talkHondaur() { + gm.ui.messageText.setText("The Hondaur growls at you and revs his engine "); + } + public void attackHondaur() { + gm.ui.messageText.setText("*You start beating the shit out of the poor Hondaur*"); + + } +} diff --git a/src/main/java/event/Event04.java b/src/main/java/event/Event04.java index 05e8356..ba7c4ec 100644 --- a/src/main/java/event/Event04.java +++ b/src/main/java/event/Event04.java @@ -1,42 +1,42 @@ -package event; - -import main.GameManager; - -public class Event04 { - - GameManager gm; - - public Event04(GameManager gm) { - - this.gm = gm; - } - public void lookDenzel() { - gm.ui.messageText.setText("This is Denzel. (He listens to Valorant music)"); - } - public void talkDenzel() { - if(gm.player.hasPistol == 0) { - gm.player.hasPistol = 1; - gm.ui.messageText.setText("My oh my I've been waiting for you heh. Here's a glock.\nI saw a monster running with an engine towards the casino!"); - - gm.player.updatePlayerStatus(); - gm.playSE(gm.reload); - } - else{ - gm.ui.messageText.setText("(You already have a glock)"); - gm.playSE(gm.cannotSound); - } - } - public void restDenzel() { - if(gm.player.playerLife != gm.player.playerMaxLife) { - gm.ui.messageText.setText("(Denzel has been lonely without his girlfriend)\n*Denzel runs up to you unexpectedly and gives you a hug*\n(Your life has been recovered)"); - gm.player.playerLife++; - gm.player.updatePlayerStatus(); - gm.playSE(gm.heal); - gm.playSE(gm.awSound); - } - else { - gm.ui.messageText.setText("(Your life is full)"); - gm.playSE(gm.cannotSound); - } - } -} +package event; + +import main.GameManager; + +public class Event04 { + + GameManager gm; + + public Event04(GameManager gm) { + + this.gm = gm; + } + public void lookDenzel() { + gm.ui.messageText.setText("This is Denzel. (He listens to Valorant music)"); + } + public void talkDenzel() { + if(gm.player.hasPistol == 0) { + gm.player.hasPistol = 1; + gm.ui.messageText.setText("My oh my I've been waiting for you heh. Here's a glock.\nI saw a monster running with an engine towards the casino!"); + + gm.player.updatePlayerStatus(); + gm.playSE(gm.reload); + } + else{ + gm.ui.messageText.setText("(You already have a glock)"); + gm.playSE(gm.cannotSound); + } + } + public void restDenzel() { + if(gm.player.playerLife != gm.player.playerMaxLife) { + gm.ui.messageText.setText("(Denzel has been lonely without his girlfriend)\n*Denzel runs up to you unexpectedly and gives you a hug*\n(Your life has been recovered)"); + gm.player.playerLife++; + gm.player.updatePlayerStatus(); + gm.playSE(gm.heal); + gm.playSE(gm.awSound); + } + else { + gm.ui.messageText.setText("(Your life is full)"); + gm.playSE(gm.cannotSound); + } + } +} diff --git a/src/main/java/event/Event05.java b/src/main/java/event/Event05.java index 1d44ad5..d5f5541 100644 --- a/src/main/java/event/Event05.java +++ b/src/main/java/event/Event05.java @@ -1,54 +1,54 @@ -package event; - -import main.GameManager; - -public class Event05 { - - GameManager gm; - - public Event05(GameManager gm) { - - this.gm = gm; - } - public void lookHondaTrunk() { - if(gm.player.hasPistol == 1){ - gm.ui.messageText.setText("IS THAT BRIAN FROM MARAUDER CODED!"); - } - else{ - gm.ui.messageText.setText("(You see Brian's dead body)"); - } - } - public void talkHondaTrunk() { - if(gm.theodoor.currentLife==0 && gm.wheeler.currentLife==0) { - if(gm.player.hasPistol == 1){ - gm.ui.messageText.setText("Eughh Please... save... Julien and please end my misery"); - } - else{ - gm.ui.messageText.setText("(Brian is already dead!)"); - } - } - else{ - gm.ui.messageText.setText("You must defeat the monsters first!"); - gm.playSE(gm.cannotSound); - } - } - public void killHondaTrunk() { - - if(gm.theodoor.currentLife == 0 && gm.wheeler.currentLife == 0) { - if(gm.player.hasPistol == 1){ - gm.playSE(gm.pistolShot); - gm.ui.messageText.setText("(You ended Brian's misery)"); - } - else{ - gm.ui.messageText.setText("(You already ended his misery!)"); - } - gm.player.hasPistol = 0; - gm.player.updatePlayerStatus(); - } - else{ - gm.ui.messageText.setText("You must defeat the monsters first!"); - gm.playSE(gm.cannotSound); - } - - } -} +package event; + +import main.GameManager; + +public class Event05 { + + GameManager gm; + + public Event05(GameManager gm) { + + this.gm = gm; + } + public void lookHondaTrunk() { + if(gm.player.hasPistol == 1){ + gm.ui.messageText.setText("IS THAT BRIAN FROM MARAUDER CODED!"); + } + else{ + gm.ui.messageText.setText("(You see Brian's dead body)"); + } + } + public void talkHondaTrunk() { + if(gm.theodoor.currentLife==0 && gm.wheeler.currentLife==0) { + if(gm.player.hasPistol == 1){ + gm.ui.messageText.setText("Eughh Please... save... Julien and please end my misery"); + } + else{ + gm.ui.messageText.setText("(Brian is already dead!)"); + } + } + else{ + gm.ui.messageText.setText("You must defeat the monsters first!"); + gm.playSE(gm.cannotSound); + } + } + public void killHondaTrunk() { + + if(gm.theodoor.currentLife == 0 && gm.wheeler.currentLife == 0) { + if(gm.player.hasPistol == 1){ + gm.playSE(gm.pistolShot); + gm.ui.messageText.setText("(You ended Brian's misery)"); + } + else{ + gm.ui.messageText.setText("(You already ended his misery!)"); + } + gm.player.hasPistol = 0; + gm.player.updatePlayerStatus(); + } + else{ + gm.ui.messageText.setText("You must defeat the monsters first!"); + gm.playSE(gm.cannotSound); + } + + } +} diff --git a/src/main/java/event/Event06.java b/src/main/java/event/Event06.java index ddb4d8a..2ef22a9 100644 --- a/src/main/java/event/Event06.java +++ b/src/main/java/event/Event06.java @@ -1,73 +1,73 @@ -package event; - -import javafx.scene.image.ImageView; -import main.GameManager; - -public class Event06 { - GameManager gm; - private ImageView denzel; - - public Event06(GameManager gm) { - - this.gm = gm; - } - public void reset(){ - if (denzel != null) { - denzel.setVisible(false); - } - } - - public void lookDenzel(){ - gm.ui.messageText.setText("Denzel shows up"); - } - public void talkDenzel(){ - gm.ui.messageText.setText("I got worried for you so I ran after you"); - - } - public void playDenzel(){ - - if(gm.player.hasAk47 == 0) { - gm.player.hasAk47 = 1; - gm.ui.messageText.setText("*You cheer Denzel up by playing Valorant music*\nYou realy know how to cheer me up!\n *Denzel gives you an ak47*"); - - gm.player.updatePlayerStatus(); - gm.playSE(gm.reload); - } - else{ - gm.ui.messageText.setText("(You already have an ak47)"); - gm.playSE(gm.cannotSound); - } - - } - - public void lookBrandon() { - gm.ui.messageText.setText("This is Brandon. He seems to be doing a fit check"); - } - public void talkBrandon() { - gm.ui.messageText.setText("Yo I wouldn't go in there if I were you! A monster is on the loose!"); - } - public void restBrandon() { - if(gm.player.playerLife != gm.player.playerMaxLife) { - gm.ui.messageText.setText("You look injured... Come here\n*Brandon gives you a warm hug*\n(You gain life)"); - gm.player.playerLife++; - gm.player.updatePlayerStatus(); - gm.playSE(gm.heal); - gm.playSE(gm.awSound); - } - else { - gm.ui.messageText.setText("(Your life is full)"); - gm.playSE(gm.cannotSound); - if (denzel == null){ - denzel = gm.ui.createObjectAndReturn(6, 450, 110, 200, 250, "denzel.png", - "Look", "Talk", "Play", "lookDenzel2", "talkDenzel2", "playDenzel"); - denzel.setVisible(true); - } - else { - denzel.setVisible(false); - } - - - } - - } -} +package event; + +import javafx.scene.image.ImageView; +import main.GameManager; + +public class Event06 { + GameManager gm; + private ImageView denzel; + + public Event06(GameManager gm) { + + this.gm = gm; + } + public void reset(){ + if (denzel != null) { + denzel.setVisible(false); + } + } + + public void lookDenzel(){ + gm.ui.messageText.setText("Denzel shows up"); + } + public void talkDenzel(){ + gm.ui.messageText.setText("I got worried for you so I ran after you"); + + } + public void playDenzel(){ + + if(gm.player.hasAk47 == 0) { + gm.player.hasAk47 = 1; + gm.ui.messageText.setText("*You cheer Denzel up by playing Valorant music*\nYou realy know how to cheer me up!\n *Denzel gives you an ak47*"); + + gm.player.updatePlayerStatus(); + gm.playSE(gm.reload); + } + else{ + gm.ui.messageText.setText("(You already have an ak47)"); + gm.playSE(gm.cannotSound); + } + + } + + public void lookBrandon() { + gm.ui.messageText.setText("This is Brandon. He seems to be doing a fit check"); + } + public void talkBrandon() { + gm.ui.messageText.setText("Yo I wouldn't go in there if I were you! A monster is on the loose!"); + } + public void restBrandon() { + if(gm.player.playerLife != gm.player.playerMaxLife) { + gm.ui.messageText.setText("You look injured... Come here\n*Brandon gives you a warm hug*\n(You gain life)"); + gm.player.playerLife++; + gm.player.updatePlayerStatus(); + gm.playSE(gm.heal); + gm.playSE(gm.awSound); + } + else { + gm.ui.messageText.setText("(Your life is full)"); + gm.playSE(gm.cannotSound); + if (denzel == null){ + denzel = gm.ui.createObjectAndReturn(6, 450, 110, 200, 250, "denzel.png", + "Look", "Talk", "Play", "lookDenzel2", "talkDenzel2", "playDenzel"); + denzel.setVisible(true); + } + else { + denzel.setVisible(false); + } + + + } + + } +} diff --git a/src/main/java/event/Event07.java b/src/main/java/event/Event07.java index 96a2825..a8a7a75 100644 --- a/src/main/java/event/Event07.java +++ b/src/main/java/event/Event07.java @@ -1,76 +1,76 @@ -package event; - -import main.GameManager; - -public class Event07 { - - GameManager gm; - public int julianLife = 2; - - public Event07(GameManager gm) { - - this.gm = gm; - } - public void lookJulian() { - gm.ui.messageText.setText("Julian is in serious condition"); - if(julianLife ==0) { - gm.ui.messageText.setText("You see Julien's lifeless body"); - } - } - public void talkJulian() { - if(julianLife == 2 || julianLife == 1) { - gm.ui.messageText.setText("*Julian cries when he sees you* I don't want to die..."); - } - else { - gm.ui.messageText.setText("Julien is already dead"); - gm.playSE(gm.cannotSound); - } - } - public void holdJulian() { - if(julianLife == 2) { - gm.ui.messageText.setText("*You hold Julian's hand and tell him it'll be okay*\nJulian says his last words: Can you spin it one last time for me?"); - julianLife=1; - } - if(julianLife == 1) { - gm.ui.messageText.setText("*You hold Julian's hand and tell him it'll be okay*\nJulian says his last words: Can you spin it one last time for me?"); - } - else{ - gm.ui.messageText.setText("Julian is already dead"); - gm.playSE(gm.cannotSound); - } - } - public void lookSlotMachine() { - gm.ui.messageText.setText("You see the slot machine that the Marauder Coded gang made"); - } - public void talkSlotMachine() { - gm.ui.messageText.setText("(The slot machine displays your aura: 10,000,000)"); - } - public void spinSlotMachine() { - if(julianLife == 1) { - gm.ui.messageText.setText("*You spin*\n YOU WIN 6 MILLION DOLLARS!!!\n *Julien sighs and passes away*"); - julianLife =0; - gm.playSE(gm.slotWin); - } - else{ - if(julianLife == 2) { - gm.ui.messageText.setText("You must hold Julian first!"); - gm.playSE(gm.cannotSound); - } - if(julianLife < 1) { - gm.ui.messageText.setText("*You have no more spins left*"); - gm.playSE(gm.cannotSound); - } - } - - } - public void lookAdrian() { - gm.ui.messageText.setText("You see Adrian, the leader of the Honda Boyz"); - } - public void talkAdrian() { - gm.ui.messageText.setText("It was supposed to be an era of peace between the Honda Boyz and Marauder Coded\n *Adrian cries*\n I tried to save him I really did"); - } - public void thankAdrian() { - gm.ui.messageText.setText("*You thank Adrian for his great efforts*\n (Adrian will give you 10% of his profits if you avenge Julian)"); - - } -} +package event; + +import main.GameManager; + +public class Event07 { + + GameManager gm; + public int julianLife = 2; + + public Event07(GameManager gm) { + + this.gm = gm; + } + public void lookJulian() { + gm.ui.messageText.setText("Julian is in serious condition"); + if(julianLife ==0) { + gm.ui.messageText.setText("You see Julien's lifeless body"); + } + } + public void talkJulian() { + if(julianLife == 2 || julianLife == 1) { + gm.ui.messageText.setText("*Julian cries when he sees you* I don't want to die..."); + } + else { + gm.ui.messageText.setText("Julien is already dead"); + gm.playSE(gm.cannotSound); + } + } + public void holdJulian() { + if(julianLife == 2) { + gm.ui.messageText.setText("*You hold Julian's hand and tell him it'll be okay*\nJulian says his last words: Can you spin it one last time for me?"); + julianLife=1; + } + if(julianLife == 1) { + gm.ui.messageText.setText("*You hold Julian's hand and tell him it'll be okay*\nJulian says his last words: Can you spin it one last time for me?"); + } + else{ + gm.ui.messageText.setText("Julian is already dead"); + gm.playSE(gm.cannotSound); + } + } + public void lookSlotMachine() { + gm.ui.messageText.setText("You see the slot machine that the Marauder Coded gang made"); + } + public void talkSlotMachine() { + gm.ui.messageText.setText("(The slot machine displays your aura: 10,000,000)"); + } + public void spinSlotMachine() { + if(julianLife == 1) { + gm.ui.messageText.setText("*You spin*\n YOU WIN 6 MILLION DOLLARS!!!\n *Julien sighs and passes away*"); + julianLife =0; + gm.playSE(gm.slotWin); + } + else{ + if(julianLife == 2) { + gm.ui.messageText.setText("You must hold Julian first!"); + gm.playSE(gm.cannotSound); + } + if(julianLife < 1) { + gm.ui.messageText.setText("*You have no more spins left*"); + gm.playSE(gm.cannotSound); + } + } + + } + public void lookAdrian() { + gm.ui.messageText.setText("You see Adrian, the leader of the Honda Boyz"); + } + public void talkAdrian() { + gm.ui.messageText.setText("It was supposed to be an era of peace between the Honda Boyz and Marauder Coded\n *Adrian cries*\n I tried to save him I really did"); + } + public void thankAdrian() { + gm.ui.messageText.setText("*You thank Adrian for his great efforts*\n (Adrian will give you 10% of his profits if you avenge Julian)"); + + } +} diff --git a/src/main/java/main/ActionHandler.java b/src/main/java/main/ActionHandler.java index 2716af9..b07565b 100644 --- a/src/main/java/main/ActionHandler.java +++ b/src/main/java/main/ActionHandler.java @@ -1,249 +1,249 @@ -package main; -/** - * This class gives the buttons an action - */ - -import javafx.event.ActionEvent; -import javafx.event.EventHandler; - -public class ActionHandler implements EventHandler { - - GameManager gm; - - public ActionHandler(GameManager gm) { - this.gm = gm; - } - - @Override - public void handle(ActionEvent e) { - String yourChoice = ((javafx.scene.control.Button) e.getSource()).getText(); - handleAction(yourChoice); - } - - // handles the action commands - public void handleAction(String yourChoice) { - switch (yourChoice) { - // SCENE 1 - case "lookJeramiah": - gm.ev1.lookJeramiah(); - break; - case "talkJeramiah": - gm.ev1.talkJeramiah(); - break; - case "restJeramiah": - gm.ev1.restJeramiah(); - break; - case "lookFlashlight": - gm.ev1.lookFlashlight(); - break; - case "grabFlashlight": - gm.ev1.grabFlashlight(); - break; - case "restFlashlight": - gm.ev1.restFlashlight(); - break; - - // SCENE 2 - case "search1Honda": - gm.ev2.search1Honda(); - break; - case "search2Honda": - gm.ev2.search2Honda(); - break; - case "restHonda": - gm.ev2.restHonda(); - break; - case "lookSponge": - gm.engineStealerMonster.lookSponge(); - break; - case "talkSponge": - gm.engineStealerMonster.talkSponge(); - break; - case "followSponge": - gm.engineStealerMonster.followSponge(); - break; - - //SCENE 3 - case "lookHondaur": - gm.hondaur.lookHondaur(); - break; - case "talkHondaur": - gm.hondaur.talkHondaur(); - break; - case "attackHondaur": - gm.hondaur.attackHondaur(); - break; - case "lookAnthony": - gm.hondaur.lookAnthony(); - break; - case "talkAnthony": - gm.hondaur.talkAnthony(); - break; - case "touchAnthony": - gm.hondaur.touchAnthony(); - break; - //SCENE 4 - case "lookDenzel": - gm.ev4.lookDenzel(); - break; - case "talkDenzel": - gm.ev4.talkDenzel(); - break; - case "restDenzel": - gm.ev4.restDenzel(); - break; - //SCENE 5 - case "lookHondaTrunk": - gm.ev5.lookHondaTrunk(); - break; - case "talkHondaTrunk": - gm.ev5.talkHondaTrunk(); - break; - case "killHondaTrunk": - gm.ev5.killHondaTrunk(); - break; - case "lookTheodoor": - gm.theodoor.lookTheodoor(); - break; - case "talkTheodoor": - gm.theodoor.talkTheodoor(); - break; - case "attackTheodoor": - gm.theodoor.attackTheodoor(); - break; - case "lookWheeler": - gm.wheeler.lookWheeler(); - break; - case "talkWheeler": - gm.wheeler.talkWheeler(); - break; - case "attackWheeler": - gm.wheeler.attackWheeler(); - break; - //SCENE 6 - case "lookBrandon": - gm.ev6.lookBrandon(); - break; - case "talkBrandon": - gm.ev6.talkBrandon(); - break; - case "restBrandon": - gm.ev6.restBrandon(); - break; - case "lookDenzel2": - gm.ev6.lookDenzel(); - break; - case "talkDenzel2": - gm.ev6.talkDenzel(); - break; - case "playDenzel": - gm.ev6.playDenzel(); - break; - //SCENE 7 - case "lookJulian": - gm.ev7.lookJulian(); - break; - case "talkJulian": - gm.ev7.talkJulian(); - break; - case "holdJulian": - gm.ev7.holdJulian(); - break; - case "lookSlotMachine": - gm.ev7.lookSlotMachine(); - break; - case "talkSlotMachine": - gm.ev7.talkSlotMachine(); - break; - case "spinSlotMachine": - gm.ev7.spinSlotMachine(); - break; - case "lookAdrian": - gm.ev7.lookAdrian(); - break; - case "talkAdrian": - gm.ev7.talkAdrian(); - break; - case "thankAdrian": - gm.ev7.thankAdrian(); - break; - case "talkSponge2": - gm.engineStealerMonster.talkSponge2(); - break; - case "attackSponge": - gm.engineStealerMonster.attackSponge(); - break; - case "letliveSponge": - gm.engineStealerMonster.letLiveSponge(); - break; - - // SCENE CHANGES - case "goScene1": - gm.sChanger.showScene1(); - break; - case "goScene2": - if(gm.player.hasFlashlight == 1){ - gm.sChanger.showScene2(); - } - else { - gm.ui.messageText.setText("It's dark outside! You need a flashlight"); - gm.playSE(gm.cannotSound); - } - break; - case "goScene3": - gm.sChanger.showScene3(); - break; - case "goScene4": - if(gm.hondaur.currentLife == 0){ - gm.sChanger.showScene4(); - } - else { - gm.ui.messageText.setText("You must beat the crap outta the Hondaur to proceed!"); - gm.playSE(gm.cannotSound); - } - break; - case "goScene5": - if(gm.player.hasPistol == 1){ - gm.sChanger.showScene5(); - } - else { - gm.ui.messageText.setText("You should get the glock from Denzel!"); - gm.playSE(gm.cannotSound); - } - break; - case "goScene6": - if(gm.theodoor.currentLife == 0 && gm.wheeler.currentLife == 0){ - gm.sChanger.showScene6(); - } - else{ - gm.ui.messageText.setText("You must kill the monsters first!"); - gm.playSE(gm.cannotSound); - } - break; - case "goScene7": - gm.sChanger.showScene7(); - break; - case "goScene8": - if(gm.ev7.julianLife == 0){ - gm.sChanger.showScene8(); - } - else { - gm.ui.messageText.setText("You need to spin the slot machine first!"); - } - break; - case "goLeaderboard": - if(gm.engineStealerMonster.currentLife == 0) { - gm.sChanger.viewLeaderboard(); - } - else{ - gm.ui.messageText.setText("You must kill or let the monster live to proceed!"); - } - break; - case "restart": - gm.sChanger.exitGameOverScreen(); - gm.sChanger.showScene1(); - gm.startGameTimer(); - break; - } - } -} +package main; +/** + * This class gives the buttons an action + */ + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; + +public class ActionHandler implements EventHandler { + + GameManager gm; + + public ActionHandler(GameManager gm) { + this.gm = gm; + } + + @Override + public void handle(ActionEvent e) { + String yourChoice = ((javafx.scene.control.Button) e.getSource()).getText(); + handleAction(yourChoice); + } + + // handles the action commands + public void handleAction(String yourChoice) { + switch (yourChoice) { + // SCENE 1 + case "lookJeramiah": + gm.ev1.lookJeramiah(); + break; + case "talkJeramiah": + gm.ev1.talkJeramiah(); + break; + case "restJeramiah": + gm.ev1.restJeramiah(); + break; + case "lookFlashlight": + gm.ev1.lookFlashlight(); + break; + case "grabFlashlight": + gm.ev1.grabFlashlight(); + break; + case "restFlashlight": + gm.ev1.restFlashlight(); + break; + + // SCENE 2 + case "search1Honda": + gm.ev2.search1Honda(); + break; + case "search2Honda": + gm.ev2.search2Honda(); + break; + case "restHonda": + gm.ev2.restHonda(); + break; + case "lookSponge": + gm.engineStealerMonster.lookSponge(); + break; + case "talkSponge": + gm.engineStealerMonster.talkSponge(); + break; + case "followSponge": + gm.engineStealerMonster.followSponge(); + break; + + //SCENE 3 + case "lookHondaur": + gm.hondaur.lookHondaur(); + break; + case "talkHondaur": + gm.hondaur.talkHondaur(); + break; + case "attackHondaur": + gm.hondaur.attackHondaur(); + break; + case "lookAnthony": + gm.hondaur.lookAnthony(); + break; + case "talkAnthony": + gm.hondaur.talkAnthony(); + break; + case "touchAnthony": + gm.hondaur.touchAnthony(); + break; + //SCENE 4 + case "lookDenzel": + gm.ev4.lookDenzel(); + break; + case "talkDenzel": + gm.ev4.talkDenzel(); + break; + case "restDenzel": + gm.ev4.restDenzel(); + break; + //SCENE 5 + case "lookHondaTrunk": + gm.ev5.lookHondaTrunk(); + break; + case "talkHondaTrunk": + gm.ev5.talkHondaTrunk(); + break; + case "killHondaTrunk": + gm.ev5.killHondaTrunk(); + break; + case "lookTheodoor": + gm.theodoor.lookTheodoor(); + break; + case "talkTheodoor": + gm.theodoor.talkTheodoor(); + break; + case "attackTheodoor": + gm.theodoor.attackTheodoor(); + break; + case "lookWheeler": + gm.wheeler.lookWheeler(); + break; + case "talkWheeler": + gm.wheeler.talkWheeler(); + break; + case "attackWheeler": + gm.wheeler.attackWheeler(); + break; + //SCENE 6 + case "lookBrandon": + gm.ev6.lookBrandon(); + break; + case "talkBrandon": + gm.ev6.talkBrandon(); + break; + case "restBrandon": + gm.ev6.restBrandon(); + break; + case "lookDenzel2": + gm.ev6.lookDenzel(); + break; + case "talkDenzel2": + gm.ev6.talkDenzel(); + break; + case "playDenzel": + gm.ev6.playDenzel(); + break; + //SCENE 7 + case "lookJulian": + gm.ev7.lookJulian(); + break; + case "talkJulian": + gm.ev7.talkJulian(); + break; + case "holdJulian": + gm.ev7.holdJulian(); + break; + case "lookSlotMachine": + gm.ev7.lookSlotMachine(); + break; + case "talkSlotMachine": + gm.ev7.talkSlotMachine(); + break; + case "spinSlotMachine": + gm.ev7.spinSlotMachine(); + break; + case "lookAdrian": + gm.ev7.lookAdrian(); + break; + case "talkAdrian": + gm.ev7.talkAdrian(); + break; + case "thankAdrian": + gm.ev7.thankAdrian(); + break; + case "talkSponge2": + gm.engineStealerMonster.talkSponge2(); + break; + case "attackSponge": + gm.engineStealerMonster.attackSponge(); + break; + case "letliveSponge": + gm.engineStealerMonster.letLiveSponge(); + break; + + // SCENE CHANGES + case "goScene1": + gm.sChanger.showScene1(); + break; + case "goScene2": + if(gm.player.hasFlashlight == 1){ + gm.sChanger.showScene2(); + } + else { + gm.ui.messageText.setText("It's dark outside! You need a flashlight"); + gm.playSE(gm.cannotSound); + } + break; + case "goScene3": + gm.sChanger.showScene3(); + break; + case "goScene4": + if(gm.hondaur.currentLife == 0){ + gm.sChanger.showScene4(); + } + else { + gm.ui.messageText.setText("You must beat the crap outta the Hondaur to proceed!"); + gm.playSE(gm.cannotSound); + } + break; + case "goScene5": + if(gm.player.hasPistol == 1){ + gm.sChanger.showScene5(); + } + else { + gm.ui.messageText.setText("You should get the glock from Denzel!"); + gm.playSE(gm.cannotSound); + } + break; + case "goScene6": + if(gm.theodoor.currentLife == 0 && gm.wheeler.currentLife == 0){ + gm.sChanger.showScene6(); + } + else{ + gm.ui.messageText.setText("You must kill the monsters first!"); + gm.playSE(gm.cannotSound); + } + break; + case "goScene7": + gm.sChanger.showScene7(); + break; + case "goScene8": + if(gm.ev7.julianLife == 0){ + gm.sChanger.showScene8(); + } + else { + gm.ui.messageText.setText("You need to spin the slot machine first!"); + } + break; + case "goLeaderboard": + if(gm.engineStealerMonster.currentLife == 0) { + gm.sChanger.viewLeaderboard(); + } + else{ + gm.ui.messageText.setText("You must kill or let the monster live to proceed!"); + } + break; + case "restart": + gm.sChanger.exitGameOverScreen(); + gm.sChanger.showScene1(); + gm.startGameTimer(); + break; + } + } +} diff --git a/src/main/java/main/GameManager.java b/src/main/java/main/GameManager.java index cd88b9e..32a5b7c 100644 --- a/src/main/java/main/GameManager.java +++ b/src/main/java/main/GameManager.java @@ -1,132 +1,132 @@ -package main; -/** - * This the main class that handles the game logic - */ - -import event.*; -import javafx.animation.AnimationTimer; -import javafx.application.Application; -import javafx.stage.Stage; -import monsters.EngineStealerMonster; -import monsters.Hondaur; -import monsters.Theodoor; -import monsters.Wheeler; - -import java.net.URL; -import java.util.List; - -public class GameManager extends Application { - - ActionHandler aHandler = new ActionHandler(this); - public UI ui = new UI(this); - public Player player = new Player(this); - public SceneChanger sChanger = new SceneChanger(this); - - private long startTime; - public AnimationTimer gameTimer; - public long elapsedTime; - private TimeManager timeManager; - - public Event01 ev1 = new Event01(this); - public Event02 ev2 = new Event02(this); - public Event03 ev3 = new Event03(this); - public Event04 ev4 = new Event04(this); - public Event05 ev5 = new Event05(this); - public Event06 ev6 = new Event06(this); - public Event07 ev7 = new Event07(this); - public Hondaur hondaur = new Hondaur(this); - public EngineStealerMonster engineStealerMonster = new EngineStealerMonster(this); - public Theodoor theodoor = new Theodoor(this); - public Wheeler wheeler = new Wheeler(this); - Music music = new Music(); - SoundEffect se = new SoundEffect(); - - //SOUND - public URL mainTheme = getClass().getClassLoader().getResource("mainTheme.wav"); - public URL monsterTheme = getClass().getClassLoader().getResource("monsterTheme.wav"); - public URL casinoMusic = getClass().getClassLoader().getResource("casinoMusic.wav"); - public URL slotWin = getClass().getClassLoader().getResource("slotWin.wav"); - public URL monsterHit = getClass().getClassLoader().getResource("monsterHit.wav"); - public URL monsterRoar = getClass().getClassLoader().getResource("monsterRoar.wav"); - public URL ak47shots = getClass().getClassLoader().getResource("ak47shots.wav"); - public URL pistolShot = getClass().getClassLoader().getResource("pistolShot.wav"); - public URL reload = getClass().getClassLoader().getResource("reload.wav"); - public URL flashlightSwitch = getClass().getClassLoader().getResource("flashlightSwitch.wav"); - public URL heal = getClass().getClassLoader().getResource("heal.wav"); - public URL awSound = getClass().getClassLoader().getResource("awSound.wav"); - public URL gameOverSound = getClass().getClassLoader().getResource("gameOverSound.wav"); - public URL gameOverVoice = getClass().getClassLoader().getResource("gameOverVoice.wav"); - public URL cannotSound = getClass().getClassLoader().getResource("cannotSound.wav"); - public URL engineNoise = getClass().getClassLoader().getResource("engineNoise.wav"); - public URL currentMusic; - - public static void main(String[] args) { - // Launch the JavaFX application - launch(args); - } - - @Override - public void start(Stage primaryStage) { - - currentMusic = mainTheme; - playMusic(currentMusic); - - ui.createTitleScreen(primaryStage); - timeManager = new TimeManager(); - - } - - public void playSE(URL url) { - - se.setFile(url); - se.play(url); - } - public void playMusic(URL url){ - - music.setFile(url); - music.play(url); - music.loop(url); - } - public void stopMusic(URL url){ - - music.stop(url); - } - - - public void startGameTimer() { - startTime = System.nanoTime(); - gameTimer = new AnimationTimer() { - @Override - public void handle(long now) { - elapsedTime = (now - startTime) / 1_000_000; // Convert to milliseconds - updateTimerUI(); - } - }; - gameTimer.start(); - } - - public void stopGameTimer() { - if (gameTimer != null) { - gameTimer.stop(); - } - // Check if the monster is defeated and save the time - if (engineStealerMonster.currentLife == 0) { - timeManager.addTime(elapsedTime); - ui.messageText.setText("Your time: " + TimeManager.TimeUtils.formatTime(elapsedTime)); - } - } - - public void updateTimerUI() { - // Format the time as minutes and seconds - long seconds = elapsedTime / 1000; - long minutes = seconds / 60; - seconds %= 60; - - // Display the timer on the UI - ui.timerLabel.setText(String.format("%02d:%02d", minutes, seconds)); - } - public void showLeaderboard() { - List leaderboard = timeManager.getFormattedFastestTimes(); - ui.displayLeaderboard(leaderboard); // Add a method in UI to display the leaderboard - } -} +package main; +/** + * This the main class that handles the game logic + */ + +import event.*; +import javafx.animation.AnimationTimer; +import javafx.application.Application; +import javafx.stage.Stage; +import monsters.EngineStealerMonster; +import monsters.Hondaur; +import monsters.Theodoor; +import monsters.Wheeler; + +import java.net.URL; +import java.util.List; + +public class GameManager extends Application { + + ActionHandler aHandler = new ActionHandler(this); + public UI ui = new UI(this); + public Player player = new Player(this); + public SceneChanger sChanger = new SceneChanger(this); + + private long startTime; + public AnimationTimer gameTimer; + public long elapsedTime; + private TimeManager timeManager; + + public Event01 ev1 = new Event01(this); + public Event02 ev2 = new Event02(this); + public Event03 ev3 = new Event03(this); + public Event04 ev4 = new Event04(this); + public Event05 ev5 = new Event05(this); + public Event06 ev6 = new Event06(this); + public Event07 ev7 = new Event07(this); + public Hondaur hondaur = new Hondaur(this); + public EngineStealerMonster engineStealerMonster = new EngineStealerMonster(this); + public Theodoor theodoor = new Theodoor(this); + public Wheeler wheeler = new Wheeler(this); + Music music = new Music(); + SoundEffect se = new SoundEffect(); + + //SOUND + public URL mainTheme = getClass().getClassLoader().getResource("mainTheme.wav"); + public URL monsterTheme = getClass().getClassLoader().getResource("monsterTheme.wav"); + public URL casinoMusic = getClass().getClassLoader().getResource("casinoMusic.wav"); + public URL slotWin = getClass().getClassLoader().getResource("slotWin.wav"); + public URL monsterHit = getClass().getClassLoader().getResource("monsterHit.wav"); + public URL monsterRoar = getClass().getClassLoader().getResource("monsterRoar.wav"); + public URL ak47shots = getClass().getClassLoader().getResource("ak47shots.wav"); + public URL pistolShot = getClass().getClassLoader().getResource("pistolShot.wav"); + public URL reload = getClass().getClassLoader().getResource("reload.wav"); + public URL flashlightSwitch = getClass().getClassLoader().getResource("flashlightSwitch.wav"); + public URL heal = getClass().getClassLoader().getResource("heal.wav"); + public URL awSound = getClass().getClassLoader().getResource("awSound.wav"); + public URL gameOverSound = getClass().getClassLoader().getResource("gameOverSound.wav"); + public URL gameOverVoice = getClass().getClassLoader().getResource("gameOverVoice.wav"); + public URL cannotSound = getClass().getClassLoader().getResource("cannotSound.wav"); + public URL engineNoise = getClass().getClassLoader().getResource("engineNoise.wav"); + public URL currentMusic; + + public static void main(String[] args) { + // Launch the JavaFX application + launch(args); + } + + @Override + public void start(Stage primaryStage) { + + currentMusic = mainTheme; + playMusic(currentMusic); + + ui.createTitleScreen(primaryStage); + timeManager = new TimeManager(); + + } + + public void playSE(URL url) { + + se.setFile(url); + se.play(url); + } + public void playMusic(URL url){ + + music.setFile(url); + music.play(url); + music.loop(url); + } + public void stopMusic(URL url){ + + music.stop(url); + } + + + public void startGameTimer() { + startTime = System.nanoTime(); + gameTimer = new AnimationTimer() { + @Override + public void handle(long now) { + elapsedTime = (now - startTime) / 1_000_000; // Convert to milliseconds + updateTimerUI(); + } + }; + gameTimer.start(); + } + + public void stopGameTimer() { + if (gameTimer != null) { + gameTimer.stop(); + } + // Check if the monster is defeated and save the time + if (engineStealerMonster.currentLife == 0) { + timeManager.addTime(elapsedTime); + ui.messageText.setText("Your time: " + TimeManager.TimeUtils.formatTime(elapsedTime)); + } + } + + public void updateTimerUI() { + // Format the time as minutes and seconds + long seconds = elapsedTime / 1000; + long minutes = seconds / 60; + seconds %= 60; + + // Display the timer on the UI + ui.timerLabel.setText(String.format("%02d:%02d", minutes, seconds)); + } + public void showLeaderboard() { + List leaderboard = timeManager.getFormattedFastestTimes(); + ui.displayLeaderboard(leaderboard); // Add a method in UI to display the leaderboard + } +} diff --git a/src/main/java/main/GameResourceManager.java b/src/main/java/main/GameResourceManager.java new file mode 100644 index 0000000..3f76c3a --- /dev/null +++ b/src/main/java/main/GameResourceManager.java @@ -0,0 +1,6 @@ +package main; + +public class GameResourceManager { + + //can put all the resources you need in here to keep the game manager more clear +} diff --git a/src/main/java/main/Music.java b/src/main/java/main/Music.java index 0053b11..b6376f0 100644 --- a/src/main/java/main/Music.java +++ b/src/main/java/main/Music.java @@ -1,39 +1,39 @@ -package main; -/** - * this class handles music - */ - -import javax.sound.sampled.*; -import java.io.IOException; -import java.net.URL; - -public class Music { - - - Clip clip; - - public void setFile(URL name){ - - try{ - AudioInputStream sound = AudioSystem.getAudioInputStream(name); - clip = AudioSystem.getClip(); - clip.open(sound); - } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) { - throw new RuntimeException(e); - } - } - - public void play(URL name){ - clip.setFramePosition(0); - clip.start(); - } - - public void loop(URL name){ - - clip.loop(Clip.LOOP_CONTINUOUSLY); - } - - public void stop(URL name){ - clip.stop(); - } -} +package main; +/** + * this class handles music + */ + +import javax.sound.sampled.*; +import java.io.IOException; +import java.net.URL; + +public class Music { + + + Clip clip; + + public void setFile(URL name){ + + try{ + AudioInputStream sound = AudioSystem.getAudioInputStream(name); + clip = AudioSystem.getClip(); + clip.open(sound); + } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) { + throw new RuntimeException(e); + } + } + + public void play(URL name){ + clip.setFramePosition(0); + clip.start(); + } + + public void loop(URL name){ + + clip.loop(Clip.LOOP_CONTINUOUSLY); + } + + public void stop(URL name){ + clip.stop(); + } +} diff --git a/src/main/java/main/Player.java b/src/main/java/main/Player.java index cd20c21..21f05c3 100644 --- a/src/main/java/main/Player.java +++ b/src/main/java/main/Player.java @@ -1,56 +1,56 @@ -package main; - -/** - * this class handles the player logic - */ -public class Player { - - GameManager gm; - - public int playerMaxLife; - public int playerLife; - - public int hasFlashlight; - public int hasPistol; - public int hasAk47; - - - public Player(GameManager gm) { - - this.gm = gm; - } - - public void setPlayerDefaultStatus() { - - playerMaxLife = 5; - playerLife = 2; - hasFlashlight = 0; - hasPistol = 0; - hasAk47 = 0; - - updatePlayerStatus(); - } - public void updatePlayerStatus() { - - int i = 0; - while (i < 5) { - gm.ui.lifeLabels[i].setVisible(false); - i++; - } - - // Set visible only the icons corresponding to playerLife - int lifeCount = playerLife; - i = 0; // Reset i to 0 to use for setting life icons - while (lifeCount > 0 && i < gm.ui.lifeLabels.length) { - gm.ui.lifeLabels[i].setVisible(true); - lifeCount--; - i++; - } - - // CHECK PLAYER ITEMS - gm.ui.flashlightLabel.setVisible(hasFlashlight == 1); - gm.ui.pistolLabel.setVisible(hasPistol == 1); - gm.ui.ak47Label.setVisible(hasAk47 == 1); - } - } - +package main; + +/** + * this class handles the player logic + */ +public class Player { + + GameManager gm; + + public int playerMaxLife; + public int playerLife; + + public int hasFlashlight; + public int hasPistol; + public int hasAk47; + + + public Player(GameManager gm) { + + this.gm = gm; + } + + public void setPlayerDefaultStatus() { + + playerMaxLife = 5; + playerLife = 2; + hasFlashlight = 0; + hasPistol = 0; + hasAk47 = 0; + + updatePlayerStatus(); + } + public void updatePlayerStatus() { + + int i = 0; + while (i < 5) { + gm.ui.lifeLabels[i].setVisible(false); + i++; + } + + // Set visible only the icons corresponding to playerLife + int lifeCount = playerLife; + i = 0; // Reset i to 0 to use for setting life icons + while (lifeCount > 0 && i < gm.ui.lifeLabels.length) { + gm.ui.lifeLabels[i].setVisible(true); + lifeCount--; + i++; + } + + // CHECK PLAYER ITEMS + gm.ui.flashlightLabel.setVisible(hasFlashlight == 1); + gm.ui.pistolLabel.setVisible(hasPistol == 1); + gm.ui.ak47Label.setVisible(hasAk47 == 1); + } + } + diff --git a/src/main/java/main/SceneChanger.java b/src/main/java/main/SceneChanger.java index b1d5043..ce98861 100644 --- a/src/main/java/main/SceneChanger.java +++ b/src/main/java/main/SceneChanger.java @@ -1,164 +1,165 @@ -package main; - -/** - * This class handles the transition of scenes - */ -public class SceneChanger { - - GameManager gm; - - public SceneChanger(GameManager gm) { - - this.gm = gm; - } - - public void showScene1(){ - - gm.ui.bgPane[1].setVisible(true); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); - gm.ui.messageText.setText("You are inside your room and you hear a sus sound outside"); - - gm.stopMusic(gm.currentMusic); - gm.currentMusic = gm.mainTheme; - gm.playMusic(gm.currentMusic); - } - public void showScene2(){ - - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(true); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); - gm.ui.messageText.setText("You are outside your house"); - } - public void showScene3(){ - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(true); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); - gm.ui.messageText.setText("The Engine Monster Stealer gets away and you find yourself lost in the woods"); - - gm.stopMusic(gm.currentMusic); - gm.currentMusic = gm.monsterTheme; - gm.playMusic(gm.currentMusic); - } - public void showScene4() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(true); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); - gm.ui.messageText.setText("You find a tall, dark, and handsome man"); - - gm.stopMusic(gm.currentMusic); - gm.currentMusic = gm.mainTheme; - gm.playMusic(gm.currentMusic); - } - public void showScene5() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(true); - gm.ui.bgPane[6].setVisible(false); - gm.ui.messageText.setText("The Casino is up ahead but 2 monsters block your way!"); - - gm.stopMusic(gm.currentMusic); - gm.currentMusic = gm.monsterTheme; - gm.playMusic(gm.currentMusic); - } - public void showScene6() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(true); - gm.ui.messageText.setText("You followed the sound of havoc and made your way to the Casino"); - - gm.stopMusic(gm.currentMusic); - gm.currentMusic = gm.mainTheme; - gm.playMusic(gm.currentMusic); - } - public void showScene7() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); - gm.ui.bgPane[7].setVisible(true); - gm.ui.messageText.setText("You enter the Casino but its too late"); - - gm.stopMusic(gm.currentMusic); - gm.currentMusic = gm.casinoMusic; - gm.playMusic(gm.currentMusic); - } - public void showScene8() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); - gm.ui.bgPane[7].setVisible(false); - gm.ui.bgPane[8].setVisible(true); - gm.ui.messageText.setText("You catch up to the monster"); - - gm.stopMusic(gm.currentMusic); - gm.currentMusic = gm.monsterTheme; - gm.playMusic(gm.currentMusic); - } - public void viewLeaderboard() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); - gm.ui.bgPane[7].setVisible(false); - gm.ui.bgPane[8].setVisible(false); - gm.ui.bgPane[9].setVisible(true); - - gm.showLeaderboard(); - gm.stopMusic(gm.currentMusic); - gm.currentMusic = gm.mainTheme; - gm.playMusic(gm.currentMusic); - gm.ui.messageText.setText("Congrats! You won!"); - - } - public void showGameOverScreen(int currentBgNum){ - - gm.ui.bgPane[currentBgNum].setVisible(false); - gm.ui.titleLabel.setVisible(true); - gm.ui.titleLabel.setText("YOU DIED"); - gm.ui.restartButton.setVisible(true); - gm.ui.restartButton.setText("Click Here To Restart"); - gm.stopGameTimer(); - - gm.stopMusic(gm.currentMusic); - - gm.playSE(gm.gameOverSound); - gm.playSE(gm.gameOverVoice); - } - public void exitGameOverScreen(){ - - gm.ui.titleLabel.setVisible(false); - gm.ui.restartButton.setVisible(false); - gm.hondaur.reset(); - gm.theodoor.reset(); - gm.wheeler.reset(); - gm.ev6.reset(); - gm.engineStealerMonster.reset(); - gm.player.setPlayerDefaultStatus(); - } - -} +package main; + +/** + * This class handles the transition of scenes + */ +public class SceneChanger { + + GameManager gm; + + public SceneChanger(GameManager gm) { + + this.gm = gm; + } + +//can avoid using booleans for all the backgrounds if a method to automatically choose a background 1-6 is used + public void showScene1(){ + + gm.ui.bgPane[1].setVisible(true); + gm.ui.bgPane[2].setVisible(false); + gm.ui.bgPane[3].setVisible(false); + gm.ui.bgPane[4].setVisible(false); + gm.ui.bgPane[5].setVisible(false); + gm.ui.bgPane[6].setVisible(false); + gm.ui.messageText.setText("You are inside your room and you hear a sus sound outside"); + + gm.stopMusic(gm.currentMusic); + gm.currentMusic = gm.mainTheme; + gm.playMusic(gm.currentMusic); + } + public void showScene2(){ + + gm.ui.bgPane[1].setVisible(false); + gm.ui.bgPane[2].setVisible(true); + gm.ui.bgPane[3].setVisible(false); + gm.ui.bgPane[4].setVisible(false); + gm.ui.bgPane[5].setVisible(false); + gm.ui.bgPane[6].setVisible(false); + gm.ui.messageText.setText("You are outside your house"); + } + public void showScene3(){ + gm.ui.bgPane[1].setVisible(false); + gm.ui.bgPane[2].setVisible(false); + gm.ui.bgPane[3].setVisible(true); + gm.ui.bgPane[4].setVisible(false); + gm.ui.bgPane[5].setVisible(false); + gm.ui.bgPane[6].setVisible(false); + gm.ui.messageText.setText("The Engine Monster Stealer gets away and you find yourself lost in the woods"); + + gm.stopMusic(gm.currentMusic); + gm.currentMusic = gm.monsterTheme; + gm.playMusic(gm.currentMusic); + } + public void showScene4() { + gm.ui.bgPane[1].setVisible(false); + gm.ui.bgPane[2].setVisible(false); + gm.ui.bgPane[3].setVisible(false); + gm.ui.bgPane[4].setVisible(true); + gm.ui.bgPane[5].setVisible(false); + gm.ui.bgPane[6].setVisible(false); + gm.ui.messageText.setText("You find a tall, dark, and handsome man"); + + gm.stopMusic(gm.currentMusic); + gm.currentMusic = gm.mainTheme; + gm.playMusic(gm.currentMusic); + } + public void showScene5() { + gm.ui.bgPane[1].setVisible(false); + gm.ui.bgPane[2].setVisible(false); + gm.ui.bgPane[3].setVisible(false); + gm.ui.bgPane[4].setVisible(false); + gm.ui.bgPane[5].setVisible(true); + gm.ui.bgPane[6].setVisible(false); + gm.ui.messageText.setText("The Casino is up ahead but 2 monsters block your way!"); + + gm.stopMusic(gm.currentMusic); + gm.currentMusic = gm.monsterTheme; + gm.playMusic(gm.currentMusic); + } + public void showScene6() { + gm.ui.bgPane[1].setVisible(false); + gm.ui.bgPane[2].setVisible(false); + gm.ui.bgPane[3].setVisible(false); + gm.ui.bgPane[4].setVisible(false); + gm.ui.bgPane[5].setVisible(false); + gm.ui.bgPane[6].setVisible(true); + gm.ui.messageText.setText("You followed the sound of havoc and made your way to the Casino"); + + gm.stopMusic(gm.currentMusic); + gm.currentMusic = gm.mainTheme; + gm.playMusic(gm.currentMusic); + } + public void showScene7() { + gm.ui.bgPane[1].setVisible(false); + gm.ui.bgPane[2].setVisible(false); + gm.ui.bgPane[3].setVisible(false); + gm.ui.bgPane[4].setVisible(false); + gm.ui.bgPane[5].setVisible(false); + gm.ui.bgPane[6].setVisible(false); + gm.ui.bgPane[7].setVisible(true); + gm.ui.messageText.setText("You enter the Casino but its too late"); + + gm.stopMusic(gm.currentMusic); + gm.currentMusic = gm.casinoMusic; + gm.playMusic(gm.currentMusic); + } + public void showScene8() { + gm.ui.bgPane[1].setVisible(false); + gm.ui.bgPane[2].setVisible(false); + gm.ui.bgPane[3].setVisible(false); + gm.ui.bgPane[4].setVisible(false); + gm.ui.bgPane[5].setVisible(false); + gm.ui.bgPane[6].setVisible(false); + gm.ui.bgPane[7].setVisible(false); + gm.ui.bgPane[8].setVisible(true); + gm.ui.messageText.setText("You catch up to the monster"); + + gm.stopMusic(gm.currentMusic); + gm.currentMusic = gm.monsterTheme; + gm.playMusic(gm.currentMusic); + } + public void viewLeaderboard() { + gm.ui.bgPane[1].setVisible(false); + gm.ui.bgPane[2].setVisible(false); + gm.ui.bgPane[3].setVisible(false); + gm.ui.bgPane[4].setVisible(false); + gm.ui.bgPane[5].setVisible(false); + gm.ui.bgPane[6].setVisible(false); + gm.ui.bgPane[7].setVisible(false); + gm.ui.bgPane[8].setVisible(false); + gm.ui.bgPane[9].setVisible(true); + + gm.showLeaderboard(); + gm.stopMusic(gm.currentMusic); + gm.currentMusic = gm.mainTheme; + gm.playMusic(gm.currentMusic); + gm.ui.messageText.setText("Congrats! You won!"); + + } + public void showGameOverScreen(int currentBgNum){ + + gm.ui.bgPane[currentBgNum].setVisible(false); + gm.ui.titleLabel.setVisible(true); + gm.ui.titleLabel.setText("YOU DIED"); + gm.ui.restartButton.setVisible(true); + gm.ui.restartButton.setText("Click Here To Restart"); + gm.stopGameTimer(); + + gm.stopMusic(gm.currentMusic); + + gm.playSE(gm.gameOverSound); + gm.playSE(gm.gameOverVoice); + } + public void exitGameOverScreen(){ + + gm.ui.titleLabel.setVisible(false); + gm.ui.restartButton.setVisible(false); + gm.hondaur.reset(); + gm.theodoor.reset(); + gm.wheeler.reset(); + gm.ev6.reset(); + gm.engineStealerMonster.reset(); + gm.player.setPlayerDefaultStatus(); + } + +} diff --git a/src/main/java/main/SoundEffect.java b/src/main/java/main/SoundEffect.java index 6410d8e..1cd2c30 100644 --- a/src/main/java/main/SoundEffect.java +++ b/src/main/java/main/SoundEffect.java @@ -1,30 +1,30 @@ -package main; - -/** - * This class handles the sound effects - */ - -import javax.sound.sampled.*; -import java.io.IOException; -import java.net.URL; - -public class SoundEffect { - - Clip clip; - - public void setFile(URL name){ - - try{ - AudioInputStream sound = AudioSystem.getAudioInputStream(name); - clip = AudioSystem.getClip(); - clip.open(sound); - } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) { - throw new RuntimeException(e); - } - } - - public void play(URL name){ - clip.setFramePosition(0); - clip.start(); - } -} +package main; + +/** + * This class handles the sound effects + */ + +import javax.sound.sampled.*; +import java.io.IOException; +import java.net.URL; + +public class SoundEffect { + + Clip clip; + + public void setFile(URL name){ + + try{ + AudioInputStream sound = AudioSystem.getAudioInputStream(name); + clip = AudioSystem.getClip(); + clip.open(sound); + } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) { + throw new RuntimeException(e); + } + } + + public void play(URL name){ + clip.setFramePosition(0); + clip.start(); + } +} diff --git a/src/main/java/main/TimeManager.java b/src/main/java/main/TimeManager.java index 25d9b19..30e2a01 100644 --- a/src/main/java/main/TimeManager.java +++ b/src/main/java/main/TimeManager.java @@ -1,110 +1,110 @@ -package main; - -/** - * This class handles the leaderboard times - */ - -import java.io.*; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class TimeManager { - private static final String BINARY_FILE_NAME = "fastest_times.dat"; - private static final String LEADERBOARD_FILE_NAME = "leaderboard.csv"; - public ArrayList fastestTimes = new ArrayList<>(); - - public TimeManager() { - loadTimes(); - loadLeaderboard(); - } - - public ArrayList getFastestTimes() { - return new ArrayList<>(fastestTimes); - } - - public List getFormattedFastestTimes() { - ArrayList formattedTimes = new ArrayList<>(); - for (Long time : fastestTimes) { - formattedTimes.add(TimeUtils.formatTime(time)); - } - return formattedTimes; - } - - public void addTime(long time) { - fastestTimes.add(time); - Collections.sort(fastestTimes); - if (fastestTimes.size() > 10) { - fastestTimes.remove(fastestTimes.size() - 1); - } - saveTimes(); - saveLeaderboard(); // Save to leaderboard file as well - } - - void saveTimes() { - try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(BINARY_FILE_NAME))) { - oos.writeObject(fastestTimes); - } catch (IOException e) { - System.err.println("Error saving times: " + e.getMessage()); - } - } - - void loadTimes() { - try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(BINARY_FILE_NAME))) { - fastestTimes = (ArrayList) ois.readObject(); - } catch (FileNotFoundException e) { - // File doesn't exist yet, no action needed - } catch (IOException | ClassNotFoundException e) { - System.err.println("Error loading times: " + e.getMessage()); - } - } - - void saveLeaderboard() { - try (BufferedWriter writer = new BufferedWriter(new FileWriter(LEADERBOARD_FILE_NAME))) { - writer.write("Rank,Time (mm:ss)"); - writer.newLine(); - List formattedTimes = getFormattedFastestTimes(); - for (int i = 0; i < formattedTimes.size(); i++) { - writer.write((i + 1) + "," + formattedTimes.get(i)); - writer.newLine(); - } - } catch (IOException e) { - System.err.println("Error saving leaderboard: " + e.getMessage()); - } - } - - void loadLeaderboard() { - try (BufferedReader reader = new BufferedReader(new FileReader(LEADERBOARD_FILE_NAME))) { - fastestTimes.clear(); - String line = reader.readLine(); // Skip the header - while ((line = reader.readLine()) != null) { - String[] parts = line.split(","); - if (parts.length == 2) { - String timeString = parts[1]; - long millis = TimeUtils.parseFormattedTime(timeString); // Parse back to milliseconds - fastestTimes.add(millis); - } - } - Collections.sort(fastestTimes); // Ensure the list is sorted - } catch (FileNotFoundException e) { - // File doesn't exist yet, no action needed - } catch (IOException e) { - System.err.println("Error loading leaderboard: " + e.getMessage()); - } - } - public class TimeUtils { - public static String formatTime(long millis) { - long seconds = millis / 1000; - long minutes = seconds / 60; - seconds %= 60; - return String.format("%02d:%02d", minutes, seconds); - } - - public static long parseFormattedTime(String formattedTime) { - String[] parts = formattedTime.split(":"); - long minutes = Long.parseLong(parts[0]); - long seconds = Long.parseLong(parts[1]); - return (minutes * 60 + seconds) * 1000; // Convert to milliseconds - } - } -} +package main; + +/** + * This class handles the leaderboard times + */ + +import java.io.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class TimeManager { + private static final String BINARY_FILE_NAME = "fastest_times.dat"; + private static final String LEADERBOARD_FILE_NAME = "leaderboard.csv"; + public ArrayList fastestTimes = new ArrayList<>(); + + public TimeManager() { + loadTimes(); + loadLeaderboard(); + } + + public ArrayList getFastestTimes() { + return new ArrayList<>(fastestTimes); + } + + public List getFormattedFastestTimes() { + ArrayList formattedTimes = new ArrayList<>(); + for (Long time : fastestTimes) { + formattedTimes.add(TimeUtils.formatTime(time)); + } + return formattedTimes; + } + + public void addTime(long time) { + fastestTimes.add(time); + Collections.sort(fastestTimes); + if (fastestTimes.size() > 10) { + fastestTimes.remove(fastestTimes.size() - 1); + } + saveTimes(); + saveLeaderboard(); // Save to leaderboard file as well + } + + void saveTimes() { + try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(BINARY_FILE_NAME))) { + oos.writeObject(fastestTimes); + } catch (IOException e) { + System.err.println("Error saving times: " + e.getMessage()); + } + } + + void loadTimes() { + try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(BINARY_FILE_NAME))) { + fastestTimes = (ArrayList) ois.readObject(); + } catch (FileNotFoundException e) { + // File doesn't exist yet, no action needed + } catch (IOException | ClassNotFoundException e) { + System.err.println("Error loading times: " + e.getMessage()); + } + } + + void saveLeaderboard() { + try (BufferedWriter writer = new BufferedWriter(new FileWriter(LEADERBOARD_FILE_NAME))) { + writer.write("Rank,Time (mm:ss)"); + writer.newLine(); + List formattedTimes = getFormattedFastestTimes(); + for (int i = 0; i < formattedTimes.size(); i++) { + writer.write((i + 1) + "," + formattedTimes.get(i)); + writer.newLine(); + } + } catch (IOException e) { + System.err.println("Error saving leaderboard: " + e.getMessage()); + } + } + + void loadLeaderboard() { + try (BufferedReader reader = new BufferedReader(new FileReader(LEADERBOARD_FILE_NAME))) { + fastestTimes.clear(); + String line = reader.readLine(); // Skip the header + while ((line = reader.readLine()) != null) { + String[] parts = line.split(","); + if (parts.length == 2) { + String timeString = parts[1]; + long millis = TimeUtils.parseFormattedTime(timeString); // Parse back to milliseconds + fastestTimes.add(millis); + } + } + Collections.sort(fastestTimes); // Ensure the list is sorted + } catch (FileNotFoundException e) { + // File doesn't exist yet, no action needed + } catch (IOException e) { + System.err.println("Error loading leaderboard: " + e.getMessage()); + } + } + public class TimeUtils { + public static String formatTime(long millis) { + long seconds = millis / 1000; + long minutes = seconds / 60; + seconds %= 60; + return String.format("%02d:%02d", minutes, seconds); + } + + public static long parseFormattedTime(String formattedTime) { + String[] parts = formattedTime.split(":"); + long minutes = Long.parseLong(parts[0]); + long seconds = Long.parseLong(parts[1]); + return (minutes * 60 + seconds) * 1000; // Convert to milliseconds + } + } +} diff --git a/src/main/java/main/UI.java b/src/main/java/main/UI.java index be2b253..5ee43e7 100644 --- a/src/main/java/main/UI.java +++ b/src/main/java/main/UI.java @@ -1,399 +1,399 @@ -package main; - -/** - * This class handles all the graphics - */ - -import javafx.animation.KeyFrame; -import javafx.animation.KeyValue; -import javafx.animation.Timeline; -import javafx.scene.Scene; -import javafx.scene.control.*; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.MenuItem; -import javafx.scene.control.TextArea; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.input.MouseButton; -import javafx.scene.layout.*; -import javafx.scene.paint.Color; -import javafx.scene.shape.Rectangle; -import javafx.scene.text.Font; -import javafx.scene.text.Text; -import javafx.stage.Stage; -import javafx.util.Duration; - -import java.util.List; -import java.util.Objects; - -public class UI { - GameManager gm; - Stage window; - public TextArea messageText; - public Pane[] bgPane = new Pane[11]; - ImageView[] bgImageView = new ImageView[11]; - public Label timerLabel; - - // PLAYER UI - public Label flashlightLabel, pistolLabel, ak47Label; - ImageView[] lifeLabels = new ImageView[5]; - - //GAME OVER UI - public Label titleLabel; - public Button restartButton; - - public UI(GameManager gm) { - this.gm = gm; - } - - public void createTitleScreen(Stage primaryStage) { - // Window setup - this.window = primaryStage; - window.setTitle("Engine Of Desolation"); - window.setWidth(800); - window.setHeight(600); - - // Create the root pane for the title screen - Pane root = new Pane(); - root.setStyle("-fx-background-color: black;"); - - // Background Image - ImageView backgroundImage = new ImageView( - new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("titleScreen.png"))) - ); - backgroundImage.setFitWidth(800); - backgroundImage.setFitHeight(600); - backgroundImage.setPreserveRatio(false); - - // Floating Text - Text floatingText = new Text(80, 200, "Engine Of Desolation"); - floatingText.setFont(Font.font("Times New Roman", 70)); - floatingText.setFill(Color.DARKRED); - - Timeline timeline = new Timeline( - new KeyFrame(Duration.ZERO, new KeyValue(floatingText.translateYProperty(), 0)), - new KeyFrame(Duration.seconds(2), new KeyValue(floatingText.translateYProperty(), -50)) - ); - timeline.setAutoReverse(true); - timeline.setCycleCount(Timeline.INDEFINITE); - timeline.play(); - - - //START BUTTON - Button startButton = new Button("Start"); - startButton.setStyle("-fx-font-family: 'Arial'; -fx-font-size: 24px; -fx-background-color: white;"); - startButton.setLayoutX((800 - 150) / 2); // Center horizontally (approximate for button width) - startButton.setLayoutY(400); // Center vertically (approximate for button height) - - // Start button functionality - startButton.setOnAction(e -> { - // Transition to the main game screen - createMainField(window); - createPlayerField(); - createGameOverField(); - gm.player.setPlayerDefaultStatus(); - generateScene(); - gm.sChanger.showScene1(); - gm.startGameTimer(); - - }); - - // Add components to root - root.getChildren().addAll(backgroundImage, floatingText, startButton); - - // Create and set the scene - Scene titleScene = new Scene(root, 800, 600); - window.setScene(titleScene); - window.show(); - } - - public void createMainField(Stage primaryStage) { - this.window = primaryStage; - window.setTitle("Engine Of Desolation"); - window.setWidth(800); - window.setHeight(600); - - // Main Pane with black background - Pane root = new Pane(); - root.setStyle("-fx-background-color: black;"); - - // Create main TextArea - messageText = new TextArea("THIS IS SAMPLE TEXT"); - messageText.setPrefSize(700, 150); - messageText.setLayoutX(50); - messageText.setLayoutY(410); - messageText.setEditable(false); - messageText.setWrapText(true); - - // Set styles for the TextArea - messageText.setStyle("-fx-font-family: 'Arial'; " + - "-fx-font-size: 26px; " + - "-fx-background-color: black; " + // - "-fx-text-fill: black; " + - "-fx-border-color: white; " + - "-fx-border-width: 1px;"); - - // Add the TextArea to the root Pane - root.getChildren().add(messageText); - - //Timer Label - timerLabel = new Label("Time: 00:00"); - timerLabel.setStyle("-fx-font-family: 'Arial'; -fx-font-size: 24px; -fx-text-fill: white;"); - timerLabel.setLayoutX((double) (800 - 100) / 2); // Center horizontally (approximate for 100px width) - timerLabel.setLayoutY(10); - root.getChildren().add(timerLabel); - - // Create and set the Scene - Scene scene = new Scene(root, 800, 600); - window.setScene(scene); // Set the scene to the primary stage - window.show(); // Show the primary stage - } - - public void createBackground(int bgNum, String bgFileName) { - bgPane[bgNum] = new Pane(); - bgPane[bgNum].setPrefSize(700, 350); - bgPane[bgNum].setLayoutX(50); - bgPane[bgNum].setLayoutY(50); - bgPane[bgNum].setVisible(false); - - // Background Image - Image bgImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(bgFileName))); - bgImageView[bgNum] = new ImageView(bgImage); - bgImageView[bgNum].setFitWidth(700); - bgImageView[bgNum].setFitHeight(350); - - bgPane[bgNum].getChildren().add(bgImageView[bgNum]); - ((Pane) window.getScene().getRoot()).getChildren().add(bgPane[bgNum]); - } - - public void createObject(int bgNum, int objx, int objy, int objWidth, int objHeight, String objFileName, - String choice1Name, String choice2Name, String choice3Name, String choice1Command, String choice2Command, String choice3Command) { - // Context Menu for Object - ContextMenu contextMenu = new ContextMenu(); - MenuItem choice1 = new MenuItem(choice1Name); - MenuItem choice2 = new MenuItem(choice2Name); - MenuItem choice3 = new MenuItem(choice3Name); - - choice1.setOnAction(e -> gm.aHandler.handleAction(choice1Command)); - choice2.setOnAction(e -> gm.aHandler.handleAction(choice2Command)); - choice3.setOnAction(e -> gm.aHandler.handleAction(choice3Command)); - - contextMenu.getItems().addAll(choice1, choice2, choice3); - - // Object Image - Image objectImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(objFileName))); - ImageView objectImageView = new ImageView(objectImage); - objectImageView.setFitWidth(objWidth); - objectImageView.setFitHeight(objHeight); - objectImageView.setLayoutX(objx); - objectImageView.setLayoutY(objy); - - objectImageView.setOnMousePressed(e -> { - if (e.getButton() == MouseButton.SECONDARY) { - contextMenu.show(objectImageView, e.getScreenX(), e.getScreenY()); - } - }); - - bgPane[bgNum].getChildren().add(objectImageView); - } -//To help objects appear and disappear when game is restarted - public ImageView createObjectAndReturn(int bgNum, int objx, int objy, int objWidth, int objHeight, String objFileName, - String choice1Name, String choice2Name, String choice3Name, String choice1Command, String choice2Command, String choice3Command) { - ContextMenu contextMenu = new ContextMenu(); - MenuItem choice1 = new MenuItem(choice1Name); - MenuItem choice2 = new MenuItem(choice2Name); - MenuItem choice3 = new MenuItem(choice3Name); - - choice1.setOnAction(e -> gm.aHandler.handleAction(choice1Command)); - choice2.setOnAction(e -> gm.aHandler.handleAction(choice2Command)); - choice3.setOnAction(e -> gm.aHandler.handleAction(choice3Command)); - - contextMenu.getItems().addAll(choice1, choice2, choice3); - - Image objectImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(objFileName))); - ImageView objectImageView = new ImageView(objectImage); - objectImageView.setFitWidth(objWidth); - objectImageView.setFitHeight(objHeight); - objectImageView.setLayoutX(objx); - objectImageView.setLayoutY(objy); - - objectImageView.setOnMousePressed(e -> { - if (e.getButton() == MouseButton.SECONDARY) { - contextMenu.show(objectImageView, e.getScreenX(), e.getScreenY()); - } - }); - - bgPane[bgNum].getChildren().add(objectImageView); - return objectImageView; // Return the created ImageView - } - - public void createArrowButton(int bgNum, int x, int y, int width, int height, String arrowFileName, String command) { - // Arrow Button Image - Image arrowImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(arrowFileName))); - Button arrowButton = new Button(); - arrowButton.setGraphic(new ImageView(arrowImage)); - arrowButton.setLayoutX(x); - arrowButton.setLayoutY(y); - arrowButton.setOnAction(e -> gm.aHandler.handleAction(command)); - bgPane[bgNum].getChildren().add(arrowButton); - } - public void createPlayerField() { - // Create a HBox to hold the life icons - HBox lifePanel = new HBox(); - lifePanel.setSpacing(10); // Space between icons - lifePanel.setLayoutX(50); // Set X position - lifePanel.setLayoutY(0); // Set Y position - - // Create a background rectangle for the life panel - Rectangle background = new Rectangle(300 , 50); - background.setLayoutX(50); - background.setLayoutY(0); - background.setFill(Color.BLACK); // Set background color to blue - - // Load the life icon image - Image lifeImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("heart.png"))); - - // Loop to create and add life icons to the lifePanel - for (int i = 0; i < 5; i++) { // 5 life icons - lifeLabels[i] = new ImageView(lifeImage); // Create a new ImageView for each icon - lifeLabels[i].setFitWidth(50); // Set width of each icon - lifeLabels[i].setFitHeight(50); // Set height of each icon - lifePanel.getChildren().add(lifeLabels[i]); - } - - HBox inventoryPanel = new HBox(); - inventoryPanel.setLayoutX(590); - inventoryPanel.setLayoutY(0); - inventoryPanel.setSpacing(10); - inventoryPanel.setPrefWidth(150); - inventoryPanel.setPrefHeight(50); - inventoryPanel.setStyle("-fx-background-color: black;"); - - // Initialize and assign flashlightLabel - Image flashlightImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("flashlightIcon.png"))); - flashlightLabel = new Label(); // Assign to flashlightLabel - flashlightLabel.setGraphic(new ImageView(flashlightImage)); - flashlightLabel.setVisible(false); // Hide initially - inventoryPanel.getChildren().add(flashlightLabel); - - // Initialize and assign pistolLabel - Image pistolImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("pistol.png"))); - pistolLabel = new Label(); // Assign to pistolLabel - pistolLabel.setGraphic(new ImageView(pistolImage)); - pistolLabel.setVisible(false); // Hide initially - inventoryPanel.getChildren().add(pistolLabel); - - // Initialize and assign ak47Label - Image ak47Image = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("ak47.png"))); - ak47Label = new Label(); // Assign to ak47Label - ak47Label.setGraphic(new ImageView(ak47Image)); - ak47Label.setVisible(false); // Hide initially - inventoryPanel.getChildren().add(ak47Label); - - Pane root = (Pane) window.getScene().getRoot(); - root.getChildren().addAll(background, lifePanel, inventoryPanel); - } - - public void createGameOverField() { - - // Title Label - titleLabel = new Label(""); - titleLabel.setLayoutX(200); - titleLabel.setLayoutY(150); - titleLabel.setTextFill(Color.RED); - titleLabel.setStyle("-fx-font-family: 'Times New Roman'; -fx-font-size: 70px;"); - titleLabel.setVisible(false); - - // Restart Button - restartButton = new Button("Restart"); - restartButton.setLayoutX(340); - restartButton.setLayoutY(320); - restartButton.setStyle("-fx-background-color: transparent; -fx-text-fill: white; -fx-border-color: transparent;"); - restartButton.setFocusTraversable(false); - restartButton.setOnAction(e -> gm.aHandler.handleAction("restart")); - restartButton.setVisible(false); - - // Add to root - Pane root = (Pane) window.getScene().getRoot(); - titleLabel.layoutXProperty().bind(root.widthProperty().subtract(titleLabel.widthProperty()).divide(2)); - titleLabel.layoutYProperty().bind(root.heightProperty().subtract(titleLabel.heightProperty()).divide(2).subtract(50)); // Adjust offset as needed - restartButton.layoutXProperty().bind(root.widthProperty().subtract(restartButton.widthProperty()).divide(2)); - restartButton.layoutYProperty().bind(root.heightProperty().subtract(restartButton.heightProperty()).divide(2).add(50)); // Adjust offset as needed - root.getChildren().addAll(titleLabel, restartButton); - } - - public void displayLeaderboard(List leaderboard) { - StringBuilder leaderboardText = new StringBuilder("Fastest Times:\n"); - for (int i = 0; i < leaderboard.size(); i++) { - leaderboardText.append((i + 1)).append(". ").append(leaderboard.get(i)).append("\n"); - } - - // Display the leaderboard in a dialog or a text area - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Leaderboard"); - alert.setHeaderText("Top 10 Fastest Times"); - alert.setContentText(leaderboardText.toString()); - alert.showAndWait(); - } - - public void generateScene() { - // SCENE 1 - createBackground(1, "bedroom.png"); - createObject(1, 100, 100, 200, 250, "jeramiah.png", - "Look", "Talk", "Rest", - "lookJeramiah", "talkJeramiah", "restJeramiah"); - createObject(1, 500, 230, 50, 50, "flashlight.png", - "Look", "Grab", "Rest", - "lookFlashlight", "grabFlashlight", "restFlashlight"); - createArrowButton(1, 650, 150, 50, 50, "rightArrow50x50.png", "goScene2"); - // SCENE 2 - createBackground(2, "driveway700x350.png"); - createObject(2, 350, 230, 200, 151, "honda200x151.png", - "Search Inside", "Search hood", "Rest", - "search1Honda", "search2Honda", "restHonda"); - // SCENE 3 - createBackground(3,"woods.png"); - gm.hondaur.addToScene(); - gm.engineStealerMonster.addToScene3(); - createArrowButton(3, 650, 150, 50, 50, "rightArrow50x50.png", "goScene4"); - // SCENE 4 - createBackground(4,"campfire.png"); - createObject(4, 100,100, 200,250,"denzel.png" - , "Look", "Talk","Rest","lookDenzel", - "talkDenzel","restDenzel"); - createArrowButton(4, 650, 150, 50, 50, "rightArrow50x50.png", "goScene5"); - // SCENE 5 - createBackground(5,"woods2.png"); - createObject(5, 250,150, 200,200,"hondaTrunk.png" - , "Look", "Talk","Kill","lookHondaTrunk", - "talkHondaTrunk","killHondaTrunk"); - createArrowButton(5, 650, 150, 50, 50, "rightArrow50x50.png", "goScene6"); - gm.theodoor.addToScene(); - gm.wheeler.addToScene(); - // SCENE 6 - createBackground(6, "casinoEntrance.png"); - createObject(6, 80, 140, 200, 250, "brandon.png", - "Look", "Talk", "Rest", - "lookBrandon", "talkBrandon", "restBrandon"); - createArrowButton(6, 650, 150, 50, 50, "rightArrow50x50.png", "goScene7"); - // SCENE 7 - createBackground(7, "casino.png"); - createObject(7, 200, 130, 200, 224, "julian.png", - "Look", "Talk", "Hold", - "lookJulian", "talkJulian", "holdJulian"); - createObject(7, 350, 30, 300, 354, "slotMachine.png", - "Look", "Talk", "Spin", - "lookSlotMachine", "talkSlotMachine", "spinSlotMachine"); - createObject(7, 80, 50, 225, 300, "adrian.png", - "Look", "Talk", "Thank", - "lookAdrian", "talkAdrian", "thankAdrian"); - createArrowButton(7, 650, 150, 50, 50, "rightArrow50x50.png", "goScene8"); - // SCENE 8 - createBackground(8, "cityStreet.png"); - gm.engineStealerMonster.addToScene8(); - createArrowButton(8, 650, 150, 50, 50, "rightArrow50x50.png", "goLeaderboard"); - // LEADERBOARD SCREEN - createBackground(9,"bedroom.png"); - } +package main; + +/** + * This class handles all the graphics + */ + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.MenuItem; +import javafx.scene.control.TextArea; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseButton; +import javafx.scene.layout.*; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Font; +import javafx.scene.text.Text; +import javafx.stage.Stage; +import javafx.util.Duration; + +import java.util.List; +import java.util.Objects; + +public class UI { + GameManager gm; + Stage window; + public TextArea messageText; + public Pane[] bgPane = new Pane[11]; + ImageView[] bgImageView = new ImageView[11]; + public Label timerLabel; + + // PLAYER UI + public Label flashlightLabel, pistolLabel, ak47Label; + ImageView[] lifeLabels = new ImageView[5]; + + //GAME OVER UI + public Label titleLabel; + public Button restartButton; + + public UI(GameManager gm) { + this.gm = gm; + } + + public void createTitleScreen(Stage primaryStage) { + // Window setup + this.window = primaryStage; + window.setTitle("Engine Of Desolation"); + window.setWidth(800); + window.setHeight(600); + + // Create the root pane for the title screen + Pane root = new Pane(); + root.setStyle("-fx-background-color: black;"); + + // Background Image + ImageView backgroundImage = new ImageView( + new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("titleScreen.png"))) + ); + backgroundImage.setFitWidth(800); + backgroundImage.setFitHeight(600); + backgroundImage.setPreserveRatio(false); + + // Floating Text + Text floatingText = new Text(80, 200, "Engine Of Desolation"); + floatingText.setFont(Font.font("Times New Roman", 70)); + floatingText.setFill(Color.DARKRED); + + Timeline timeline = new Timeline( + new KeyFrame(Duration.ZERO, new KeyValue(floatingText.translateYProperty(), 0)), + new KeyFrame(Duration.seconds(2), new KeyValue(floatingText.translateYProperty(), -50)) + ); + timeline.setAutoReverse(true); + timeline.setCycleCount(Timeline.INDEFINITE); + timeline.play(); + + + //START BUTTON + Button startButton = new Button("Start"); + startButton.setStyle("-fx-font-family: 'Arial'; -fx-font-size: 24px; -fx-background-color: white;"); + startButton.setLayoutX((800 - 150) / 2); // Center horizontally (approximate for button width) + startButton.setLayoutY(400); // Center vertically (approximate for button height) + + // Start button functionality + startButton.setOnAction(e -> { + // Transition to the main game screen + createMainField(window); + createPlayerField(); + createGameOverField(); + gm.player.setPlayerDefaultStatus(); + generateScene(); + gm.sChanger.showScene1(); + gm.startGameTimer(); + + }); + + // Add components to root + root.getChildren().addAll(backgroundImage, floatingText, startButton); + + // Create and set the scene + Scene titleScene = new Scene(root, 800, 600); + window.setScene(titleScene); + window.show(); + } + + public void createMainField(Stage primaryStage) { + this.window = primaryStage; + window.setTitle("Engine Of Desolation"); + window.setWidth(800); + window.setHeight(600); + + // Main Pane with black background + Pane root = new Pane(); + root.setStyle("-fx-background-color: black;"); + + // Create main TextArea + messageText = new TextArea("THIS IS SAMPLE TEXT"); + messageText.setPrefSize(700, 150); + messageText.setLayoutX(50); + messageText.setLayoutY(410); + messageText.setEditable(false); + messageText.setWrapText(true); + + // Set styles for the TextArea + messageText.setStyle("-fx-font-family: 'Arial'; " + + "-fx-font-size: 26px; " + + "-fx-background-color: black; " + // + "-fx-text-fill: black; " + + "-fx-border-color: white; " + + "-fx-border-width: 1px;"); + + // Add the TextArea to the root Pane + root.getChildren().add(messageText); + + //Timer Label + timerLabel = new Label("Time: 00:00"); + timerLabel.setStyle("-fx-font-family: 'Arial'; -fx-font-size: 24px; -fx-text-fill: white;"); + timerLabel.setLayoutX((double) (800 - 100) / 2); // Center horizontally (approximate for 100px width) + timerLabel.setLayoutY(10); + root.getChildren().add(timerLabel); + + // Create and set the Scene + Scene scene = new Scene(root, 800, 600); + window.setScene(scene); // Set the scene to the primary stage + window.show(); // Show the primary stage + } + + public void createBackground(int bgNum, String bgFileName) { + bgPane[bgNum] = new Pane(); + bgPane[bgNum].setPrefSize(700, 350); + bgPane[bgNum].setLayoutX(50); + bgPane[bgNum].setLayoutY(50); + bgPane[bgNum].setVisible(false); + + // Background Image + Image bgImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(bgFileName))); + bgImageView[bgNum] = new ImageView(bgImage); + bgImageView[bgNum].setFitWidth(700); + bgImageView[bgNum].setFitHeight(350); + + bgPane[bgNum].getChildren().add(bgImageView[bgNum]); + ((Pane) window.getScene().getRoot()).getChildren().add(bgPane[bgNum]); + } + + public void createObject(int bgNum, int objx, int objy, int objWidth, int objHeight, String objFileName, + String choice1Name, String choice2Name, String choice3Name, String choice1Command, String choice2Command, String choice3Command) { + // Context Menu for Object + ContextMenu contextMenu = new ContextMenu(); + MenuItem choice1 = new MenuItem(choice1Name); + MenuItem choice2 = new MenuItem(choice2Name); + MenuItem choice3 = new MenuItem(choice3Name); + + choice1.setOnAction(e -> gm.aHandler.handleAction(choice1Command)); + choice2.setOnAction(e -> gm.aHandler.handleAction(choice2Command)); + choice3.setOnAction(e -> gm.aHandler.handleAction(choice3Command)); + + contextMenu.getItems().addAll(choice1, choice2, choice3); + + // Object Image + Image objectImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(objFileName))); + ImageView objectImageView = new ImageView(objectImage); + objectImageView.setFitWidth(objWidth); + objectImageView.setFitHeight(objHeight); + objectImageView.setLayoutX(objx); + objectImageView.setLayoutY(objy); + + objectImageView.setOnMousePressed(e -> { + if (e.getButton() == MouseButton.SECONDARY) { + contextMenu.show(objectImageView, e.getScreenX(), e.getScreenY()); + } + }); + + bgPane[bgNum].getChildren().add(objectImageView); + } +//To help objects appear and disappear when game is restarted + public ImageView createObjectAndReturn(int bgNum, int objx, int objy, int objWidth, int objHeight, String objFileName, + String choice1Name, String choice2Name, String choice3Name, String choice1Command, String choice2Command, String choice3Command) { + ContextMenu contextMenu = new ContextMenu(); + MenuItem choice1 = new MenuItem(choice1Name); + MenuItem choice2 = new MenuItem(choice2Name); + MenuItem choice3 = new MenuItem(choice3Name); + + choice1.setOnAction(e -> gm.aHandler.handleAction(choice1Command)); + choice2.setOnAction(e -> gm.aHandler.handleAction(choice2Command)); + choice3.setOnAction(e -> gm.aHandler.handleAction(choice3Command)); + + contextMenu.getItems().addAll(choice1, choice2, choice3); + + Image objectImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(objFileName))); + ImageView objectImageView = new ImageView(objectImage); + objectImageView.setFitWidth(objWidth); + objectImageView.setFitHeight(objHeight); + objectImageView.setLayoutX(objx); + objectImageView.setLayoutY(objy); + + objectImageView.setOnMousePressed(e -> { + if (e.getButton() == MouseButton.SECONDARY) { + contextMenu.show(objectImageView, e.getScreenX(), e.getScreenY()); + } + }); + + bgPane[bgNum].getChildren().add(objectImageView); + return objectImageView; // Return the created ImageView + } + + public void createArrowButton(int bgNum, int x, int y, int width, int height, String arrowFileName, String command) { + // Arrow Button Image + Image arrowImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(arrowFileName))); + Button arrowButton = new Button(); + arrowButton.setGraphic(new ImageView(arrowImage)); + arrowButton.setLayoutX(x); + arrowButton.setLayoutY(y); + arrowButton.setOnAction(e -> gm.aHandler.handleAction(command)); + bgPane[bgNum].getChildren().add(arrowButton); + } + public void createPlayerField() { + // Create a HBox to hold the life icons + HBox lifePanel = new HBox(); + lifePanel.setSpacing(10); // Space between icons + lifePanel.setLayoutX(50); // Set X position + lifePanel.setLayoutY(0); // Set Y position + + // Create a background rectangle for the life panel + Rectangle background = new Rectangle(300 , 50); + background.setLayoutX(50); + background.setLayoutY(0); + background.setFill(Color.BLACK); // Set background color to blue + + // Load the life icon image + Image lifeImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("heart.png"))); + + // Loop to create and add life icons to the lifePanel + for (int i = 0; i < 5; i++) { // 5 life icons + lifeLabels[i] = new ImageView(lifeImage); // Create a new ImageView for each icon + lifeLabels[i].setFitWidth(50); // Set width of each icon + lifeLabels[i].setFitHeight(50); // Set height of each icon + lifePanel.getChildren().add(lifeLabels[i]); + } + + HBox inventoryPanel = new HBox(); + inventoryPanel.setLayoutX(590); + inventoryPanel.setLayoutY(0); + inventoryPanel.setSpacing(10); + inventoryPanel.setPrefWidth(150); + inventoryPanel.setPrefHeight(50); + inventoryPanel.setStyle("-fx-background-color: black;"); + + // Initialize and assign flashlightLabel + Image flashlightImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("flashlightIcon.png"))); + flashlightLabel = new Label(); // Assign to flashlightLabel + flashlightLabel.setGraphic(new ImageView(flashlightImage)); + flashlightLabel.setVisible(false); // Hide initially + inventoryPanel.getChildren().add(flashlightLabel); + + // Initialize and assign pistolLabel + Image pistolImage = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("pistol.png"))); + pistolLabel = new Label(); // Assign to pistolLabel + pistolLabel.setGraphic(new ImageView(pistolImage)); + pistolLabel.setVisible(false); // Hide initially + inventoryPanel.getChildren().add(pistolLabel); + + // Initialize and assign ak47Label + Image ak47Image = new Image(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream("ak47.png"))); + ak47Label = new Label(); // Assign to ak47Label + ak47Label.setGraphic(new ImageView(ak47Image)); + ak47Label.setVisible(false); // Hide initially + inventoryPanel.getChildren().add(ak47Label); + + Pane root = (Pane) window.getScene().getRoot(); + root.getChildren().addAll(background, lifePanel, inventoryPanel); + } + + public void createGameOverField() { + + // Title Label + titleLabel = new Label(""); + titleLabel.setLayoutX(200); + titleLabel.setLayoutY(150); + titleLabel.setTextFill(Color.RED); + titleLabel.setStyle("-fx-font-family: 'Times New Roman'; -fx-font-size: 70px;"); + titleLabel.setVisible(false); + + // Restart Button + restartButton = new Button("Restart"); + restartButton.setLayoutX(340); + restartButton.setLayoutY(320); + restartButton.setStyle("-fx-background-color: transparent; -fx-text-fill: white; -fx-border-color: transparent;"); + restartButton.setFocusTraversable(false); + restartButton.setOnAction(e -> gm.aHandler.handleAction("restart")); + restartButton.setVisible(false); + + // Add to root + Pane root = (Pane) window.getScene().getRoot(); + titleLabel.layoutXProperty().bind(root.widthProperty().subtract(titleLabel.widthProperty()).divide(2)); + titleLabel.layoutYProperty().bind(root.heightProperty().subtract(titleLabel.heightProperty()).divide(2).subtract(50)); // Adjust offset as needed + restartButton.layoutXProperty().bind(root.widthProperty().subtract(restartButton.widthProperty()).divide(2)); + restartButton.layoutYProperty().bind(root.heightProperty().subtract(restartButton.heightProperty()).divide(2).add(50)); // Adjust offset as needed + root.getChildren().addAll(titleLabel, restartButton); + } + + public void displayLeaderboard(List leaderboard) { + StringBuilder leaderboardText = new StringBuilder("Fastest Times:\n"); + for (int i = 0; i < leaderboard.size(); i++) { + leaderboardText.append((i + 1)).append(". ").append(leaderboard.get(i)).append("\n"); + } + + // Display the leaderboard in a dialog or a text area + Alert alert = new Alert(Alert.AlertType.INFORMATION); + alert.setTitle("Leaderboard"); + alert.setHeaderText("Top 10 Fastest Times"); + alert.setContentText(leaderboardText.toString()); + alert.showAndWait(); + } + + public void generateScene() { + // SCENE 1 + createBackground(1, "bedroom.png"); + createObject(1, 100, 100, 200, 250, "jeramiah.png", + "Look", "Talk", "Rest", + "lookJeramiah", "talkJeramiah", "restJeramiah"); + createObject(1, 500, 230, 50, 50, "flashlight.png", + "Look", "Grab", "Rest", + "lookFlashlight", "grabFlashlight", "restFlashlight"); + createArrowButton(1, 650, 150, 50, 50, "rightArrow50x50.png", "goScene2"); + // SCENE 2 + createBackground(2, "driveway700x350.png"); + createObject(2, 350, 230, 200, 151, "honda200x151.png", + "Search Inside", "Search hood", "Rest", + "search1Honda", "search2Honda", "restHonda"); + // SCENE 3 + createBackground(3,"woods.png"); + gm.hondaur.addToScene(); + gm.engineStealerMonster.addToScene3(); + createArrowButton(3, 650, 150, 50, 50, "rightArrow50x50.png", "goScene4"); + // SCENE 4 + createBackground(4,"campfire.png"); + createObject(4, 100,100, 200,250,"denzel.png" + , "Look", "Talk","Rest","lookDenzel", + "talkDenzel","restDenzel"); + createArrowButton(4, 650, 150, 50, 50, "rightArrow50x50.png", "goScene5"); + // SCENE 5 + createBackground(5,"woods2.png"); + createObject(5, 250,150, 200,200,"hondaTrunk.png" + , "Look", "Talk","Kill","lookHondaTrunk", + "talkHondaTrunk","killHondaTrunk"); + createArrowButton(5, 650, 150, 50, 50, "rightArrow50x50.png", "goScene6"); + gm.theodoor.addToScene(); + gm.wheeler.addToScene(); + // SCENE 6 + createBackground(6, "casinoEntrance.png"); + createObject(6, 80, 140, 200, 250, "brandon.png", + "Look", "Talk", "Rest", + "lookBrandon", "talkBrandon", "restBrandon"); + createArrowButton(6, 650, 150, 50, 50, "rightArrow50x50.png", "goScene7"); + // SCENE 7 + createBackground(7, "casino.png"); + createObject(7, 200, 130, 200, 224, "julian.png", + "Look", "Talk", "Hold", + "lookJulian", "talkJulian", "holdJulian"); + createObject(7, 350, 30, 300, 354, "slotMachine.png", + "Look", "Talk", "Spin", + "lookSlotMachine", "talkSlotMachine", "spinSlotMachine"); + createObject(7, 80, 50, 225, 300, "adrian.png", + "Look", "Talk", "Thank", + "lookAdrian", "talkAdrian", "thankAdrian"); + createArrowButton(7, 650, 150, 50, 50, "rightArrow50x50.png", "goScene8"); + // SCENE 8 + createBackground(8, "cityStreet.png"); + gm.engineStealerMonster.addToScene8(); + createArrowButton(8, 650, 150, 50, 50, "rightArrow50x50.png", "goLeaderboard"); + // LEADERBOARD SCREEN + createBackground(9,"bedroom.png"); + } } \ No newline at end of file diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index de39c27..9f2fedc 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,22 +1,22 @@ -module EngineOfDesolation { - requires javafx.controls; - requires javafx.graphics; - requires javafx.fxml; - requires javafx.web; - requires javafx.media; - requires java.desktop; - - requires google.api.services.sheets.v4.rev612; - requires google.http.client; - requires google.http.client.jackson2; - requires google.api.client; - - requires org.testfx.junit5; - requires org.testfx; - //requires junit; - - //opens com.yourpackage to javafx.graphics, javafx.fxml, org.testfx; - - exports main to javafx.graphics; - +module EngineOfDesolation { + requires javafx.controls; + requires javafx.graphics; + requires javafx.fxml; + requires javafx.web; + requires javafx.media; + requires java.desktop; + + requires google.api.services.sheets.v4.rev612; + requires google.http.client; + requires google.http.client.jackson2; + requires google.api.client; + + requires org.testfx.junit5; + requires org.testfx; + //requires junit; + + //opens com.yourpackage to javafx.graphics, javafx.fxml, org.testfx; + + exports main to javafx.graphics; + } \ No newline at end of file diff --git a/src/main/java/monsters/EngineStealerMonster.java b/src/main/java/monsters/EngineStealerMonster.java index 7ae0240..430060a 100644 --- a/src/main/java/monsters/EngineStealerMonster.java +++ b/src/main/java/monsters/EngineStealerMonster.java @@ -1,142 +1,148 @@ -package monsters; - -import javafx.scene.image.ImageView; -import main.GameManager; - -public class EngineStealerMonster extends Monster { - - private ImageView blood; - - public EngineStealerMonster(GameManager gm) { - super(gm,10, 10,"Engine Stealer Monster",3); - } - public void addToScene3() { - - gm.ui.createObject(2, 600,250,50,38,"sponge.png", - "Look","Talk", "Follow", "lookSponge", - "talkSponge", "followSponge"); - } - public void addToScene8() { - gm.ui.createObject(8,200,100,350, 263,"spongeFinalBoss.png", - "Talk","Attack","Let Live","talkSponge2","attackSponge", "letLiveSponge"); - } - - public void talkSponge2(){ - gm.ui.messageText.setText("So you've finally caught up to me. Put the gun down and I'll give your engine back."); - gm.playSE(gm.monsterRoar); - } - public void attackSponge(){ - if(gm.player.hasAk47 == 1 && gm.player.hasPistol ==0){ - currentLife -= 5; - gm.player.playerLife -= 2; - gm.player.updatePlayerStatus(); - gm.ui.messageText.setText("*You shot it with your AK47*.\n (The monster loses 3 lives)"); - gm.playSE(gm.ak47shots); - gm.playSE(gm.monsterRoar); - } - if(gm.player.hasPistol == 1 && gm.player.hasAk47 == 0){ - currentLife -= 2; - gm.player.playerLife -= 2; - gm.player.updatePlayerStatus(); - gm.ui.messageText.setText("*You shot it with your pistol*\n (The monster loses 2 lives)."); - gm.playSE(gm.pistolShot); - gm.playSE(gm.monsterRoar); - } - if(gm.player.hasAk47 == 1 && gm.player.hasPistol == 1){ - currentLife -= 5; - gm.player.playerLife -= 2; - gm.player.updatePlayerStatus(); - gm.ui.messageText.setText("*You shot it with your AK47*.\n (The monster loses 3 lives)"); - gm.playSE(gm.ak47shots); - gm.playSE(gm.monsterRoar); - } - else { - currentLife -= 1; - gm.player.playerLife -= 2; - gm.player.updatePlayerStatus(); - gm.ui.messageText.setText("*You attack it with your fists*\n (The monster loses 1 life)."); - gm.playSE(gm.monsterRoar); - } - - if(gm.player.playerLife <=0){ - gm.sChanger.showGameOverScreen(8); - gm.ui.messageText.setText("You baka! You tested your luck!"); - } - else{ - gm.ui.messageText.setText("You lost 2 lives! Be careful!"); - gm.playSE(gm.pistolShot); - gm.playSE(gm.monsterHit); - - - } - - if(currentLife == 0){ - if (blood == null) { - blood = gm.ui.createObjectAndReturn(8, 200, 100, 200, 233, "blood.png", "", "", "", "", "", ""); - } - - // Make them visible - blood.setVisible(true); - gm.stopGameTimer(); - - }else if (currentLife > 0) { - // Hide blood while the monster is still alive - if (blood != null) blood.setVisible(false); - } - } - public void letLiveSponge() { - gm.playSE(gm.monsterRoar); - } - - @Override - public void reset() { - currentLife = maxLife; // Reset life - - if (blood != null) { - blood.setVisible(false); - } - } - - @Override - public void lookHondaur() {} - @Override - public void talkHondaur() {} - @Override - public void attackHondaur() {} - - @Override - public void lookSponge() { - gm.ui.messageText.setText("An unknown creature is lurking"); - } - - @Override - public void talkSponge() { - gm.ui.messageText.setText("(It roars and runs way with what you make out to be your engine)"); - gm.playSE(gm.monsterRoar); - } - - @Override - public void followSponge() { - gm.ui.messageText.setText("(You follow the creature into the woods)"); - gm.sChanger.showScene3(); - } - @Override - public void lookAnthony() {} - @Override - public void talkAnthony() {} - @Override - public void touchAnthony() {} - @Override - public void lookTheodoor() {} - @Override - public void talkTheodoor() {} - @Override - public void attackTheodoor() {} - @Override - public void lookWheeler() {} - @Override - public void talkWheeler() {} - @Override - public void attackWheeler() {} - -} +package monsters; + +import javafx.scene.image.ImageView; +import main.GameManager; + +public class EngineStealerMonster extends Monster { +/** +This sets the engine stealer monster, its interactions + */ +//should include javadoc for all of the game + + private ImageView blood; + + public EngineStealerMonster(GameManager gm) { + super(gm,10, 10,"Engine Stealer Monster",3); + } + public void addToScene3() { + + gm.ui.createObject(2, 600,250,50,38,"sponge.png", + "Look","Talk", "Follow", "lookSponge", + "talkSponge", "followSponge"); + } + public void addToScene8() { + gm.ui.createObject(8,200,100,350, 263,"spongeFinalBoss.png", + "Talk","Attack","Let Live","talkSponge2","attackSponge", "letLiveSponge"); + } + + public void talkSponge2(){ + gm.ui.messageText.setText("So you've finally caught up to me. Put the gun down and I'll give your engine back."); + gm.playSE(gm.monsterRoar); + } + public void attackSponge(){ + if(gm.player.hasAk47 == 1 && gm.player.hasPistol ==0){ + currentLife -= 5; + gm.player.playerLife -= 2; + gm.player.updatePlayerStatus(); + gm.ui.messageText.setText("*You shot it with your AK47*.\n (The monster loses 3 lives)"); + gm.playSE(gm.ak47shots); + gm.playSE(gm.monsterRoar); + } + if(gm.player.hasPistol == 1 && gm.player.hasAk47 == 0){ + currentLife -= 2; + gm.player.playerLife -= 2; + gm.player.updatePlayerStatus(); + gm.ui.messageText.setText("*You shot it with your pistol*\n (The monster loses 2 lives)."); + gm.playSE(gm.pistolShot); + gm.playSE(gm.monsterRoar); + } + if(gm.player.hasAk47 == 1 && gm.player.hasPistol == 1){ + currentLife -= 5; + gm.player.playerLife -= 2; + gm.player.updatePlayerStatus(); + gm.ui.messageText.setText("*You shot it with your AK47*.\n (The monster loses 3 lives)"); + gm.playSE(gm.ak47shots); + gm.playSE(gm.monsterRoar); + } + else { + currentLife -= 1; + gm.player.playerLife -= 2; + gm.player.updatePlayerStatus(); + gm.ui.messageText.setText("*You attack it with your fists*\n (The monster loses 1 life)."); + gm.playSE(gm.monsterRoar); + } + + if(gm.player.playerLife <=0){ + gm.sChanger.showGameOverScreen(8); + gm.ui.messageText.setText("You baka! You tested your luck!"); + } + else{ + gm.ui.messageText.setText("You lost 2 lives! Be careful!"); + gm.playSE(gm.pistolShot); + gm.playSE(gm.monsterHit); + + + } + + if(currentLife == 0){ + if (blood == null) { + blood = gm.ui.createObjectAndReturn(8, 200, 100, 200, 233, "blood.png", "", "", "", "", "", ""); + } + + // Make them visible + blood.setVisible(true); + gm.stopGameTimer(); + + }else if (currentLife > 0) { + // Hide blood while the monster is still alive + if (blood != null) blood.setVisible(false); + } + } + //added dialogue to help make the battle more clear... I assume that's what was happening + public void letLiveSponge() { + gm.ui.messageText.setText("Mercy was never an option."); + gm.playSE(gm.monsterRoar); + } + + @Override + public void reset() { + currentLife = maxLife; // Reset life + + if (blood != null) { + blood.setVisible(false); + } + } + + @Override + public void lookHondaur() {} + @Override + public void talkHondaur() {} + @Override + public void attackHondaur() {} + + @Override + public void lookSponge() { + gm.ui.messageText.setText("An unknown creature is lurking"); + } + + @Override + public void talkSponge() { + gm.ui.messageText.setText("(It roars and runs way with what you make out to be your engine)"); + gm.playSE(gm.monsterRoar); + } + + @Override + public void followSponge() { + gm.ui.messageText.setText("(You follow the creature into the woods)"); + gm.sChanger.showScene3(); + } + @Override + public void lookAnthony() {} + @Override + public void talkAnthony() {} + @Override + public void touchAnthony() {} + @Override + public void lookTheodoor() {} + @Override + public void talkTheodoor() {} + @Override + public void attackTheodoor() {} + @Override + public void lookWheeler() {} + @Override + public void talkWheeler() {} + @Override + public void attackWheeler() {} + +} diff --git a/src/main/java/monsters/Hondaur.java b/src/main/java/monsters/Hondaur.java index 84afd64..392b0bc 100644 --- a/src/main/java/monsters/Hondaur.java +++ b/src/main/java/monsters/Hondaur.java @@ -1,125 +1,125 @@ -package monsters; - -import javafx.scene.image.ImageView; -import main.GameManager; - -public class Hondaur extends Monster { - - private ImageView anthony; // Reference for anthony - private ImageView blood; // Reference for blood - - public Hondaur(GameManager gm) { - super(gm,4,4, "Hondaur", 1); - } - public void addToScene() { - - gm.ui.createObject(3, 300,100,200,283,"Hondaur_2.png", - "Look","Talk", "Attack", "lookHondaur", - "talkHondaur", "attackHondaur"); - } - - @Override - public void lookHondaur() { - if(currentLife >0) { - gm.ui.messageText.setText("You see a fearsome weakened " + monster+ " ready to rev its engine."); - gm.playSE(gm.monsterRoar); - } - else { - gm.ui.messageText.setText("The "+ monster+ " is dead"); - gm.playSE(gm.cannotSound); - } - } - @Override - public void talkHondaur() { - if(currentLife >0) { - gm.ui.messageText.setText("The "+monster+" growls at you, its engine roaring."); - gm.playSE(gm.monsterRoar); - } - else { - gm.ui.messageText.setText("The "+monster+" is already dead"); - gm.playSE(gm.cannotSound); - } - } - @Override - public void attackHondaur() { - - currentLife--; - gm.player.playerLife -=1; - gm.player.updatePlayerStatus(); - gm.ui.messageText.setText("You attack the "+monster+" with your fists! (Its health decreases)"); - if(gm.player.playerLife <=0){ - gm.sChanger.showGameOverScreen(3); - gm.ui.messageText.setText("You baka! You tested your luck!"); - } - else{ - gm.ui.messageText.setText("You lost a life! Be careful!"); - gm.playSE(gm.monsterHit); - - } - - if(currentLife == 0){ - if (blood == null) { - blood = gm.ui.createObjectAndReturn(3, 340, 100, 200, 233, "blood.png", "", "", "", "", "", ""); - } - if (anthony == null) { - anthony = gm.ui.createObjectAndReturn(3, 100, 100, 200, 250, "anthony.png", - "Look", "Talk", "Touch", "lookAnthony", "talkAnthony", "touchAnthony"); - } - - // Make them visible - blood.setVisible(true); - anthony.setVisible(true); - - gm.ui.messageText.setText("The " + monster+ " has been defeated!"); - }else if (currentLife > 0) { - // Hide anthony and blood while the monster is still alive - if (anthony != null) anthony.setVisible(false); - if (blood != null) blood.setVisible(false); - } - } - - @Override - public void reset() { - currentLife = maxLife; // Reset Hondaur's life - - if (anthony != null) { - anthony.setVisible(false); - } - if (blood != null) { - blood.setVisible(false); - } - } - - @Override - public void lookAnthony() { - gm.ui.messageText.setText("A gorgeous short king appears out of no where!"); - } - - @Override - public void talkAnthony() { - gm.ui.messageText.setText("Yoooo did you kill THE "+monster+"?? My clan has been hunting it down for years!"); - } - @Override - public void touchAnthony() { - gm.ui.messageText.setText("*You grasp his cheek. He sheds a tear* My boy Denzel should be up ahead!"); - } - - @Override - public void lookTheodoor() {} - @Override - public void talkTheodoor() {} - @Override - public void attackTheodoor() {} - @Override - public void lookWheeler() {} - @Override - public void talkWheeler() {} - @Override - public void attackWheeler() {} - @Override - public void lookSponge() {} - @Override - public void talkSponge() {} - @Override public void followSponge() {} - -} +package monsters; + +import javafx.scene.image.ImageView; +import main.GameManager; + +public class Hondaur extends Monster { + + private ImageView anthony; // Reference for anthony + private ImageView blood; // Reference for blood + + public Hondaur(GameManager gm) { + super(gm,4,4, "Hondaur", 1); + } + public void addToScene() { + + gm.ui.createObject(3, 300,100,200,283,"Hondaur_2.png", + "Look","Talk", "Attack", "lookHondaur", + "talkHondaur", "attackHondaur"); + } + + @Override + public void lookHondaur() { + if(currentLife >0) { + gm.ui.messageText.setText("You see a fearsome weakened " + monster+ " ready to rev its engine."); + gm.playSE(gm.monsterRoar); + } + else { + gm.ui.messageText.setText("The "+ monster+ " is dead"); + gm.playSE(gm.cannotSound); + } + } + @Override + public void talkHondaur() { + if(currentLife >0) { + gm.ui.messageText.setText("The "+monster+" growls at you, its engine roaring."); + gm.playSE(gm.monsterRoar); + } + else { + gm.ui.messageText.setText("The "+monster+" is already dead"); + gm.playSE(gm.cannotSound); + } + } + @Override + public void attackHondaur() { + + currentLife--; + gm.player.playerLife -=1; + gm.player.updatePlayerStatus(); + gm.ui.messageText.setText("You attack the "+monster+" with your fists! (Its health decreases)"); + if(gm.player.playerLife <=0){ + gm.sChanger.showGameOverScreen(3); + gm.ui.messageText.setText("You baka! You tested your luck!"); + } + else{ + gm.ui.messageText.setText("You lost a life! Be careful!"); + gm.playSE(gm.monsterHit); + + } + + if(currentLife == 0){ + if (blood == null) { + blood = gm.ui.createObjectAndReturn(3, 340, 100, 200, 233, "blood.png", "", "", "", "", "", ""); + } + if (anthony == null) { + anthony = gm.ui.createObjectAndReturn(3, 100, 100, 200, 250, "anthony.png", + "Look", "Talk", "Touch", "lookAnthony", "talkAnthony", "touchAnthony"); + } + + // Make them visible + blood.setVisible(true); + anthony.setVisible(true); + + gm.ui.messageText.setText("The " + monster+ " has been defeated!"); + }else if (currentLife > 0) { + // Hide anthony and blood while the monster is still alive + if (anthony != null) anthony.setVisible(false); + if (blood != null) blood.setVisible(false); + } + } + + @Override + public void reset() { + currentLife = maxLife; // Reset Hondaur's life + + if (anthony != null) { + anthony.setVisible(false); + } + if (blood != null) { + blood.setVisible(false); + } + } + + @Override + public void lookAnthony() { + gm.ui.messageText.setText("A gorgeous short king appears out of no where!"); + } + + @Override + public void talkAnthony() { + gm.ui.messageText.setText("Yoooo did you kill THE "+monster+"?? My clan has been hunting it down for years!"); + } + @Override + public void touchAnthony() { + gm.ui.messageText.setText("*You grasp his cheek. He sheds a tear* My boy Denzel should be up ahead!"); + } + + @Override + public void lookTheodoor() {} + @Override + public void talkTheodoor() {} + @Override + public void attackTheodoor() {} + @Override + public void lookWheeler() {} + @Override + public void talkWheeler() {} + @Override + public void attackWheeler() {} + @Override + public void lookSponge() {} + @Override + public void talkSponge() {} + @Override public void followSponge() {} + +} diff --git a/src/main/java/monsters/Monster.java b/src/main/java/monsters/Monster.java index caa7cc4..ec77421 100644 --- a/src/main/java/monsters/Monster.java +++ b/src/main/java/monsters/Monster.java @@ -1,41 +1,41 @@ -package monsters; - -import main.GameManager; - -public abstract class Monster { - - protected GameManager gm; - public int currentLife; - protected int maxLife; - protected String monster; - protected int attackDamage; - - public Monster(GameManager gm,int currentLife,int maxLife, String monster, int attackDamage) { - this.gm = gm; - this.currentLife = currentLife; - this.maxLife = maxLife; - this.attackDamage = attackDamage; - this.monster = monster; - } - - public abstract void reset(); - public abstract void lookHondaur(); - public abstract void talkHondaur(); - public abstract void attackHondaur(); - public abstract void lookSponge(); - public abstract void talkSponge(); - public abstract void followSponge(); - public abstract void lookAnthony(); - public abstract void talkAnthony(); - public abstract void touchAnthony(); - public abstract void lookTheodoor(); - public abstract void talkTheodoor(); - public abstract void attackTheodoor(); - public abstract void lookWheeler(); - public abstract void talkWheeler(); - public abstract void attackWheeler(); - - - - -} +package monsters; + +import main.GameManager; + +public abstract class Monster { + + protected GameManager gm; + public int currentLife; + protected int maxLife; + protected String monster; + protected int attackDamage; + + public Monster(GameManager gm,int currentLife,int maxLife, String monster, int attackDamage) { + this.gm = gm; + this.currentLife = currentLife; + this.maxLife = maxLife; + this.attackDamage = attackDamage; + this.monster = monster; + } + + public abstract void reset(); + public abstract void lookHondaur(); + public abstract void talkHondaur(); + public abstract void attackHondaur(); + public abstract void lookSponge(); + public abstract void talkSponge(); + public abstract void followSponge(); + public abstract void lookAnthony(); + public abstract void talkAnthony(); + public abstract void touchAnthony(); + public abstract void lookTheodoor(); + public abstract void talkTheodoor(); + public abstract void attackTheodoor(); + public abstract void lookWheeler(); + public abstract void talkWheeler(); + public abstract void attackWheeler(); + + + + +} diff --git a/src/main/java/monsters/Theodoor.java b/src/main/java/monsters/Theodoor.java index ee83726..4882642 100644 --- a/src/main/java/monsters/Theodoor.java +++ b/src/main/java/monsters/Theodoor.java @@ -1,109 +1,109 @@ -package monsters; - -import javafx.scene.image.ImageView; -import main.GameManager; - -public class Theodoor extends Monster { - - private ImageView blood; // Reference for blood - - public Theodoor(GameManager gm) { - super(gm,4,4, "Theodoor", 2); - } - public void addToScene() { - - gm.ui.createObject(5, 450,95,200,283,"theodoor.png", - "Look","Talk", "Attack", "lookTheodoor", - "talkTheodoor", "attackTheodoor"); - } - - @Override - public void lookTheodoor() { - if(currentLife >0) { - gm.ui.messageText.setText("You see " + monster+ " the door ready to feast on your adorable body."); - gm.playSE(gm.monsterRoar); - } - else { - gm.ui.messageText.setText(monster+ " the door is dead"); - gm.playSE(gm.cannotSound); - } - } - - @Override - public void talkTheodoor() { - if(currentLife >0) { - gm.ui.messageText.setText(monster+" the door roars at you, its hinges creaking."); - gm.playSE(gm.monsterRoar); - } - else { - gm.ui.messageText.setText(monster+" the door is already dead"); - gm.playSE(gm.cannotSound); - } - } - - @Override - public void attackTheodoor() { - currentLife-=2; - gm.player.playerLife -=1; - gm.player.updatePlayerStatus(); - gm.ui.messageText.setText("You shoot "+monster+" the door with your glock! (Its health decreases by 2)"); - if(gm.player.playerLife <=0){ - gm.sChanger.showGameOverScreen(5); - gm.ui.messageText.setText("You baka! You tested your luck!"); - } - else{ - gm.ui.messageText.setText("You lost a life! Be careful!"); - gm.playSE(gm.pistolShot); - gm.playSE(gm.monsterHit); - - - } - - if(currentLife == 0){ - if (blood == null) { - blood = gm.ui.createObjectAndReturn(5, 450, 95, 200, 233, "blood.png", "", "", "", "", "", ""); - } - - // Make them visible - blood.setVisible(true); - - gm.ui.messageText.setText( monster+ " the door has been defeated!"); - }else if (currentLife > 0) { - // Hide blood while the monster is still alive - if (blood != null) blood.setVisible(false); - } - } - - @Override - public void reset() { - currentLife = maxLife; // Reset Theodoor's life - - if (blood != null) { - blood.setVisible(false); - } - } - @Override - public void lookHondaur() {} - @Override - public void talkHondaur() {} - @Override - public void attackHondaur() {} - @Override - public void lookSponge() {} - @Override - public void talkSponge() {} - @Override - public void followSponge() {} - @Override - public void lookAnthony() {} - @Override - public void talkAnthony() {} - @Override - public void touchAnthony() {} - @Override - public void lookWheeler() {} - @Override - public void talkWheeler() {} - @Override - public void attackWheeler() {} -} +package monsters; + +import javafx.scene.image.ImageView; +import main.GameManager; + +public class Theodoor extends Monster { + + private ImageView blood; // Reference for blood + + public Theodoor(GameManager gm) { + super(gm,4,4, "Theodoor", 2); + } + public void addToScene() { + + gm.ui.createObject(5, 450,95,200,283,"theodoor.png", + "Look","Talk", "Attack", "lookTheodoor", + "talkTheodoor", "attackTheodoor"); + } + + @Override + public void lookTheodoor() { + if(currentLife >0) { + gm.ui.messageText.setText("You see " + monster+ " the door ready to feast on your adorable body."); + gm.playSE(gm.monsterRoar); + } + else { + gm.ui.messageText.setText(monster+ " the door is dead"); + gm.playSE(gm.cannotSound); + } + } + + @Override + public void talkTheodoor() { + if(currentLife >0) { + gm.ui.messageText.setText(monster+" the door roars at you, its hinges creaking."); + gm.playSE(gm.monsterRoar); + } + else { + gm.ui.messageText.setText(monster+" the door is already dead"); + gm.playSE(gm.cannotSound); + } + } + + @Override + public void attackTheodoor() { + currentLife-=2; + gm.player.playerLife -=1; + gm.player.updatePlayerStatus(); + gm.ui.messageText.setText("You shoot "+monster+" the door with your glock! (Its health decreases by 2)"); + if(gm.player.playerLife <=0){ + gm.sChanger.showGameOverScreen(5); + gm.ui.messageText.setText("You baka! You tested your luck!"); + } + else{ + gm.ui.messageText.setText("You lost a life! Be careful!"); + gm.playSE(gm.pistolShot); + gm.playSE(gm.monsterHit); + + + } + + if(currentLife == 0){ + if (blood == null) { + blood = gm.ui.createObjectAndReturn(5, 450, 95, 200, 233, "blood.png", "", "", "", "", "", ""); + } + + // Make them visible + blood.setVisible(true); + + gm.ui.messageText.setText( monster+ " the door has been defeated!"); + }else if (currentLife > 0) { + // Hide blood while the monster is still alive + if (blood != null) blood.setVisible(false); + } + } + + @Override + public void reset() { + currentLife = maxLife; // Reset Theodoor's life + + if (blood != null) { + blood.setVisible(false); + } + } + @Override + public void lookHondaur() {} + @Override + public void talkHondaur() {} + @Override + public void attackHondaur() {} + @Override + public void lookSponge() {} + @Override + public void talkSponge() {} + @Override + public void followSponge() {} + @Override + public void lookAnthony() {} + @Override + public void talkAnthony() {} + @Override + public void touchAnthony() {} + @Override + public void lookWheeler() {} + @Override + public void talkWheeler() {} + @Override + public void attackWheeler() {} +} diff --git a/src/main/java/monsters/Wheeler.java b/src/main/java/monsters/Wheeler.java index f13aa07..d6ad7f5 100644 --- a/src/main/java/monsters/Wheeler.java +++ b/src/main/java/monsters/Wheeler.java @@ -1,109 +1,109 @@ -package monsters; - -import javafx.scene.image.ImageView; -import main.GameManager; - -public class Wheeler extends Monster { - - private ImageView blood; // Reference for blood - - public Wheeler(GameManager gm) { - super(gm,4,4, "Wheeler", 2); - } - public void addToScene() { - - gm.ui.createObject(5, 50,95,200,283,"wheel.png", - "Look","Talk", "Attack", "lookWheeler", - "talkWheeler", "attackWheeler"); - } - - @Override - public void lookWheeler() { - if(currentLife >0) { - gm.ui.messageText.setText("You see the " + monster+ " ready to run you over."); - gm.playSE(gm.monsterRoar); - } - else { - gm.ui.messageText.setText(monster+ " is dead"); - gm.playSE(gm.cannotSound); - } - } - - @Override - public void talkWheeler() { - if(currentLife >0) { - gm.ui.messageText.setText(monster+" roars at you! (He is scared of the glock)."); - gm.playSE(gm.monsterRoar); - } - else { - gm.ui.messageText.setText(monster+" is already dead"); - gm.playSE(gm.cannotSound); - } - } - - @Override - public void attackWheeler() { - currentLife-=2; - gm.player.playerLife -=1; - gm.player.updatePlayerStatus(); - gm.ui.messageText.setText("You shoot "+monster+" with your glock! (Its health decreases by 2)"); - if(gm.player.playerLife <=0){ - gm.sChanger.showGameOverScreen(5); - gm.ui.messageText.setText("You baka! You tested your luck!"); - } - else{ - gm.ui.messageText.setText("You lost a life! Be careful!"); - gm.playSE(gm.pistolShot); - gm.playSE(gm.monsterHit); - - - } - - if(currentLife == 0){ - if (blood == null) { - blood = gm.ui.createObjectAndReturn(5, 50, 95, 200, 233, "blood.png", "", "", "", "", "", ""); - } - - // Make them visible - blood.setVisible(true); - - gm.ui.messageText.setText( monster+ " has been defeated!"); - }else if (currentLife > 0) { - // Hide blood while the monster is still alive - if (blood != null) blood.setVisible(false); - } - } - @Override - public void reset() { - currentLife = maxLife; // Reset Wheeler's life - - if (blood != null) { - blood.setVisible(false); - } - } - - @Override - public void lookHondaur() {} - @Override - public void talkHondaur() {} - @Override - public void attackHondaur() {} - @Override - public void lookSponge() {} - @Override - public void talkSponge() {} - @Override - public void followSponge() {} - @Override - public void lookAnthony() {} - @Override - public void talkAnthony() {} - @Override - public void touchAnthony() {} - @Override - public void lookTheodoor() {} - @Override - public void talkTheodoor() {} - @Override - public void attackTheodoor() {} -} +package monsters; + +import javafx.scene.image.ImageView; +import main.GameManager; + +public class Wheeler extends Monster { + + private ImageView blood; // Reference for blood + + public Wheeler(GameManager gm) { + super(gm,4,4, "Wheeler", 2); + } + public void addToScene() { + + gm.ui.createObject(5, 50,95,200,283,"wheel.png", + "Look","Talk", "Attack", "lookWheeler", + "talkWheeler", "attackWheeler"); + } + + @Override + public void lookWheeler() { + if(currentLife >0) { + gm.ui.messageText.setText("You see the " + monster+ " ready to run you over."); + gm.playSE(gm.monsterRoar); + } + else { + gm.ui.messageText.setText(monster+ " is dead"); + gm.playSE(gm.cannotSound); + } + } + + @Override + public void talkWheeler() { + if(currentLife >0) { + gm.ui.messageText.setText(monster+" roars at you! (He is scared of the glock)."); + gm.playSE(gm.monsterRoar); + } + else { + gm.ui.messageText.setText(monster+" is already dead"); + gm.playSE(gm.cannotSound); + } + } + + @Override + public void attackWheeler() { + currentLife-=2; + gm.player.playerLife -=1; + gm.player.updatePlayerStatus(); + gm.ui.messageText.setText("You shoot "+monster+" with your glock! (Its health decreases by 2)"); + if(gm.player.playerLife <=0){ + gm.sChanger.showGameOverScreen(5); + gm.ui.messageText.setText("You baka! You tested your luck!"); + } + else{ + gm.ui.messageText.setText("You lost a life! Be careful!"); + gm.playSE(gm.pistolShot); + gm.playSE(gm.monsterHit); + + + } + + if(currentLife == 0){ + if (blood == null) { + blood = gm.ui.createObjectAndReturn(5, 50, 95, 200, 233, "blood.png", "", "", "", "", "", ""); + } + + // Make them visible + blood.setVisible(true); + + gm.ui.messageText.setText( monster+ " has been defeated!"); + }else if (currentLife > 0) { + // Hide blood while the monster is still alive + if (blood != null) blood.setVisible(false); + } + } + @Override + public void reset() { + currentLife = maxLife; // Reset Wheeler's life + + if (blood != null) { + blood.setVisible(false); + } + } + + @Override + public void lookHondaur() {} + @Override + public void talkHondaur() {} + @Override + public void attackHondaur() {} + @Override + public void lookSponge() {} + @Override + public void talkSponge() {} + @Override + public void followSponge() {} + @Override + public void lookAnthony() {} + @Override + public void talkAnthony() {} + @Override + public void touchAnthony() {} + @Override + public void lookTheodoor() {} + @Override + public void talkTheodoor() {} + @Override + public void attackTheodoor() {} +} diff --git a/target/classes/adrian.png b/target/classes/adrian.png new file mode 100644 index 0000000..dc58b9d Binary files /dev/null and b/target/classes/adrian.png differ diff --git a/target/classes/ak47.png b/target/classes/ak47.png new file mode 100644 index 0000000..02d6927 Binary files /dev/null and b/target/classes/ak47.png differ diff --git a/target/classes/ak47Shots.wav b/target/classes/ak47Shots.wav new file mode 100644 index 0000000..f8da1d3 Binary files /dev/null and b/target/classes/ak47Shots.wav differ diff --git a/target/classes/anthony.png b/target/classes/anthony.png new file mode 100644 index 0000000..0af5ab8 Binary files /dev/null and b/target/classes/anthony.png differ diff --git a/target/classes/awSound.wav b/target/classes/awSound.wav new file mode 100644 index 0000000..f8c3d60 Binary files /dev/null and b/target/classes/awSound.wav differ diff --git a/target/classes/bedroom.png b/target/classes/bedroom.png new file mode 100644 index 0000000..e7ac8e4 Binary files /dev/null and b/target/classes/bedroom.png differ diff --git a/target/classes/bedroom_bg.png b/target/classes/bedroom_bg.png new file mode 100644 index 0000000..0b7da61 Binary files /dev/null and b/target/classes/bedroom_bg.png differ diff --git a/target/classes/blood.png b/target/classes/blood.png new file mode 100644 index 0000000..09e6424 Binary files /dev/null and b/target/classes/blood.png differ diff --git a/target/classes/brandon.png b/target/classes/brandon.png new file mode 100644 index 0000000..d056514 Binary files /dev/null and b/target/classes/brandon.png differ diff --git a/target/classes/brandon2.png b/target/classes/brandon2.png new file mode 100644 index 0000000..5f790cd Binary files /dev/null and b/target/classes/brandon2.png differ diff --git a/target/classes/campfire.png b/target/classes/campfire.png new file mode 100644 index 0000000..ef64f31 Binary files /dev/null and b/target/classes/campfire.png differ diff --git a/target/classes/cannotSound.wav b/target/classes/cannotSound.wav new file mode 100644 index 0000000..8e96a58 Binary files /dev/null and b/target/classes/cannotSound.wav differ diff --git a/target/classes/casino.png b/target/classes/casino.png new file mode 100644 index 0000000..bac4411 Binary files /dev/null and b/target/classes/casino.png differ diff --git a/target/classes/casinoEntrance.png b/target/classes/casinoEntrance.png new file mode 100644 index 0000000..2215c01 Binary files /dev/null and b/target/classes/casinoEntrance.png differ