Compare commits
6 Commits
1443722f0c
...
600a225064
| Author | SHA1 | Date | |
|---|---|---|---|
|
600a225064
|
|||
|
9916fa8b25
|
|||
|
285b18b4cc
|
|||
|
730c7d406e
|
|||
|
49c8b59d68
|
|||
|
5f9fd8ea99
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -30,3 +30,6 @@ bin/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
|
||||
### JPackage ###
|
||||
JGame2D
|
||||
@@ -3,6 +3,7 @@
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
||||
BIN
assets/interactive_tiles/destructiblewall.png
Normal file
BIN
assets/interactive_tiles/destructiblewall.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
BIN
assets/interactive_tiles/drytree.png
Normal file
BIN
assets/interactive_tiles/drytree.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.3 KiB |
BIN
assets/interactive_tiles/metalplate.png
Normal file
BIN
assets/interactive_tiles/metalplate.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 539 B |
BIN
assets/interactive_tiles/trunk.png
Normal file
BIN
assets/interactive_tiles/trunk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.0 KiB |
@@ -10,7 +10,7 @@
|
||||
12 12 12 12 12 12 18 41 40 39 39 39 40 41 41 41 41 41 41 41 10 17 12 12 12 18 10 41 41 41 41 41 41 41 31 26 26 26 26 26 26 30 17 12 12 12 12 12 12 12
|
||||
12 12 12 13 12 12 18 41 40 39 39 39 40 41 41 41 41 41 41 41 10 17 12 12 12 18 11 41 41 41 41 41 41 41 31 26 26 26 26 26 26 30 17 12 13 12 12 12 12 12
|
||||
12 12 12 12 13 12 18 41 40 39 39 39 40 41 41 41 41 41 41 41 10 19 20 20 20 21 10 41 41 41 41 41 41 41 31 26 26 26 26 26 26 30 17 12 12 12 12 12 12 12
|
||||
12 12 12 12 12 12 18 41 40 40 39 40 40 41 41 41 41 41 41 41 11 10 35 33 36 10 10 41 41 41 41 41 41 41 37 28 28 29 26 27 28 38 17 13 12 12 12 12 12 12
|
||||
12 12 12 12 12 12 18 41 40 40 39 40 40 41 41 41 41 41 41 41 11 10 35 33 36 10 10 10 10 10 10 10 10 10 37 28 28 29 26 27 28 38 17 13 12 12 12 12 12 12
|
||||
12 12 12 12 12 12 18 41 41 41 10 41 41 41 41 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 41 41 31 26 30 14 15 25 12 12 12 12 12 12 12
|
||||
12 12 12 12 13 12 18 41 41 41 10 41 41 41 41 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 41 41 31 26 30 17 12 12 12 12 13 12 12 12 12
|
||||
12 12 12 12 12 12 24 15 16 41 10 41 41 41 41 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 41 41 31 26 30 17 12 12 12 12 12 12 12 12 12
|
||||
|
||||
7
build.sh
Normal file
7
build.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
jpackage \
|
||||
--input out/artifacts/JGame2D_jar/ \
|
||||
--main-jar JGame2D.jar \
|
||||
--main-class de.miaurizius.jgame2d.core.Boot \
|
||||
--name JGame2D \
|
||||
--type app-image \
|
||||
--add-modules ALL-MODULE-PATH
|
||||
@@ -5,6 +5,7 @@ import de.miaurizius.jgame2d.core.handlers.*;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
import de.miaurizius.jgame2d.entity.Player;
|
||||
import de.miaurizius.jgame2d.tile.TileManager;
|
||||
import de.miaurizius.jgame2d.tile.interactive.InteractiveTile;
|
||||
|
||||
import javax.sound.sampled.Clip;
|
||||
import javax.swing.*;
|
||||
@@ -49,6 +50,7 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
public Entity[] obj = new Entity[20];
|
||||
public Entity[] npc = new Entity[10];
|
||||
public Entity[] monster = new Entity[20];
|
||||
public InteractiveTile[] iTile = new InteractiveTile[50];
|
||||
public ArrayList<Entity> projectileList = new ArrayList<>();
|
||||
ArrayList<Entity> entityList = new ArrayList<>();
|
||||
|
||||
@@ -120,6 +122,7 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
else projectileList.remove(i);
|
||||
}
|
||||
}
|
||||
for(Entity entity : iTile) if(entity != null) entity.update();
|
||||
break;
|
||||
case PAUSE:
|
||||
break;
|
||||
@@ -141,6 +144,7 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
|
||||
// GAME
|
||||
tileM.draw(graphics2d);
|
||||
for(Entity entity : iTile) if(entity != null) entity.draw(graphics2d);
|
||||
|
||||
// ENTITY RENDER SYSTEM
|
||||
entityList.add(player);
|
||||
@@ -196,6 +200,7 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
assetSetter.setObject();
|
||||
assetSetter.setNPC();
|
||||
assetSetter.setMonster();
|
||||
assetSetter.setITiles();
|
||||
gameState = GameState.TITLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.entity.item.*;
|
||||
import de.miaurizius.jgame2d.entity.npc.OldManNPC;
|
||||
import de.miaurizius.jgame2d.entity.monster.GreenSlimeMON;
|
||||
import de.miaurizius.jgame2d.tile.interactive.DryTreeTI;
|
||||
|
||||
public class AssetSetter {
|
||||
|
||||
@@ -74,4 +75,15 @@ public class AssetSetter {
|
||||
panel.monster[i].worldY = panel.tileSize*42;
|
||||
}
|
||||
|
||||
public void setITiles() {
|
||||
int i = 0;
|
||||
panel.iTile[i] = new DryTreeTI(panel,27,12);i++;
|
||||
panel.iTile[i] = new DryTreeTI(panel,28,12);i++;
|
||||
panel.iTile[i] = new DryTreeTI(panel,29,12);i++;
|
||||
panel.iTile[i] = new DryTreeTI(panel,30,12);i++;
|
||||
panel.iTile[i] = new DryTreeTI(panel,31,12);i++;
|
||||
panel.iTile[i] = new DryTreeTI(panel,32,12);i++;
|
||||
panel.iTile[i] = new DryTreeTI(panel,33,12);i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class Sound {
|
||||
load(8, "assets/sounds/levelup.wav");
|
||||
load(9, "assets/sounds/cursor.wav");
|
||||
load(10, "assets/sounds/burning.wav");
|
||||
load(11, "assets/sounds/cuttree.wav");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
||||
@@ -86,6 +86,7 @@ public class Entity {
|
||||
panel.collisionH.checkObject(this, false);
|
||||
panel.collisionH.checkEntity(this, panel.npc);
|
||||
panel.collisionH.checkEntity(this, panel.monster);
|
||||
panel.collisionH.checkEntity(this, panel.iTile);
|
||||
boolean contactPlayer = panel.collisionH.checkPlayer(this);
|
||||
|
||||
if(this.type == EntityType.MONSTER && contactPlayer) damagePlayer(attack);
|
||||
|
||||
@@ -79,6 +79,9 @@ public class Player extends Entity {
|
||||
int monsterIndex = panel.collisionH.checkEntity(this, panel.monster);
|
||||
interactMonster(monsterIndex);
|
||||
|
||||
// CHECK INTERACTIVE TILE COLLISION
|
||||
int iTileIndex = panel.collisionH.checkEntity(this, panel.iTile);
|
||||
|
||||
// CHECK EVENT
|
||||
panel.eventH.checkEvent();
|
||||
|
||||
@@ -181,6 +184,9 @@ public class Player extends Entity {
|
||||
int monsterIndex = panel.collisionH.checkEntity(this, panel.monster);
|
||||
damageMonster(monsterIndex, attack);
|
||||
|
||||
int iTileIndex = panel.collisionH.checkEntity(this, panel.iTile);
|
||||
interactTile(iTileIndex);
|
||||
|
||||
worldX = currentWorldX;
|
||||
worldY = currentWorldY;
|
||||
solidArea.width = solidAreaWidth;
|
||||
@@ -213,6 +219,14 @@ public class Player extends Entity {
|
||||
checkLevelUp();
|
||||
}
|
||||
}
|
||||
public void interactTile(int index) {
|
||||
if(index == 999 || !panel.iTile[index].destructible || panel.iTile[index].invincible) return;
|
||||
if(!panel.iTile[index].meetItemReq(this)) return;
|
||||
panel.iTile[index].playSE();
|
||||
panel.iTile[index].life--;
|
||||
panel.iTile[index].invincible = true;
|
||||
if(panel.iTile[index].life == 0) panel.iTile[index] = panel.iTile[index].getDestroyedForm();
|
||||
}
|
||||
|
||||
public void interactNPC(int index) {
|
||||
if(index == 999) return;
|
||||
|
||||
34
src/de/miaurizius/jgame2d/tile/interactive/DryTreeTI.java
Normal file
34
src/de/miaurizius/jgame2d/tile/interactive/DryTreeTI.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package de.miaurizius.jgame2d.tile.interactive;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
public class DryTreeTI extends InteractiveTile{
|
||||
|
||||
GamePanel panel;
|
||||
|
||||
public DryTreeTI(GamePanel panel, int col, int row) {
|
||||
super(panel, col, row);
|
||||
this.panel = panel;
|
||||
this.worldX = panel.tileSize * col;
|
||||
this.worldY = panel.tileSize * row;
|
||||
|
||||
down1 = initEntitySprites("/interactive_tiles/drytree");
|
||||
destructible = true;
|
||||
life = 3;
|
||||
}
|
||||
|
||||
// PRE_CONFIGURED
|
||||
public void playSE() {
|
||||
panel.playSE(11);
|
||||
}
|
||||
|
||||
// GETTERS
|
||||
public boolean meetItemReq(Entity entity) {
|
||||
return entity.currentWeapon.weaponType == EntityType.WeaponType.AXE;
|
||||
}
|
||||
public InteractiveTile getDestroyedForm() {
|
||||
return new TrunkIT(panel, worldX/panel.tileSize, worldY/panel.tileSize);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package de.miaurizius.jgame2d.tile.interactive;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
public class InteractiveTile extends Entity {
|
||||
|
||||
GamePanel panel;
|
||||
public boolean destructible;
|
||||
|
||||
public InteractiveTile(GamePanel panel, int col, int row) {
|
||||
super(panel);
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
// GENERAL
|
||||
public void update() {
|
||||
// INVINCIBLE COUNTER
|
||||
if(!invincible) return;
|
||||
invincibleCount++;
|
||||
if(invincibleCount > 20) {
|
||||
invincible = false;
|
||||
invincibleCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// PRE-CONFIGURED
|
||||
public void playSE() {}
|
||||
|
||||
// UTILITY
|
||||
public boolean meetItemReq(Entity entity) {
|
||||
return false;
|
||||
}
|
||||
public InteractiveTile getDestroyedForm() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
26
src/de/miaurizius/jgame2d/tile/interactive/TrunkIT.java
Normal file
26
src/de/miaurizius/jgame2d/tile/interactive/TrunkIT.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package de.miaurizius.jgame2d.tile.interactive;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
|
||||
public class TrunkIT extends InteractiveTile {
|
||||
|
||||
GamePanel panel;
|
||||
|
||||
public TrunkIT(GamePanel panel, int col, int row) {
|
||||
super(panel, col, row);
|
||||
this.panel = panel;
|
||||
|
||||
this.worldX = panel.tileSize * col;
|
||||
this.worldY = panel.tileSize * row;
|
||||
|
||||
down1 = initEntitySprites("/interactive_tiles/trunk");
|
||||
|
||||
solidArea.x = 0;
|
||||
solidArea.y = 0;
|
||||
solidArea.width = 0;
|
||||
solidArea.height = 0;
|
||||
solidAreaDefaultX = 0;
|
||||
solidAreaDefaultY = 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user