mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
Collision detector seems like fixed, it still may cause problems (e.g. sudden teleportation), camera position now clamps at tile index [1, width - 1]; "rim" is now not shown
Former-commit-id: 6a285ed713728601cf16435b258522ecc10448a8 Former-commit-id: 4e562028ab08e170461ec0938a1846bc66dbaeb2
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -37,8 +37,6 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
private final float VELO_HARD_LIMIT = 10000;
|
||||
|
||||
boolean grounded = false;
|
||||
boolean walledLeft = false;
|
||||
boolean walledRight = false;
|
||||
|
||||
SpriteAnimation sprite;
|
||||
@Nullable SpriteAnimation spriteGlow;
|
||||
@@ -57,7 +55,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 final float MASS_LOWEST = 2f;
|
||||
|
||||
private static final int TSIZE = MapDrawer.TILE_SIZE;
|
||||
private static int AUTO_CLIMB_RATE = TSIZE / 8;
|
||||
@@ -687,14 +685,6 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
return grounded;
|
||||
}
|
||||
|
||||
public boolean isWalledLeft() {
|
||||
return walledLeft;
|
||||
}
|
||||
|
||||
public boolean isWalledRight() {
|
||||
return walledRight;
|
||||
}
|
||||
|
||||
public int getBaseHitboxW() {
|
||||
return baseHitboxW;
|
||||
}
|
||||
|
||||
@@ -145,8 +145,6 @@ public class Game extends BasicGameState {
|
||||
|
||||
TileStat.update();
|
||||
|
||||
|
||||
|
||||
actorContainer.forEach(actor -> actor.update(gc, delta_t));
|
||||
actorContainer.forEach(
|
||||
actor -> {
|
||||
@@ -158,10 +156,7 @@ public class Game extends BasicGameState {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/** Placed before actor update to give some dynamic view of player on screen,
|
||||
* or else player will always stay same spot, which is somewhat dull.
|
||||
*/
|
||||
|
||||
MapDrawer.update(gc, delta_t);
|
||||
MapCamera.update(gc, delta_t);
|
||||
|
||||
|
||||
@@ -85,11 +85,11 @@ public class LightmapRenderer {
|
||||
}
|
||||
|
||||
|
||||
int for_y_start = div16(MapCamera.getCameraY());
|
||||
int for_x_start = div16(MapCamera.getCameraX());
|
||||
int for_y_start = div16(MapCamera.getCameraY()) - MUL;
|
||||
int for_x_start = div16(MapCamera.getCameraX()) - MUL;
|
||||
|
||||
int for_y_end = clampHTile(for_y_start + div16(MapCamera.getRenderHeight()) + 2);
|
||||
int for_x_end = clampWTile(for_x_start + div16(MapCamera.getRenderWidth()) + 2);
|
||||
int for_y_end = clampHTile(for_y_start + div16(MapCamera.getRenderHeight()) + 2) + MUL;
|
||||
int for_x_end = clampWTile(for_x_start + div16(MapCamera.getRenderWidth()) + 2) + MUL;
|
||||
|
||||
/**
|
||||
* Updating order:
|
||||
|
||||
@@ -137,14 +137,14 @@ public class MapCamera {
|
||||
renderHeight = FastMath.ceil(Terrarum.HEIGHT / Terrarum.game.screenZoom);
|
||||
|
||||
// position - (WH / 2)
|
||||
cameraX = clamp(
|
||||
Math.round(player.getHitbox().getCenteredX() - (renderWidth / 2))
|
||||
, map.width * TSIZE - renderWidth
|
||||
);
|
||||
cameraY = clamp(
|
||||
Math.round(player.getHitbox().getCenteredY() - (renderHeight / 2))
|
||||
, map.height * TSIZE - renderHeight
|
||||
);
|
||||
cameraX = Math.round(FastMath.clamp(
|
||||
player.getHitbox().getCenteredX() - (renderWidth / 2)
|
||||
, TSIZE, map.width * TSIZE - renderWidth - TSIZE
|
||||
));
|
||||
cameraY = Math.round(FastMath.clamp(
|
||||
player.getHitbox().getCenteredY() - (renderHeight / 2)
|
||||
, TSIZE, map.height * TSIZE - renderHeight - TSIZE
|
||||
));
|
||||
}
|
||||
|
||||
public static void renderBehind(GameContainer gc, Graphics g) {
|
||||
@@ -371,18 +371,6 @@ public class MapCamera {
|
||||
}
|
||||
}
|
||||
|
||||
public static int clamp(int x, int lim) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (x > lim) {
|
||||
return lim;
|
||||
}
|
||||
else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
private static Image getTileByIndex(SpriteSheet s, int i) {
|
||||
return s.getSprite(i % 16, i / 16);
|
||||
}
|
||||
|
||||
@@ -35,14 +35,14 @@ public class TileStat {
|
||||
int renderWidth = FastMath.ceil(Terrarum.WIDTH);
|
||||
int renderHeight = FastMath.ceil(Terrarum.HEIGHT);
|
||||
|
||||
int noZoomCameraX = MapCamera.clamp(
|
||||
Math.round(player.getHitbox().getPointedX() - (renderWidth / 2))
|
||||
, map.width * TSIZE - renderWidth
|
||||
);
|
||||
int noZoomCameraY = MapCamera.clamp(
|
||||
Math.round(player.getHitbox().getPointedY() - (renderHeight / 2))
|
||||
, map.height * TSIZE - renderHeight
|
||||
);
|
||||
int noZoomCameraX = Math.round(FastMath.clamp(
|
||||
player.getHitbox().getCenteredX() - (renderWidth / 2)
|
||||
, TSIZE, map.width * TSIZE - renderWidth - TSIZE
|
||||
));
|
||||
int noZoomCameraY = Math.round(FastMath.clamp(
|
||||
player.getHitbox().getCenteredY() - (renderHeight / 2)
|
||||
, TSIZE, map.height * TSIZE - renderHeight - TSIZE
|
||||
));
|
||||
|
||||
int for_x_start = MapCamera.div16(noZoomCameraX);
|
||||
int for_y_start = MapCamera.div16(noZoomCameraY);
|
||||
|
||||
Reference in New Issue
Block a user