invisible wall for ActorWithBoby to prevent ArrayIndexException, faction system documentation, actor value: new boolean type, improvement on wall drawing
Former-commit-id: 6f90894a004acea32ef9361dbbece06a9b1db26a Former-commit-id: 80757a7d641eac3687e552f657a0dee5692e6cf8
BIN
out/production/Terrarum_renewed/com/Torvald/JsonGetter.class
Normal file
BIN
res/graphics/terrain/terrain.png
Executable file → Normal file
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 24 KiB |
BIN
res/graphics/terrain/terrain_old.png
Executable file
|
After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 90 KiB |
BIN
res/graphics/terrain/wall.png
Executable file → Normal file
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
BIN
res/graphics/terrain/wall_old.png
Executable file
|
After Width: | Height: | Size: 29 KiB |
@@ -4,15 +4,15 @@
|
||||
"baseheight" : 40,
|
||||
"basemass" : 60.0,
|
||||
|
||||
"toolsize" : 15,
|
||||
|
||||
"strength" : 1000,
|
||||
"strengthvariable" : [100,100,100,100,100,100,100],
|
||||
|
||||
"accel" : 0.2,
|
||||
|
||||
"speed" : 3.0,
|
||||
"speedvariable" : [100,100,100,100,100,100,100],
|
||||
|
||||
"jumppower" : 6.0,
|
||||
"jumppower" : 5.5,
|
||||
"jumppowervariable" : [100,100,100,100,100,100,100],
|
||||
|
||||
"scale" : 1,
|
||||
@@ -21,10 +21,12 @@
|
||||
"speed" : 2.0,
|
||||
"speedvariable" : [100,100,100,100,100,100,100],
|
||||
|
||||
"jump" : 5.5,
|
||||
"jumpvariable" : [100,100,100,100,100,100,100],
|
||||
"physiquemult" : [100,100,100,100,100,100,100],
|
||||
|
||||
"encumbrance" : 1000,
|
||||
"basedefence" : "work in progress"
|
||||
"basedefence" : "work in progress",
|
||||
|
||||
"toolsize" : 15,
|
||||
"intelligent" : true
|
||||
|
||||
}
|
||||
8
res/raw/FactionGenericPlayer.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"factionname" : "player",
|
||||
|
||||
"factionamicable" : ["follower"],
|
||||
"factionneutral" : [],
|
||||
"factionhostile" : ["wildlifehostile"],
|
||||
"factionfearful" : ["wildlifeflee"]
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"factionname" : "sigrid",
|
||||
|
||||
"factionamicable" : ["follower"],
|
||||
"factionneutral" : ["controlledvillager"],
|
||||
"factionneutral" : ["controlledvillager", "wildhamletcontroller"],
|
||||
"factionhostile" : ["wildlifehostile"],
|
||||
"factionfearful" : ["peasant", "wildlifeflee"]
|
||||
"factionfearful" : ["wildhamletvillager", "wildlifeflee"]
|
||||
}
|
||||
35
res/raw/Faction_doc.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"factionname" : "player",
|
||||
|
||||
"factionamicable" : ["follower"],
|
||||
"factionneutral" : [],
|
||||
"factionhostile" : ["wildlifehostile"],
|
||||
"factionfearful" : ["wildlifeflee"]
|
||||
}
|
||||
|
||||
factionname : Identifier of the faction data
|
||||
|
||||
factionamicable : Amicable faction. Players can give/take items of actors of this faction, in plus
|
||||
to the ability of trading. Assigned actors (usually follower) will follow players
|
||||
in game.
|
||||
|
||||
factionneutral : Explicit neutrality. If the assigned actor is intelligent (NPC AV), players can
|
||||
trade with them. Unassigned faction will be treated like neutral, but players can
|
||||
not make any trade with them.
|
||||
|
||||
factionhostile : Assigned faction will attack players on the sight. e.g. 'wildlifehostile'
|
||||
|
||||
factionfearful : Assigned faction will flee from players on the sight. e.g. 'wildlifeflee'
|
||||
|
||||
|
||||
|
||||
|
||||
== Generic faction information ==
|
||||
|
||||
* player : Self-explanatory
|
||||
* follower : Self-explanatory
|
||||
* controlledvillager : Villagers of your hamlet
|
||||
* wildlifehostile : Hostile mobs, self-explanatory
|
||||
* wildlifeflee : Fleeing mobs, self-explanatory
|
||||
* wildhamletvillager : Generic villager of the pre-generated hamlets.
|
||||
* wildhamletcontroller : Ruler of the pre-generated hamlets.
|
||||
@@ -158,24 +158,16 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
if (!playerNoClip()) {
|
||||
updateNextHitboxY();
|
||||
updateVerticalPos();
|
||||
clampNextHitbox();
|
||||
updateHitboxY();
|
||||
|
||||
updateNextHitboxX();
|
||||
updateHorizontalPos();
|
||||
clampNextHitbox();
|
||||
updateHitboxX();
|
||||
}
|
||||
|
||||
/**
|
||||
* clamp position
|
||||
*/
|
||||
hitbox.setPositionFromPoint(
|
||||
clampW(hitbox.getPointedX())
|
||||
, clampH(hitbox.getPointedY())
|
||||
);
|
||||
nextHitbox.setPositionFromPoint(
|
||||
clampW(nextHitbox.getPointedX())
|
||||
, clampH(nextHitbox.getPointedY())
|
||||
);
|
||||
clampHitbox();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,22 +445,30 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
; i < Math.round((side % 2 == 0) ? nextHitbox.getWidth() : nextHitbox.getHeight())
|
||||
; i++) {
|
||||
// set tile positions
|
||||
int tileX = 0, tileY = 0;
|
||||
int tileX, tileY;
|
||||
if (side == CONTACT_AREA_BOTTOM) {
|
||||
tileX = div16(Math.round(nextHitbox.getHitboxStart().getX()) + i + translateX);
|
||||
tileY = div16(FastMath.floor(nextHitbox.getHitboxEnd().getY()) + translateY);
|
||||
tileX = div16TruncateToMapWidth(Math.round(nextHitbox.getHitboxStart().getX())
|
||||
+ i + translateX);
|
||||
tileY = div16TruncateToMapHeight(FastMath.floor(nextHitbox.getHitboxEnd().getY())
|
||||
+ translateY);
|
||||
}
|
||||
else if (side == CONTACT_AREA_TOP) {
|
||||
tileX = div16(Math.round(nextHitbox.getHitboxStart().getX()) + i + translateX);
|
||||
tileY = div16(FastMath.ceil(nextHitbox.getHitboxStart().getY()) + translateY);
|
||||
tileX = div16TruncateToMapWidth(Math.round(nextHitbox.getHitboxStart().getX())
|
||||
+ i + translateX);
|
||||
tileY = div16TruncateToMapHeight(FastMath.ceil(nextHitbox.getHitboxStart().getY())
|
||||
+ translateY);
|
||||
}
|
||||
else if (side == CONTACT_AREA_RIGHT) {
|
||||
tileX = div16(FastMath.floor(nextHitbox.getHitboxEnd().getX()) + translateX);
|
||||
tileY = div16(Math.round(nextHitbox.getHitboxStart().getY()) + i + translateY);
|
||||
tileX = div16TruncateToMapWidth(FastMath.floor(nextHitbox.getHitboxEnd().getX())
|
||||
+ translateX);
|
||||
tileY = div16TruncateToMapHeight(Math.round(nextHitbox.getHitboxStart().getY())
|
||||
+ i + translateY);
|
||||
}
|
||||
else if (side == CONTACT_AREA_LEFT) {
|
||||
tileX = div16(FastMath.ceil(nextHitbox.getHitboxStart().getX()) + translateX);
|
||||
tileY = div16(Math.round(nextHitbox.getHitboxStart().getY()) + i + translateY);
|
||||
tileX = div16TruncateToMapWidth(FastMath.ceil(nextHitbox.getHitboxStart().getX())
|
||||
+ translateX);
|
||||
tileY = div16TruncateToMapHeight(Math.round(nextHitbox.getHitboxStart().getY())
|
||||
+ i + translateY);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(String.valueOf(side) + ": Wrong side input");
|
||||
@@ -483,6 +483,20 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
return contactAreaCounter;
|
||||
}
|
||||
|
||||
private void clampHitbox() {
|
||||
hitbox.setPositionFromPoint(
|
||||
clampW(hitbox.getPointedX())
|
||||
, clampH(hitbox.getPointedY())
|
||||
);
|
||||
}
|
||||
|
||||
private void clampNextHitbox() {
|
||||
nextHitbox.setPositionFromPoint(
|
||||
clampW(nextHitbox.getPointedX())
|
||||
, clampH(nextHitbox.getPointedY())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGlow(GameContainer gc, Graphics g) {
|
||||
if (visible && spriteGlow != null) {
|
||||
@@ -553,31 +567,31 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
public float topLeftPosX() { return hitbox.getPosX(); }
|
||||
public float topLeftPosY() { return hitbox.getPosY(); }
|
||||
|
||||
private static float clampW(float x) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
private float clampW(float x) {
|
||||
if (x < TSIZE + nextHitbox.getWidth() / 2) {
|
||||
return TSIZE + nextHitbox.getWidth() / 2;
|
||||
}
|
||||
else if (x >= Terrarum.game.map.width * TSIZE) {
|
||||
return Terrarum.game.map.width * TSIZE - 1;
|
||||
else if (x >= Terrarum.game.map.width * TSIZE - TSIZE - nextHitbox.getWidth() / 2) {
|
||||
return Terrarum.game.map.width * TSIZE - 1 - TSIZE - nextHitbox.getWidth() / 2;
|
||||
}
|
||||
else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
private static float clampH(float x) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
private float clampH(float y) {
|
||||
if (y < TSIZE + nextHitbox.getHeight()) {
|
||||
return TSIZE + nextHitbox.getHeight();
|
||||
}
|
||||
else if (x >= Terrarum.game.map.height * TSIZE) {
|
||||
return Terrarum.game.map.height * TSIZE - 1;
|
||||
else if (y >= Terrarum.game.map.height * TSIZE - TSIZE - nextHitbox.getHeight()) {
|
||||
return Terrarum.game.map.height * TSIZE - 1 - TSIZE - nextHitbox.getHeight();
|
||||
}
|
||||
else {
|
||||
return x;
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
||||
private static int clampWtile(int x) {
|
||||
private int clampWtile(int x) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -589,7 +603,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
}
|
||||
}
|
||||
|
||||
private static int clampHtile(int x) {
|
||||
private int clampHtile(int x) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -606,13 +620,25 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
}
|
||||
|
||||
private static int div16(int x) {
|
||||
if (x < 0) { throw new IllegalArgumentException("div16: Positive integer only:"
|
||||
if (x < 0) { throw new IllegalArgumentException("div16: Positive integer only: "
|
||||
+ String.valueOf(x)); }
|
||||
return (x & 0x7FFF_FFFF) >> 4;
|
||||
}
|
||||
|
||||
private static int div16TruncateToMapWidth(int x) {
|
||||
if (x < 0) return 0;
|
||||
else if (x >= Terrarum.game.map.width << 4) return Terrarum.game.map.width - 1;
|
||||
else return (x & 0x7FFF_FFFF) >> 4;
|
||||
}
|
||||
|
||||
private static int div16TruncateToMapHeight(int y) {
|
||||
if (y < 0) return 0;
|
||||
else if (y >= Terrarum.game.map.height << 4) return Terrarum.game.map.height - 1;
|
||||
else return (y & 0x7FFF_FFFF) >> 4;
|
||||
}
|
||||
|
||||
private static int mod16(int x) {
|
||||
if (x < 0) { throw new IllegalArgumentException("mod16: Positive integer only:"
|
||||
if (x < 0) { throw new IllegalArgumentException("mod16: Positive integer only: "
|
||||
+ String.valueOf(x)); }
|
||||
return x & 0b1111;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.Torvald.Terrarum.Actors;
|
||||
import com.Torvald.JsonGetter;
|
||||
import com.Torvald.Rand.Fudge3;
|
||||
import com.Torvald.Rand.HQRNG;
|
||||
import com.Torvald.Terrarum.LangPack.Lang;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.newdawn.slick.SlickException;
|
||||
@@ -24,32 +25,43 @@ public class CreatureBuildFactory {
|
||||
|
||||
|
||||
String[] elementsString = {
|
||||
"racename"
|
||||
"racename"
|
||||
, "racenameplural"
|
||||
};
|
||||
|
||||
String[] elementsFloat = {
|
||||
"baseheight"
|
||||
"baseheight"
|
||||
, "basemass"
|
||||
, "accel"
|
||||
, "toolsize"
|
||||
, "encumbrance"
|
||||
};
|
||||
|
||||
String[] elementsFloatVariable = {
|
||||
"baseheight"
|
||||
, "strength"
|
||||
"strength"
|
||||
, "speed"
|
||||
, "jumppower"
|
||||
, "scale"
|
||||
, "speed"
|
||||
, "jump"
|
||||
};
|
||||
|
||||
String[] elementsBoolean = {
|
||||
"intelligent"
|
||||
};
|
||||
|
||||
String[] elementsMultiplyFromOne = {
|
||||
"physiquemult"
|
||||
};
|
||||
|
||||
|
||||
setAVStrings(actor, elementsString, jsonObj);
|
||||
setAVFloats(actor, elementsFloat, jsonObj);
|
||||
setAVFloatsVariable(actor, elementsFloatVariable, jsonObj);
|
||||
setAVMultiplyFromOne(actor, elementsMultiplyFromOne, jsonObj);
|
||||
setAVBooleans(actor, elementsBoolean, jsonObj);
|
||||
|
||||
actor.actorValue.set("accel", Player.WALK_ACCEL_BASE);
|
||||
actor.actorValue.set("accelmult", 1f);
|
||||
|
||||
actor.inventory = new ActorInventory((int) actor.actorValue.get("encumberance"), true);
|
||||
|
||||
@@ -84,7 +96,8 @@ public class CreatureBuildFactory {
|
||||
*/
|
||||
private void setAVStrings(ActorWithBody p, String[] elemSet, JsonObject jsonObject) {
|
||||
for (String s : elemSet) {
|
||||
p.actorValue.set(s, jsonObject.get(s).getAsString());
|
||||
String key = jsonObject.get(s).getAsString();
|
||||
p.actorValue.set(s, Lang.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,4 +112,30 @@ public class CreatureBuildFactory {
|
||||
p.actorValue.set(s, jsonObject.get(s).getAsFloat());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and set actor values that should multiplier be applied to the base value of 1.
|
||||
* E.g. physiquemult
|
||||
* @param p
|
||||
* @param elemSet
|
||||
* @param jsonObject
|
||||
*/
|
||||
private void setAVMultiplyFromOne(ActorWithBody p, String[] elemSet, JsonObject jsonObject) {
|
||||
for (String s : elemSet) {
|
||||
float baseValue = 1f;
|
||||
// roll fudge dice and get value [-3, 3] as [0, 6]
|
||||
int varSelected = new Fudge3().create(new HQRNG()).roll() + 3;
|
||||
// get multiplier from json. Assuming percentile
|
||||
int multiplier = jsonObject.get(s).getAsJsonArray().get(varSelected).getAsInt();
|
||||
float realValue = baseValue * multiplier / 100f;
|
||||
|
||||
p.actorValue.set(s, realValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAVBooleans(ActorWithBody p, String[] elemSet, JsonObject jsonObject) {
|
||||
for (String s : elemSet) {
|
||||
p.actorValue.set(s, jsonObject.get(s).getAsBoolean());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class PBFSigrid {
|
||||
p.actorValue.set("scale", 1.0f);
|
||||
p.actorValue.set("speed", 4.0f);
|
||||
p.actorValue.set("speedmult", 1.0f);
|
||||
p.actorValue.set("accel", p.WALK_ACCEL_BASE);
|
||||
p.actorValue.set("accel", Player.WALK_ACCEL_BASE);
|
||||
p.actorValue.set("accelmult", 1.0f);
|
||||
|
||||
p.actorValue.set("jumppower", 6.5f);
|
||||
@@ -52,9 +52,11 @@ public class PBFSigrid {
|
||||
|
||||
p.actorValue.set("name", "Sigrid");
|
||||
|
||||
p.actorValue.set("intelligent", true);
|
||||
|
||||
p.setHitboxDimension(17, 47, 9, 0);
|
||||
|
||||
p.inventory = new ActorInventory((int) p.actorValue.get("encumbrance"), true);
|
||||
p.inventory = new ActorInventory(0x7FFFFFFF, true);
|
||||
|
||||
p.setPosition(4096 * 16, 300 * 16);
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
private int prevVMoveKey = -1;
|
||||
private final int KEY_NULL = -1;
|
||||
|
||||
final float ACCEL_MULT_IN_FLIGHT = 0.45f;
|
||||
final float WALK_STOP_ACCEL = 0.2f;
|
||||
final float WALK_ACCEL_BASE = 0.2f;
|
||||
static final float ACCEL_MULT_IN_FLIGHT = 0.45f;
|
||||
static final float WALK_STOP_ACCEL = 0.2f;
|
||||
static final float WALK_ACCEL_BASE = 0.2f;
|
||||
|
||||
private boolean noClip = false;
|
||||
|
||||
public final long PLAYER_REF_ID = 0x51621D;
|
||||
public static final long PLAYER_REF_ID = 0x51621D;
|
||||
|
||||
private final float AXIS_POSMAX = 1.0f;
|
||||
private final int GAMEPAD_JUMP = 5;
|
||||
|
||||
@@ -29,8 +29,12 @@ public class GetAV implements ConsoleCommand {
|
||||
printUsage();
|
||||
}
|
||||
else if (args.length == 2) {
|
||||
echo.execute("player." + args[1] + ": "
|
||||
echo.execute("player." + args[1] + " = "
|
||||
+ Terrarum.game.getPlayer().getActorValue().get(args[1])
|
||||
+ " ("
|
||||
+ Terrarum.game.getPlayer().getActorValue().get(args[1]).getClass()
|
||||
.getSimpleName()
|
||||
+ ")"
|
||||
);
|
||||
}
|
||||
else if (args.length == 3) {
|
||||
|
||||
@@ -29,7 +29,16 @@ class SetAV implements ConsoleCommand {
|
||||
|
||||
try { val = new Float(args[2]); } // try for number
|
||||
catch (NumberFormatException e) {
|
||||
val = new String(args[2]); // string if not number
|
||||
|
||||
if (args[2].toLowerCase() == "true") {
|
||||
val = new Boolean(true);
|
||||
}
|
||||
else if (args[2].toLowerCase() == "false") {
|
||||
val = new Boolean(false);
|
||||
}
|
||||
else {
|
||||
val = new String(args[2]); // string if not number
|
||||
}
|
||||
}
|
||||
|
||||
Terrarum.game.getPlayer().getActorValue().set(args[1], val);
|
||||
|
||||
@@ -33,6 +33,10 @@ public class GameMap {
|
||||
|
||||
public LinkedList<MapPoint> houseDesignation;
|
||||
|
||||
public static final int WALL = 0;
|
||||
public static final int TERRAIN = 1;
|
||||
public static final int WIRE = 2;
|
||||
|
||||
//public World physWorld = new World( new Vec2(0, -TerrarumMain.game.gravitationalAccel) );
|
||||
//physics
|
||||
@NotNull
|
||||
@@ -114,6 +118,13 @@ public class GameMap {
|
||||
return uint8ToInt32(layerWire.data[y][x]);
|
||||
}
|
||||
|
||||
public int getTileFrom(int mode, int x, int y) {
|
||||
if (mode == TERRAIN) { return getTileFromTerrain(x, y); }
|
||||
else if (mode == WALL) { return getTileFromWall(x, y); }
|
||||
else if (mode == WIRE) { return getTileFromWire(x, y); }
|
||||
else throw new IllegalArgumentException("illegal mode input: " + String.valueOf(mode));
|
||||
}
|
||||
|
||||
private int uint8ToInt32(byte x) {
|
||||
int ret;
|
||||
if ((x & 0b1000_0000) != 0) {
|
||||
|
||||
@@ -29,9 +29,9 @@ public class MapCamera {
|
||||
|
||||
private static SpriteSheet[] tilesetBook;
|
||||
|
||||
private static final int WALL = 0;
|
||||
private static final int TERRAIN = 1;
|
||||
private static final int WIRE = 2;
|
||||
private static final int WALL = GameMap.WALL;
|
||||
private static final int TERRAIN = GameMap.TERRAIN;
|
||||
private static final int WIRE = GameMap.WIRE;
|
||||
|
||||
private static int renderWidth;
|
||||
private static int renderHeight;
|
||||
@@ -114,7 +114,7 @@ public class MapCamera {
|
||||
, TSIZE
|
||||
);
|
||||
|
||||
tilesTerrain = new SpriteSheet("./res/graphics/terrain/terrainplusplus.png"
|
||||
tilesTerrain = new SpriteSheet("./res/graphics/terrain/terrain.png"
|
||||
, TSIZE
|
||||
, TSIZE
|
||||
);
|
||||
@@ -124,7 +124,7 @@ public class MapCamera {
|
||||
, TSIZE
|
||||
);
|
||||
|
||||
tilesetBook = new SpriteSheet[9];
|
||||
tilesetBook = new SpriteSheet[3];
|
||||
tilesetBook[WALL] = tilesWall;
|
||||
tilesetBook[TERRAIN] = tilesTerrain;
|
||||
tilesetBook[WIRE] = tilesWire;
|
||||
@@ -188,7 +188,7 @@ public class MapCamera {
|
||||
|
||||
(
|
||||
( // wall and not blocked
|
||||
(mode == WALL) && (!isOpaque(thisTerrainTile))
|
||||
(mode == WALL) && isWallThatBeDrawn(x, y)
|
||||
)
|
||||
||
|
||||
(mode == TERRAIN)
|
||||
@@ -205,48 +205,43 @@ public class MapCamera {
|
||||
// check if light level of this tile is zero, for y = 0
|
||||
((y == 0)
|
||||
&& (LightmapRenderer.getValueFromMap(x, y) > 0)
|
||||
))
|
||||
) {
|
||||
))) {
|
||||
|
||||
if (mode == TERRAIN) {
|
||||
int nearbyTilesInfo;
|
||||
//if (thisTile == DIRT) {
|
||||
// nearbyTilesInfo = getGrassInfo(x, y, GRASS);
|
||||
//}
|
||||
//else {
|
||||
// nearbyTilesInfo = getNearbyTilesInfo(x, y, AIR);
|
||||
//}
|
||||
int nearbyTilesInfo;
|
||||
//if (thisTile == DIRT) {
|
||||
// nearbyTilesInfo = getGrassInfo(x, y, GRASS);
|
||||
//}
|
||||
//else {
|
||||
// nearbyTilesInfo = getNearbyTilesInfo(x, y, AIR);
|
||||
//}
|
||||
|
||||
if (isDarkenAir((byte) thisTile)) {
|
||||
nearbyTilesInfo = getNearbyTilesInfo(x, y, AIR);
|
||||
}
|
||||
else if (isConnectSelf((byte) thisTile)) {
|
||||
nearbyTilesInfo = getNearbyTilesInfo(x, y, thisTile);
|
||||
}
|
||||
else {
|
||||
nearbyTilesInfo = 0;
|
||||
}
|
||||
if (isDarkenAir((byte) thisTile)) {
|
||||
nearbyTilesInfo = getNearbyTilesInfo(x, y, mode, AIR);
|
||||
}
|
||||
else if (isConnectSelf((byte) thisTile)) {
|
||||
nearbyTilesInfo = getNearbyTilesInfo(x, y, mode, thisTile);
|
||||
}
|
||||
else {
|
||||
nearbyTilesInfo = 0;
|
||||
}
|
||||
|
||||
|
||||
int thisTileX = nearbyTilesInfo;
|
||||
int thisTileY = thisTile;
|
||||
int thisTileX = nearbyTilesInfo;
|
||||
int thisTileY = thisTile;
|
||||
|
||||
if (drawModeTilesBlendMul) {
|
||||
if (isBlendMul((byte) thisTile)) drawTile(TERRAIN, x, y, thisTileX, thisTileY);
|
||||
}
|
||||
else {
|
||||
// currently it draws all the transparent tile and colour mixes
|
||||
// on top of the previously drawn tile
|
||||
// TODO check wether it works as intended when skybox is dark
|
||||
// add instruction "if (!isBlendMul((byte) thisTile))"
|
||||
drawTile(TERRAIN, x, y, thisTileX, thisTileY);
|
||||
if (drawModeTilesBlendMul) {
|
||||
if (isBlendMul((byte) thisTile)) {
|
||||
drawTile(mode, x, y, thisTileX, thisTileY);
|
||||
}
|
||||
}
|
||||
else {
|
||||
drawTile(mode, x, y, mod16(thisTile), div16(thisTile));
|
||||
// currently it draws all the transparent tile and colour mixes
|
||||
// on top of the previously drawn tile
|
||||
// TODO check wether it works as intended when skybox is dark
|
||||
// add instruction "if (!isBlendMul((byte) thisTile))"
|
||||
drawTile(mode, x, y, thisTileX, thisTileY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,19 +258,19 @@ public class MapCamera {
|
||||
* @param y
|
||||
* @return [0-15] 1: up, 2: right, 4: down, 8: left
|
||||
*/
|
||||
private static int getNearbyTilesInfo(int x, int y, int mark) {
|
||||
private static int getNearbyTilesInfo(int x, int y, int mode, int mark) {
|
||||
int[] nearbyTiles = new int[4];
|
||||
if (x == 0) { nearbyTiles[NEARBY_TILE_KEY_LEFT] = 0xFF; }
|
||||
else { nearbyTiles[NEARBY_TILE_KEY_LEFT] = map.getTileFromTerrain(x - 1, y); }
|
||||
else { nearbyTiles[NEARBY_TILE_KEY_LEFT] = map.getTileFrom(mode, x - 1, y); }
|
||||
|
||||
if (x == map.width - 1) { nearbyTiles[NEARBY_TILE_KEY_RIGHT] = 0xFF; }
|
||||
else { nearbyTiles[NEARBY_TILE_KEY_RIGHT] = map.getTileFromTerrain(x + 1, y); }
|
||||
else { nearbyTiles[NEARBY_TILE_KEY_RIGHT] = map.getTileFrom(mode, x + 1, y); }
|
||||
|
||||
if (y == 0) { nearbyTiles[NEARBY_TILE_KEY_UP] = 0; }
|
||||
else { nearbyTiles[NEARBY_TILE_KEY_UP] = map.getTileFromTerrain(x, y - 1); }
|
||||
else { nearbyTiles[NEARBY_TILE_KEY_UP] = map.getTileFrom(mode, x, y - 1); }
|
||||
|
||||
if (y == map.height - 1) { nearbyTiles[NEARBY_TILE_KEY_DOWN] = 0xFF; }
|
||||
else { nearbyTiles[NEARBY_TILE_KEY_DOWN] = map.getTileFromTerrain(x, y + 1); }
|
||||
else { nearbyTiles[NEARBY_TILE_KEY_DOWN] = map.getTileFrom(mode, x, y + 1); }
|
||||
|
||||
// try for
|
||||
int ret = 0;
|
||||
@@ -387,12 +382,25 @@ public class MapCamera {
|
||||
return s.getSprite(i % 16, i / 16);
|
||||
}
|
||||
|
||||
private static boolean isWallThatBeDrawn(int x, int y) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
int tx = x + (i % 3 - 1);
|
||||
int ty = y + (i / 3 - 1);
|
||||
|
||||
if (tx < 0) tx = 0;
|
||||
else if (tx >= map.width) tx = map.width;
|
||||
if (ty < 0) ty = 0;
|
||||
else if (ty >= map.width) ty = map.width;
|
||||
|
||||
if (!isOpaque(map.getTileFromTerrain(tx, ty))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isOpaque(int x) {
|
||||
return (x >= 1 && x <= 38)
|
||||
|| (x >= 41 && x <= 44)
|
||||
|| (x >= 46 && x <= 47)
|
||||
|| (x >= 64 && x <= 86)
|
||||
|| (x >= 88 && x <= 116);
|
||||
return !(x == GRASS || x == AIR);
|
||||
}
|
||||
|
||||
public static int getCameraX() {
|
||||
|
||||
@@ -108,12 +108,12 @@ public class MapGenerator {
|
||||
placeGlacierMount(heightMap);
|
||||
heightMapToObjectMap(heightMap);
|
||||
|
||||
/*carveByMap(
|
||||
carveByMap(
|
||||
generate2DSimplexNoiseWorldSize(2.5f, 1.666f)
|
||||
, 1
|
||||
, AIR
|
||||
, "Carving out cave..."
|
||||
);*/
|
||||
);
|
||||
|
||||
/*fillByMapInverseGradFilter(
|
||||
generate2DSimplexNoiseWorldSize(2.5f, 2.5f)
|
||||
@@ -121,8 +121,8 @@ public class MapGenerator {
|
||||
, DIRT
|
||||
, STONE
|
||||
, "Planting stones on dirt layers..."
|
||||
);*/
|
||||
/*fillByMapInverseGradFilter(
|
||||
);
|
||||
fillByMapInverseGradFilter(
|
||||
generate2DSimplexNoiseWorldSize(2.5f, 2.5f)
|
||||
, 0.98f
|
||||
, STONE
|
||||
|
||||