Skip to content

Commit

Permalink
Laristic SpawnPoint of Enemy
Browse files Browse the repository at this point in the history
  • Loading branch information
GriszlyExe committed May 20, 2023
1 parent d53be4e commit c0b43a6
Show file tree
Hide file tree
Showing 56 changed files with 750 additions and 397 deletions.
Binary file modified res/.DS_Store
Binary file not shown.
Binary file modified 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/moleDerKaiserDead.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/normalMoleDead.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/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 modified 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 modified 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 modified 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/waterBottom.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/waterBottomLeft.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/waterBottomRight.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/waterEdge1.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/waterEdge2.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/waterEdge3.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/waterEdge4.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/waterLeft.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/waterRight.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/waterTop.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/waterTopLeft.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/waterTopRight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Binary file added res/other/Sword1.mp3
Binary file not shown.
Binary file added res/other/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.
Binary file added res/other/shoot1.mp3
Binary file not shown.
Binary file added res/player/playerLeft.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/player/playerLeftAtk.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/player/playerLeftWalk.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/player/playerRight.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/player/playerRightAtk.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/player/playerRightWalk.png
Binary file added res/sound/GriszlyEyeSound.wav
Binary file not shown.
Binary file added res/sound/IngameSong.wav
Binary file not shown.
Binary file added res/sound/chicknight.mp3
Binary file not shown.
Binary file added res/sound/monsterdie.wav
Binary file not shown.
Binary file added res/sound/npcSound.wav
Binary file not shown.
Binary file added res/sound/shootSound.mp3
Binary file not shown.
Binary file added res/sound/skill1.wav
Binary file not shown.
Binary file added res/sound/swing.mp3
Binary file not shown.
Binary file modified src/.DS_Store
Binary file not shown.
28 changes: 28 additions & 0 deletions src/Object/Ball.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package Object;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.shape.Rectangle;
import logic.game.GameLogic;
import sharedObject.RenderableHolder;

public class Ball extends Projectile{

public Ball(double worldX, double worldY, double angle, GameLogic gameLogic) {
super(worldX, worldY, angle, gameLogic);
speed = 3;
xspeed = Math.cos(angle) * speed;
yspeed = Math.sin(angle) * speed;
dmg = 10;
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);
}

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

}
41 changes: 11 additions & 30 deletions src/Object/Projectile.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,38 @@
import sharedObject.IRenderable;
import sharedObject.RenderableHolder;

public class Projectile implements IRenderable {
public abstract class Projectile implements IRenderable {

protected double worldX, worldY;
public double screenX, screenY;
private Rectangle solidArea,solidScreen;
private double angle;
private int dmg, speed;
protected Rectangle solidArea,solidScreen;
protected double angle;
protected int dmg, speed;
protected int z, radius;
protected boolean visible, destroyed;
public GameLogic gameLogic;
private double xspeed, yspeed;
protected 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 = 10;
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;
}
solidScreen = new Rectangle(screenX+solidArea.getX(),screenY+solidArea.getY(),solidArea.getWidth(),solidArea.getHeight());
checkEnemyHit();
}

Expand All @@ -57,15 +49,10 @@ public void checkEnemyHit() {
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) {
if (solidScreen.intersects(x,y,width,height)) {
p.changeHealthTo(p.getCurrentHealth() - dmg);
destroyed = true;
}
solidArea.setX(screenX);
solidArea.setY(screenY);
}

public Rectangle getSolidArea() {
Expand All @@ -78,13 +65,7 @@ public int getZ() {
return 0;
}

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

public abstract void draw(GraphicsContext gc);
@Override
public boolean isDestroyed() {
// TODO Auto-generated method stub
Expand All @@ -102,7 +83,7 @@ public boolean isVisible() {
public void drawHitbox(GraphicsContext gc) {
gc.setLineWidth(2);
gc.setFill(Color.RED);
gc.strokeRect(solidArea.getX(), solidArea.getY(), solidArea.getWidth(),
solidArea.getHeight());
gc.strokeRect(solidScreen.getX(), solidScreen.getY(), solidScreen.getWidth(),
solidScreen.getHeight());
}
}
}
30 changes: 30 additions & 0 deletions src/Object/SwordBeam.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package Object;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.shape.Rectangle;
import logic.game.GameLogic;
import sharedObject.RenderableHolder;

public class SwordBeam extends Projectile{

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

}
50 changes: 24 additions & 26 deletions src/logic/entity/Chicknight.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,28 @@ public void draw(GraphicsContext gc) {
// System.out.println(c);
switch (direction) {
case "right":
if (currentState == "attacking")
if (gameLogic.getCounter() / 10 % 2 == 1) {
image = RenderableHolder.CKRight;
} else {
if(canAttack)
image = RenderableHolder.CKRightAtk;
else
image =RenderableHolder.CKRightWalk1;
}

if (attackState)
image = RenderableHolder.CKRightAtk;
else {
image = RenderableHolder.CKRight;
image = RenderableHolder.CKRight;
if (currentState == "attacking") {
if (gameLogic.getCounter() / 10 % 2 == 1)
image = RenderableHolder.CKRightWalk1;
}
}
break;
case "left":
if (currentState == "attacking")
if (gameLogic.getCounter() / 10 % 2 == 1) {
image = RenderableHolder.CKLeft;
} else {
if(canAttack)
image = RenderableHolder.CKLeftAtk;
else
image =RenderableHolder.CKLeftWalk1;
}

if (attackState)
image = RenderableHolder.CKLeftAtk;
else {
image = RenderableHolder.CKLeft;
image = RenderableHolder.CKLeft;
if (currentState == "attacking") {
if (gameLogic.getCounter() / 10 % 2 == 1)
image = RenderableHolder.CKLeftWalk1;
}
}
break;

}

gc.drawImage(image, screenX, screenY);
Expand All @@ -79,11 +71,16 @@ public void update() {
(int) (32));
if (currentState == "attacking") {
if(canAttack) {
if(delay==0) {
attackState = true;
attack(gameLogic.getPlayer());
RenderableHolder.chicknightSound.play(0.2);
delay = 60;
}
}
else {
double xspeed = Math.cos(angle) * speed;
double yspeed = Math.sin(angle) * speed;
xspeed = Math.cos(angle) * speed;
yspeed = Math.sin(angle) * speed;


if (yspeed < 0)
Expand All @@ -108,7 +105,8 @@ public void update() {
worldX += xspeed;
}
}

if(delay==40) attackState = false;
if (delay>0) delay--;

}
updateAttackBlock();
Expand Down
14 changes: 6 additions & 8 deletions src/logic/entity/Enemy.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

public abstract class Enemy extends Entity{
protected double angle = 0;
protected String currentState = "default";
protected double delay = 0;
protected boolean canAttack;
protected double xspeed,yspeed;

Expand Down Expand Up @@ -48,7 +46,6 @@ public int getCurrentHealth() {

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);
}
Expand All @@ -63,7 +60,7 @@ public void drawHitbox(GraphicsContext gc) {

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

Expand All @@ -73,7 +70,6 @@ public void updateAttackBlock() {
else if (direction == "left")
attackBlock.setX(solidScreen.getX()+solidScreen.getWidth()-attackBlock.getWidth());
attackBlock.setY(screenY);

}

public void update() {
Expand All @@ -84,6 +80,9 @@ public void update() {
}

public void move() {
xspeed = Math.cos(angle) * speed;
yspeed = Math.sin(angle) * speed;

if (yspeed < 0)
direction = "up";
else
Expand All @@ -92,9 +91,8 @@ public void move() {
gameLogic.checkTile(this);
if (collisionOn == false) {
worldY += yspeed;

}

if (xspeed < 0)
direction = "left";
else
Expand Down Expand Up @@ -125,4 +123,4 @@ public boolean playerfound(int range) {

public abstract void initSolidArea();
public abstract void initAttackBlock();
}
}
3 changes: 3 additions & 0 deletions src/logic/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import sharedObject.IRenderable;

public abstract class Entity implements IRenderable {
protected boolean attackState = false;
protected double delay = 0;
protected double worldX, worldY;
public double screenX, screenY;
protected int z, radius;
Expand All @@ -16,6 +18,7 @@ public abstract class Entity implements IRenderable {
public Rectangle solidArea,solidScreen;
public boolean collisionOn = false;
public GameLogic gameLogic;
protected String currentState = "default";

// Status
protected int maxHp;
Expand Down
1 change: 1 addition & 0 deletions src/logic/entity/EyeOfQwifot.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void initAttackBlock() {
attackBlock = new Rectangle(0,0,0,0);
}

@Override
public void changeHealthTo(int health) {
if (health>=maxHp) {
currentHealth = maxHp;
Expand Down
1 change: 1 addition & 0 deletions src/logic/entity/GriszlyEye.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void update() {
}
if (delay ==30) {
speed = normalSpeed*3;
RenderableHolder.griszlyEyeSound.play(0.1);
xspeed = Math.cos(angle) * speed;
yspeed = Math.sin(angle) * speed;
}
Expand Down
Loading

0 comments on commit c0b43a6

Please sign in to comment.