fixed "jump to teleport to ceiling" and added some warning on the code comment

Former-commit-id: 985626c4d0b8d3a48182a2266835debb2abe8074
Former-commit-id: 8970c37017e4ae50ee1adb3973e65fcb0c1f0e45
This commit is contained in:
Song Minjae
2016-03-01 01:08:25 +09:00
parent ef44aae418
commit 9eb5b00a95
7 changed files with 50 additions and 37 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -57,6 +57,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
*/
private volatile float scale = 1;
private volatile float mass = 1f;
private final float MASS_LOWEST = Float.MIN_NORMAL;
private static final int TSIZE = MapDrawer.TILE_SIZE;
private static int AUTO_CLIMB_RATE = TSIZE / 8;
@@ -163,6 +164,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
/**
* Update variables
*/
if (mass < MASS_LOWEST) mass = MASS_LOWEST; // clamp to minimum possible mass
baseSpriteHeight = sprite.getHeight();
baseSpriteWidth = sprite.getWidth();
gravitation = Terrarum.game.map.getGravitation();
@@ -259,7 +261,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
}
private void adjustHitBottom() {
float newX = nextHitbox.getPointedX();
float newX = nextHitbox.getPointedX(); // look carefully, getPos or getPointed
// int-ify posY of nextHitbox
nextHitbox.setPositionYFromPoint( FastMath.floor(nextHitbox.getPointedY()) );
@@ -275,10 +277,10 @@ public class ActorWithBody implements Actor, Visible, Glowing {
nextHitbox.setPositionFromPoint(newX, newY + 1);
}
private void adjustHitTop() { // FIXME jump to teleport to ceiling
float newX = nextHitbox.getPointedX();
private void adjustHitTop() {
float newX = nextHitbox.getPosX();
// int-ify posY of nextHitbox
nextHitbox.setPositionY( FastMath.floor(nextHitbox.getPosY()) );
nextHitbox.setPositionY( FastMath.ceil(nextHitbox.getPosY()) );
int newYOff = 0; // always positive
@@ -289,7 +291,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
} while (colliding);
float newY = nextHitbox.getPosY() + newYOff;
nextHitbox.setPositionFromPoint(newX, newY - 1);
nextHitbox.setPosition(newX, newY - 1);
}
private void updateHorizontalPos() {

View File

@@ -150,24 +150,30 @@ public class LightmapRenderer {
if (Terrarum.game.screenZoom >= 1 && ((boolean) Terrarum.game.gameConfig.get("smoothlighting"))) {
char thisLightLevel = staticLightMap[y][x];
if (y > 0 && x < for_x_end && thisLightLevel == 0 && staticLightMap[y - 1][x] == 0) {
// coalesce zero intensity blocks to one
int zeroLevelCounter = 1;
while (staticLightMap[y][x + zeroLevelCounter] == 0
&& staticLightMap[y - 1][x + zeroLevelCounter] == 0) {
zeroLevelCounter += 1;
try {
// coalesce zero intensity blocks to one
int zeroLevelCounter = 1;
while (staticLightMap[y][x + zeroLevelCounter] == 0
&& staticLightMap[y - 1][x + zeroLevelCounter] == 0) {
zeroLevelCounter += 1;
if (x + zeroLevelCounter >= for_x_end) break;
if (x + zeroLevelCounter >= for_x_end) break;
}
g.setColor(new Color(0));
g.fillRect(
Math.round(x * TSIZE * Terrarum.game.screenZoom)
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
, FastMath.ceil(
TSIZE * Terrarum.game.screenZoom) * zeroLevelCounter
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
);
x += (zeroLevelCounter - 1);
}
catch (ArrayIndexOutOfBoundsException e) {
// do nothing
}
g.setColor(new Color(0));
g.fillRect(
Math.round(x * TSIZE * Terrarum.game.screenZoom)
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom) * zeroLevelCounter
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
);
x += (zeroLevelCounter - 1);
}
else {
/** a
@@ -216,25 +222,30 @@ public class LightmapRenderer {
}
// Retro
else {
int thisLightLevel = staticLightMap[y][x];
try {
int thisLightLevel = staticLightMap[y][x];
// coalesce identical intensity blocks to one
int sameLevelCounter = 1;
while (staticLightMap[y][x + sameLevelCounter] == thisLightLevel) {
sameLevelCounter += 1;
// coalesce identical intensity blocks to one
int sameLevelCounter = 1;
while (staticLightMap[y][x + sameLevelCounter] == thisLightLevel) {
sameLevelCounter += 1;
if (x + sameLevelCounter >= for_x_end) break;
if (x + sameLevelCounter >= for_x_end) break;
}
g.setColor(toTargetColour(staticLightMap[y][x]));
g.fillRect(
Math.round(x * TSIZE * Terrarum.game.screenZoom)
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom) * sameLevelCounter
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
);
x += (sameLevelCounter - 1);
}
catch (ArrayIndexOutOfBoundsException e) {
// do nothing
}
g.setColor(toTargetColour(staticLightMap[y][x]));
g.fillRect(
Math.round(x * TSIZE * Terrarum.game.screenZoom)
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom) * sameLevelCounter
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
);
x += (sameLevelCounter - 1);
}
}
}