Skip to content

Commit

Permalink
fix Hitbox
Browse files Browse the repository at this point in the history
  • Loading branch information
GriszlyExe committed May 18, 2023
1 parent a06c4c5 commit 40ac784
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 10 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added res/pause/PauseOverlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/drawing/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
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 logic.game.GameLogic;
import sharedObject.IRenderable;
import sharedObject.RenderableHolder;
Expand Down Expand Up @@ -77,6 +79,11 @@ public void paintComponent() {
}
}

public void drawGamePauseOverlay() {
GraphicsContext gc = this.getGraphicsContext2D();
gc.drawImage(RenderableHolder.pauseOverlay, 480, 252 );
}

public GameScreen getGameScreen() {
return this;
}
Expand Down
6 changes: 3 additions & 3 deletions src/logic/entity/Chicknight.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ public void update() {
}

public void initSolidArea() {
solidArea = new Rectangle(16, 0, 32, 64);
solidArea = new Rectangle(0, 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);
attackBlock = new Rectangle(screenX, screenY, 10 * 2, 7 * 2);
// attackOffset = (int)(*2);
}

Expand Down Expand Up @@ -179,7 +179,7 @@ public void drawHitbox(GraphicsContext gc) {

public void drawAttackBlock(GraphicsContext gc) {
gc.setFill(Color.BLACK);
gc.strokeRect(attackBlock.getX(), attackBlock.getY(), attackBlock.getWidth(), attackBlock.getHeight());
gc.strokeRect(attackBlock.getX()+solidArea.getWidth(), attackBlock.getY(), attackBlock.getWidth(), attackBlock.getHeight());
}

}
4 changes: 2 additions & 2 deletions src/logic/entity/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ else if (health<=0) {
}

public void initSolidArea() {
solidArea = new Rectangle(0,0,44,64);
solidArea = new Rectangle(0,0,32,64);
}

public void initAttackBlock() {
Expand All @@ -195,7 +195,7 @@ public void updateAttackBlock() {
attackBlock.setX(screenX+(int)solidArea.getWidth());
// attackBlock.setLayoutX(0);
}else if(direction=="left") {
attackBlock.setX(screenX+(int)solidArea.getWidth()-(int)(42d*2));
attackBlock.setX(screenX+(int)solidArea.getWidth()-(int)(30*2));
}
attackBlock.setY(screenY+(int)(10*2));
}
Expand Down
5 changes: 5 additions & 0 deletions src/logic/entity/ShadowPot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package logic.entity;

public class ShadowPot {

}
2 changes: 2 additions & 0 deletions src/logic/game/GameLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import drawing.GameScreen;
import input.InputUtility;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.KeyCode;
import logic.entity.Chicknight;
import logic.entity.Entity;
Expand Down Expand Up @@ -159,6 +160,7 @@ public void checkGameState() {

if(gameState == playState) {
gameState = pauseState;
gameScreen.drawGamePauseOverlay();
}
else if (gameState == pauseState) {
gameState = playState;
Expand Down
11 changes: 6 additions & 5 deletions src/sharedObject/RenderableHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RenderableHolder {
public static Image blackStarTile;
public static Image blackTile;
public static Image CKLeft, CKLeftWalk1, CKLeftWalk2, CKLeftAtk, CKRight, CKRightWalk1, CKRightWalk2, CKRightAtk;
public static Image pauseMenu, soundButton, urm, volumeButton;
public static Image pauseOverlay,pauseMenu, soundButton, urm, volumeButton;
public static Image GELeft, GELeftWalk, GELeftWalk2, GERight, GERightWalk, GERightWalk2;
public static Image MTLeft1, MTLeft2, MTRight1, MTRight2;
public static Image moonSprite;
Expand Down Expand Up @@ -81,10 +81,11 @@ public static void loadResource() {
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());
pauseOverlay = new Image(ClassLoader.getSystemResource("pause/PauseOverlay.png").toString());
// pauseMenu = new Image(ClassLoader.getSystemResource("pause/.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());
Expand Down

0 comments on commit 40ac784

Please sign in to comment.