Skip to content

Commit

Permalink
AddConstant
Browse files Browse the repository at this point in the history
  • Loading branch information
GriszlyExe committed May 20, 2023
1 parent be0d11d commit f723f30
Show file tree
Hide file tree
Showing 52 changed files with 605 additions and 569 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified res/.DS_Store
Binary file not shown.
Binary file removed res/Elysia.jpeg
Binary file not shown.
Binary file removed res/Map.png
Binary file not shown.
Binary file added res/MoleDerKaiser/moleDerKaiser1.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/normalMole1.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 removed res/Rabbi.png
Binary file not shown.
Binary file removed res/RabbiLeft.png
Binary file not shown.
Binary file removed res/health_power_bar.png
Binary file not shown.
Binary file added res/llaristicKnight/llaristicKnightLeft1.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/llaristicKnight/llaristicKnightLeft2.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/llaristicKnight/llaristicKnightLeftAtk.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/llaristicKnight/llaristicKnightRight1.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/llaristicKnight/llaristicKnightRight2.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/llaristicKnight/llaristicKnightRightAtk.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 removed res/moon.png
Binary file not shown.
Binary file added res/other/darkSoul4.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/sound/katana.mp3
Binary file not shown.
Binary file added res/swordBeam/beam.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/swordBeam/beamBottom.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/swordBeam/beamLeft.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/swordBeam/beamRight.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/swordBeam/beamtop.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 src/.DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion src/MainMenu/MenuButton.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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;
Expand Down
9 changes: 5 additions & 4 deletions src/Object/Ball.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ public class Ball extends Projectile{

public Ball(double worldX, double worldY, double angle, GameLogic gameLogic) {
super(worldX, worldY, angle, gameLogic);
speed = 3;
speed = 7;
xspeed = Math.cos(angle) * speed;
yspeed = Math.sin(angle) * speed;
dmg = 10;
dmg = 5;
solidArea = new Rectangle(0, 0, 8, 8);
solidScreen = new Rectangle(screenX+solidArea.getX(),screenY+solidArea.getY(),solidArea.getWidth(),solidArea.getHeight());
RenderableHolder.shootSound.play(0.1);
image = RenderableHolder.ball;
}

@Override
public void draw(GraphicsContext gc) {
// TODO Auto-generated method stub
gc.drawImage(RenderableHolder.ball, screenX, screenY);
drawHitbox(gc);
gc.drawImage(image, screenX, screenY);
// drawHitbox(gc);
}

}
4 changes: 2 additions & 2 deletions src/Object/Projectile.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package Object;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import logic.entity.Player;
import logic.game.GameLogic;
import sharedObject.IRenderable;
import sharedObject.RenderableHolder;

public abstract class Projectile implements IRenderable {

protected Image image;
protected double worldX, worldY;
public double screenX, screenY;
protected Rectangle solidArea,solidScreen;
Expand Down
27 changes: 20 additions & 7 deletions src/Object/SwordBeam.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
package Object;

import javafx.scene.SnapshotParameters;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import logic.game.GameLogic;
import sharedObject.RenderableHolder;

public class SwordBeam extends Projectile{

ImageView rotatedImage;
SnapshotParameters params;
public SwordBeam(double worldX, double worldY, double angle, GameLogic gameLogic) {
super(worldX, worldY, angle, gameLogic);
speed = 5;
xspeed = Math.cos(angle) * speed;
yspeed = Math.sin(angle) * speed;
dmg = 20;
if(Math.abs(xspeed)>Math.abs(yspeed))
solidArea = new Rectangle(0, -16, 16, 128);
else
solidArea = new Rectangle(-16,0,128,16);
dmg = 10;
image = RenderableHolder.beam;
rotatedImage = new ImageView(image);
rotatedImage.setRotate(angle*180/Math.PI);
params = new SnapshotParameters();
params.setFill(Color.TRANSPARENT);
if(Math.abs(xspeed)>Math.abs(yspeed)) {
solidArea = new Rectangle(0, -32, 32, 128);
}
else {
solidArea = new Rectangle(-32,0,128,32);
}
solidScreen = new Rectangle(screenX+solidArea.getX(),screenY+solidArea.getY(),solidArea.getWidth(),solidArea.getHeight());
RenderableHolder.shootSound.play(0.1);
}

@Override
public void draw(GraphicsContext gc) {
// TODO Auto-generated method stub
drawHitbox(gc);
gc.drawImage(rotatedImage.snapshot(params, null), screenX, screenY);

// drawHitbox(gc);
}

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

public class Vector <T>{
private T x,y;

public Vector(T x , T y) {
this.x = x;
this.y = y;
}

public T getX() {
return x;
}

public T getY() {
return y;
}

public void setX(T x) {
this.x = x;
}

public void setY(T y) {
this.y = y;
}


}
55 changes: 22 additions & 33 deletions src/application/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package application;

import MainMenu.GameMenu;
import constant.Constant;
import drawing.GameScreen;
import input.InputUtility;
import javafx.animation.AnimationTimer;
Expand All @@ -9,26 +10,18 @@
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 {

Scene gameScene, mainScene;

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

public static int second;
public static long lastTimeTriggered = -1;

private static long lastTimeTriggered = -1;
public static boolean isStart = false;
private static GameMenu gameMenu;
public static Stage stage;
Expand All @@ -38,33 +31,26 @@ public static void main(String[] args) {
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);
gameScreen = new GameScreen(Constant.ScreenSize.GAMEWIDTH, Constant.ScreenSize.GAMEHEIGHT);
logic = new GameLogic(gameScreen);
root.getChildren().add(gameScreen);
gameScreen.requestFocus();
//
//
second = 0 ;
second = 0;
animation = new AnimationTimer() {
long previousTime = 0;
double drawInterval = 1e9 / 60;
double delta = 0;

public void handle(long now) {
// timer
lastTimeTriggered = (lastTimeTriggered < 0 ? now : lastTimeTriggered);
Expand All @@ -83,7 +69,7 @@ public void handle(long now) {
InputUtility.updateInputState();
delta--;
}
System.out.println(second);
// System.out.println(second);
}
};
animation.start();
Expand All @@ -100,37 +86,40 @@ public void start(Stage stage) {

Main.stage = stage;
Main.root = new StackPane();
root.setPrefSize(width, height);
root.setPrefSize(Constant.ScreenSize.GAMEWIDTH, Constant.ScreenSize.GAMEHEIGHT);

gameMenu = new GameMenu();

Image img = new Image(ClassLoader.getSystemResource("Elysia.jpeg").toString());
Image img = new Image(ClassLoader.getSystemResource("other/darkSoul4.png").toString());
bg = new ImageView(img);
bg.setFitWidth(width);
bg.setFitHeight(height);
bg.setFitWidth(Constant.ScreenSize.GAMEWIDTH);
bg.setFitHeight(Constant.ScreenSize.GAMEHEIGHT);

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

Scene scene = new Scene(root);
if (!gameMenu.isVisible()) {
scene.setOnKeyPressed(e -> {
// System.out.println("attempt");

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.setTitle("Black Light Matter");
stage.setScene(scene);
stage.show();
}

public static void main(String[] args) {
// TODO Auto-generated method stub

//
//
Application.launch(args);
}

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

public class Constant {
public static class ScreenSize {
public final static int GAMEWIDTH = 1280;
public final static int GAMEHEIGHT = 720;
}

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

public enum Direction {
UP,DOWN,LEFT,RIGHT
}
5 changes: 5 additions & 0 deletions src/constant/EntityState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package constant;

public enum EntityState {
DEFAULT,ALIVE,DEAD,ATTACK,MOVING
}
5 changes: 5 additions & 0 deletions src/constant/GameState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package constant;

public enum GameState {
PLAYSTATE,PAUSESTATE,NPCSTATE,GAMEOVERSTATE,WINSTATE
}
8 changes: 1 addition & 7 deletions src/drawing/GameScreen.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
package drawing;

import MainMenu.GameOverButton;
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;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import logic.game.GameLogic;
import sharedObject.IRenderable;
import sharedObject.RenderableHolder;

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


public GameScreen(double width, double height) {
super(width, height);
Expand Down
Binary file modified src/logic/.DS_Store
Binary file not shown.
Loading

0 comments on commit f723f30

Please sign in to comment.