diff --git a/res/Elysia.jpeg b/res/Elysia.jpeg new file mode 100644 index 0000000..4504bf5 Binary files /dev/null and b/res/Elysia.jpeg differ diff --git a/res/John.png b/res/John.png new file mode 100644 index 0000000..4a84953 Binary files /dev/null and b/res/John.png differ diff --git a/res/Map.png b/res/Map.png new file mode 100644 index 0000000..d7267e4 Binary files /dev/null and b/res/Map.png differ diff --git a/res/Rabbi.png b/res/Rabbi.png new file mode 100644 index 0000000..8e1f6a6 Binary files /dev/null and b/res/Rabbi.png differ diff --git a/res/RabbiLeft.png b/res/RabbiLeft.png new file mode 100644 index 0000000..3337d82 Binary files /dev/null and b/res/RabbiLeft.png differ diff --git a/res/health_power_bar.png b/res/health_power_bar.png new file mode 100644 index 0000000..62c77cf Binary files /dev/null and b/res/health_power_bar.png differ diff --git a/res/pause/pause_menu.png b/res/pause/pause_menu.png new file mode 100644 index 0000000..f16a565 Binary files /dev/null and b/res/pause/pause_menu.png differ diff --git a/res/pause/sound_button.png b/res/pause/sound_button.png new file mode 100644 index 0000000..1b9c447 Binary files /dev/null and b/res/pause/sound_button.png differ diff --git a/res/pause/urm_buttons.png b/res/pause/urm_buttons.png new file mode 100644 index 0000000..4018962 Binary files /dev/null and b/res/pause/urm_buttons.png differ diff --git a/res/pause/volume_buttons.png b/res/pause/volume_buttons.png new file mode 100644 index 0000000..20f8efd Binary files /dev/null and b/res/pause/volume_buttons.png differ diff --git a/src/MainMenu/GameMenu.java b/src/MainMenu/GameMenu.java new file mode 100644 index 0000000..e1ddd4a --- /dev/null +++ b/src/MainMenu/GameMenu.java @@ -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; + } +} diff --git a/src/MainMenu/MenuButton.java b/src/MainMenu/MenuButton.java new file mode 100644 index 0000000..2701d9f --- /dev/null +++ b/src/MainMenu/MenuButton.java @@ -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;"); + } + +} diff --git a/src/application/GameStart.java b/src/application/GameStart.java new file mode 100644 index 0000000..c5fb7f8 --- /dev/null +++ b/src/application/GameStart.java @@ -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(); +} +} diff --git a/src/application/Main.java b/src/application/Main.java index 0b4108f..1fe2038 100644 --- a/src/application/Main.java +++ b/src/application/Main.java @@ -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); @@ -46,7 +46,6 @@ public void handle(long now) { previousTime = now; logic.checkGameState(); if (delta >= 1) { - logic.count(); // logic.logicUpdate(); // gameScreen.paintComponent(); diff --git a/src/drawing/GameScreen.java b/src/drawing/GameScreen.java index 5c53554..a11457c 100644 --- a/src/drawing/GameScreen.java +++ b/src/drawing/GameScreen.java @@ -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; @@ -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(); } @@ -59,6 +61,7 @@ public void addListerner() { InputUtility.mouseY = event.getY(); } }); + } public void paintComponent() { @@ -73,4 +76,8 @@ public void paintComponent() { } } } + + public GameScreen getGameScreen() { + return this; + } } diff --git a/src/input/InputUtility.java b/src/input/InputUtility.java index 861071c..81f638f 100644 --- a/src/input/InputUtility.java +++ b/src/input/InputUtility.java @@ -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)){ @@ -42,8 +41,8 @@ public static boolean isLeftClickTriggered(){ public static void updateInputState(){ isLeftClickedLastTick = false; } - public static ArrayList getKeyPressed() { return keyPressed; } + } diff --git a/src/logic/entity/Chicknight.java b/src/logic/entity/Chicknight.java index 1ece545..00e9b7b 100644 --- a/src/logic/entity/Chicknight.java +++ b/src/logic/entity/Chicknight.java @@ -2,74 +2,97 @@ import javafx.scene.canvas.GraphicsContext; import javafx.scene.image.Image; +import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import logic.game.GameLogic; import sharedObject.RenderableHolder; -public class Chicknight extends Entity{ +public class Chicknight extends Entity { private double angle = 0; private Image image = RenderableHolder.CKRight; private String currentState = "default"; - public Chicknight(int x, int y,GameLogic gameLogic) { + + // Status + protected int maxHp; + protected int currentHealth; + protected int dmg; + + // AttackBlock + private Rectangle attackBlock; + private int attackOffset; + + public Chicknight(int x, int y, GameLogic gameLogic) { super(x,y,gameLogic); + this.maxHp = 10; + this.currentHealth = maxHp; + this.dmg = 5; this.z = -100; - this.speed =1; - solidArea = new Rectangle(16,0,32,64); + this.speed = 1; + initSolidArea(); + initAttackBlock(); } + @Override public void draw(GraphicsContext gc) { // TODO Auto-generated method stub - - - switch(direction) { +// System.out.println(c); + switch (direction) { case "right": - if(currentState=="default") - if (gameLogic.getCounter()/10%2==1) { + if (currentState == "attack") + if (gameLogic.getCounter() / 10 % 2 == 1) { image = RenderableHolder.CKRight; - } - else + } else { image = RenderableHolder.CKRightAtk; + } + else { - if (gameLogic.getCounter()/10%2==1) { + if (gameLogic.getCounter() / 10 % 2 == 1) { image = RenderableHolder.CKRightWalk1; - } - else + } else image = RenderableHolder.CKRight; } break; case "left": - if(currentState=="default") - if (gameLogic.getCounter()/10%2==1) { + if (currentState == "attack") + if (gameLogic.getCounter() / 10 % 2 == 1) { image = RenderableHolder.CKLeft; - } - else + } else { image = RenderableHolder.CKLeftAtk; + } + else { - if (gameLogic.getCounter()/10%2==1) { + if (gameLogic.getCounter() / 10 % 2 == 1) { image = RenderableHolder.CKLeftWalk1; - } - else + } else image = RenderableHolder.CKLeft; } break; + } gc.drawImage(image, screenX, screenY); + // debugging +// gc.drawImage(RenderableHolder.pauseMenu,screenX,screenY); + drawHitbox(gc); + drawAttackBlock(gc); } - @Override - public void attack() { + public void attack(Entity p) { // TODO Auto-generated method stub + System.out.println(currentState); + ((Player) p).changeHealthTo(gameLogic.getPlayer().getCurrentHealth()-dmg); + System.out.println("SKDASDKLASMDKANDKLDKLMLWQD"); } + @Override public void update() { // TODO Auto-generated method stub - screenX = worldX-gameLogic.getPlayer().worldX+gameLogic.getPlayer().screenX; - screenY = worldY-gameLogic.getPlayer().worldY+gameLogic.getPlayer().screenY; + screenX = worldX - gameLogic.getPlayer().worldX + gameLogic.getPlayer().screenX; + screenY = worldY - gameLogic.getPlayer().worldY + gameLogic.getPlayer().screenY; Player player = gameLogic.getPlayer(); - if (!canAttack(player.worldX, player.worldY, worldX, worldY, 24)) { - angle = Math.atan2(player.worldY-worldY,player.worldX-worldX); + if (!canAttack(player.worldX, player.worldY, worldX, worldY, (int)(attackBlock.getWidth()+solidArea.getWidth()))) { + angle = Math.atan2(player.worldY - worldY, player.worldX - worldX); double xspeed = Math.cos(angle) * speed; double yspeed = Math.sin(angle) * speed; currentState = "walking"; @@ -94,13 +117,69 @@ public void update() { if (collisionOn == false) { worldX += xspeed; } - } - + else { - currentState = "default"; - attack(); + currentState = "attack"; + attack(gameLogic.getPlayer()); } + + updateAttackBlock(); + } + + public void initSolidArea() { + solidArea = new Rectangle(16, 0, 32, 64); + } + + public void initAttackBlock() { +// screenX = worldX-gameLogic.getPlayer().worldX+gameLogic.getPlayer().screenX; +// screenY = worldY-gameLogic.getPlayer().worldY+gameLogic.getPlayer().screenY; + attackBlock = new Rectangle(screenX, screenY, 20 * 2, 20 * 2); +// attackOffset = (int)(*2); + } + + public void checkEnemyHit(Rectangle attackBlock) { + int x = (int) getSolidArea().getX(); + int y = (int) getSolidArea().getY(); + int width = (int) getSolidArea().getWidth(); + int height = (int) getSolidArea().getHeight(); + boolean overlap = attackBlock.intersects(x,y,width,height); + if (overlap) this.attack(gameLogic.getPlayer()); + } + + public void updateAttackBlock() { + attackBlock.setX(screenX + solidArea.getX()); + attackBlock.setY(screenY + solidArea.getY()); + } + + public void changeHealthTo(int health) { + if (health>=maxHp) { + currentHealth = maxHp; + } + else if (health<=0) { + currentHealth = 0; + setDestroyed(true); + } + else { + currentHealth = health; +// System.out.println("Plathong" + currentHealth); + } + } + + public int getCurrentHealth() { + return currentHealth; + } + + // for Debugging + public void drawHitbox(GraphicsContext gc) { + gc.setLineWidth(2); + gc.setFill(Color.PINK); + gc.strokeRect(screenX, screenY, 32, 64); + } + + public void drawAttackBlock(GraphicsContext gc) { + gc.setFill(Color.BLACK); + gc.strokeRect(attackBlock.getX(), attackBlock.getY(), attackBlock.getWidth(), attackBlock.getHeight()); } } diff --git a/src/logic/entity/Entity.java b/src/logic/entity/Entity.java index 17fe2b4..2dab434 100644 --- a/src/logic/entity/Entity.java +++ b/src/logic/entity/Entity.java @@ -24,7 +24,7 @@ public Entity(int x, int y,GameLogic gameLogic){ this.direction = "right"; } - public abstract void attack(); + public abstract void attack(Entity t); public abstract void update(); public boolean canAttack(double x1,double y1,double x2,double y2,int attackRange) { @@ -88,4 +88,9 @@ public boolean isCollisionOn() { public void setCollisionOn(boolean collisionOn) { this.collisionOn = collisionOn; } + + public void setDestroyed(boolean destroyed) { + this.destroyed = destroyed; + } + } diff --git a/src/logic/entity/GriszlyEye.java b/src/logic/entity/GriszlyEye.java index 4707ef4..93972af 100644 --- a/src/logic/entity/GriszlyEye.java +++ b/src/logic/entity/GriszlyEye.java @@ -50,7 +50,7 @@ public void draw(GraphicsContext gc) { @Override - public void attack() { + public void attack(Entity p) { // TODO Auto-generated method stub } @@ -92,7 +92,7 @@ public void update() { else { currentState = "default"; - attack(); + attack(gameLogic.getPlayer()); } } diff --git a/src/logic/entity/MagicalTortoise.java b/src/logic/entity/MagicalTortoise.java index 28d12d3..c784edb 100644 --- a/src/logic/entity/MagicalTortoise.java +++ b/src/logic/entity/MagicalTortoise.java @@ -37,7 +37,7 @@ public void draw(GraphicsContext gc) { } @Override - public void attack() { + public void attack(Entity p) { // TODO Auto-generated method stub } diff --git a/src/logic/entity/Player.java b/src/logic/entity/Player.java index 2b65594..d12ad41 100644 --- a/src/logic/entity/Player.java +++ b/src/logic/entity/Player.java @@ -1,7 +1,5 @@ package logic.entity; - - import input.InputUtility; import javafx.scene.canvas.GraphicsContext; import javafx.scene.image.Image; @@ -9,19 +7,46 @@ import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import logic.game.GameLogic; +import sharedObject.IRenderable; import sharedObject.RenderableHolder; public class Player extends Entity{ - + + private String attackState = "no"; + + //Status Position + private int statusBarWidth = (int) (180*1.5); + private int statusBarHeight = (int) (38*2); + private int statusBarX = (int) (10*1.5); + private int statusBarY = (int) (10*1.5); + + //Bar Position + private int healthBarWidth = (int) (144*1.5); + private int healthBarHeight = (int) (4*2); + private int healthBarX = (int) (30*1.5); + private int healthBarY = (int) (11*1.5); + + //Status + protected int maxHp = 100; + protected int currentHealth = maxHp; + protected float healthWidth = healthBarWidth; + protected int dmg = 5; + protected int iframe = 0; + + //AttackBlock + private Rectangle attackBlock; + int counter; public Player(int x, int y,GameLogic gameLogic) { super(x,y,gameLogic); this.speed = 3; this.radius = 32; + screenX = gameLogic.getGameScreen().getWidth()/2-radius; screenY = gameLogic.getGameScreen().getHeight()/2-radius; - solidArea = new Rectangle(16,32,32,32); + initSolidArea(); + initAttackBlock(); } @Override public void draw(GraphicsContext gc) { @@ -38,13 +63,37 @@ public void draw(GraphicsContext gc) { } gc.drawImage(playerImage , screenX, screenY); + drawUI(gc); + + //Debugging + drawHitbox(gc, 44, 64); + drawAttackBlock(gc); + } + + public void drawHitbox(GraphicsContext gc,int width , int height) { + gc.setLineWidth(2); + gc.setFill(Color.PINK); + gc.strokeRect(screenX,screenY,width,height); } - public void attack() { + public void drawUI(GraphicsContext gc) { + gc.drawImage(RenderableHolder.healthBar, statusBarX, statusBarY, statusBarWidth, statusBarHeight); + gc.setFill(Color.BLACK); + gc.fillRect(healthBarX+statusBarX,healthBarY+statusBarY,healthWidth,healthBarHeight); + } + + public void drawAttackBlock(GraphicsContext gc){ + gc.setFill(Color.BLACK); + gc.strokeRect(attackBlock.getX(), attackBlock.getY(), attackBlock.getWidth(),attackBlock.getHeight()); + } + + public void attack(Entity enemy) { attackState = "yes"; + ((Chicknight)enemy).changeHealthTo(((Chicknight)enemy).getCurrentHealth()-dmg); + } - @Override + public void update() { // TODO Auto-generated method stub direction = ""; @@ -91,9 +140,73 @@ public void update() { } } if (InputUtility.isLeftClickTriggered()) { + for (Entity entity: gameLogic.getGameObjectContainer()) { + if ((entity instanceof Chicknight)) { + Chicknight enemy = ((Chicknight)entity); + boolean canAtk = canAttack(worldX,worldY,enemy.getWorldX(),enemy.getWorldY(),(int) (solidArea.getWidth()+attackBlock.getWidth())); + if (canAtk) { + attack(entity); + } + + } + } + + } + + updateHealthBar(); + updateAttackBlock(); + if(iframe>0)iframe--; + } + public void updateHealthBar() { + healthWidth = (float) (currentHealth/(float) maxHp) * healthBarWidth; +// healthWidth = (int) (0.5 * healthBarWidth); +// System.out.println(healthWidth); + } + + public void changeHealthTo(int health) { + if(iframe == 0){ + if (health>=maxHp) { + currentHealth = maxHp; + } + else if (health<=0) { + currentHealth = 0; +// GameOver(); + } + else { + currentHealth = health; + System.out.println("Plathong" + currentHealth); + } + iframe = 30; } - + + } + + public void initSolidArea() { + solidArea = new Rectangle(0,0,44,64); + } + + public void initAttackBlock() { + attackBlock = new Rectangle(worldX,worldY,20*2,20*2); + } + + public void updateAttackBlock() { + if (direction=="right") { + attackBlock.setX(screenX+(int)solidArea.getWidth()); +// attackBlock.setLayoutX(0); + }else if(direction=="left") { + attackBlock.setX(screenX+(int)solidArea.getWidth()-(int)(42d*2)); + } + attackBlock.setY(screenY+(int)(10*2)); + } + + public void GameOver() { + System.exit(0); + } + public int getCurrentHealth() { + return currentHealth; + } + public void setCurrentHealth(int currentHealth) { + this.currentHealth = currentHealth; } - } diff --git a/src/logic/field/Map1.java b/src/logic/field/Map1.java index 145e03b..119339e 100644 --- a/src/logic/field/Map1.java +++ b/src/logic/field/Map1.java @@ -1,7 +1,6 @@ package logic.field; import javafx.scene.canvas.GraphicsContext; -import javafx.scene.image.Image; import javafx.scene.image.WritableImage; import javafx.scene.shape.Rectangle; import logic.entity.Player; @@ -58,14 +57,14 @@ public int getTileIndex(int x, int y) { public int getZ() { return -9999; } + @Override public void draw(GraphicsContext gc) { double width = field[0].length*tileSize; double height = field.length*tileSize; int worldCol = 0; int worldRow = 0; - - gc.drawImage(RenderableHolder.moonSprite,500-gL.getPlayer().getWorldX() + gL.getPlayer().screenX,-500 - gL.getPlayer().getWorldY() + gL.getPlayer().screenY,500,500); + while (worldCol < field[0].length && worldRow < field.length) { int worldX = worldCol * tileSize; int worldY = worldRow * tileSize; diff --git a/src/logic/field/WhiteMap.java b/src/logic/field/WhiteMap.java new file mode 100644 index 0000000..cc0c07e --- /dev/null +++ b/src/logic/field/WhiteMap.java @@ -0,0 +1,32 @@ +package logic.field; + +import javafx.scene.canvas.GraphicsContext; +import sharedObject.IRenderable; + +public class WhiteMap implements IRenderable{ + + @Override + public int getZ() { + // TODO Auto-generated method stub + return -9999; + } + + @Override + public void draw(GraphicsContext gc) { + // TODO Auto-generated method stub + gc.fillRect(0, 0, 768, 576); + } + + @Override + public boolean isDestroyed() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isVisible() { + // TODO Auto-generated method stub + return true; + } + +} diff --git a/src/logic/game/GameLogic.java b/src/logic/game/GameLogic.java index 4592f62..affaa55 100644 --- a/src/logic/game/GameLogic.java +++ b/src/logic/game/GameLogic.java @@ -6,26 +6,27 @@ import drawing.GameScreen; import input.InputUtility; import javafx.scene.input.KeyCode; -import javafx.scene.paint.Color; import logic.entity.Chicknight; import logic.entity.Entity; import logic.entity.GriszlyEye; import logic.entity.MagicalTortoise; import logic.entity.Player; import logic.field.Map1; +import logic.field.WhiteMap; import sharedObject.RenderableHolder; public class GameLogic { - private List gameObjectContainer; + private ArrayList gameObjectContainer; private static int counter = 0; private GameScreen gameScreen; private Player player; - private GriszlyEye ge; private Chicknight ck1; - private MagicalTortoise mt; + private GriszlyEye GE1; + private MagicalTortoise MG; private Map1 map; + //GameState public int gameState = 1; public final int playState = 1; public final int pauseState = 2; @@ -37,13 +38,14 @@ public GameLogic(GameScreen gameScreen){ map = new Map1(this); RenderableHolder.getInstance().add(map); - ge = new GriszlyEye(200,200,this); - ck1 = new Chicknight(384,288,this); - mt = new MagicalTortoise(350,250,this); + + ck1 = new Chicknight(200,0,this); + MG = new MagicalTortoise(200,200,this); + GE1 = new GriszlyEye(200,200,this); addNewObject(player); addNewObject(ck1); - addNewObject(ge); - addNewObject(mt); + addNewObject(MG); + addNewObject(GE1); } public GameScreen getGameScreen() { @@ -113,12 +115,6 @@ public void checkTile(Entity entity) { } } - public void logicUpdate(){ - ck1.update(); - player.update(); - ge.update(); - mt.update(); - } public void update() { // System.out.println(gameState); @@ -132,6 +128,17 @@ else if (gameState == pauseState) { } } + public void logicUpdate(){ + if (counter == 60){ + counter = 0;} + ArrayList objectContainer = getGameObjectContainer(); + for (int i = 0 ;i getGameObjectContainer(){ + return gameObjectContainer; + } + } diff --git a/src/logic/weapon/BaseWeapon.java b/src/logic/weapon/BaseWeapon.java new file mode 100644 index 0000000..8a065d8 --- /dev/null +++ b/src/logic/weapon/BaseWeapon.java @@ -0,0 +1,5 @@ +package logic.weapon; + +public class BaseWeapon { + +} diff --git a/src/sharedObject/RenderableHolder.java b/src/sharedObject/RenderableHolder.java index 5622b72..4e03b82 100644 --- a/src/sharedObject/RenderableHolder.java +++ b/src/sharedObject/RenderableHolder.java @@ -23,10 +23,13 @@ public class RenderableHolder { public static Image pathTile; public static Image blackStarTile; public static Image blackTile; - public static Image CKLeft,CKLeftWalk1,CKLeftAtk,CKRight,CKRightWalk1,CKRightAtk; - public static Image GELeft,GELeftWalk,GELeftWalk2,GERight,GERightWalk,GERightWalk2; - public static Image MTLeft1,MTLeft2,MTRight1,MTRight2; + public static Image CKLeft, CKLeftWalk1, CKLeftWalk2, CKLeftAtk, CKRight, CKRightWalk1, CKRightWalk2, CKRightAtk; + public static Image pauseMenu, soundButton, urm, volumeButton; + public static Image GELeft, GELeftWalk, GELeftWalk2, GERight, GERightWalk, GERightWalk2; + public static Image MTLeft1, MTLeft2, MTRight1, MTRight2; public static Image moonSprite; + public static Image healthBar; + static { loadResource(); } @@ -45,47 +48,57 @@ public static RenderableHolder getInstance() { } public static void loadResource() { - //player's Resource playerLeft = new Image(ClassLoader.getSystemResource("player/RabbiLeft.png").toString()); playerRight = new Image(ClassLoader.getSystemResource("player/Rabbi.png").toString()); playerRightAtk = new Image(ClassLoader.getSystemResource("player/RabbiRightAtk.png").toString()); - + johnSprite = new Image(ClassLoader.getSystemResource("John.png").toString()); whiteTile = new Image(ClassLoader.getSystemResource("Tiles/WhiteTile.png").toString()); grayTile = new Image(ClassLoader.getSystemResource("Tiles/GrayTile.png").toString()); pathTile = new Image(ClassLoader.getSystemResource("Tiles/pathTile.png").toString()); blackStarTile = new Image(ClassLoader.getSystemResource("Tiles/blackStarTile.png").toString()); blackTile = new Image(ClassLoader.getSystemResource("Tiles/blackTile.png").toString()); - moonSprite = new Image(ClassLoader.getSystemResource("moon.png").toString()); - - //Chicknight's Resource + + // Chicknight's Resource CKLeft = new Image(ClassLoader.getSystemResource("Chicknight/ChicknightLeft.png").toString()); CKLeftWalk1 = new Image(ClassLoader.getSystemResource("Chicknight/ChicknightLeftWalk1.png").toString()); + CKLeftWalk2 = new Image(ClassLoader.getSystemResource("Chicknight/ChicknightLeftWalk2.png").toString()); CKLeftAtk = new Image(ClassLoader.getSystemResource("Chicknight/ChicknightLeftAtk.png").toString()); CKRight = new Image(ClassLoader.getSystemResource("Chicknight/ChicknightRight.png").toString()); CKRightWalk1 = new Image(ClassLoader.getSystemResource("Chicknight/ChicknightRightWalk1.png").toString()); + CKRightWalk2 = new Image(ClassLoader.getSystemResource("Chicknight/ChicknightRightWalk2.png").toString()); CKRightAtk = new Image(ClassLoader.getSystemResource("Chicknight/ChicknightRightAtk.png").toString()); - //GriszlyEye's Resource + // GriszlyEye's Resource GELeft = new Image(ClassLoader.getSystemResource("GriszlyEye/GriszlyEyeLeft.png").toString()); GELeftWalk = new Image(ClassLoader.getSystemResource("GriszlyEye/GriszlyEyeLeftWalk.png").toString()); GELeftWalk2 = new Image(ClassLoader.getSystemResource("GriszlyEye/GriszlyEyeLeftWalk2.png").toString()); GERight = new Image(ClassLoader.getSystemResource("GriszlyEye/GriszlyEyeRight.png").toString()); GERightWalk = new Image(ClassLoader.getSystemResource("GriszlyEye/GriszlyEyeRightWalk.png").toString()); GERightWalk2 = new Image(ClassLoader.getSystemResource("GriszlyEye/GriszlyEyeRightWalk2.png").toString()); - //MagicalTortoise + // MagicalTortoise MTLeft1 = new Image(ClassLoader.getSystemResource("MagicalTortoise/MagicalTortoiseLeft1.png").toString()); MTLeft2 = new Image(ClassLoader.getSystemResource("MagicalTortoise/MagicalTortoiseLeft2.png").toString()); MTRight1 = new Image(ClassLoader.getSystemResource("MagicalTortoise/MagicalTortoiseRight1.png").toString()); MTRight2 = new Image(ClassLoader.getSystemResource("MagicalTortoise/MagicalTortoiseRight2.png").toString()); + + // Pause + pauseMenu = new Image(ClassLoader.getSystemResource("pause/pause_menu.png").toString()); + soundButton = new Image(ClassLoader.getSystemResource("pause/sound_button.png").toString()); + urm = new Image(ClassLoader.getSystemResource("pause/urm_buttons.png").toString()); + volumeButton = new Image(ClassLoader.getSystemResource("pause/volume_buttons.png").toString()); + + // StatusBar + healthBar = new Image(ClassLoader.getSystemResource("health_power_bar.png").toString()); + } - + public void add(IRenderable entity) { System.out.println("add"); entities.add(entity); Collections.sort(entities, comparator); - for(IRenderable x: entities){ - - if(x instanceof Player) System.out.println("player"); - + for (IRenderable x : entities) { + if (x instanceof Player) + System.out.println("player"); + } }