added projectile system and sample fireball projectile
This commit is contained in:
@@ -7,6 +7,7 @@ import de.miaurizius.jgame2d.core.enums.GameState;
|
||||
import de.miaurizius.jgame2d.core.handlers.KeyHandler;
|
||||
import de.miaurizius.jgame2d.entity.item.ShieldWoodObj;
|
||||
import de.miaurizius.jgame2d.entity.item.SwordNormalObj;
|
||||
import de.miaurizius.jgame2d.entity.projectile.FireballObj;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -106,6 +107,12 @@ public class Player extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
if(panel.keyH.shotKeyPressed && !projectile.alive) {
|
||||
projectile.set(worldX, worldY, direction, true, this);
|
||||
panel.projectileList.add(projectile);
|
||||
panel.playSE(10);
|
||||
}
|
||||
|
||||
// INVINCIBLE COUNTER
|
||||
if(!invincible) return;
|
||||
invincibleCount++;
|
||||
@@ -130,8 +137,7 @@ public class Player extends Entity {
|
||||
|
||||
public void interactMonster(int index) {
|
||||
if(index == 999) return;
|
||||
if(invincible) return;
|
||||
if(panel.monster[index].dying || !panel.monster[index].alive) return;
|
||||
if(invincible || panel.monster[index].dying || !panel.monster[index].alive) return;
|
||||
|
||||
int damage = panel.monster[index].attack - defense;
|
||||
|
||||
@@ -163,7 +169,7 @@ public class Player extends Entity {
|
||||
solidArea.height = attackArea.height;
|
||||
|
||||
int monsterIndex = panel.collisionH.checkEntity(this, panel.monster);
|
||||
damageMonster(monsterIndex);
|
||||
damageMonster(monsterIndex, attack);
|
||||
|
||||
worldX = currentWorldX;
|
||||
worldY = currentWorldY;
|
||||
@@ -177,7 +183,7 @@ public class Player extends Entity {
|
||||
attacking = false;
|
||||
}
|
||||
}
|
||||
public void damageMonster(int index) {
|
||||
public void damageMonster(int index, int attack) {
|
||||
if(index == 999) return;
|
||||
if(panel.monster[index].invincible) return;
|
||||
|
||||
@@ -262,6 +268,7 @@ public class Player extends Entity {
|
||||
coins = 0;
|
||||
currentWeapon = new SwordNormalObj(panel);
|
||||
currentShield = new ShieldWoodObj(panel);
|
||||
projectile = new FireballObj(panel);
|
||||
attack = getAttack();
|
||||
defense = getDefense();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user