Support for tile damage, increasing available tiles to 4096, has issue on MapCamera where 'nearbyTilesInfo' does not work properly
Former-commit-id: 84b4c7d70604743c3981078c5f53e615be714b0b Former-commit-id: d8e79628cae968e7636a19e5e36be23a4bf8edd2
@@ -1,49 +1,60 @@
|
||||
"id";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"opaque";"drop";"fall";"friction"
|
||||
"0";"TILE_AIR" ; "1641"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0";"16"
|
||||
"1";"TILE_STONE" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "1"; "0";"16"
|
||||
"2";"TILE_DIRT" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "0";"16"
|
||||
"3";"TILE_GRASS" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "0";"16"
|
||||
"4";"TILE_PLANK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "4"; "0";"16"
|
||||
"5";"TILE_PLANK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "0";"16"
|
||||
"6";"TILE_PLANK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "6"; "0";"16"
|
||||
"7";"TILE_PLANK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "7"; "0";"16"
|
||||
"8";"TILE_TRUNK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "0";"16"
|
||||
"9";"TILE_TRUNK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "9"; "0";"16"
|
||||
"10";"TILE_TRUNK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "10"; "0";"16"
|
||||
"11";"TILE_TRUNK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "11"; "0";"16"
|
||||
"12";"TILE_STONE_QUARRIED" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "12"; "0";"16"
|
||||
"13";"TILE_SAND" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "13"; "1";"16"
|
||||
"14";"TILE_GRAVEL" ; "8205"; "6"; "0"; "0"; "1"; "0"; "0"; "1"; "14"; "1";"16"
|
||||
"id";"dmg";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"opaque";"drop";"ddmg";"fall";"friction"
|
||||
"0"; "0";"TILE_AIR" ; "1641"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0";"16"
|
||||
"1"; "0";"TILE_STONE" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "1"; "0"; "0";"16"
|
||||
"1"; "1";"TILE_STONE_QUARRIED" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "1"; "1"; "0";"16"
|
||||
"2"; "0";"TILE_DIRT" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "0"; "0";"16"
|
||||
"2"; "1";"TILE_GRASS" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "1"; "0";"16"
|
||||
|
||||
"15";"TILE_ORE_MALACHITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "15"; "0";"16"
|
||||
"16";"TILE_ORE_HEMATITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "16"; "0";"16"
|
||||
"17";"TILE_ORE_NATURAL_GOLD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "17"; "0";"16"
|
||||
"18";"TILE_ORE_NATURAL_SILVER" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "18"; "0";"16"
|
||||
"19";"TILE_ORE_RUTILE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "19"; "0";"16"
|
||||
"20";"TILE_ORE_AURICHALCUMITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "20"; "0";"16"
|
||||
"21";"TILE_GEM_RUBY" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "21"; "0";"16"
|
||||
"22";"TILE_GEM_EMERALD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "22"; "0";"16"
|
||||
"23";"TILE_GEM_SAPPHIRE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "23"; "0";"16"
|
||||
"24";"TILE_GEM_TOPAZ" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "24"; "0";"16"
|
||||
"25";"TILE_GEM_DIAMOND" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "25"; "0";"16"
|
||||
"26";"TILE_GEM_AMETHYST" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "26"; "0";"16"
|
||||
"3"; "0";"TILE_PLANK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "3"; "0"; "0";"16"
|
||||
"3"; "1";"TILE_PLANK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "3"; "1"; "0";"16"
|
||||
"3"; "2";"TILE_PLANK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "3"; "2"; "0";"16"
|
||||
"3"; "3";"TILE_PLANK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "3"; "3"; "0";"16"
|
||||
|
||||
"27";"TILE_SNOW" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "27"; "0";"16"
|
||||
"28";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "0"; "1"; "0"; "0"; "0"; "28"; "0";"16"
|
||||
"29";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "29"; "0"; "8"
|
||||
"30";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "0"; "1"; "1"; "5009"; "0"; "30"; "0"; "8"
|
||||
# see scandinavian name set female of this tile id!
|
||||
"31";"TILE_PLATFORM_STONE" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "31"; "0";"16"
|
||||
"32";"TILE_PLATFORM_WOODEN" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "32"; "0";"16"
|
||||
"33";"TILE_PLATFORM_EBONY" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "33"; "0";"16"
|
||||
"34";"TILE_PLATFORM_BIRCH" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "34"; "0";"16"
|
||||
"35";"TILE_PLATFORM_BLOODROSE" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "35"; "0";"16"
|
||||
"4"; "0";"TILE_TRUNK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "3"; "0"; "0";"16"
|
||||
"4"; "1";"TILE_TRUNK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "3"; "1"; "0";"16"
|
||||
"4"; "2";"TILE_TRUNK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "3"; "2"; "0";"16"
|
||||
"4"; "3";"TILE_TRUNK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "3"; "3"; "0";"16"
|
||||
|
||||
"36";"TILE_TORCH" ; "0"; "0"; "0"; "0"; "0"; "0"; "63412"; "0"; "36"; "0";"16"
|
||||
"5"; "0";"TILE_SAND" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "0"; "1";"16"
|
||||
"5"; "1";"TILE_SAND_WHITE" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "1"; "1";"16"
|
||||
"5"; "2";"TILE_SAND_RED" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "2"; "1";"16"
|
||||
"5"; "3";"TILE_SAND" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "3"; "1";"16"
|
||||
"5"; "4";"TILE_SAND_BLACK" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "4"; "1";"16"
|
||||
|
||||
"6"; "0";"TILE_GRAVEL" ; "8205"; "6"; "0"; "0"; "1"; "0"; "0"; "1"; "6"; "0"; "1";"16"
|
||||
"6"; "1";"TILE_GRAVEL_GREY" ; "8205"; "6"; "0"; "0"; "1"; "0"; "0"; "1"; "6"; "1"; "1";"16"
|
||||
|
||||
"7"; "0";"TILE_ORE_MALACHITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "0"; "0";"16"
|
||||
"7"; "1";"TILE_ORE_HEMATITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "1"; "0";"16"
|
||||
"7"; "2";"TILE_ORE_NATURAL_GOLD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "2"; "0";"16"
|
||||
"7"; "3";"TILE_ORE_NATURAL_SILVER" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "3"; "0";"16"
|
||||
"7"; "4";"TILE_ORE_RUTILE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "4"; "0";"16"
|
||||
"7"; "5";"TILE_ORE_AURICHALCUMITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "5"; "0";"16"
|
||||
|
||||
"8"; "0";"TILE_GEM_RUBY" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "0"; "0";"16"
|
||||
"8"; "1";"TILE_GEM_EMERALD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "1"; "0";"16"
|
||||
"8"; "2";"TILE_GEM_SAPPHIRE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "2"; "0";"16"
|
||||
"8"; "3";"TILE_GEM_TOPAZ" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "3"; "0";"16"
|
||||
"8"; "4";"TILE_GEM_DIAMOND" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "4"; "0";"16"
|
||||
"8"; "5";"TILE_GEM_AMETHYST" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "5"; "0";"16"
|
||||
|
||||
"9"; "0";"TILE_SNOW" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "9"; "0"; "0";"16"
|
||||
"9"; "1";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "0"; "1"; "0"; "0"; "0"; "9"; "1"; "0";"16"
|
||||
"9"; "2";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "9"; "2"; "0"; "8"
|
||||
"9"; "3";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "0"; "1"; "1"; "5009"; "0"; "9"; "3"; "0"; "8"
|
||||
|
||||
"10"; "0";"TILE_PLATFORM_STONE" ; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "10"; "0"; "0";"16"
|
||||
"10"; "1";"TILE_PLATFORM_WOODEN" ; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "10"; "1"; "0";"16"
|
||||
"10"; "2";"TILE_PLATFORM_EBONY" ; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "10"; "2"; "0";"16"
|
||||
"10"; "3";"TILE_PLATFORM_BIRCH" ; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "10"; "3"; "0";"16"
|
||||
"10"; "4";"TILE_PLATFORM_BLOODROSE" ; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "10"; "4"; "0";"16"
|
||||
|
||||
"11"; "0";"TILE_TORCH" ; "0"; "0"; "0"; "0"; "0"; "0"; "63412"; "0"; "11"; "0"; "0";"16"
|
||||
# 63412 (ffa44e) : real candlelight colour taken from properly configured camera.
|
||||
"239";"TILE_WATER" ; "6522"; "100"; "1"; "16"; "0"; "0"; "0"; "0"; "239"; "0";"16"
|
||||
"255";"TILE_LAVA" ; "62358"; "100"; "1"; "16"; "0"; "0"; "48320"; "0"; "239"; "0";"16"
|
||||
"254"; "15";"TILE_WATER" ; "6522"; "100"; "1"; "16"; "0"; "0"; "0"; "0"; "-1"; "-1"; "0";"16"
|
||||
"255"; "15";"TILE_LAVA" ; "62358"; "100"; "1"; "16"; "0"; "0"; "48320"; "0"; "-1"; "-1"; "0";"16"
|
||||
# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky
|
||||
# Opacity/Lumcolor: 40-step RGB
|
||||
# Opaque: whether the tile completely hides wall behind
|
||||
# Solid: whether the tile has collision
|
||||
# Viscosity: (walkspeedmax) * (1 + (n/16))
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 12.
|
|
Before Width: | Height: | Size: 785 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 147 B |
BIN
res/graphics/fonts/number_small.png
Executable file
|
After Width: | Height: | Size: 168 B |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 331 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 183 KiB |
@@ -110,11 +110,24 @@ public class GameFontBase implements Font {
|
||||
return hanIndex % JONG_COUNT;
|
||||
}
|
||||
|
||||
private int getHanChosungShift(int hanIndex) {
|
||||
private int getHanChoseongShift(int hanIndex) {
|
||||
int jungseongIndex = getHanJungseong(hanIndex);
|
||||
Integer[] jungseongWide = {8, 12, 13, 17, 18, 21};
|
||||
return (Arrays.asList(jungseongWide).contains(jungseongIndex))
|
||||
? 1 : 0;
|
||||
|
||||
if (getHanJongseong(hanIndex) != 0)
|
||||
return (Arrays.asList(jungseongWide).contains(jungseongIndex))
|
||||
? 1 : 0;
|
||||
else
|
||||
return (Arrays.asList(jungseongWide).contains(jungseongIndex))
|
||||
? 1 : 0;
|
||||
}
|
||||
|
||||
private int getHanJungseongShift(int hanIndex) {
|
||||
return (getHanJongseong(hanIndex) == 0) ? 4 : 5;
|
||||
}
|
||||
|
||||
private int getHanJongseongShift() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
private boolean isAsciiEF(char c) {
|
||||
@@ -336,9 +349,9 @@ public class GameFontBase implements Font {
|
||||
int indexJung = getHanJungseong(hIndex);
|
||||
int indexJong = getHanJongseong(hIndex);
|
||||
|
||||
int choRow = getHanChosungShift(hIndex);
|
||||
int jungRow = 2;
|
||||
int jongRow = 3;
|
||||
int choRow = getHanChoseongShift(hIndex);
|
||||
int jungRow = getHanJungseongShift(hIndex);
|
||||
int jongRow = getHanJongseongShift();
|
||||
|
||||
int glyphW = getWidth("" + ch);
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.Rand.HQRNG;
|
||||
import com.Torvald.Terrarum.*;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapDrawer;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.Terrarum.TileProperties.TilePropCodex;
|
||||
import com.Torvald.spriteAnimation.SpriteAnimation;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
|
||||
@@ -20,7 +18,8 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
|
||||
ActorInventory inventory;
|
||||
|
||||
private @NotNull float hitboxTranslateX; // relative to spritePosX
|
||||
private @NotNull
|
||||
float hitboxTranslateX; // relative to spritePosX
|
||||
private @NotNull float hitboxTranslateY; // relative to spritePosY
|
||||
private @NotNull int baseHitboxW;
|
||||
private @NotNull int baseHitboxH;
|
||||
@@ -38,12 +37,18 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
|
||||
boolean grounded = false;
|
||||
|
||||
@Nullable
|
||||
SpriteAnimation sprite;
|
||||
@Nullable SpriteAnimation spriteGlow;
|
||||
/** Default to 'false' */
|
||||
private boolean visible = false;
|
||||
/** Default to 'true' */
|
||||
private boolean update = true;
|
||||
|
||||
@NotNull int baseSpriteWidth, baseSpriteHeight;
|
||||
private boolean noSubjectToGrav = false;
|
||||
private boolean noCollideWorld = false;
|
||||
|
||||
int baseSpriteWidth, baseSpriteHeight;
|
||||
|
||||
/**
|
||||
* Positions: top-left point
|
||||
@@ -53,9 +58,15 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
/**
|
||||
* Physical properties
|
||||
*/
|
||||
@NonZero
|
||||
private volatile float scale = 1;
|
||||
private volatile float mass = 1f;
|
||||
@NonZero private volatile float mass = 2f;
|
||||
private final float MASS_LOWEST = 2f;
|
||||
/** Valid range: [0, 1] */
|
||||
private float elasticity = 0;
|
||||
private final float ELASTICITY_MAX = 0.993f;
|
||||
@NoNegative
|
||||
private float buoyancy = 0;
|
||||
|
||||
private static final int TSIZE = MapDrawer.TILE_SIZE;
|
||||
private static int AUTO_CLIMB_RATE = TSIZE / 8;
|
||||
@@ -162,13 +173,20 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
/**
|
||||
* Update variables
|
||||
*/
|
||||
if (this instanceof Player) {
|
||||
noSubjectToGrav = isPlayerNoClip();
|
||||
noCollideWorld = isPlayerNoClip();
|
||||
}
|
||||
|
||||
if (mass < MASS_LOWEST) mass = MASS_LOWEST; // clamp to minimum possible mass
|
||||
baseSpriteHeight = sprite.getHeight();
|
||||
baseSpriteWidth = sprite.getWidth();
|
||||
if (sprite != null) {
|
||||
baseSpriteHeight = sprite.getHeight();
|
||||
baseSpriteWidth = sprite.getWidth();
|
||||
}
|
||||
gravitation = Terrarum.game.map.getGravitation();
|
||||
AUTO_CLIMB_RATE = (int) Math.min(TSIZE / 8 * FastMath.sqrt(scale), TSIZE);
|
||||
|
||||
if (!isPlayerNoClip()) {
|
||||
if (!isNoSubjectToGrav()) {
|
||||
applyGravitation();
|
||||
}
|
||||
|
||||
@@ -226,17 +244,17 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
}
|
||||
|
||||
private void updateVerticalPos() {
|
||||
if (!isPlayerNoClip()) {
|
||||
if (!isNoCollideWorld()) {
|
||||
// check downward
|
||||
if (veloY >= 0) {
|
||||
// order of the if-elseif chain is IMPORTANT
|
||||
if (isColliding(CONTACT_AREA_BOTTOM)) {
|
||||
adjustHitBottom();
|
||||
veloY = 0;
|
||||
if (veloY != 0) veloY = -veloY * elasticity;
|
||||
grounded = true;
|
||||
}
|
||||
else if (isColliding(CONTACT_AREA_BOTTOM, 0, 1)) {
|
||||
veloY = 0;
|
||||
if (veloY != 0) veloY = -veloY * elasticity;
|
||||
grounded = true;
|
||||
}
|
||||
else {
|
||||
@@ -249,10 +267,10 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
// order of the if-elseif chain is IMPORTANT
|
||||
if (isColliding(CONTACT_AREA_TOP)) {
|
||||
adjustHitTop();
|
||||
veloY = 0;
|
||||
if (veloY != 0) veloY = -veloY * elasticity;
|
||||
}
|
||||
else if (isColliding(CONTACT_AREA_TOP, 0, -1)) {
|
||||
veloY = 0; // for reversed gravity
|
||||
if (veloY != 0) veloY = -veloY * elasticity; // for reversed gravity
|
||||
}
|
||||
else {
|
||||
}
|
||||
@@ -295,17 +313,17 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
}
|
||||
|
||||
private void updateHorizontalPos() {
|
||||
if (!isPlayerNoClip()) {
|
||||
if (!isNoCollideWorld()) {
|
||||
// check right
|
||||
if (veloX > 0) {
|
||||
// order of the if-elseif chain is IMPORTANT
|
||||
if (isColliding(CONTACT_AREA_RIGHT) && !isColliding(CONTACT_AREA_LEFT)) {
|
||||
adjustHitRight();
|
||||
veloX = 0;
|
||||
if (veloX != 0) veloX = -veloX * elasticity;
|
||||
}
|
||||
else if (isColliding(CONTACT_AREA_RIGHT, 1, 0)
|
||||
&& !isColliding(CONTACT_AREA_LEFT, -1, 0)) {
|
||||
veloX = 0;
|
||||
if (veloX != 0) veloX = -veloX * elasticity;
|
||||
}
|
||||
else {
|
||||
}
|
||||
@@ -314,11 +332,11 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
// order of the if-elseif chain is IMPORTANT
|
||||
if (isColliding(CONTACT_AREA_LEFT) && !isColliding(CONTACT_AREA_RIGHT)) {
|
||||
adjustHitLeft();
|
||||
veloX = 0;
|
||||
if (veloX != 0) veloX = -veloX * elasticity;
|
||||
}
|
||||
else if (isColliding(CONTACT_AREA_LEFT, -1, 0)
|
||||
&& !isColliding(CONTACT_AREA_RIGHT, 1, 0)) {
|
||||
veloX = 0;
|
||||
if (veloX != 0) veloX = -veloX * elasticity;
|
||||
}
|
||||
else {
|
||||
}
|
||||
@@ -511,7 +529,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
|
||||
@Override
|
||||
public void drawBody(GameContainer gc, Graphics g) {
|
||||
if (visible) {
|
||||
if (visible && sprite != null) {
|
||||
if (!sprite.flippedHorizontal()) {
|
||||
sprite.render(g
|
||||
, (hitbox.getPosX() - (hitboxTranslateX * scale))
|
||||
@@ -535,14 +553,12 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
|
||||
@Override
|
||||
public void updateGlowSprite(GameContainer gc, int delta_t) {
|
||||
if (spriteGlow != null) {
|
||||
spriteGlow.update(delta_t);
|
||||
}
|
||||
if (spriteGlow != null) spriteGlow.update(delta_t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBodySprite(GameContainer gc, int delta_t) {
|
||||
sprite.update(delta_t);
|
||||
if (sprite != null) sprite.update(delta_t);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -718,6 +734,40 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
private int quantiseTSize(float v) {
|
||||
return FastMath.floor(v / TSIZE) * TSIZE;
|
||||
}
|
||||
|
||||
public boolean isNoSubjectToGrav() {
|
||||
return noSubjectToGrav;
|
||||
}
|
||||
|
||||
public void setNoSubjectToGrav(boolean noSubjectToGrav) {
|
||||
this.noSubjectToGrav = noSubjectToGrav;
|
||||
}
|
||||
|
||||
public boolean isNoCollideWorld() {
|
||||
return noCollideWorld;
|
||||
}
|
||||
|
||||
public void setNoCollideWorld(boolean noCollideWorld) {
|
||||
this.noCollideWorld = noCollideWorld;
|
||||
}
|
||||
|
||||
public void setElasticity(float elasticity) {
|
||||
if (elasticity < 0)
|
||||
throw new IllegalArgumentException("[ActorWithBody] " + elasticity + ": valid elasticity value is [0, 1].");
|
||||
|
||||
if (elasticity > 1) {
|
||||
System.out.println("[ActorWithBody] Elasticity were capped to 1.");
|
||||
this.elasticity = ELASTICITY_MAX;
|
||||
}
|
||||
else this.elasticity = elasticity * ELASTICITY_MAX;
|
||||
}
|
||||
|
||||
public void setBuoyancy(float buoyancy) {
|
||||
if (buoyancy < 0)
|
||||
throw new IllegalArgumentException("[ActorWithBody] " + buoyancy + ": buoyancy cannot be negative.");
|
||||
|
||||
this.buoyancy = buoyancy;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
29
src/com/Torvald/Terrarum/Actors/PhysTestBall.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
*/
|
||||
public class PhysTestBall extends ActorWithBody {
|
||||
|
||||
public PhysTestBall() {
|
||||
super();
|
||||
setHitboxDimension(16, 16, 0, 0);
|
||||
setVisible(true);
|
||||
setMass(10f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBody(GameContainer gc, Graphics g) {
|
||||
g.setColor(Color.orange);
|
||||
g.fillOval(
|
||||
getHitbox().getPosX()
|
||||
, getHitbox().getPosY()
|
||||
, getHitbox().getWidth()
|
||||
, getHitbox().getHeight()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,8 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
|
||||
private HashSet<Faction> factionSet = new HashSet<>();
|
||||
|
||||
private final float BASE_BUOYANCY = 0.98f;
|
||||
|
||||
|
||||
/**
|
||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.). <br />
|
||||
@@ -73,6 +75,7 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
super();
|
||||
referenceID = PLAYER_REF_ID;
|
||||
setVisible(true);
|
||||
super.setBuoyancy(BASE_BUOYANCY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ public class CommandDict {
|
||||
dict.put("setgl", new SetGlobalLightLevel());
|
||||
dict.put("getfaction", new GetFactioning());
|
||||
dict.put("auth", Terrarum.game.auth);
|
||||
dict.put("spawnball", new SpawnPhysTestBall());
|
||||
}
|
||||
|
||||
public static ConsoleCommand getCommand(String commandName) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.Actor;
|
||||
import com.Torvald.Terrarum.Actors.ActorWithBody;
|
||||
import com.Torvald.Terrarum.Actors.PhysTestBall;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapCamera;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
*/
|
||||
public class SpawnPhysTestBall implements ConsoleCommand {
|
||||
@Override
|
||||
public void execute(String[] args) throws Exception {
|
||||
if (args.length == 2) {
|
||||
int mouseX = Terrarum.appgc.getInput().getMouseX();
|
||||
int mouseY = Terrarum.appgc.getInput().getMouseY();
|
||||
|
||||
float elasticity = new Float(args[1]);
|
||||
|
||||
ActorWithBody ball = new PhysTestBall();
|
||||
ball.setPosition(mouseX + MapCamera.getCameraX()
|
||||
, mouseY + MapCamera.getCameraY());
|
||||
ball.setElasticity(elasticity);
|
||||
|
||||
Terrarum.game.addActor(ball);
|
||||
}
|
||||
else {
|
||||
printUsage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printUsage() {
|
||||
new Echo().execute("usage: spawnball [elasticity]");
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import com.Torvald.Terrarum.MapGenerator.MapGenerator;
|
||||
import com.Torvald.Terrarum.TileProperties.TilePropCodex;
|
||||
import com.Torvald.Terrarum.TileStat.TileStat;
|
||||
import com.Torvald.Terrarum.UserInterface.*;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.newdawn.slick.*;
|
||||
import org.newdawn.slick.Graphics;
|
||||
@@ -26,7 +25,7 @@ import org.newdawn.slick.state.StateBasedGame;
|
||||
import shader.Shader;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-30.
|
||||
@@ -41,15 +40,14 @@ public class Game extends BasicGameState {
|
||||
|
||||
public GameMap map;
|
||||
|
||||
public LinkedList<Actor> actorContainer = new LinkedList<>();
|
||||
public LinkedList<UIHandler> uiContainer = new LinkedList<>();
|
||||
public HashSet<Actor> actorContainer = new HashSet<>();
|
||||
public HashSet<UIHandler> uiContainer = new HashSet<>();
|
||||
|
||||
public UIHandler consoleHandler;
|
||||
public UIHandler debugWindow;
|
||||
public UIHandler bulletin;
|
||||
|
||||
@NotNull
|
||||
Player player;
|
||||
@NotNull Player player;
|
||||
|
||||
private Image GRADIENT_IMAGE;
|
||||
private Rectangle skyBox;
|
||||
@@ -141,7 +139,6 @@ public class Game extends BasicGameState {
|
||||
setAppTitle();
|
||||
|
||||
GameController.processInput(gc.getInput());
|
||||
KeyToggler.update(gc);
|
||||
|
||||
TileStat.update();
|
||||
|
||||
@@ -164,7 +161,7 @@ public class Game extends BasicGameState {
|
||||
|
||||
//bulletin.update(gc, delta_t);
|
||||
|
||||
Terrarum.appgc.setVSync(Terrarum.appgc.getFPS() >= 59);
|
||||
Terrarum.appgc.setVSync(Terrarum.appgc.getFPS() >= Terrarum.VSYNC_TRIGGER_THRESHOLD);
|
||||
}
|
||||
|
||||
private void setAppTitle() {
|
||||
@@ -220,6 +217,14 @@ public class Game extends BasicGameState {
|
||||
GL11.glEnd();
|
||||
}
|
||||
|
||||
public boolean addActor(Actor e) {
|
||||
return actorContainer.add(e);
|
||||
}
|
||||
|
||||
public boolean removeActor(Actor e) {
|
||||
return actorContainer.remove(e);
|
||||
}
|
||||
|
||||
private Color[] getGradientColour(int timeSec) {
|
||||
Color[] colourTable = new Color[2];
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@ public class GameController {
|
||||
/ MapDrawer.TILE_SIZE);
|
||||
|
||||
|
||||
KeyToggler.update(input);
|
||||
|
||||
|
||||
if (!Terrarum.game.consoleHandler.isTakingControl()) {
|
||||
if (Terrarum.game.getPlayer().vehicleRiding != null) {
|
||||
Terrarum.game.getPlayer().vehicleRiding.processInput(input);
|
||||
|
||||
@@ -13,10 +13,7 @@ public class KeyToggler {
|
||||
return currentState[key];
|
||||
}
|
||||
|
||||
public static void update(GameContainer gc){
|
||||
|
||||
Input input = gc.getInput();
|
||||
|
||||
public static void update(Input input){
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if (input.isKeyDown(i)) {
|
||||
isPressed[i] = true;
|
||||
|
||||
@@ -23,6 +23,7 @@ public class GameMap {
|
||||
private volatile MapLayer layerWall;
|
||||
private volatile MapLayer layerTerrain;
|
||||
private volatile MapLayer layerWire;
|
||||
private volatile PairedMapLayer wallDamageCode;
|
||||
private volatile PairedMapLayer terrainDamageCode;
|
||||
|
||||
//properties
|
||||
@@ -56,6 +57,7 @@ public class GameMap {
|
||||
layerWall = new MapLayer(width, height);
|
||||
layerWire = new MapLayer(width, height);
|
||||
terrainDamageCode = new PairedMapLayer(width, height);
|
||||
wallDamageCode = new PairedMapLayer(width, height);
|
||||
|
||||
globalLight = (char) 63999;
|
||||
worldTime = new WorldTime();
|
||||
@@ -122,28 +124,62 @@ public class GameMap {
|
||||
return terrainDamageCode;
|
||||
}
|
||||
|
||||
public PairedMapLayer getWallDamageCode() {
|
||||
return wallDamageCode;
|
||||
}
|
||||
|
||||
public int getTileFromWall(int x, int y) {
|
||||
return uint8ToInt32(layerWall.data[y][x]);
|
||||
return layerWall.getTile(x, y) * PairedMapLayer.RANGE + getWallDamage(x, y);
|
||||
}
|
||||
|
||||
public int getTileFromTerrain(int x, int y) {
|
||||
return uint8ToInt32(layerTerrain.data[y][x]);
|
||||
return layerTerrain.getTile(x, y) * PairedMapLayer.RANGE + getTerrainDamage(x, y);
|
||||
}
|
||||
|
||||
public int getTileFromWire(int x, int y) {
|
||||
return uint8ToInt32(layerWire.data[y][x]);
|
||||
return layerWire.getTile(x, y);
|
||||
}
|
||||
|
||||
public int getDamageData(int x, int y) {
|
||||
public int getWallDamage(int x, int y) {
|
||||
return wallDamageCode.getData(x, y);
|
||||
}
|
||||
|
||||
public int getTerrainDamage(int x, int y) {
|
||||
return terrainDamageCode.getData(x, y);
|
||||
}
|
||||
|
||||
public void setTileWall(int x, int y, byte tile) {
|
||||
layerWall.data[y][x] = tile;
|
||||
/**
|
||||
* Set the tile of wall as specified, with damage value of zero.
|
||||
* @param x
|
||||
* @param y
|
||||
* @param combinedTilenum (tilenum * 16) + damage
|
||||
*/
|
||||
public void setTileWall(int x, int y, int combinedTilenum) {
|
||||
setTileWall(x, y
|
||||
, (byte) (combinedTilenum / PairedMapLayer.RANGE)
|
||||
, combinedTilenum % PairedMapLayer.RANGE);
|
||||
}
|
||||
|
||||
public void setTileTerrain(int x, int y, byte tile) {
|
||||
layerTerrain.data[y][x] = tile;
|
||||
/**
|
||||
* Set the tile of wall as specified, with damage value of zero.
|
||||
* @param x
|
||||
* @param y
|
||||
* @param combinedTilenum (tilenum * 16) + damage
|
||||
*/
|
||||
public void setTileTerrain(int x, int y, int combinedTilenum) {
|
||||
setTileTerrain(x, y
|
||||
, (byte) (combinedTilenum / PairedMapLayer.RANGE)
|
||||
, combinedTilenum % PairedMapLayer.RANGE);
|
||||
}
|
||||
|
||||
public void setTileWall(int x, int y, byte tile, int damage) {
|
||||
layerWall.setTile(x, y, tile);
|
||||
wallDamageCode.setData(x, y, damage);
|
||||
}
|
||||
|
||||
public void setTileTerrain(int x, int y, byte tile, int damage) {
|
||||
layerTerrain.setTile(x, y, tile);
|
||||
terrainDamageCode.setData(x, y, damage);
|
||||
}
|
||||
|
||||
public void setTileWire(int x, int y, byte tile) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MapLayer implements Iterable<Byte> {
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Byte> iterator() {
|
||||
Iterator<Byte> it = new Iterator<Byte>() {
|
||||
return new Iterator<Byte>() {
|
||||
|
||||
private int iteratorCount = 0;
|
||||
|
||||
@@ -55,8 +55,6 @@ public class MapLayer implements Iterable<Byte> {
|
||||
return data[y][x];
|
||||
}
|
||||
};
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,11 +103,11 @@ public class MapLayer implements Iterable<Byte> {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int getTile(int x, int y) {
|
||||
int getTile(int x, int y) {
|
||||
return uint8ToInt32(data[y][x]);
|
||||
}
|
||||
|
||||
public void setTile(int x, int y, byte tile) {
|
||||
void setTile(int x, int y, byte tile) {
|
||||
data[y][x] = tile;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PairedMapLayer implements Iterable<Integer> {
|
||||
public int width;
|
||||
public int height;
|
||||
|
||||
public static final int MAX_VALUE = 16;
|
||||
public static final int RANGE = 16;
|
||||
|
||||
public PairedMapLayer(int width, int height) {
|
||||
this.width = width / 2;
|
||||
@@ -44,7 +44,7 @@ public class PairedMapLayer implements Iterable<Integer> {
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Integer> iterator() {
|
||||
Iterator<Integer> it = new Iterator<Integer>() {
|
||||
return new Iterator<Integer>() {
|
||||
|
||||
private int iteratorCount = 0;
|
||||
|
||||
@@ -63,8 +63,6 @@ public class PairedMapLayer implements Iterable<Integer> {
|
||||
return getData(x, y);
|
||||
}
|
||||
};
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +83,7 @@ public class PairedMapLayer implements Iterable<Integer> {
|
||||
* @since 1.8
|
||||
*/
|
||||
@Override
|
||||
public void forEach(Consumer<? super Integer> action) {
|
||||
public void forEach(Consumer action) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -111,7 +109,7 @@ public class PairedMapLayer implements Iterable<Integer> {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int getData(int x, int y) {
|
||||
int getData(int x, int y) {
|
||||
if ((x & 0x1) == 0)
|
||||
// higher four bits for i = 0, 2, 4, ...
|
||||
return (dataPair[y][x / 2] & 0xF0) >>> 4;
|
||||
@@ -119,4 +117,14 @@ public class PairedMapLayer implements Iterable<Integer> {
|
||||
// lower four bits for i = 1, 3, 5, ...
|
||||
return dataPair[y][x / 2] & 0x0F;
|
||||
}
|
||||
|
||||
void setData(int x, int y, int data) {
|
||||
if (data < 0 || data >= 16) throw new IllegalArgumentException("[PairedMapLayer] " + data + ": invalid data value.");
|
||||
if ((x & 0x1) == 0)
|
||||
// higher four bits for i = 0, 2, 4, ...
|
||||
dataPair[y][x / 2] = (byte) (dataPair[y][x / 2] & 0x0F | (data & 0xF) << 4);
|
||||
else
|
||||
// lower four bits for i = 1, 3, 5, ...
|
||||
dataPair[y][x / 2] = (byte) (dataPair[y][x / 2] & 0xF0 | (data & 0xF));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.Torvald.Terrarum.*;
|
||||
import com.Torvald.Terrarum.Actors.Player;
|
||||
import com.Torvald.Terrarum.GameMap.GameMap;
|
||||
import com.Torvald.Terrarum.GameMap.MapLayer;
|
||||
import com.Torvald.Terrarum.GameMap.PairedMapLayer;
|
||||
import com.Torvald.Terrarum.TileProperties.TileNameCode;
|
||||
import com.Torvald.Terrarum.TileProperties.TilePropCodex;
|
||||
import com.jme3.math.FastMath;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -47,49 +49,26 @@ public class MapCamera {
|
||||
private static final int NEARBY_TILE_CODE_DOWN = 0b0100;
|
||||
private static final int NEARBY_TILE_CODE_LEFT = 0b1000;
|
||||
|
||||
private static final byte AIR = 0;
|
||||
|
||||
private static final byte STONE = 1;
|
||||
private static final byte DIRT = 2;
|
||||
private static final byte GRASS = 3;
|
||||
|
||||
private static final byte SAND = 13;
|
||||
private static final byte GRAVEL = 14;
|
||||
|
||||
private static final byte COPPER = 15;
|
||||
private static final byte IRON = 16;
|
||||
private static final byte GOLD = 17;
|
||||
private static final byte SILVER = 18;
|
||||
private static final byte ILMENITE = 19;
|
||||
private static final byte AURICHALCUM = 20;
|
||||
|
||||
private static final byte SNOW = 27;
|
||||
private static final byte ICE_FRAGILE = 28;
|
||||
private static final byte ICE_NATURAL = 29;
|
||||
private static final byte ICE_MAGICAL = 30;
|
||||
|
||||
private static Byte[] TILES_CONNECT_SELF = {
|
||||
COPPER
|
||||
, IRON
|
||||
, GOLD
|
||||
, SILVER
|
||||
, ILMENITE
|
||||
, AURICHALCUM
|
||||
, ICE_MAGICAL
|
||||
private static Integer[] TILES_CONNECT_SELF = {
|
||||
TileNameCode.ORE_COPPER
|
||||
, TileNameCode.ORE_IRON
|
||||
, TileNameCode.ORE_GOLD
|
||||
, TileNameCode.ORE_SILVER
|
||||
, TileNameCode.ORE_ILMENITE
|
||||
, TileNameCode.ORE_AURICHALCUM
|
||||
, TileNameCode.ICE_MAGICAL
|
||||
};
|
||||
|
||||
private static Byte[] TILES_DARKEN_AIR = {
|
||||
STONE
|
||||
, DIRT
|
||||
, GRASS
|
||||
, SAND
|
||||
, GRAVEL
|
||||
, SNOW
|
||||
, ICE_NATURAL
|
||||
, (byte)224, (byte)225, (byte)226, (byte)227, (byte)228, (byte)229, (byte)230, (byte)231
|
||||
, (byte)232, (byte)233, (byte)234, (byte)235, (byte)236, (byte)237, (byte)238, (byte)239
|
||||
, (byte)240, (byte)241, (byte)242, (byte)243, (byte)244, (byte)245, (byte)246, (byte)247
|
||||
, (byte)248, (byte)249, (byte)250, (byte)251, (byte)252, (byte)253, (byte)254, (byte)255
|
||||
private static Integer[] TILES_DARKEN_AIR = {
|
||||
TileNameCode.STONE
|
||||
, TileNameCode.DIRT
|
||||
, TileNameCode.GRASS
|
||||
, TileNameCode.SAND
|
||||
, TileNameCode.GRAVEL
|
||||
, TileNameCode.SNOW
|
||||
, TileNameCode.ICE_NATURAL
|
||||
, TileNameCode.WATER
|
||||
, TileNameCode.LAVA
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -170,10 +149,6 @@ public class MapCamera {
|
||||
int for_y_end = clampHTile(for_y_start + div16(renderHeight) + 2);
|
||||
int for_x_end = clampWTile(for_x_start + div16(renderWidth) + 2);
|
||||
|
||||
MapLayer currentLayer = (mode % 3 == WALL) ? map.getLayerWall()
|
||||
: (mode % 3 == TERRAIN) ? map.getLayerTerrain()
|
||||
: map.getLayerWire();
|
||||
|
||||
// initialise
|
||||
tilesetBook[mode].startUse();
|
||||
|
||||
@@ -181,8 +156,13 @@ public class MapCamera {
|
||||
for (int y = for_y_start; y < for_y_end; y++) {
|
||||
for (int x = for_x_start; x < for_x_end; x++) {
|
||||
|
||||
int thisTile = currentLayer.getTile(x, y);
|
||||
int thisTerrainTile = map.getTileFromTerrain(x, y);
|
||||
int thisTile;
|
||||
if (mode % 3 == WALL) thisTile = map.getTileFromWall(x, y);
|
||||
else if (mode % 3 == TERRAIN) thisTile = map.getTileFromTerrain(x, y);
|
||||
else if (mode % 3 == WIRE) thisTile = map.getTileFromWire(x, y);
|
||||
else throw new IllegalArgumentException();
|
||||
|
||||
boolean noDamageLayer = (mode % 3 == WIRE);
|
||||
|
||||
// draw
|
||||
try {
|
||||
@@ -210,17 +190,10 @@ public class MapCamera {
|
||||
))) {
|
||||
|
||||
int nearbyTilesInfo;
|
||||
//if (thisTile == DIRT) {
|
||||
// nearbyTilesInfo = getGrassInfo(x, y, GRASS);
|
||||
//}
|
||||
//else {
|
||||
// nearbyTilesInfo = getNearbyTilesInfo(x, y, AIR);
|
||||
//}
|
||||
|
||||
if (isDarkenAir((byte) thisTile)) {
|
||||
nearbyTilesInfo = getNearbyTilesInfo(x, y, mode, AIR);
|
||||
if (isDarkenAir(thisTile)) {
|
||||
nearbyTilesInfo = getNearbyTilesInfo(x, y, mode, TileNameCode.AIR);
|
||||
}
|
||||
else if (isConnectSelf((byte) thisTile)) {
|
||||
else if (isConnectSelf(thisTile)) {
|
||||
nearbyTilesInfo = getNearbyTilesInfo(x, y, mode, thisTile);
|
||||
}
|
||||
else {
|
||||
@@ -228,8 +201,14 @@ public class MapCamera {
|
||||
}
|
||||
|
||||
|
||||
int thisTileX = nearbyTilesInfo;
|
||||
int thisTileY = thisTile;
|
||||
int thisTileX;
|
||||
if (!noDamageLayer)
|
||||
thisTileX = PairedMapLayer.RANGE * (thisTile % PairedMapLayer.RANGE)
|
||||
+ nearbyTilesInfo;
|
||||
else
|
||||
thisTileX = nearbyTilesInfo;
|
||||
|
||||
int thisTileY = thisTile / PairedMapLayer.RANGE;
|
||||
|
||||
if (drawModeTilesBlendMul) {
|
||||
if (isBlendMul((byte) thisTile)) {
|
||||
@@ -266,16 +245,16 @@ public class MapCamera {
|
||||
*/
|
||||
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; }
|
||||
if (x == 0) { nearbyTiles[NEARBY_TILE_KEY_LEFT] = 4096; }
|
||||
else { nearbyTiles[NEARBY_TILE_KEY_LEFT] = map.getTileFrom(mode, x - 1, y); }
|
||||
|
||||
if (x == map.width - 1) { nearbyTiles[NEARBY_TILE_KEY_RIGHT] = 0xFF; }
|
||||
if (x == map.width - 1) { nearbyTiles[NEARBY_TILE_KEY_RIGHT] = 4096; }
|
||||
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.getTileFrom(mode, x, y - 1); }
|
||||
|
||||
if (y == map.height - 1) { nearbyTiles[NEARBY_TILE_KEY_DOWN] = 0xFF; }
|
||||
if (y == map.height - 1) { nearbyTiles[NEARBY_TILE_KEY_DOWN] = 4096; }
|
||||
else { nearbyTiles[NEARBY_TILE_KEY_DOWN] = map.getTileFrom(mode, x, y + 1); }
|
||||
|
||||
// try for
|
||||
@@ -434,16 +413,16 @@ public class MapCamera {
|
||||
return clampHTile(getRenderStartY() + div16(renderHeight) + 2);
|
||||
}
|
||||
|
||||
private static boolean isConnectSelf(byte b) {
|
||||
return (Arrays.asList(TILES_CONNECT_SELF).contains(b));
|
||||
private static boolean isConnectSelf(int b) {
|
||||
return (Arrays.asList(TILES_CONNECT_SELF).contains((byte) b));
|
||||
}
|
||||
|
||||
private static boolean isDarkenAir(byte b) {
|
||||
return (Arrays.asList(TILES_DARKEN_AIR).contains(b));
|
||||
private static boolean isDarkenAir(int b) {
|
||||
return (Arrays.asList(TILES_DARKEN_AIR).contains((byte) b));
|
||||
}
|
||||
|
||||
private static boolean isBlendMul(byte b) {
|
||||
return (Arrays.asList(TILES_BLEND_MUL).contains(b));
|
||||
private static boolean isBlendMul(int b) {
|
||||
return (Arrays.asList(TILES_BLEND_MUL).contains((byte) b));
|
||||
}
|
||||
|
||||
private static void setBlendModeMul() {
|
||||
|
||||
@@ -516,11 +516,11 @@ public class MapGenerator {
|
||||
for (int i = 0; i < height - pillarOffset; i++) {
|
||||
|
||||
if (i < dirtThickness) {
|
||||
map.getTerrainArray()[i + pillarOffset][x] = TileNameCode.DIRT;
|
||||
map.getWallArray()[i + pillarOffset][x] = TileNameCode.DIRT;
|
||||
MapGenerator.map.setTileTerrain(x, i + pillarOffset, TileNameCode.DIRT);
|
||||
MapGenerator.map.setTileWall(x, i + pillarOffset, TileNameCode.DIRT);
|
||||
} else {
|
||||
map.getTerrainArray()[i + pillarOffset][x] = TileNameCode.STONE;
|
||||
map.getWallArray()[i + pillarOffset][x] = TileNameCode.STONE;
|
||||
MapGenerator.map.setTileTerrain(x, i + pillarOffset, TileNameCode.STONE);
|
||||
MapGenerator.map.setTileWall(x, i + pillarOffset, TileNameCode.STONE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -594,13 +594,13 @@ public class MapGenerator {
|
||||
|
||||
/* 2. Carve */
|
||||
|
||||
private static void carveCave(float[][] map, byte tile, String message) {
|
||||
private static void carveCave(float[][] map, int tile, String message) {
|
||||
System.out.println("[MapGenerator] " + message);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
if (map[i][j] > 0.9) {
|
||||
MapGenerator.map.getTerrainArray()[i][j] = tile;
|
||||
MapGenerator.map.setTileTerrain(j, i, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -613,14 +613,14 @@ public class MapGenerator {
|
||||
* @param tile
|
||||
* @param message
|
||||
*/
|
||||
private static void carveByMap(float[][] map, float scarcity, byte tile, String message) {
|
||||
private static void carveByMap(float[][] map, float scarcity, int tile, String message) {
|
||||
System.out.println("[MapGenerator] " + message);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
if (map[i][j] > gradientQuadratic(i, noiseGradientStart, noiseGrdCaveEnd) *
|
||||
scarcity) {
|
||||
MapGenerator.map.getTerrainArray()[i][j] = tile;
|
||||
MapGenerator.map.setTileTerrain(j, i, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -634,14 +634,14 @@ public class MapGenerator {
|
||||
* @param tile
|
||||
* @param message
|
||||
*/
|
||||
private static void fillByMap(float[][] map, float scarcity, byte replaceFrom, byte tile, String message) {
|
||||
private static void fillByMap(float[][] map, float scarcity, int replaceFrom, int tile, String message) {
|
||||
System.out.println("[MapGenerator] " + message);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
if (map[i][j] > getNoiseGradient(i, noiseGradientStart, noiseGradientEnd) * scarcity
|
||||
&& MapGenerator.map.getTileFromTerrain(j, i) == replaceFrom) {
|
||||
MapGenerator.map.getTerrainArray()[i][j] = tile;
|
||||
MapGenerator.map.setTileTerrain(j, i, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -655,7 +655,7 @@ public class MapGenerator {
|
||||
* @param tile
|
||||
* @param message
|
||||
*/
|
||||
private static void fillByMapInverseGradFilter(float[][] map, float scarcity, byte replaceFrom, byte tile, String message) {
|
||||
private static void fillByMapInverseGradFilter(float[][] map, float scarcity, int replaceFrom, int tile, String message) {
|
||||
System.out.println("[MapGenerator] " + message);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
@@ -663,7 +663,7 @@ public class MapGenerator {
|
||||
if (map[i][j] > getNoiseGradientInversed(i, noiseGradientEnd, noiseGradientStart)
|
||||
* scarcity
|
||||
&& MapGenerator.map.getTileFromTerrain(j, i) == replaceFrom) {
|
||||
MapGenerator.map.getTerrainArray()[i][j] = tile;
|
||||
MapGenerator.map.setTileTerrain(j, i, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -679,20 +679,20 @@ public class MapGenerator {
|
||||
* @param tile
|
||||
* @param message
|
||||
*/
|
||||
private static void fillByMapNoFilter(float[][] map, float scarcity, byte replaceFrom, byte tile, String message) {
|
||||
private static void fillByMapNoFilter(float[][] map, float scarcity, int replaceFrom, int tile, String message) {
|
||||
System.out.println("[MapGenerator] " + message);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
if (map[i][j] > noiseGradientStart * scarcity
|
||||
&& MapGenerator.map.getTileFromTerrain(j, i) == replaceFrom) {
|
||||
MapGenerator.map.getTerrainArray()[i][j] = tile;
|
||||
MapGenerator.map.setTileTerrain(j, i, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void fillByMapNoFilterUnderground(float[][] map, float scarcity, byte replaceFrom, byte
|
||||
private static void fillByMapNoFilterUnderground(float[][] map, float scarcity, int replaceFrom, int
|
||||
tile, String message) {
|
||||
System.out.println("[MapGenerator] " + message);
|
||||
|
||||
@@ -701,21 +701,20 @@ public class MapGenerator {
|
||||
if (map[i][j] > noiseGradientStart * scarcity
|
||||
&& MapGenerator.map.getTileFromTerrain(j, i) == replaceFrom
|
||||
&& MapGenerator.map.getTileFromWall(j, i) == TileNameCode.STONE) {
|
||||
MapGenerator.map.getTerrainArray()[i][j] = tile;
|
||||
MapGenerator.map.setTileTerrain(j, i, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void fillByMap(float[][] map, float scarcity, byte replaceFrom, byte[] tile, String message) {
|
||||
private static void fillByMap(float[][] map, float scarcity, int replaceFrom, int[] tile, String message) {
|
||||
System.out.println("[MapGenerator] " + message);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
if (map[i][j] > getNoiseGradient(i, noiseGradientStart, noiseGradientEnd) * scarcity
|
||||
&& MapGenerator.map.getTileFromTerrain(j, i) == replaceFrom) {
|
||||
MapGenerator.map.getTerrainArray()[i][j]
|
||||
= tile[random.nextInt(tile.length)];
|
||||
MapGenerator.map.setTileTerrain(j, i, tile[random.nextInt(tile.length)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -908,7 +907,7 @@ public class MapGenerator {
|
||||
for (int i = height * 14 / 15; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
if (map.getTerrainArray()[i][j] == 0) {
|
||||
map.getTerrainArray()[i][j] = TileNameCode.LAVA;
|
||||
map.setTileTerrain(j, i, TileNameCode.LAVA);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -938,7 +937,7 @@ public class MapGenerator {
|
||||
catch (ArrayIndexOutOfBoundsException e) {}
|
||||
|
||||
if (i != 4 && thisTile == TileNameCode.DIRT && nearbyWallTile == TileNameCode.AIR) {
|
||||
map.getTerrainArray()[y][x] = TileNameCode.GRASS;
|
||||
map.setTileTerrain(x, y, TileNameCode.GRASS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -951,15 +950,15 @@ public class MapGenerator {
|
||||
return map.getTileFromTerrain(x, y) == TileNameCode.GRASS || map.getTileFromTerrain(x, y) == TileNameCode.DIRT;
|
||||
}
|
||||
|
||||
private static void replaceIfTerrain(byte ifTile, int x, int y, byte replaceTile) {
|
||||
if (map.getTileFromTerrain(x, y) == ifTile) {
|
||||
map.getTerrainArray()[y][x] = replaceTile;
|
||||
private static void replaceIfTerrain(int ifTileRaw, int x, int y, int replaceTileRaw) {
|
||||
if (map.getTileFromTerrain(x, y) == ifTileRaw) {
|
||||
map.setTileTerrain(x, y, replaceTileRaw);
|
||||
}
|
||||
}
|
||||
|
||||
private static void replaceIfWall(byte ifTile, int x, int y, byte replaceTile) {
|
||||
if (map.getTileFromWall(x, y) == ifTile) {
|
||||
map.getWallArray()[y][x] = replaceTile;
|
||||
private static void replaceIfWall(int ifTileRaw, int x, int y, int replaceTileRaw) {
|
||||
if (map.getTileFromWall(x, y) == ifTileRaw) {
|
||||
map.setTileWall(x, y, replaceTileRaw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -973,16 +972,14 @@ public class MapGenerator {
|
||||
for (int y = getTerrainHeightFromHeightMap(OCEAN_WIDTH)
|
||||
; y < getTerrainHeightFromHeightMap(ix)
|
||||
; y++) {
|
||||
map.getTerrainArray()
|
||||
[y][ix] = TileNameCode.WATER;
|
||||
map.setTileTerrain(ix, y, TileNameCode.WATER);
|
||||
}
|
||||
}
|
||||
else if (worldOceanPosition == TYPE_OCEAN_RIGHT) {
|
||||
for (int y = getTerrainHeightFromHeightMap(map.width - 1 - OCEAN_WIDTH)
|
||||
; y < getTerrainHeightFromHeightMap(map.width - 1 - ix)
|
||||
; y++) {
|
||||
map.getTerrainArray()
|
||||
[y][map.width - 1 - ix] = TileNameCode.WATER;
|
||||
map.setTileTerrain(map.width - 1 - ix, y, TileNameCode.WATER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -992,22 +989,17 @@ public class MapGenerator {
|
||||
if (worldOceanPosition == TYPE_OCEAN_LEFT) {
|
||||
int terrainPoint = getTerrainHeightFromHeightMap(ix);
|
||||
|
||||
map.getTerrainArray()
|
||||
[terrainPoint + iy]
|
||||
[ix] = TileNameCode.SAND;
|
||||
map.getTerrainArray()
|
||||
[terrainPoint + iy - 1] // clear grass and make the sheet thicker
|
||||
[ix] = TileNameCode.SAND;
|
||||
|
||||
map.setTileTerrain(ix, terrainPoint + iy, TileNameCode.SAND_BEACH);
|
||||
// clear grass and make the sheet thicker
|
||||
map.setTileTerrain(ix, terrainPoint + iy - 1, TileNameCode.SAND_BEACH);
|
||||
}
|
||||
else if (worldOceanPosition == TYPE_OCEAN_RIGHT) {
|
||||
int terrainPoint = getTerrainHeightFromHeightMap(map.width - 1 - ix);
|
||||
|
||||
map.getTerrainArray()
|
||||
[terrainPoint + iy]
|
||||
[map.width - 1 - ix] = TileNameCode.SAND;
|
||||
map.getTerrainArray()
|
||||
[terrainPoint + iy - 1] // clear grass and make the sheet thicker
|
||||
[map.width - 1 - ix] = TileNameCode.SAND;
|
||||
map.setTileTerrain(map.width - 1 - ix, terrainPoint + iy, TileNameCode.SAND_BEACH);
|
||||
// clear grass and make the sheet thicker
|
||||
map.setTileTerrain(map.width - 1 - ix, terrainPoint + iy - 1, TileNameCode.SAND_BEACH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
8
src/com/Torvald/Terrarum/NoNegative.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.Torvald.Terrarum;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
*/
|
||||
public @interface NoNegative {
|
||||
String info() default "Only positive number is acceptable.";
|
||||
}
|
||||
8
src/com/Torvald/Terrarum/NonZero.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.Torvald.Terrarum;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
*/
|
||||
public @interface NonZero {
|
||||
String info() default "Non-zero value";
|
||||
}
|
||||
8
src/com/Torvald/Terrarum/NotNull.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.Torvald.Terrarum;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
*/
|
||||
public @interface NotNull {
|
||||
String info() default "Cannot be null.";
|
||||
}
|
||||
8
src/com/Torvald/Terrarum/Nullable.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.Torvald.Terrarum;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
*/
|
||||
public @interface Nullable {
|
||||
String info() default "Null value is acceptable.";
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class Terrarum extends StateBasedGame {
|
||||
public static final int WIDTH = 1060;
|
||||
public static final int HEIGHT = 742; // IMAX ratio
|
||||
public static boolean VSYNC = true;
|
||||
public static final int VSYNC_TRIGGER_THRESHOLD = 56;
|
||||
|
||||
public static Game game;
|
||||
|
||||
@@ -102,6 +103,8 @@ public class Terrarum extends StateBasedGame {
|
||||
}
|
||||
}
|
||||
|
||||
appgc.getInput().enableKeyRepeat();
|
||||
|
||||
game = new Game();
|
||||
addState(game);
|
||||
}
|
||||
|
||||
@@ -7,52 +7,58 @@ import com.Torvald.Terrarum.Terrarum;
|
||||
*/
|
||||
public class TileNameCode {
|
||||
|
||||
public static final byte AIR = 0;
|
||||
public static final int AIR = 0;
|
||||
|
||||
public static final byte STONE = 1;
|
||||
public static final byte DIRT = 2;
|
||||
public static final byte GRASS = 3;
|
||||
public static final int STONE = TilePropCodex.indexDamageToArrayAddr(1, 0);
|
||||
public static final int STONE_QUARRIED = TilePropCodex.indexDamageToArrayAddr(1, 1);
|
||||
public static final int DIRT = TilePropCodex.indexDamageToArrayAddr(2, 0);
|
||||
public static final int GRASS = TilePropCodex.indexDamageToArrayAddr(2, 1);
|
||||
|
||||
public static final byte PLANK_NORMAL = 4;
|
||||
public static final byte PLANK_EBONY = 5;
|
||||
public static final byte PLANK_BIRCH = 6;
|
||||
public static final byte PLANK_BLOODROSE = 7;
|
||||
public static final int PLANK_NORMAL = TilePropCodex.indexDamageToArrayAddr(3, 0);
|
||||
public static final int PLANK_EBONY = TilePropCodex.indexDamageToArrayAddr(3, 1);
|
||||
public static final int PLANK_BIRCH = TilePropCodex.indexDamageToArrayAddr(3, 2);
|
||||
public static final int PLANK_BLOODROSE = TilePropCodex.indexDamageToArrayAddr(3, 3);
|
||||
|
||||
public static final byte TRUNK_NORMAL = 8;
|
||||
public static final byte TRUNK_EBONY = 9;
|
||||
public static final byte TRUNK_BIRCH = 10;
|
||||
public static final byte TRUNK_BLOODROSE = 11;
|
||||
public static final int TRUNK_NORMAL = TilePropCodex.indexDamageToArrayAddr(4, 0);
|
||||
public static final int TRUNK_EBONY = TilePropCodex.indexDamageToArrayAddr(4, 1);
|
||||
public static final int TRUNK_BIRCH = TilePropCodex.indexDamageToArrayAddr(4, 2);
|
||||
public static final int TRUNK_BLOODROSE = TilePropCodex.indexDamageToArrayAddr(4, 3);
|
||||
|
||||
public static final byte STONE_QUARRIED = 12;
|
||||
public static final byte SAND = 13;
|
||||
public static final byte GRAVEL = 14;
|
||||
public static final int SAND = TilePropCodex.indexDamageToArrayAddr(5, 0);
|
||||
public static final int SAND_BEACH = TilePropCodex.indexDamageToArrayAddr(5, 1);
|
||||
public static final int SAND_RED = TilePropCodex.indexDamageToArrayAddr(5, 2);
|
||||
public static final int SAND_DESERT = TilePropCodex.indexDamageToArrayAddr(5, 3);
|
||||
public static final int SAND_BLACK = TilePropCodex.indexDamageToArrayAddr(5, 4);
|
||||
public static final int GRAVEL = TilePropCodex.indexDamageToArrayAddr(6, 0);
|
||||
|
||||
public static final byte ORE_COPPER = 15;
|
||||
public static final byte ORE_IRON = 16;
|
||||
public static final byte ORE_GOLD = 17;
|
||||
public static final byte ORE_SILVER = 18;
|
||||
public static final byte ORE_ILMENITE = 19;
|
||||
public static final byte ORE_AURICHALCUM = 20;
|
||||
public static final int ORE_COPPER = TilePropCodex.indexDamageToArrayAddr(7, 0);
|
||||
public static final int ORE_IRON = TilePropCodex.indexDamageToArrayAddr(7, 1);
|
||||
public static final int ORE_GOLD = TilePropCodex.indexDamageToArrayAddr(7, 2);
|
||||
public static final int ORE_SILVER = TilePropCodex.indexDamageToArrayAddr(7, 3);
|
||||
public static final int ORE_ILMENITE = TilePropCodex.indexDamageToArrayAddr(7, 4);
|
||||
public static final int ORE_AURICHALCUM = TilePropCodex.indexDamageToArrayAddr(7, 5);
|
||||
|
||||
public static final byte RAW_RUBY = 21;
|
||||
public static final byte RAW_EMERALD = 22;
|
||||
public static final byte RAW_SAPPHIRE = 23;
|
||||
public static final byte RAW_TOPAZ = 24;
|
||||
public static final byte RAW_DIAMOND = 25;
|
||||
public static final byte RAW_AMETHYST = 26;
|
||||
public static final int RAW_RUBY = TilePropCodex.indexDamageToArrayAddr(8, 0);
|
||||
public static final int RAW_EMERALD = TilePropCodex.indexDamageToArrayAddr(8, 1);
|
||||
public static final int RAW_SAPPHIRE = TilePropCodex.indexDamageToArrayAddr(8, 2);
|
||||
public static final int RAW_TOPAZ = TilePropCodex.indexDamageToArrayAddr(8, 3);
|
||||
public static final int RAW_DIAMOND = TilePropCodex.indexDamageToArrayAddr(8, 4);
|
||||
public static final int RAW_AMETHYST = TilePropCodex.indexDamageToArrayAddr(8, 5);
|
||||
|
||||
public static final byte SNOW = 27;
|
||||
public static final byte ICE_FRAGILE = 28;
|
||||
public static final byte ICE_NATURAL = 29;
|
||||
public static final byte ICE_MAGICAL = 30;
|
||||
public static final int SNOW = TilePropCodex.indexDamageToArrayAddr(9, 0);
|
||||
public static final int ICE_FRAGILE = TilePropCodex.indexDamageToArrayAddr(9, 1);
|
||||
public static final int ICE_NATURAL = TilePropCodex.indexDamageToArrayAddr(9, 2);
|
||||
public static final int ICE_MAGICAL = TilePropCodex.indexDamageToArrayAddr(9, 3);
|
||||
|
||||
public static final byte PLATFORM_STONE = 31;
|
||||
public static final byte PLATFORM_WOODEN = 32;
|
||||
public static final byte PLATFORM_EBONY = 33;
|
||||
public static final byte PLATFORM_BIRCH = 34;
|
||||
public static final byte PLATFORM_BLOODROSE = 35;
|
||||
public static final int PLATFORM_STONE = TilePropCodex.indexDamageToArrayAddr(10, 0);
|
||||
public static final int PLATFORM_WOODEN = TilePropCodex.indexDamageToArrayAddr(10, 1);
|
||||
public static final int PLATFORM_EBONY = TilePropCodex.indexDamageToArrayAddr(10, 2);
|
||||
public static final int PLATFORM_BIRCH = TilePropCodex.indexDamageToArrayAddr(10, 3);
|
||||
public static final int PLATFORM_BLOODROSE = TilePropCodex.indexDamageToArrayAddr(10, 4);
|
||||
|
||||
public static final byte WATER = (byte) 239;
|
||||
public static final byte LAVA = (byte) 255;
|
||||
public static final int TORCH = TilePropCodex.indexDamageToArrayAddr(11, 0);
|
||||
|
||||
public static final int WATER = TilePropCodex.indexDamageToArrayAddr(254, 15);
|
||||
public static final int LAVA = TilePropCodex.indexDamageToArrayAddr(255, 15);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package com.Torvald.Terrarum.TileProperties;
|
||||
public class TileProp {
|
||||
|
||||
private int id;
|
||||
private int damage;
|
||||
private String name;
|
||||
|
||||
private char opacity; // colour attenuation
|
||||
@@ -22,7 +23,9 @@ public class TileProp {
|
||||
private boolean opaque; // hides wall or not
|
||||
|
||||
private char luminosity;
|
||||
|
||||
private int drop;
|
||||
private int dropDamage;
|
||||
|
||||
private boolean fallable;
|
||||
|
||||
@@ -36,6 +39,14 @@ public class TileProp {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(int damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -116,6 +127,14 @@ public class TileProp {
|
||||
this.drop = drop;
|
||||
}
|
||||
|
||||
public int getDropDamage() {
|
||||
return dropDamage;
|
||||
}
|
||||
|
||||
public void setDropDamage(int dropDamage) {
|
||||
this.dropDamage = dropDamage;
|
||||
}
|
||||
|
||||
public boolean isFallable() {
|
||||
return fallable;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.Torvald.Terrarum.TileProperties;
|
||||
|
||||
import com.Torvald.CSVFetcher;
|
||||
import com.Torvald.Terrarum.GameMap.MapLayer;
|
||||
import com.Torvald.Terrarum.GameMap.PairedMapLayer;
|
||||
import org.apache.commons.csv.CSVRecord;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -16,7 +17,7 @@ public class TilePropCodex {
|
||||
private static TileProp[] tileProps;
|
||||
|
||||
public TilePropCodex() {
|
||||
tileProps = new TileProp[MapLayer.TILES_SUPPORTED];
|
||||
tileProps = new TileProp[MapLayer.TILES_SUPPORTED * (PairedMapLayer.RANGE)];
|
||||
|
||||
for (int i = 0; i < tileProps.length; i++) {
|
||||
tileProps[i] = new TileProp();
|
||||
@@ -31,7 +32,10 @@ public class TilePropCodex {
|
||||
System.out.println("[TilePropCodex] Building tile properties table");
|
||||
|
||||
records.forEach(record ->
|
||||
setProp(tileProps[intVal(record, "id")], record
|
||||
setProp(tileProps[indexDamageToArrayAddr
|
||||
(intVal(record, "id")
|
||||
, intVal(record, "dmg"))
|
||||
], record
|
||||
));
|
||||
}
|
||||
catch (IOException e) {
|
||||
@@ -39,27 +43,42 @@ public class TilePropCodex {
|
||||
}
|
||||
}
|
||||
|
||||
public static TileProp getProp(int index) {
|
||||
public static TileProp getProp(int index, int damage) {
|
||||
try {
|
||||
tileProps[index].getId();
|
||||
tileProps[indexDamageToArrayAddr(index, damage)].getId();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
throw new NullPointerException("Tile prop with id " + String.valueOf(index)
|
||||
throw new NullPointerException("Tile prop with id " + index
|
||||
+ " and damage " + damage
|
||||
+ " does not exist.");
|
||||
}
|
||||
|
||||
return tileProps[index];
|
||||
return tileProps[indexDamageToArrayAddr(index, damage)];
|
||||
}
|
||||
|
||||
public static TileProp getProp(int rawIndex) {
|
||||
try {
|
||||
tileProps[rawIndex].getId();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
throw new NullPointerException("Tile prop with raw id " + rawIndex
|
||||
+ " does not exist.");
|
||||
}
|
||||
|
||||
return tileProps[rawIndex];
|
||||
}
|
||||
|
||||
private static void setProp(TileProp prop, CSVRecord record) {
|
||||
prop.setName(record.get("name"));
|
||||
|
||||
prop.setId(intVal(record, "id"));
|
||||
prop.setDamage(intVal(record, "dmg"));
|
||||
|
||||
prop.setOpacity((char) intVal(record, "opacity"));
|
||||
prop.setStrength(intVal(record, "strength"));
|
||||
prop.setLuminosity((char) intVal(record, "lumcolor"));
|
||||
prop.setDrop(intVal(record, "drop"));
|
||||
prop.setDropDamage(intVal(record, "ddmg"));
|
||||
prop.setFriction(intVal(record, "friction"));
|
||||
|
||||
prop.setFluid(boolVal(record, "fluid"));
|
||||
@@ -81,4 +100,8 @@ public class TilePropCodex {
|
||||
private static boolean boolVal(CSVRecord rec, String s) {
|
||||
return !(intVal(rec, s) == 0);
|
||||
}
|
||||
|
||||
public static int indexDamageToArrayAddr(int index, int damage) {
|
||||
return (index * (PairedMapLayer.RANGE) + damage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,60 @@
|
||||
"id";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"opaque";"drop";"fall";"friction"
|
||||
"0";"TILE_AIR" ; "1641"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0";"16"
|
||||
"1";"TILE_STONE" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "1"; "0";"16"
|
||||
"2";"TILE_DIRT" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "0";"16"
|
||||
"3";"TILE_GRASS" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "0";"16"
|
||||
"4";"TILE_PLANK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "4"; "0";"16"
|
||||
"5";"TILE_PLANK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "0";"16"
|
||||
"6";"TILE_PLANK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "6"; "0";"16"
|
||||
"7";"TILE_PLANK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "7"; "0";"16"
|
||||
"8";"TILE_TRUNK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "0";"16"
|
||||
"9";"TILE_TRUNK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "9"; "0";"16"
|
||||
"10";"TILE_TRUNK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "10"; "0";"16"
|
||||
"11";"TILE_TRUNK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "11"; "0";"16"
|
||||
"12";"TILE_STONE_QUARRIED" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "12"; "0";"16"
|
||||
"13";"TILE_SAND" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "13"; "1";"16"
|
||||
"14";"TILE_GRAVEL" ; "8205"; "6"; "0"; "0"; "1"; "0"; "0"; "1"; "14"; "1";"16"
|
||||
"id";"dmg";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"opaque";"drop";"ddmg";"fall";"friction"
|
||||
"0"; "0";"TILE_AIR" ; "1641"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0";"16"
|
||||
"1"; "0";"TILE_STONE" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "1"; "0"; "0";"16"
|
||||
"1"; "1";"TILE_STONE_QUARRIED" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "1"; "1"; "0";"16"
|
||||
"2"; "0";"TILE_DIRT" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "0"; "0";"16"
|
||||
"2"; "1";"TILE_GRASS" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "1"; "0";"16"
|
||||
|
||||
"15";"TILE_ORE_MALACHITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "15"; "0";"16"
|
||||
"16";"TILE_ORE_HEMATITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "16"; "0";"16"
|
||||
"17";"TILE_ORE_NATURAL_GOLD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "17"; "0";"16"
|
||||
"18";"TILE_ORE_NATURAL_SILVER" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "18"; "0";"16"
|
||||
"19";"TILE_ORE_RUTILE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "19"; "0";"16"
|
||||
"20";"TILE_ORE_AURICHALCUMITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "20"; "0";"16"
|
||||
"21";"TILE_GEM_RUBY" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "21"; "0";"16"
|
||||
"22";"TILE_GEM_EMERALD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "22"; "0";"16"
|
||||
"23";"TILE_GEM_SAPPHIRE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "23"; "0";"16"
|
||||
"24";"TILE_GEM_TOPAZ" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "24"; "0";"16"
|
||||
"25";"TILE_GEM_DIAMOND" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "25"; "0";"16"
|
||||
"26";"TILE_GEM_AMETHYST" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "26"; "0";"16"
|
||||
"3"; "0";"TILE_PLANK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "3"; "0"; "0";"16"
|
||||
"3"; "1";"TILE_PLANK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "3"; "1"; "0";"16"
|
||||
"3"; "2";"TILE_PLANK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "3"; "2"; "0";"16"
|
||||
"3"; "3";"TILE_PLANK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "3"; "3"; "0";"16"
|
||||
|
||||
"27";"TILE_SNOW" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "27"; "0";"16"
|
||||
"28";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "0"; "1"; "0"; "0"; "0"; "28"; "0";"16"
|
||||
"29";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "29"; "0"; "8"
|
||||
"30";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "0"; "1"; "1"; "5009"; "0"; "30"; "0"; "8"
|
||||
# see scandinavian name set female of this tile id!
|
||||
"31";"TILE_PLATFORM_STONE" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "31"; "0";"16"
|
||||
"32";"TILE_PLATFORM_WOODEN" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "32"; "0";"16"
|
||||
"33";"TILE_PLATFORM_EBONY" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "33"; "0";"16"
|
||||
"34";"TILE_PLATFORM_BIRCH" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "34"; "0";"16"
|
||||
"35";"TILE_PLATFORM_BLOODROSE" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "35"; "0";"16"
|
||||
"4"; "0";"TILE_TRUNK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "3"; "0"; "0";"16"
|
||||
"4"; "1";"TILE_TRUNK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "3"; "1"; "0";"16"
|
||||
"4"; "2";"TILE_TRUNK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "3"; "2"; "0";"16"
|
||||
"4"; "3";"TILE_TRUNK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "3"; "3"; "0";"16"
|
||||
|
||||
"36";"TILE_TORCH" ; "0"; "0"; "0"; "0"; "0"; "0"; "63412"; "0"; "36"; "0";"16"
|
||||
"5"; "0";"TILE_SAND" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "0"; "1";"16"
|
||||
"5"; "1";"TILE_SAND_WHITE" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "1"; "1";"16"
|
||||
"5"; "2";"TILE_SAND_RED" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "2"; "1";"16"
|
||||
"5"; "3";"TILE_SAND" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "3"; "1";"16"
|
||||
"5"; "4";"TILE_SAND_BLACK" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "4"; "1";"16"
|
||||
|
||||
"6"; "0";"TILE_GRAVEL" ; "8205"; "6"; "0"; "0"; "1"; "0"; "0"; "1"; "6"; "0"; "1";"16"
|
||||
"6"; "1";"TILE_GRAVEL_GREY" ; "8205"; "6"; "0"; "0"; "1"; "0"; "0"; "1"; "6"; "1"; "1";"16"
|
||||
|
||||
"7"; "0";"TILE_ORE_MALACHITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "0"; "0";"16"
|
||||
"7"; "1";"TILE_ORE_HEMATITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "1"; "0";"16"
|
||||
"7"; "2";"TILE_ORE_NATURAL_GOLD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "2"; "0";"16"
|
||||
"7"; "3";"TILE_ORE_NATURAL_SILVER" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "3"; "0";"16"
|
||||
"7"; "4";"TILE_ORE_RUTILE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "4"; "0";"16"
|
||||
"7"; "5";"TILE_ORE_AURICHALCUMITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "7"; "5"; "0";"16"
|
||||
|
||||
"8"; "0";"TILE_GEM_RUBY" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "0"; "0";"16"
|
||||
"8"; "1";"TILE_GEM_EMERALD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "1"; "0";"16"
|
||||
"8"; "2";"TILE_GEM_SAPPHIRE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "2"; "0";"16"
|
||||
"8"; "3";"TILE_GEM_TOPAZ" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "3"; "0";"16"
|
||||
"8"; "4";"TILE_GEM_DIAMOND" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "4"; "0";"16"
|
||||
"8"; "5";"TILE_GEM_AMETHYST" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "5"; "0";"16"
|
||||
|
||||
"9"; "0";"TILE_SNOW" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "9"; "0"; "0";"16"
|
||||
"9"; "1";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "0"; "1"; "0"; "0"; "0"; "9"; "1"; "0";"16"
|
||||
"9"; "2";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "9"; "2"; "0"; "8"
|
||||
"9"; "3";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "0"; "1"; "1"; "5009"; "0"; "9"; "3"; "0"; "8"
|
||||
|
||||
"10"; "0";"TILE_PLATFORM_STONE" ; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "10"; "0"; "0";"16"
|
||||
"10"; "1";"TILE_PLATFORM_WOODEN" ; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "10"; "1"; "0";"16"
|
||||
"10"; "2";"TILE_PLATFORM_EBONY" ; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "10"; "2"; "0";"16"
|
||||
"10"; "3";"TILE_PLATFORM_BIRCH" ; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "10"; "3"; "0";"16"
|
||||
"10"; "4";"TILE_PLATFORM_BLOODROSE" ; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "10"; "4"; "0";"16"
|
||||
|
||||
"11"; "0";"TILE_TORCH" ; "0"; "0"; "0"; "0"; "0"; "0"; "63412"; "0"; "11"; "0"; "0";"16"
|
||||
# 63412 (ffa44e) : real candlelight colour taken from properly configured camera.
|
||||
"239";"TILE_WATER" ; "6522"; "100"; "1"; "16"; "0"; "0"; "0"; "0"; "239"; "0";"16"
|
||||
"255";"TILE_LAVA" ; "62358"; "100"; "1"; "16"; "0"; "0"; "48320"; "0"; "239"; "0";"16"
|
||||
"254"; "15";"TILE_WATER" ; "6522"; "100"; "1"; "16"; "0"; "0"; "0"; "0"; "-1"; "-1"; "0";"16"
|
||||
"255"; "15";"TILE_LAVA" ; "62358"; "100"; "1"; "16"; "0"; "0"; "48320"; "0"; "-1"; "-1"; "0";"16"
|
||||
# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky
|
||||
# Opacity/Lumcolor: 40-step RGB
|
||||
# Opaque: whether the tile completely hides wall behind
|
||||
# Solid: whether the tile has collision
|
||||
# Viscosity: (walkspeedmax) * (1 + (n/16))
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 12.
|
@@ -198,51 +198,6 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(int key, char c) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(int key, char c) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(int oldx, int oldy, int newx, int newy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int button, int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(int change) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void controllerButtonPressed(int controller, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void controllerButtonReleased(int controller, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processInput(Input input) {
|
||||
|
||||
|
||||
@@ -70,51 +70,6 @@ public class Bulletin implements UICanvas {
|
||||
System.out.println("arst");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(int key, char c) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(int key, char c) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(int oldx, int oldy, int newx, int newy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int button, int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(int change) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void controllerButtonPressed(int controller, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void controllerButtonReleased(int controller, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processInput(Input input) {
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.newdawn.slick.Input;
|
||||
/**
|
||||
* Created by minjaesong on 15-12-31.
|
||||
*/
|
||||
public class ConsoleWindow implements UICanvas {
|
||||
public class ConsoleWindow implements UICanvas, UITypable {
|
||||
|
||||
Color UIColour = new Color(0x90000000);
|
||||
|
||||
@@ -106,41 +106,6 @@ public class ConsoleWindow implements UICanvas {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(int oldx, int oldy, int newx, int newy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int button, int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(int change) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void controllerButtonPressed(int controller, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void controllerButtonReleased(int controller, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processInput(Input input) {
|
||||
|
||||
|
||||
@@ -70,51 +70,6 @@ public class Message implements UICanvas {
|
||||
g.setDrawMode(Graphics.MODE_NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(int key, char c) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(int key, char c) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(int oldx, int oldy, int newx, int newy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int button, int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(int change) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void controllerButtonPressed(int controller, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void controllerButtonReleased(int controller, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processInput(Input input) {
|
||||
|
||||
|
||||
@@ -8,22 +8,6 @@ import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-31. <br>
|
||||
* <br>
|
||||
* Methods: <br>
|
||||
* UICanvas() <br>
|
||||
* update(GameContainer gc, int delta_t) <br>
|
||||
* render(GameContainer gc, Graphics g) <br>
|
||||
* keyPressed(int key, char c) <br>
|
||||
* keyReleased(int key, char c) <br>
|
||||
* mouseMoved(int oldx, int oldy, int newx, int newy) <br>
|
||||
* mouseDragged(int oldx, int oldy, int newx, int newy) <br>
|
||||
* mousePressed(int button, int x, int y) <br>
|
||||
* mouseReleased(int button, int x, int y) <br>
|
||||
* mouseWheelMoved(int change) <br>
|
||||
* controllerButtonPressed(int controller, int button) <br>
|
||||
* controllerButtonReleased(int controller, int button) <br>
|
||||
* processInput(Input input) <br>
|
||||
* <br>
|
||||
*/
|
||||
public interface UICanvas {
|
||||
|
||||
@@ -35,24 +19,6 @@ public interface UICanvas {
|
||||
|
||||
void render(GameContainer gc, Graphics g);
|
||||
|
||||
void keyPressed(int key, char c);
|
||||
|
||||
void keyReleased(int key, char c);
|
||||
|
||||
void mouseMoved(int oldx, int oldy, int newx, int newy);
|
||||
|
||||
void mouseDragged(int oldx, int oldy, int newx, int newy);
|
||||
|
||||
void mousePressed(int button, int x, int y);
|
||||
|
||||
void mouseReleased(int button, int x, int y);
|
||||
|
||||
void mouseWheelMoved(int change);
|
||||
|
||||
void controllerButtonPressed(int controller, int button);
|
||||
|
||||
void controllerButtonReleased(int controller, int button);
|
||||
|
||||
void processInput(Input input);
|
||||
|
||||
}
|
||||
|
||||
22
src/com/Torvald/Terrarum/UserInterface/UIClickable.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.Torvald.Terrarum.UserInterface;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-06.
|
||||
*/
|
||||
public interface UIClickable {
|
||||
|
||||
void mouseMoved(int oldx, int oldy, int newx, int newy);
|
||||
|
||||
void mouseDragged(int oldx, int oldy, int newx, int newy);
|
||||
|
||||
void mousePressed(int button, int x, int y);
|
||||
|
||||
void mouseReleased(int button, int x, int y);
|
||||
|
||||
void mouseWheelMoved(int change);
|
||||
|
||||
void controllerButtonPressed(int controller, int button);
|
||||
|
||||
void controllerButtonReleased(int controller, int button);
|
||||
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class UIHandler {
|
||||
|
||||
public void setVisibility(boolean b){
|
||||
if (alwaysVisible) {
|
||||
throw new RuntimeException("Tried to 'set visibility of' constant UI");
|
||||
throw new RuntimeException("[UIHandler] Tried to 'set visibility of' constant UI");
|
||||
}
|
||||
visible = b;
|
||||
}
|
||||
@@ -110,21 +110,21 @@ public class UIHandler {
|
||||
|
||||
public void setAsOpening(){
|
||||
if (alwaysVisible) {
|
||||
throw new RuntimeException("Tried to 'open' constant UI");
|
||||
throw new RuntimeException("[UIHandler] Tried to 'open' constant UI");
|
||||
}
|
||||
visible = true;
|
||||
}
|
||||
|
||||
public void setAsClosing(){
|
||||
if (alwaysVisible) {
|
||||
throw new RuntimeException("Tried to 'close' constant UI");
|
||||
throw new RuntimeException("[UIHandler] Tried to 'close' constant UI");
|
||||
}
|
||||
visible = false;
|
||||
}
|
||||
|
||||
public void toggleOpening() {
|
||||
if (alwaysVisible) {
|
||||
throw new RuntimeException("Tried to 'toggle opening of' constant UI");
|
||||
throw new RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI");
|
||||
}
|
||||
if (visible) {
|
||||
if (!closing) {
|
||||
@@ -143,39 +143,39 @@ public class UIHandler {
|
||||
}
|
||||
|
||||
public void keyPressed(int key, char c) {
|
||||
if (visible) { ui.keyPressed(key, c); }
|
||||
if (visible && ui instanceof UITypable) { ((UITypable) (ui)).keyPressed(key, c); }
|
||||
}
|
||||
|
||||
public void keyReleased(int key, char c) {
|
||||
if (visible) { ui.keyReleased(key, c); }
|
||||
if (visible && ui instanceof UITypable) { ((UITypable) (ui)).keyReleased(key, c); }
|
||||
}
|
||||
|
||||
public void mouseMoved(int oldx, int oldy, int newx, int newy) {
|
||||
if (visible) { ui.mouseMoved(oldx, oldy, newx, newy); }
|
||||
if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).mouseMoved(oldx, oldy, newx, newy); }
|
||||
}
|
||||
|
||||
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
|
||||
if (visible) { ui.mouseDragged(oldx, oldy, newx, newy); }
|
||||
if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).mouseDragged(oldx, oldy, newx, newy); }
|
||||
}
|
||||
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
if (visible) { ui.mousePressed(button, x, y); }
|
||||
if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).mousePressed(button, x, y); }
|
||||
}
|
||||
|
||||
public void mouseReleased(int button, int x, int y) {
|
||||
if (visible) { ui.mouseReleased(button, x, y); }
|
||||
if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).mouseReleased(button, x, y); }
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(int change) {
|
||||
if (visible) { ui.mouseWheelMoved(change); }
|
||||
if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).mouseWheelMoved(change); }
|
||||
}
|
||||
|
||||
public void controllerButtonPressed(int controller, int button) {
|
||||
if (visible) { ui.controllerButtonPressed(controller, button); }
|
||||
if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).controllerButtonPressed(controller, button); }
|
||||
}
|
||||
|
||||
public void controllerButtonReleased(int controller, int button) {
|
||||
if (visible) { ui.controllerButtonReleased(controller, button); }
|
||||
if (visible && ui instanceof UIClickable) { ((UIClickable) (ui)).controllerButtonReleased(controller, button); }
|
||||
}
|
||||
|
||||
public boolean isTakingControl() {
|
||||
|
||||
12
src/com/Torvald/Terrarum/UserInterface/UITypable.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.Torvald.Terrarum.UserInterface;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-06.
|
||||
*/
|
||||
public interface UITypable {
|
||||
|
||||
void keyPressed(int key, char c);
|
||||
|
||||
void keyReleased(int key, char c);
|
||||
|
||||
}
|
||||