Skip to content

Commit

Permalink
MainMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
GriszlyExe committed May 19, 2023
1 parent 3c6179a commit d53be4e
Show file tree
Hide file tree
Showing 45 changed files with 816 additions and 601 deletions.
Binary file modified res/Chicknight/ChicknightLeft.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 modified res/Chicknight/ChicknightLeftAtk.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 modified res/Chicknight/ChicknightLeftWalk1.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 modified res/Chicknight/ChicknightRight.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 modified res/Chicknight/ChicknightRightAtk.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 modified res/Chicknight/ChicknightRightWalk1.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/IngameSong.wav
Binary file not shown.
Binary file removed res/John.png
Binary file not shown.
Binary file added res/MoleDerKaiser/moleDerKaiser.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/MoleDerKaiser/normalMole.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/mapTile/BottomLeftMap.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/mapTile/BottomMap.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/mapTile/BottomRightMap.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/mapTile/LeftMap.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/mapTile/RightMap.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/mapTile/Tomb.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/mapTile/TopLeftMap.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/mapTile/TopMap.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/mapTile/TopRightMap.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/mapTile/ground1.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/mapTile/ground2.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/mapTile/ground3.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/mapTile/spawn1.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/mapTile/spawn2.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/mapTile/water1.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/mapTile/water2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions src/MainMenu/GameMenu.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package MainMenu;

import application.GameStart;
import application.Main;
import javafx.animation.FadeTransition;
import javafx.animation.TranslateTransition;
import javafx.scene.Parent;
Expand Down Expand Up @@ -54,9 +54,12 @@ public GameMenu() {
ft.setToValue(0);
ft.setOnFinished(evt-> setVisible(false));
ft.play();
Main.isStart = true;
Main.GameStart();

GameStart.start();

gameMenu.getChildren().remove(playMenu);
gameMenu.getChildren().addAll(mainMenu);
transition(playMenu,mainMenu,640);
});

MenuButton ContBtn = new MenuButton("CONTINUE");
Expand Down
2 changes: 1 addition & 1 deletion src/MainMenu/GameOverButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void draw(GraphicsContext gc) {
gc.strokeRect(x,y,width,height);
gc.setFill(Color.BLACK);
gc.setFont(Font.font("Times New Roman", FontWeight.BOLD, 32));
gc.fillText(text.getText(), (x+width/2-55), (y+height/1.3));
gc.fillText(text.getText(), (x+width/2-75), (y+height/1.3));
}

public int getX() {
Expand Down
71 changes: 0 additions & 71 deletions src/application/GameStart.java

This file was deleted.

135 changes: 98 additions & 37 deletions src/application/Main.java
Original file line number Diff line number Diff line change
@@ -1,62 +1,123 @@
package application;

import MainMenu.GameMenu;
import drawing.GameScreen;
import input.InputUtility;
import javafx.animation.AnimationTimer;
import javafx.animation.FadeTransition;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Duration;
import logic.game.GameLogic;
import logic.entity.Player;
import sharedObject.RenderableHolder;

public class Main extends Application{
public class Main extends Application {

Scene gameScene, mainScene;

public static void main(String[] args) {
// TODO Auto-generated method stub
Application.launch(args);
}

@Override
public void start(Stage stage) throws Exception {
final int width = 1280;
final int height = 720;
// TODO Auto-generated method stub
StackPane root = new StackPane();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setTitle("2D Game");


GameScreen gameScreen = new GameScreen(width, height);
GameLogic logic = new GameLogic(gameScreen);
public static boolean isStart = false;
private static GameMenu gameMenu;
public static Stage stage;
private static StackPane root;
private static ImageView bg;
private static GameScreen gameScreen;
private static GameLogic logic;
private static AnimationTimer animation;

final static int width = 1280;
final static int height = 720;

public Stage getStage() {
return stage;
}

public boolean isStart() {
return isStart;
}

public static void GameStart() {

System.out.println(isStart);
root.getChildren().removeAll(bg, gameMenu);
gameScreen = new GameScreen(width, height);
logic = new GameLogic(gameScreen);
root.getChildren().add(gameScreen);
gameScreen.requestFocus();

stage.show();

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

public void handle(long now) {
delta += (now-previousTime)/drawInterval;
previousTime = now;
logic.checkGameState();
if (delta >= 1) {
logic.count();
// logic.logicUpdate();
// gameScreen.paintComponent();
logic.update();
RenderableHolder.getInstance().update();
InputUtility.updateInputState();
delta--;
//
//
animation = new AnimationTimer() {
long previousTime = 0;
double drawInterval = 1e9 / 60;
double delta = 0;

public void handle(long now) {
delta += (now - previousTime) / drawInterval;
previousTime = now;
logic.checkGameState();
if (delta >= 1) {
logic.count();
logic.update();
RenderableHolder.getInstance().update();
InputUtility.updateInputState();
delta--;
}
}
}
};
animation.start();
};
animation.start();
}

public static void GoToMenu() {
animation.stop();
root.getChildren().remove(gameScreen);
root.getChildren().addAll(bg,gameMenu);
}

@Override
public void start(Stage stage) {

Main.stage = stage;
Main.root = new StackPane();
root.setPrefSize(width, height);

gameMenu = new GameMenu();

Image img = new Image(ClassLoader.getSystemResource("Elysia.jpeg").toString());
bg = new ImageView(img);
bg.setFitWidth(width);
bg.setFitHeight(height);

root.getChildren().addAll(bg, gameMenu);
gameMenu.setVisible(false);

Scene scene = new Scene(root);

scene.setOnKeyPressed(e -> {
if (!gameMenu.isVisible()) {
FadeTransition ft = new FadeTransition(Duration.seconds(1), gameMenu);
ft.setFromValue(0);
ft.setToValue(1);
gameMenu.setVisible(true);
ft.play();
}
});

stage.setTitle("2D Game");
stage.setScene(scene);
stage.show();
// TODO Auto-generated method stub

//
//
}
}
Loading

0 comments on commit d53be4e

Please sign in to comment.