Skip to content

Commit 3294849

Browse files
committed
New objects, entities, new map.
1 parent f664dac commit 3294849

File tree

25 files changed

+748
-348
lines changed

25 files changed

+748
-348
lines changed

src/main/java/com/khomsi/game/entity/Entity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ public class Entity extends Tools {
114114
public static final int TYPE_OBSTACLE = 8;
115115
public static final int TYPE_LIGHT = 9;
116116
public static final int TYPE_HOOK = 10;
117-
118117
//TOOLS
119118
public int dialogueIndex = 0;
120119
public int dialogueSet = 0;
@@ -410,7 +409,6 @@ public void draw(Graphics2D graphics2D) {
410409
}
411410
}
412411

413-
414412
if (invincible) {
415413
hpBarOn = true;
416414
hpBarCounter = 0;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.khomsi.game.entity.npc.beach;
2+
3+
import com.khomsi.game.entity.Entity;
4+
import com.khomsi.game.main.GameManager;
5+
6+
import java.awt.*;
7+
8+
public class NpcRock extends Entity {
9+
public static final String NPC_NAME = "Rock";
10+
11+
public NpcRock(GameManager gameManager) {
12+
super(gameManager);
13+
direction = "down";
14+
speed = 3;
15+
name = NPC_NAME;
16+
17+
solidArea = new Rectangle();
18+
solidArea.x = 2;
19+
solidArea.y = 6;
20+
21+
solidAreaDefaultX = solidArea.x;
22+
solidAreaDefaultY = solidArea.y;
23+
//boundaries of npc
24+
solidArea.width = 44;
25+
solidArea.height = 40;
26+
dialogueSet = -1;
27+
28+
getImage();
29+
setDialog();
30+
}
31+
32+
@Override
33+
public void update() {
34+
}
35+
36+
public void getImage() {
37+
up = setup("/objects/Rock");
38+
up1 = setup("/objects/Rock");
39+
up2 = setup("/objects/Rock");
40+
up3 = setup("/objects/Rock");
41+
down = setup("/objects/Rock");
42+
down1 = setup("/objects/Rock");
43+
down2 = setup("/objects/Rock");
44+
down3 = setup("/objects/Rock");
45+
left = setup("/objects/Rock");
46+
left1 = setup("/objects/Rock");
47+
left2 = setup("/objects/Rock");
48+
left3 = setup("/objects/Rock");
49+
right = setup("/objects/Rock");
50+
right1 = setup("/objects/Rock");
51+
right2 = setup("/objects/Rock");
52+
right3 = setup("/objects/Rock");
53+
}
54+
55+
56+
private void setDialog() {
57+
dialogues[0][0] = "I'm just a rock.\nWhat do you want from me?";
58+
59+
dialogues[1][0] = "Uhh, how do I supposed to move it?\nIt's better come back later...";
60+
}
61+
62+
@Override
63+
public void setAction() {
64+
65+
}
66+
67+
@Override
68+
public void speak() {
69+
facePlayer();
70+
startDialogue(this, 0);
71+
}
72+
73+
@Override
74+
public void moveObj(String direction) {
75+
this.direction = direction;
76+
int itemIndex = gameManager.player.searchItemInventory("Magic Necklace");
77+
if (itemIndex != 999) {
78+
changeDirection(direction);
79+
} else {
80+
startDialogue(this, 1);
81+
}
82+
}
83+
}

src/main/java/com/khomsi/game/entity/npc/object/NpcRock.java renamed to src/main/java/com/khomsi/game/entity/npc/dungeon/NpcHeavyRock.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.khomsi.game.entity.npc.object;
1+
package com.khomsi.game.entity.npc.dungeon;
22

33
import com.khomsi.game.main.GameManager;
44
import com.khomsi.game.entity.Entity;
@@ -12,10 +12,10 @@
1212
import java.util.List;
1313
import java.util.stream.IntStream;
1414

15-
public class NpcRock extends Entity {
15+
public class NpcHeavyRock extends Entity {
1616
public static final String NPC_NAME = "Rock";
1717

18-
public NpcRock(GameManager gameManager) {
18+
public NpcHeavyRock(GameManager gameManager) {
1919
super(gameManager);
2020
direction = "down";
2121
speed = 4;
@@ -85,6 +85,7 @@ public void speak() {
8585
public void moveObj(String direction) {
8686
this.direction = direction;
8787
changeDirection(direction);
88+
8889
detectPlate();
8990
}
9091

@@ -96,7 +97,7 @@ public void detectPlate() {
9697
.toList();
9798

9899
List<Entity> rocks = Arrays.stream(gameManager.npcList[currentMap])
99-
.filter(NpcRock.class::isInstance)
100+
.filter(NpcHeavyRock.class::isInstance)
100101
.toList();
101102

102103
//Scan the plates
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.khomsi.game.entity.npc.dungeon;
2+
3+
import com.khomsi.game.entity.npc.beach.NpcRock;
4+
import com.khomsi.game.main.GameManager;
5+
6+
public class NpcRockMovable extends NpcRock {
7+
public NpcRockMovable(GameManager gameManager) {
8+
super(gameManager);
9+
}
10+
11+
@Override
12+
public void moveObj(String direction) {
13+
this.direction = direction;
14+
changeDirection(direction);
15+
}
16+
}

src/main/java/com/khomsi/game/entity/player/Player.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.khomsi.game.objects.equipment.MetalShieldObject;
77
import com.khomsi.game.objects.equipment.MetalSwordObject;
88
import com.khomsi.game.objects.interact.KeyObject;
9+
import com.khomsi.game.objects.interact.MagicNecklaceObject;
910
import com.khomsi.game.objects.projectTiles.FireBallObject;
1011

1112
import java.awt.*;
@@ -116,6 +117,7 @@ private void setItems() {
116117
inventory.add(currentWeapon);
117118
inventory.add(currentShield);
118119
inventory.add(new KeyObject(gameManager));
120+
inventory.add(new MagicNecklaceObject(gameManager));
119121
}
120122

121123
public int getCurrentWeaponSlot() {

src/main/java/com/khomsi/game/enviroment/Lightning.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void update() {
9090
//Check the state of the day
9191
if (dayState == DAY) {
9292
dayCounter++;
93-
if (dayCounter > 2200) {
93+
if (dayCounter > 3200) {
9494
dayState = NIGHTFALL;
9595
dayCounter = 0;
9696
}
@@ -104,7 +104,7 @@ public void update() {
104104
}
105105
if (dayState == NIGHT) {
106106
dayCounter++;
107-
if (dayCounter > 2200) {
107+
if (dayCounter > 3200) {
108108
dayState = DAWN;
109109
dayCounter = 0;
110110
}

src/main/java/com/khomsi/game/main/logic/CutSceneManager.java

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class CutSceneManager {
1313
Graphics2D g2d;
1414
public int sceneNumber;
1515
public int scenePhase;
16+
float alpha = 0.0F;
1617
//Scene number
1718
public static final int NA = 0;
1819
public static final int DUNGEON_BOSS = 1;
@@ -28,6 +29,123 @@ public void draw(Graphics2D g2d) {
2829
}
2930
}
3031

32+
/* public void scene_opening() {
33+
int pressEnterY = 520;
34+
String text;
35+
if (this.scenePhase == 0) {
36+
this.drawBlackBackground(1.0F);
37+
this.alpha += 0.005F;
38+
if (this.alpha > 1.0F) {
39+
this.alpha = 1.0F;
40+
}
41+
42+
text = "This is an island somewhere far away.\n\nBlue Boy, an aspiring adventurer, \ncomes to this island because he hears \nthat it holds a legendary treasure.\n\n\n\n\n";
43+
this.drawString(this.alpha, 35.0F, 170, text, 40);
44+
this.drawString(this.alpha, 35.0F, pressEnterY, "(Press Enter to continue)", 40);
45+
if (this.gameManager.keyHandler.isEnterPressed) {
46+
this.gameManager.keyHandler.isEnterPressed = false;
47+
++this.scenePhase;
48+
}
49+
}
50+
51+
if (this.scenePhase == 1) {
52+
this.drawBlackBackground(1.0F);
53+
this.alpha -= 0.02F;
54+
if (this.alpha < 0.0F) {
55+
this.alpha = 0.0F;
56+
++this.scenePhase;
57+
}
58+
59+
text = "This is an island somewhere far away.\n\nBlue Boy, an aspiring adventurer, \ncomes to this island because he hears \nthat it holds a legendary treasure.\n\n\n\n\n";
60+
this.drawString(this.alpha, 35.0F, 170, text, 40);
61+
this.drawString(this.alpha, 35.0F, pressEnterY, "(Press Enter to continue)", 40);
62+
}
63+
64+
if (this.scenePhase == 2) {
65+
this.drawBlackBackground(1.0F);
66+
this.alpha += 0.01F;
67+
if (this.alpha > 1.0F) {
68+
this.alpha = 1.0F;
69+
}
70+
71+
text = "Can he safely find the treasure on this island,\nwhere dangerous monsters roam?\n\nIt all depends on you.\n\n\n\n\n\n";
72+
this.drawString(this.alpha, 35.0F, 200, text, 40);
73+
this.drawString(this.alpha, 35.0F, pressEnterY, "(Press Enter to continue)", 40);
74+
if (this.gameManager.keyHandler.isEnterPressed) {
75+
this.gameManager.keyHandler.isEnterPressed = false;
76+
++this.scenePhase;
77+
}
78+
}
79+
80+
if (this.scenePhase == 3) {
81+
this.drawBlackBackground(1.0F);
82+
this.alpha -= 0.02F;
83+
if (this.alpha < 0.0F) {
84+
this.alpha = 0.0F;
85+
++this.scenePhase;
86+
}
87+
88+
text = "Can he safely find the treasure on this island,\nwhere dangerous monsters roam?\n\nIt all depends on you.\n\n\n\n\n";
89+
this.drawString(this.alpha, 35.0F, 200, text, 40);
90+
this.drawString(this.alpha, 35.0F, pressEnterY, "(Press Enter to continue)", 40);
91+
}
92+
93+
if (this.scenePhase == 4) {
94+
this.drawBlackBackground(1.0F);
95+
this.alpha += 0.005F;
96+
if (this.alpha > 1.0F) {
97+
this.alpha = 1.0F;
98+
}
99+
100+
this.drawString(this.alpha, 35.0F, 50, "<How to Play>", 40);
101+
text = "Move: [W/A/S/D]\nAttack/Interact/Confirm: [ENTER]\nMagic: [F]\nGuard/Parry: [SPACE]\nInventory/Status: [C]\nMap: [M] Mini Map: [X]\nPause: [P]\nOptions: [ESC]\n\n";
102+
this.drawString(this.alpha, 35.0F, 120, text, 45);
103+
this.drawString(this.alpha, 35.0F, pressEnterY, "(Press Enter to start the adventure)", 40);
104+
if (this.gameManager.keyHandler.isEnterPressed) {
105+
this.gameManager.keyHandler.isEnterPressed = false;
106+
++this.scenePhase;
107+
}
108+
}
109+
110+
if (this.scenePhase == 5) {
111+
this.gameManager.keyHandler.isEnterPressed = false;
112+
this.sceneNumber = 0;
113+
this.scenePhase = 0;
114+
GameManager var10000 = this.gameManager;
115+
this.gameManager.getClass();
116+
var10000.gameState = 1;
117+
this.gameManager.playMusic(0);
118+
}
119+
120+
}
121+
122+
public void drawBlackBackground(float alpha) {
123+
this.g2d.setComposite(AlphaComposite.getInstance(3, alpha));
124+
this.g2d.setColor(Color.black);
125+
Graphics2D var10000 = this.g2d;
126+
this.gameManager.getClass();
127+
this.gameManager.getClass();
128+
var10000.fillRect(0, 0, 960, 576);
129+
this.g2d.setComposite(AlphaComposite.getInstance(3, 1.0F));
130+
}
131+
132+
public void drawString(float alpha, float fontSize, int y, String text, int lineHeight) {
133+
this.g2d.setComposite(AlphaComposite.getInstance(3, alpha));
134+
this.g2d.setColor(Color.white);
135+
this.g2d.setFont(this.g2d.getFont().deriveFont(fontSize));
136+
String[] var9;
137+
int var8 = (var9 = text.split("\n")).length;
138+
139+
for (int var7 = 0; var7 < var8; ++var7) {
140+
String line = var9[var7];
141+
int x = this.gameManager.ui.getXCenterText(line);
142+
this.g2d.drawString(line, x, y);
143+
y += lineHeight;
144+
}
145+
146+
this.g2d.setComposite(AlphaComposite.getInstance(3, 1.0F));
147+
}*/
148+
31149
public void sceneDungeonBoss() {
32150
switch (scenePhase) {
33151
case 0 -> {

0 commit comments

Comments
 (0)