Skip to content

Commit df76618

Browse files
committed
NPCs can now dive in lava
1 parent 5a115ce commit df76618

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/com/redomar/game/Game.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void setMap(String Map_str) {
131131

132132
public static void npcSpawn(){
133133
if(isNpc() == true){
134-
game.setDummy(new Dummy(Game.getLevel(), "h", 215, 215, 500, 543));
134+
game.setDummy(new Dummy(Game.getLevel(), "h", 215, 185, 500, 543));
135135
game.level.addEntity(Game.getDummy());
136136
}
137137
}

src/com/redomar/game/entities/Dummy.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ public void tick() {
3131
isSwimming = false;
3232
}
3333

34+
if (level.getTile(this.getX() >> 3, this.getY() >> 3).getId() == 12) {
35+
isMagma = true;
36+
}
37+
38+
if (isMagma && level.getTile(this.getX() >> 3, this.getY() >> 3).getId() != 12){
39+
isMagma = false;
40+
}
41+
3442
tickCount++;
3543

3644
}
@@ -76,12 +84,36 @@ public void render(Screen screen) {
7684
screen.render(xOffset + 8, yOffset + 3, 31 + 31 * 32, waterColour,
7785
0x01, 1);
7886
}
87+
88+
if (isMagma) {
89+
int waterColour = 0;
90+
yOffset += 4;
91+
92+
colour = Colours.get(-1, 111, -1, faceCol);
93+
94+
if (tickCount % 60 < 15) {
95+
waterColour = Colours.get(-1, -1, 541, -1);
96+
} else if (15 <= tickCount % 60 && tickCount % 60 < 30) {
97+
yOffset--;
98+
waterColour = Colours.get(-1, 521, 510, -1);
99+
} else if (30 <= tickCount % 60 && tickCount % 60 < 45) {
100+
waterColour = Colours.get(-1, 510, -1, 521);
101+
} else {
102+
yOffset--;
103+
waterColour = Colours.get(-1, -1, 521, 510);
104+
}
105+
106+
screen.render(xOffset, yOffset + 3, 31 + 31 * 32, waterColour,
107+
0x00, 1);
108+
screen.render(xOffset + 8, yOffset + 3, 31 + 31 * 32, waterColour,
109+
0x01, 1);
110+
}
79111

80112
screen.render((xOffset + (modifier * flipTop)), yOffset,
81113
(xTile + yTile * 32), colour, flipTop, scale);
82114
screen.render((xOffset + modifier - (modifier * flipTop)), yOffset,
83115
((xTile + 1) + yTile * 32), colour, flipTop, scale);
84-
if (!isSwimming) {
116+
if (!isSwimming && !isMagma) {
85117
screen.render((xOffset + (modifier * flipBottom)),
86118
(yOffset + modifier), (xTile + (yTile + 1) * 32), colour,
87119
flipBottom, scale);

0 commit comments

Comments
 (0)