Skip to content

Commit

Permalink
Hi
Browse files Browse the repository at this point in the history
  • Loading branch information
GriszlyExe committed May 18, 2023
1 parent 40ac784 commit a63eac1
Show file tree
Hide file tree
Showing 24 changed files with 538 additions and 141 deletions.
Binary file added res/EyeOfQwifot/EyeOfQwifot1.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/EyeOfQwifot/EyeOfQwifot2.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/EyeOfQwifot/EyeOfQwifotDead1.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/EyeOfQwifot/EyeOfQwifotDead2.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/ShadowPot/ShadowPotLeft1.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/ShadowPot/ShadowPotLeft2.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/ShadowPot/ShadowPotLeftAtk.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/ShadowPot/ShadowPotRight1.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/ShadowPot/ShadowPotRight2.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/ShadowPot/ShadowPotRightAtk.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/ShadowPot/ball.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/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.
108 changes: 108 additions & 0 deletions src/Object/Projectile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package Object;

import javafx.scene.canvas.GraphicsContext;
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 class Projectile implements IRenderable {

protected double worldX, worldY;
public double screenX, screenY;
private Rectangle solidArea,solidScreen;
private double angle;
private int dmg, speed;
protected int z, radius;
protected boolean visible, destroyed;
public GameLogic gameLogic;
private double xspeed, yspeed;

public Projectile(double worldX, double worldY, double angle, GameLogic gameLogic) {
this.worldX = worldX;
this.worldY = worldY;
this.gameLogic = gameLogic;
this.angle = angle;
this.speed = 3;
this.z = 10;
this.visible = true;
this.destroyed = false;
this.xspeed = Math.cos(angle) * speed;
this.yspeed = Math.sin(angle) * speed;
this.dmg = 5;
solidArea = new Rectangle(0, 0, 8, 8);
solidScreen = new Rectangle(screenX,screenY,8,8);
}

public void update() {
worldX += xspeed;
worldY += yspeed;
screenX = worldX - gameLogic.getPlayer().getWorldX() + gameLogic.getPlayer().screenX;
screenY = worldY - gameLogic.getPlayer().getWorldY() + gameLogic.getPlayer().screenY;
solidArea.setX(screenX);
solidArea.setY(screenY);
// System.out.println("X =" + xspeed + " Y = " + yspeed);
boolean isOut = screenX < 0 || screenX > 1280 || screenY < 0 || screenY > 720;
if (isOut) {
destroyed = true;
}
checkEnemyHit();
}

public void checkEnemyHit() {
Player p =gameLogic.getPlayer();
int x = (int) p.getScreenX();
int y = (int) p.getScreenY();
int width = (int) p.getSolidArea().getWidth();
int height = (int) p.getSolidArea().getHeight();
boolean overlap = solidArea.intersects(x,y,width,height);
System.out.println("Overlap = " + overlap);
System.out.println("X = " + x + " Y = " + y);
if (overlap) {
p.changeHealthTo(p.getCurrentHealth() - dmg);
destroyed = true;
}
solidArea.setX(screenX);
solidArea.setY(screenY);
}

public Rectangle getSolidArea() {
return solidArea;
}

@Override
public int getZ() {
// TODO Auto-generated method stub
return 0;
}

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

@Override
public boolean isDestroyed() {
// TODO Auto-generated method stub

return destroyed;
}

@Override
public boolean isVisible() {
// TODO Auto-generated method stub
return visible;
}

// Debugger
public void drawHitbox(GraphicsContext gc) {
gc.setLineWidth(2);
gc.setFill(Color.RED);
gc.strokeRect(solidArea.getX(), solidArea.getY(), solidArea.getWidth(),
solidArea.getHeight());
}
}
74 changes: 10 additions & 64 deletions src/logic/entity/Chicknight.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,10 @@
import logic.game.GameLogic;
import sharedObject.RenderableHolder;

public class Chicknight extends Entity {
private double angle = 0;
public class Chicknight extends Enemy {
private Image image = RenderableHolder.CKRight;
private String currentState = "default";

// 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;
Expand Down Expand Up @@ -76,14 +66,7 @@ public void draw(GraphicsContext gc) {
drawAttackBlock(gc);
}

@Override
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() {
Expand Down Expand Up @@ -123,63 +106,26 @@ public void update() {
currentState = "attack";
attack(gameLogic.getPlayer());
}

solidArea.setX(screenX);
solidArea.setY(screenY);
updateAttackBlock();
}

public void initSolidArea() {
solidArea = new Rectangle(0, 0, 32, 64);
solidScreen = new Rectangle(screenX+solidArea.getX(),screenY+solidArea.getY(),8,8);
}

public void initAttackBlock() {
// screenX = worldX-gameLogic.getPlayer().worldX+gameLogic.getPlayer().screenX;
// screenY = worldY-gameLogic.getPlayer().worldY+gameLogic.getPlayer().screenY;
attackBlock = new Rectangle(screenX, screenY, 10 * 2, 7 * 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());
attackBlock = new Rectangle(screenX+solidArea.getWidth(), screenY, 10 * 2, 7 * 2);
}

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);
}

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


}
75 changes: 75 additions & 0 deletions src/logic/entity/Enemy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package logic.entity;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import logic.game.GameLogic;

public abstract class Enemy extends Entity{

protected double angle = 0;
protected String currentState;

public Enemy(int x, int y, GameLogic gameLogic) {
super(x, y, gameLogic);
// TODO Auto-generated constructor stub
}

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 boolean checkEnemyHit() {
Player p =gameLogic.getPlayer();
int x = (int) p.getScreenX();
int y = (int) p.getScreenY();
int width = (int) p.getSolidArea().getWidth();
int height = (int) p.getSolidArea().getHeight();
boolean overlap = solidArea.intersects(x,y,width,height);
// System.out.println("Overlap = " + overlap);
// System.out.println("X = " + x + " Y = " + y);
return overlap;

}

public int getCurrentHealth() {
return currentHealth;
}

public void attack(Entity p) {
// TODO Auto-generated method stub
System.out.println(this.getClass().getSimpleName()+"Attack");
if (checkEnemyHit()) ((Player) p).changeHealthTo(gameLogic.getPlayer().getCurrentHealth()-dmg);
}

//Debugger
public void drawHitbox(GraphicsContext gc) {
gc.setLineWidth(2);
gc.setFill(Color.PINK);
gc.strokeRect(solidScreen.getX(), solidScreen.getY(), solidArea.getWidth(), solidArea.getHeight());
}

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

public void updateAttackBlock() {
attackBlock.setX(screenX);
attackBlock.setY(screenY);
}

public abstract void update();
public abstract void initSolidArea();
public abstract void initAttackBlock();
}
45 changes: 28 additions & 17 deletions src/logic/entity/Entity.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
package logic.entity;

import javafx.scene.image.Image;
import javafx.scene.shape.Rectangle;
import logic.game.GameLogic;
import sharedObject.IRenderable;

public abstract class Entity implements IRenderable{
protected double worldX,worldY;
public double screenX,screenY;
protected int z,radius;
protected boolean visible,destroyed;
public abstract class Entity implements IRenderable {
protected double worldX, worldY;
public double screenX, screenY;
protected int z, radius;
protected boolean visible, destroyed;
protected int speed;
protected String direction;
public Rectangle solidArea;
protected Image image;
public Rectangle solidArea,solidScreen;
public boolean collisionOn = false;
public GameLogic gameLogic;

public Entity(int x, int y,GameLogic gameLogic){

// Status
protected int maxHp;
protected int currentHealth;
protected int dmg;

// AttackBlock
protected Rectangle attackBlock;

public Entity(int x, int y, GameLogic gameLogic) {
visible = true;
destroyed = false;
worldX = x;
worldY = y;
this.gameLogic = gameLogic;
this.direction = "right";
}

public abstract void attack(Entity t);

public abstract void update();
public boolean canAttack(double x1,double y1,double x2,double y2,int attackRange) {
return (Math.abs(x1-x2) < attackRange && Math.abs(y1-y2) < attackRange);

public boolean canAttack(double x1, double y1, double x2, double y2, int attackRange) {
return (Math.abs(x1 - x2) < attackRange && Math.abs(y1 - y2) < attackRange);
}

@Override
public int getZ() {
// TODO Auto-generated method stub
Expand All @@ -55,8 +66,8 @@ public double getWorldX() {

public double getWorldY() {
return worldY;
}
}

public String getDirection() {
return direction;
}
Expand Down Expand Up @@ -84,13 +95,13 @@ public Rectangle getSolidArea() {
public boolean isCollisionOn() {
return collisionOn;
}

public void setCollisionOn(boolean collisionOn) {
this.collisionOn = collisionOn;
}

public void setDestroyed(boolean destroyed) {
this.destroyed = destroyed;
}

}
Loading

0 comments on commit a63eac1

Please sign in to comment.