Skip to content

Commit

Permalink
HealthBar Attack and Remove corpse
Browse files Browse the repository at this point in the history
  • Loading branch information
GriszlyExe committed May 17, 2023
1 parent db1989d commit a06c4c5
Show file tree
Hide file tree
Showing 26 changed files with 566 additions and 86 deletions.
Binary file added res/Elysia.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/John.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/Map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/Rabbi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/RabbiLeft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/health_power_bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/pause/pause_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/pause/sound_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/pause/urm_buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/pause/volume_buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions src/MainMenu/GameMenu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package MainMenu;

import application.GameStart;
import javafx.animation.FadeTransition;
import javafx.animation.TranslateTransition;
import javafx.scene.Parent;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;

public class GameMenu extends Parent{

public GameMenu() {
GameMenu gameMenu = this;
VBox mainMenu = new VBox(10);
VBox playMenu = new VBox(10);

mainMenu.setTranslateX(1280/2.5);
mainMenu.setTranslateY(720*3/4);
playMenu.setTranslateX(1280/1.5);
playMenu.setTranslateY(720*3/4);

//Main menu
MenuButton startBtn = new MenuButton("START");

startBtn.setOnMouseClicked(e->{
transition(mainMenu,playMenu,-640);
// gameMenu.getChildren().remove(mainMenu);
gameMenu.getChildren().addAll(playMenu);
});

MenuButton exitBtn = new MenuButton("QUIT");

exitBtn.setOnMouseClicked(e->{
System.exit(0);
});

MenuButton optionBtn = new MenuButton("OPTION");

optionBtn.setOnMouseClicked(e->{
getChildren().add(playMenu);
transition(mainMenu,playMenu,-640);

});

//PlayMenu

MenuButton playBtn = new MenuButton("PLAY");

playBtn.setOnMouseClicked(e->{
FadeTransition ft = new FadeTransition(Duration.seconds(0.5),this);
ft.setFromValue(1);
ft.setToValue(0);
ft.setOnFinished(evt-> setVisible(false));
ft.play();

GameStart.start();

});

MenuButton ContBtn = new MenuButton("CONTINUE");

ContBtn.setOnMouseClicked(e->{

});

MenuButton backBtn = new MenuButton("BACK");

backBtn.setOnMouseClicked(e->{
gameMenu.getChildren().remove(playMenu);
gameMenu.getChildren().addAll(mainMenu);
transition(playMenu,mainMenu,640);

});


Rectangle bg = new Rectangle(1280,720);
bg.setOpacity(0.1);
bg.setFill(Color.PINK);
mainMenu.getChildren().addAll(startBtn,optionBtn,exitBtn);
playMenu.getChildren().addAll(playBtn,ContBtn,backBtn);

getChildren().addAll(bg,mainMenu);

}

public void transition(VBox menuToOut,VBox menuToin,int Xtrans) {
TranslateTransition ttOut = new TranslateTransition(Duration.seconds(0.5),menuToOut);
ttOut.setToX(menuToOut.getTranslateX()+Xtrans);

TranslateTransition ttIn = new TranslateTransition(Duration.seconds(0.5),menuToin);
ttIn.setToX(menuToOut.getTranslateX());

ttOut.play();
ttIn.play();

ttOut.setOnFinished(evt-> getGameMenu().getChildren().remove(menuToOut));
}

public GameMenu getGameMenu() {
return this;
}
}
45 changes: 45 additions & 0 deletions src/MainMenu/MenuButton.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package MainMenu;

import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.effect.*;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;

public class MenuButton extends StackPane{
private Text text;

public MenuButton(String name) {
text = new Text(name);
text.setFont(text.getFont().font(20));

Rectangle bg = new Rectangle(250,30);
bg.setOpacity(0.5);
bg.setFill(Color.WHITE);
bg.setEffect(new Bloom(3));

setAlignment(Pos.CENTER);

getChildren().addAll(text,bg);

setOnMouseEntered(e->{
bg.setTranslateX(10);
text.setTranslateX(10);
bg.setFill(Color.LIGHTPINK);
text.setFill(Color.RED);

});

setOnMouseExited(e->{
bg.setTranslateX(0);
text.setTranslateX(0);
bg.setFill(Color.WHITE);
text.setFill(Color.BLACK);
});

this.setStyle("-fx-border-radius: 10;");
}

}
71 changes: 71 additions & 0 deletions src/application/GameStart.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package application;

import drawing.GameScreen;
import input.InputUtility;
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import logic.game.GameLogic;
import logic.entity.Player;
import sharedObject.RenderableHolder;

public class GameStart{


public static void start(){
final int width = 1280;
final int height = 720;
// VBox statBar = new VBox();
ProgressBar hpBar = new ProgressBar();
hpBar.setStyle("-fx-accent: Green; \n -fx-background-color: White; \n");
hpBar.setMaxWidth(width);
hpBar.setProgress(1);
ProgressBar manaBar = new ProgressBar();
manaBar.setStyle("-fx-accent: Blue; \n -fx-background-color: White; \n");
manaBar.setMaxWidth(width);
manaBar.setProgress(1);

Stage gameWindow = new Stage();
gameWindow.initModality(Modality.APPLICATION_MODAL);
VBox root = new VBox();
Scene gameScene = new Scene(root);
gameWindow.setScene(gameScene);
gameWindow.setTitle("Test");

GameScreen gameScreen = new GameScreen(width, height);
GameLogic logic = new GameLogic(gameScreen);
root.getChildren().addAll(gameScreen,hpBar,manaBar);
gameScreen.requestFocus();


AnimationTimer animation = new AnimationTimer() {
long previousTime = 0;
double drawInterval = 1e9/30;
double delta = 0;

public void handle(long now) {
delta += (now-previousTime)/drawInterval;
previousTime = now;

if (delta >= 1) {

gameScreen.paintComponent();
logic.logicUpdate();
RenderableHolder.getInstance().update();
InputUtility.updateInputState();
delta--;
}
}
};
animation.start();
gameWindow.show();
}
}
5 changes: 2 additions & 3 deletions src/application/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public static void main(String[] args) {

@Override
public void start(Stage stage) throws Exception {
final int width = 1920;
final int height = 1000;
final int width = 1280;
final int height = 720;
// TODO Auto-generated method stub
StackPane root = new StackPane();
Scene scene = new Scene(root);
Expand All @@ -46,7 +46,6 @@ public void handle(long now) {
previousTime = now;
logic.checkGameState();
if (delta >= 1) {

logic.count();
// logic.logicUpdate();
// gameScreen.paintComponent();
Expand Down
9 changes: 8 additions & 1 deletion src/drawing/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import input.InputUtility;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
Expand All @@ -12,10 +13,11 @@
import sharedObject.RenderableHolder;

public class GameScreen extends Canvas{
private boolean paused = false;

public GameScreen(double width, double height) {
super(width, height);
this.setVisible(true);
this.
addListerner();
}

Expand Down Expand Up @@ -59,6 +61,7 @@ public void addListerner() {
InputUtility.mouseY = event.getY();
}
});

}

public void paintComponent() {
Expand All @@ -73,4 +76,8 @@ public void paintComponent() {
}
}
}

public GameScreen getGameScreen() {
return this;
}
}
3 changes: 1 addition & 2 deletions src/input/InputUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class InputUtility {
public static boolean getKeyPressed(KeyCode keycode) {
return keyPressed.contains(keycode);
}

public static void setKeyPressed(KeyCode keycode,boolean pressed) {
if(pressed){
if(!keyPressed.contains(keycode)){
Expand Down Expand Up @@ -42,8 +41,8 @@ public static boolean isLeftClickTriggered(){
public static void updateInputState(){
isLeftClickedLastTick = false;
}

public static ArrayList<KeyCode> getKeyPressed() {
return keyPressed;
}

}
Loading

0 comments on commit a06c4c5

Please sign in to comment.