added concept for monsters
BIN
assets/monster/bat_down_1.png
Normal file
|
After Width: | Height: | Size: 156 B |
BIN
assets/monster/bat_down_2.png
Normal file
|
After Width: | Height: | Size: 156 B |
BIN
assets/monster/greenslime_down_1.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
assets/monster/greenslime_down_2.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/monster/orc_attack_down_1.png
Normal file
|
After Width: | Height: | Size: 360 B |
BIN
assets/monster/orc_attack_down_2.png
Normal file
|
After Width: | Height: | Size: 417 B |
BIN
assets/monster/orc_attack_left_1.png
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
assets/monster/orc_attack_left_2.png
Normal file
|
After Width: | Height: | Size: 336 B |
BIN
assets/monster/orc_attack_right_1.png
Normal file
|
After Width: | Height: | Size: 330 B |
BIN
assets/monster/orc_attack_right_2.png
Normal file
|
After Width: | Height: | Size: 345 B |
BIN
assets/monster/orc_attack_up_1.png
Normal file
|
After Width: | Height: | Size: 354 B |
BIN
assets/monster/orc_attack_up_2.png
Normal file
|
After Width: | Height: | Size: 396 B |
BIN
assets/monster/orc_down_1.png
Normal file
|
After Width: | Height: | Size: 330 B |
BIN
assets/monster/orc_down_2.png
Normal file
|
After Width: | Height: | Size: 360 B |
BIN
assets/monster/orc_left_1.png
Normal file
|
After Width: | Height: | Size: 273 B |
BIN
assets/monster/orc_left_2.png
Normal file
|
After Width: | Height: | Size: 324 B |
BIN
assets/monster/orc_right_1.png
Normal file
|
After Width: | Height: | Size: 282 B |
BIN
assets/monster/orc_right_2.png
Normal file
|
After Width: | Height: | Size: 315 B |
BIN
assets/monster/orc_up_1.png
Normal file
|
After Width: | Height: | Size: 312 B |
BIN
assets/monster/orc_up_2.png
Normal file
|
After Width: | Height: | Size: 288 B |
BIN
assets/monster/redslime_down_1.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/monster/redslime_down_2.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
assets/monster/skeletonlord_attack_down_1.png
Normal file
|
After Width: | Height: | Size: 538 B |
BIN
assets/monster/skeletonlord_attack_down_2.png
Normal file
|
After Width: | Height: | Size: 551 B |
BIN
assets/monster/skeletonlord_attack_left_1.png
Normal file
|
After Width: | Height: | Size: 521 B |
BIN
assets/monster/skeletonlord_attack_left_2.png
Normal file
|
After Width: | Height: | Size: 545 B |
BIN
assets/monster/skeletonlord_attack_right_1.png
Normal file
|
After Width: | Height: | Size: 506 B |
BIN
assets/monster/skeletonlord_attack_right_2.png
Normal file
|
After Width: | Height: | Size: 517 B |
BIN
assets/monster/skeletonlord_attack_up_1.png
Normal file
|
After Width: | Height: | Size: 548 B |
BIN
assets/monster/skeletonlord_attack_up_2.png
Normal file
|
After Width: | Height: | Size: 517 B |
BIN
assets/monster/skeletonlord_down_1.png
Normal file
|
After Width: | Height: | Size: 551 B |
BIN
assets/monster/skeletonlord_down_2.png
Normal file
|
After Width: | Height: | Size: 528 B |
BIN
assets/monster/skeletonlord_left_1.png
Normal file
|
After Width: | Height: | Size: 443 B |
BIN
assets/monster/skeletonlord_left_2.png
Normal file
|
After Width: | Height: | Size: 495 B |
BIN
assets/monster/skeletonlord_phase2_attack_down_1.png
Normal file
|
After Width: | Height: | Size: 569 B |
BIN
assets/monster/skeletonlord_phase2_attack_down_2.png
Normal file
|
After Width: | Height: | Size: 567 B |
BIN
assets/monster/skeletonlord_phase2_attack_left_1.png
Normal file
|
After Width: | Height: | Size: 540 B |
BIN
assets/monster/skeletonlord_phase2_attack_left_2.png
Normal file
|
After Width: | Height: | Size: 549 B |
BIN
assets/monster/skeletonlord_phase2_attack_right_1.png
Normal file
|
After Width: | Height: | Size: 506 B |
BIN
assets/monster/skeletonlord_phase2_attack_right_2.png
Normal file
|
After Width: | Height: | Size: 538 B |
BIN
assets/monster/skeletonlord_phase2_attack_up_1.png
Normal file
|
After Width: | Height: | Size: 548 B |
BIN
assets/monster/skeletonlord_phase2_attack_up_2.png
Normal file
|
After Width: | Height: | Size: 517 B |
BIN
assets/monster/skeletonlord_phase2_down_1.png
Normal file
|
After Width: | Height: | Size: 569 B |
BIN
assets/monster/skeletonlord_phase2_down_2.png
Normal file
|
After Width: | Height: | Size: 548 B |
BIN
assets/monster/skeletonlord_phase2_left_1.png
Normal file
|
After Width: | Height: | Size: 464 B |
BIN
assets/monster/skeletonlord_phase2_left_2.png
Normal file
|
After Width: | Height: | Size: 520 B |
BIN
assets/monster/skeletonlord_phase2_right_1.png
Normal file
|
After Width: | Height: | Size: 466 B |
BIN
assets/monster/skeletonlord_phase2_right_2.png
Normal file
|
After Width: | Height: | Size: 522 B |
BIN
assets/monster/skeletonlord_phase2_up_1.png
Normal file
|
After Width: | Height: | Size: 532 B |
BIN
assets/monster/skeletonlord_phase2_up_2.png
Normal file
|
After Width: | Height: | Size: 557 B |
BIN
assets/monster/skeletonlord_right_1.png
Normal file
|
After Width: | Height: | Size: 448 B |
BIN
assets/monster/skeletonlord_right_2.png
Normal file
|
After Width: | Height: | Size: 506 B |
BIN
assets/monster/skeletonlord_up_1.png
Normal file
|
After Width: | Height: | Size: 532 B |
BIN
assets/monster/skeletonlord_up_2.png
Normal file
|
After Width: | Height: | Size: 557 B |
@@ -48,6 +48,7 @@ public class GamePanel extends JPanel implements Runnable {
|
|||||||
public Player player = new Player(this, keyH);
|
public Player player = new Player(this, keyH);
|
||||||
public Entity[] obj = new Entity[10];
|
public Entity[] obj = new Entity[10];
|
||||||
public Entity[] npc = new Entity[10];
|
public Entity[] npc = new Entity[10];
|
||||||
|
public Entity[] monster = new Entity[20];
|
||||||
ArrayList<Entity> entityList = new ArrayList<>();
|
ArrayList<Entity> entityList = new ArrayList<>();
|
||||||
|
|
||||||
// GAME STATE
|
// GAME STATE
|
||||||
@@ -64,7 +65,7 @@ public class GamePanel extends JPanel implements Runnable {
|
|||||||
public void setupGame() {
|
public void setupGame() {
|
||||||
assetSetter.setObject();
|
assetSetter.setObject();
|
||||||
assetSetter.setNPC();
|
assetSetter.setNPC();
|
||||||
//playMusic(0); //Play main theme
|
assetSetter.setMonster();
|
||||||
gameState = GameState.TITLE;
|
gameState = GameState.TITLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +108,7 @@ public class GamePanel extends JPanel implements Runnable {
|
|||||||
case PLAY:
|
case PLAY:
|
||||||
player.update();
|
player.update();
|
||||||
for(Entity entity : npc) if(entity != null) entity.update();
|
for(Entity entity : npc) if(entity != null) entity.update();
|
||||||
|
for(Entity entity : monster) if(entity != null) entity.update();
|
||||||
break;
|
break;
|
||||||
case PAUSE:
|
case PAUSE:
|
||||||
break;
|
break;
|
||||||
@@ -134,6 +136,7 @@ public class GamePanel extends JPanel implements Runnable {
|
|||||||
entityList.add(player);
|
entityList.add(player);
|
||||||
for(Entity entity : npc) if(entity != null) entityList.add(entity);
|
for(Entity entity : npc) if(entity != null) entityList.add(entity);
|
||||||
for(Entity entity : obj) if(entity != null) entityList.add(entity);
|
for(Entity entity : obj) if(entity != null) entityList.add(entity);
|
||||||
|
for(Entity entity : monster) if(entity != null) entityList.add(entity);
|
||||||
entityList.sort(Comparator.comparingInt(o -> o.worldY));
|
entityList.sort(Comparator.comparingInt(o -> o.worldY));
|
||||||
for(Entity entity : entityList) entity.draw(graphics2d);
|
for(Entity entity : entityList) entity.draw(graphics2d);
|
||||||
entityList.clear();
|
entityList.clear();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package de.miaurizius.jgame2d.core.handlers;
|
|||||||
|
|
||||||
import de.miaurizius.jgame2d.core.GamePanel;
|
import de.miaurizius.jgame2d.core.GamePanel;
|
||||||
import de.miaurizius.jgame2d.entity.OldManNPC;
|
import de.miaurizius.jgame2d.entity.OldManNPC;
|
||||||
|
import de.miaurizius.jgame2d.entity.monster.GreenSlimeMON;
|
||||||
import de.miaurizius.jgame2d.entity.objects.DoorObj;
|
import de.miaurizius.jgame2d.entity.objects.DoorObj;
|
||||||
|
|
||||||
public class AssetSetter {
|
public class AssetSetter {
|
||||||
@@ -14,14 +15,6 @@ public class AssetSetter {
|
|||||||
|
|
||||||
public void setObject() {
|
public void setObject() {
|
||||||
|
|
||||||
panel.obj[0] = new DoorObj(panel);
|
|
||||||
panel.obj[0].worldX = panel.tileSize*21;
|
|
||||||
panel.obj[0].worldY = panel.tileSize*22;
|
|
||||||
|
|
||||||
panel.obj[1] = new DoorObj(panel);
|
|
||||||
panel.obj[1].worldX = panel.tileSize*23;
|
|
||||||
panel.obj[1].worldY = panel.tileSize*25;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNPC() {
|
public void setNPC() {
|
||||||
@@ -30,4 +23,14 @@ public class AssetSetter {
|
|||||||
panel.npc[0].worldY = panel.tileSize*21;
|
panel.npc[0].worldY = panel.tileSize*21;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMonster() {
|
||||||
|
panel.monster[0] = new GreenSlimeMON(panel);
|
||||||
|
panel.monster[0].worldX = panel.tileSize*23;
|
||||||
|
panel.monster[0].worldY = panel.tileSize*36;
|
||||||
|
|
||||||
|
panel.monster[1] = new GreenSlimeMON(panel);
|
||||||
|
panel.monster[1].worldX = panel.tileSize*23;
|
||||||
|
panel.monster[1].worldY = panel.tileSize*37;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
51
src/de/miaurizius/jgame2d/entity/monster/GreenSlimeMON.java
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package de.miaurizius.jgame2d.entity.monster;
|
||||||
|
|
||||||
|
import de.miaurizius.jgame2d.core.GamePanel;
|
||||||
|
import de.miaurizius.jgame2d.core.enums.Direction;
|
||||||
|
import de.miaurizius.jgame2d.entity.Entity;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class GreenSlimeMON extends Entity {
|
||||||
|
|
||||||
|
public GreenSlimeMON(GamePanel panel) {
|
||||||
|
super(panel);
|
||||||
|
name = "green-slime";
|
||||||
|
speed = 1;
|
||||||
|
maxLife = 4;
|
||||||
|
life = maxLife;
|
||||||
|
|
||||||
|
solidArea.x = 3;
|
||||||
|
solidArea.y = 18;
|
||||||
|
solidArea.width = 42;
|
||||||
|
solidArea.height = 30;
|
||||||
|
solidAreaDefaultX = solidArea.x;
|
||||||
|
solidAreaDefaultY = solidArea.y;
|
||||||
|
|
||||||
|
getImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getImage() {
|
||||||
|
up1 = initEntitySprites("monster/greenslime_down_1");
|
||||||
|
up2 = initEntitySprites("monster/greenslime_down_2");
|
||||||
|
down1 = initEntitySprites("monster/greenslime_down_1");
|
||||||
|
down2 = initEntitySprites("monster/greenslime_down_2");
|
||||||
|
left1 = initEntitySprites("monster/greenslime_down_1");
|
||||||
|
left2 = initEntitySprites("monster/greenslime_down_2");
|
||||||
|
right1 = initEntitySprites("monster/greenslime_down_1");
|
||||||
|
right2 = initEntitySprites("monster/greenslime_down_2");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction() {
|
||||||
|
actionLock++;
|
||||||
|
if(actionLock != 120) return; //lock action for x frames
|
||||||
|
Random rand = new Random();
|
||||||
|
int i = rand.nextInt(100)+1; //Generate number between 1 and 100
|
||||||
|
if(i <= 25) direction = Direction.UP;
|
||||||
|
if(i > 25 && i <= 50) direction = Direction.DOWN;
|
||||||
|
if(i > 50 && i <= 75) direction = Direction.LEFT;
|
||||||
|
if(i > 75) direction = Direction.RIGHT;
|
||||||
|
actionLock = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,6 +10,13 @@ public class DoorObj extends Entity {
|
|||||||
name = "door";
|
name = "door";
|
||||||
down1 = initEntitySprites("objects/door");
|
down1 = initEntitySprites("objects/door");
|
||||||
collision = true;
|
collision = true;
|
||||||
|
|
||||||
|
solidArea.x = 0;
|
||||||
|
solidArea.y = 16;
|
||||||
|
solidArea.width = 48;
|
||||||
|
solidArea.height = 32;
|
||||||
|
solidAreaDefaultX = solidArea.x;
|
||||||
|
solidAreaDefaultY = solidArea.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||