mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-13 15:16:07 +09:00
40-step coloured lighting instead of previous 256 steps, reducing memory usage by half (size of array of 'int' > size of array of 'char'), kerning in bitmap fonts (interchar, spacing of unihan/hangul/kana), new jp/kr unihan font from chinese font as jp/kr language has slightly different glyph for certain han character
Former-commit-id: 5d88e02857e6d33d87421fb5a2a39b423c540e0f Former-commit-id: e4ea5a98bf738db1478fa91dbd4a43231c2354af
This commit is contained in:
@@ -10,6 +10,11 @@ public class Col216 implements LimitedColours {
|
||||
private byte data;
|
||||
private static int[] LOOKUP = {0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF};
|
||||
|
||||
public static final int MUL = 6;
|
||||
public static final int MUL_2 = MUL * MUL;
|
||||
public static final int MAX_STEP = MUL - 1;
|
||||
public static final int COLOUR_DOMAIN_SIZE = MUL_2 * MUL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
@@ -31,9 +36,9 @@ public class Col216 implements LimitedColours {
|
||||
@Override
|
||||
public Color createSlickColor(int raw) {
|
||||
assertRaw(raw);
|
||||
int r = LOOKUP[(raw / 36)];
|
||||
int g = LOOKUP[((raw % 36) / 6)];
|
||||
int b = LOOKUP[raw % 6];
|
||||
int r = raw / MUL_2;
|
||||
int g = (raw % MUL_2) / MUL;
|
||||
int b = raw % MUL;
|
||||
|
||||
return createSlickColor(r, g, b);
|
||||
}
|
||||
@@ -53,20 +58,20 @@ public class Col216 implements LimitedColours {
|
||||
@Override
|
||||
public void create(int r, int g, int b) {
|
||||
assertRGB(r, g, b);
|
||||
data = (byte) (36 * r + 6 * g + b);
|
||||
data = (byte) (MUL_2 * r + MUL * g + b);
|
||||
}
|
||||
|
||||
public byte getRaw() { return data; }
|
||||
|
||||
private void assertRaw(int i) {
|
||||
if (i > 0xFF || i < 0) {
|
||||
if (i >= COLOUR_DOMAIN_SIZE || i < 0) {
|
||||
System.out.println("i: " + String.valueOf(i));
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertRGB(int r, int g, int b) {
|
||||
if (r > 5 || g > 5 || b > 5 || r < 0 || g < 0 || b < 0) {
|
||||
if (r > MAX_STEP || g > MAX_STEP || b > MAX_STEP || r < 0 || g < 0 || b < 0) {
|
||||
System.out.println("r: " + String.valueOf(r));
|
||||
System.out.println("g: " + String.valueOf(g));
|
||||
System.out.println("b: " + String.valueOf(b));
|
||||
|
||||
64
src/com/Torvald/ColourUtil/Col40.java
Normal file
64
src/com/Torvald/ColourUtil/Col40.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.Torvald.ColourUtil;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-20.
|
||||
*/
|
||||
public class Col40 implements LimitedColours {
|
||||
|
||||
private char data;
|
||||
private static int[] LOOKUP = {0,7,13,20,26,33,39,46,52,59,65,72,78,85,92,98,105,111,118,124
|
||||
,131,137,144,150,157,163,170,177,183,190,196,203,209,216,222,229,235,242,248,255};
|
||||
|
||||
public static final int MUL = 40;
|
||||
public static final int MUL_2 = MUL * MUL;
|
||||
public static final int MAX_STEP = MUL - 1;
|
||||
public static final int COLOUR_DOMAIN_SIZE = MUL_2 * MUL;
|
||||
|
||||
@Override
|
||||
public Color createSlickColor(int raw) {
|
||||
assertRaw(raw);
|
||||
int r = raw / MUL_2;
|
||||
int g = (raw % MUL_2) / MUL;
|
||||
int b = raw % MUL;
|
||||
|
||||
return createSlickColor(r, g, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color createSlickColor(int r, int g, int b) {
|
||||
assertRGB(r, g, b);
|
||||
return new Color((LOOKUP[r] << 16) | (LOOKUP[g] << 8) | LOOKUP[b]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(int raw) {
|
||||
assertRaw(raw);
|
||||
data = (char) raw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(int r, int g, int b) {
|
||||
assertRGB(r, g, b);
|
||||
data = (char) (MUL_2 * r + MUL * g + b);
|
||||
}
|
||||
|
||||
public char getRaw() { return data; }
|
||||
|
||||
private void assertRaw(int i) {
|
||||
if (i >= COLOUR_DOMAIN_SIZE || i < 0) {
|
||||
System.out.println("i: " + String.valueOf(i));
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertRGB(int r, int g, int b) {
|
||||
if (r > MAX_STEP || g > MAX_STEP || b > MAX_STEP || r < 0 || g < 0 || b < 0) {
|
||||
System.out.println("r: " + String.valueOf(r));
|
||||
System.out.println("g: " + String.valueOf(g));
|
||||
System.out.println("b: " + String.valueOf(b));
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ public class GameFontBase implements Font {
|
||||
|
||||
static final int W_CJK = 10;
|
||||
static final int W_UNIHAN = 16;
|
||||
static final int W_CJK_DRAW = 11;
|
||||
static final int W_LATIN_WIDE = 9; // width of regular letters, including m
|
||||
static final int W_LATIN_NARROW = 5; // width of letter f, t, i, l
|
||||
static final int H = 20;
|
||||
@@ -81,6 +80,8 @@ public class GameFontBase implements Font {
|
||||
,'ᛂ','᛬','᛫','᛭','ᛮ','ᛯ','ᛰ'
|
||||
};
|
||||
|
||||
static int interchar = 0;
|
||||
|
||||
|
||||
public GameFontBase() throws SlickException {
|
||||
|
||||
@@ -201,24 +202,44 @@ public class GameFontBase implements Font {
|
||||
|
||||
@Override
|
||||
public int getWidth(String s) {
|
||||
int len = 0;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
return getWidthSubstr(s, s.length());
|
||||
}
|
||||
|
||||
switch (getSheetType(c)) {
|
||||
case SHEET_ASCII_EF:
|
||||
len += W_LATIN_NARROW; break;
|
||||
case SHEET_KANA: case SHEET_CJK_PUNCT:
|
||||
len += W_CJK_DRAW; break;
|
||||
case SHEET_HANGUL:
|
||||
len += W_CJK_DRAW;
|
||||
break;
|
||||
case SHEET_UNIHAN:
|
||||
len += W_UNIHAN; break;
|
||||
default:
|
||||
len += W_LATIN_WIDE;
|
||||
private int getWidthSubstr(String s, int endIndex) {
|
||||
int len = 0;
|
||||
for (int i = 0; i < endIndex; i++) {
|
||||
int c = getSheetType(s.charAt(i));
|
||||
|
||||
if (i > 0 && s.charAt(i) > 0x20) { // Kerning
|
||||
int cpre = getSheetType(s.charAt(i - 1));
|
||||
if (
|
||||
((cpre == SHEET_UNIHAN || cpre == SHEET_HANGUL)
|
||||
&& !(c == SHEET_UNIHAN || c == SHEET_HANGUL))
|
||||
|
||||
|| ((c == SHEET_UNIHAN || c == SHEET_HANGUL)
|
||||
&& !(cpre == SHEET_UNIHAN || cpre == SHEET_HANGUL))
|
||||
) {
|
||||
// margin after/before hangul/unihan
|
||||
len += 2;
|
||||
}
|
||||
else if ((c == SHEET_HANGUL || c == SHEET_KANA)
|
||||
&& (cpre == SHEET_HANGUL || cpre == SHEET_KANA)) {
|
||||
// margin between hangul/kana
|
||||
len += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (c == SHEET_ASCII_EF || c == SHEET_EXTA_EF || c == SHEET_CYRILIC_EF)
|
||||
len += W_LATIN_NARROW;
|
||||
else if (c == SHEET_KANA || c == SHEET_HANGUL || c == SHEET_CJK_PUNCT)
|
||||
len += W_CJK;
|
||||
else if (c == SHEET_UNIHAN)
|
||||
len += W_UNIHAN;
|
||||
else
|
||||
len += W_LATIN_WIDE;
|
||||
|
||||
if (i < endIndex - 1) len += interchar;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
@@ -247,9 +268,10 @@ public class GameFontBase implements Font {
|
||||
|
||||
if (isHangul(ch)) {
|
||||
int[] hanPos = getHan(ch - 0xAC00);
|
||||
int glyphW = getWidth("" + ch);
|
||||
hangulSheet.renderInUse(
|
||||
Math.round(x
|
||||
+ getWidth(s.substring(0, i))
|
||||
+ getWidthSubstr(s, i + 1) - glyphW
|
||||
)
|
||||
, Math.round((H - H_HANGUL) / 2 + y + 1)
|
||||
, hanPos[0]
|
||||
@@ -265,9 +287,10 @@ public class GameFontBase implements Font {
|
||||
char ch = s.charAt(i);
|
||||
|
||||
if (isUniHan(ch)) {
|
||||
int glyphW = getWidth("" + ch);
|
||||
uniHan.renderInUse(
|
||||
Math.round(x
|
||||
+ getWidth(s.substring(0, i))
|
||||
+ getWidthSubstr(s, i + 1) - glyphW
|
||||
)
|
||||
, Math.round((H - H_HANGUL) / 2 + y)
|
||||
, uniHanIndexX(ch)
|
||||
@@ -334,10 +357,11 @@ public class GameFontBase implements Font {
|
||||
}
|
||||
|
||||
try {
|
||||
int glyphW = getWidth("" + ch);
|
||||
sheetKey[prevInstance].renderInUse(
|
||||
Math.round(x + getWidth(s.substring(0, i)))
|
||||
// pull punct right next to hangul to the left
|
||||
+ ((i > 0 && isHangul(s.charAt(i - 1))) ? -2 : 0)
|
||||
Math.round(x + getWidthSubstr(s, i + 1) - glyphW)
|
||||
// Interchar: pull punct right next to hangul to the left
|
||||
+ ((i > 0 && isHangul(s.charAt(i - 1))) ? -3 : 0)
|
||||
, Math.round(y)
|
||||
- ((prevInstance == SHEET_CJK_PUNCT) ? 1 : 0)
|
||||
, sheetX
|
||||
@@ -384,4 +408,15 @@ public class GameFontBase implements Font {
|
||||
|
||||
}
|
||||
|
||||
public void reloadUnihan() throws SlickException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set margin between characters
|
||||
* @param margin
|
||||
*/
|
||||
public void setInterchar(int margin) {
|
||||
interchar = margin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.Torvald.ImageFont;
|
||||
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import org.newdawn.slick.*;
|
||||
|
||||
/**
|
||||
@@ -43,7 +44,10 @@ public class GameFontWhite extends GameFontBase {
|
||||
, W_CJK, H_KANA
|
||||
);
|
||||
uniHan = new SpriteSheet(
|
||||
"./res/graphics/fonts/unifont_unihan.png"
|
||||
"./res/graphics/fonts/unifont_unihan"
|
||||
+ (((Terrarum.gameLocale.contains("jp") || Terrarum.gameLocale.contains("ko")))
|
||||
? "_jp" : "")
|
||||
+".png"
|
||||
, W_UNIHAN, H_UNIHAN
|
||||
);
|
||||
cyrilic = new SpriteSheet(
|
||||
@@ -71,4 +75,14 @@ public class GameFontWhite extends GameFontBase {
|
||||
sheetKey = shk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadUnihan() throws SlickException {
|
||||
uniHan = new SpriteSheet(
|
||||
"./res/graphics/fonts/unifont_unihan"
|
||||
+ ((!Terrarum.gameLocale.contains("cn"))
|
||||
? "_jp" : "")
|
||||
+".png"
|
||||
, W_UNIHAN, H_UNIHAN
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ HEARTS, CLUBS, DIAMONDS, SPADES: PLAYERS WHO SUIT MUDS
|
||||
- (Optional) SFX
|
||||
|
||||
* Size
|
||||
- Regular sprite 'height': 40 px
|
||||
- Regular sprite 'height' (hitbox height) : 40 px
|
||||
- Apparent height may vary
|
||||
|
||||
|
||||
@@ -160,6 +160,4 @@ HEARTS, CLUBS, DIAMONDS, SPADES: PLAYERS WHO SUIT MUDS
|
||||
|
||||
* Colour: 4096 colours (12-bit 0x000 - 0xFFF)
|
||||
|
||||
* Height variation option (.85 - .90 - .95 - 1 - 1.05 - 1.10 - 1.15)
|
||||
|
||||
* Base mass: 60 kg
|
||||
|
||||
16
src/com/Torvald/Terrarum/Actors/Landholder.java
Normal file
16
src/com/Torvald/Terrarum/Actors/Landholder.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-20.
|
||||
*/
|
||||
public interface Landholder {
|
||||
|
||||
ArrayList<Integer> getHouseDesignation();
|
||||
void setHouseDesignation(ArrayList<Integer> list);
|
||||
void addHouseTile(int x, int y);
|
||||
void removeHouseTile(int x, int y);
|
||||
void clearHouseDesignation();
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ package com.Torvald.Terrarum.Actors;
|
||||
*/
|
||||
public interface Luminous {
|
||||
|
||||
void setLuminance(int RGB);
|
||||
int getLuminance();
|
||||
void setLuminance(char RGB);
|
||||
char getLuminance();
|
||||
|
||||
}
|
||||
|
||||
@@ -2,15 +2,17 @@ package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.Faction.Faction;
|
||||
import com.Torvald.Terrarum.GameItem.InventoryItem;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-31.
|
||||
*/
|
||||
public class TestNPC extends ActorWithBody implements AIControlled, Pocketed, CanBeStoredAsItem,
|
||||
Factionable {
|
||||
public class NPCIntelligentBase extends ActorWithBody implements AIControlled, Pocketed, CanBeStoredAsItem,
|
||||
Factionable, Landholder {
|
||||
|
||||
private InventoryItem itemData;
|
||||
// private ActorAI ai;
|
||||
@@ -18,6 +20,8 @@ public class TestNPC extends ActorWithBody implements AIControlled, Pocketed, Ca
|
||||
|
||||
private HashSet<Faction> factionSet = new HashSet<>();
|
||||
|
||||
private ArrayList<Integer> houseTiles = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void attachAI() {
|
||||
|
||||
@@ -88,6 +92,31 @@ public class TestNPC extends ActorWithBody implements AIControlled, Pocketed, Ca
|
||||
return super.getMass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Integer> getHouseDesignation() {
|
||||
return houseTiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHouseDesignation(ArrayList<Integer> list) {
|
||||
houseTiles = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHouseTile(int x, int y) {
|
||||
houseTiles.add(Terrarum.game.map.width * y + x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHouseTile(int x, int y) {
|
||||
houseTiles.remove(new Integer(Terrarum.game.map.width * y + x));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearHouseDesignation() {
|
||||
houseTiles.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopUpdateAndDraw() {
|
||||
super.setUpdate(false);
|
||||
@@ -55,7 +55,7 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
|
||||
private final int TSIZE = MapDrawer.TILE_SIZE;
|
||||
|
||||
private int LUMINANCE_RGB = 0xFFFFFF;
|
||||
private char LUMINANCE_RGB = 63999;
|
||||
|
||||
private HashSet<Faction> factionSet = new HashSet<>();
|
||||
|
||||
@@ -174,7 +174,7 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
* |
|
||||
* 0+------············ t
|
||||
*
|
||||
* which is unrealistic, so this method tries to introduce some realism by:
|
||||
* which is unrealistic, so this method tries to introduce some realism by doing:
|
||||
*
|
||||
* a
|
||||
* | ------------
|
||||
@@ -547,12 +547,12 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLuminance(int RGB) {
|
||||
public void setLuminance(char RGB) {
|
||||
LUMINANCE_RGB = RGB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLuminance() {
|
||||
public char getLuminance() {
|
||||
return LUMINANCE_RGB;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,38 +3,40 @@ package com.Torvald.Terrarum.ConsoleCommand;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.Terrarum.UserInterface.ConsoleWindow;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.newdawn.slick.SlickException;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-19.
|
||||
*/
|
||||
public class Authenticator implements ConsoleCommand {
|
||||
|
||||
private static final String A = "0d34076fc15db1b7c7a0943045699eba6f186ec1"; // alpine
|
||||
// or 'srisrimahasri'
|
||||
|
||||
private static boolean B = false;
|
||||
private static boolean a = false;
|
||||
|
||||
@Override
|
||||
public void execute(String[] args) {
|
||||
if (args.length == 2) {
|
||||
String pwd = args[1];
|
||||
|
||||
String hashedPwd = DigestUtils.sha1Hex(pwd);
|
||||
String hashedPwd = DigestUtils.sha256Hex(pwd);
|
||||
|
||||
if (A.equalsIgnoreCase(hashedPwd)) {
|
||||
new Echo().execute(((B) ? "Dis" : "") + "authenticated.");
|
||||
B = !B;
|
||||
if ("54c5b3dd459d5ef778bb2fa1e23a5fb0e1b62ae66970bcb436e8f81a1a1a8e41".equalsIgnoreCase(hashedPwd)) {
|
||||
// alpine
|
||||
String msg = (a) ? "Locked" : "Authenticated";
|
||||
new Echo().execute(msg);
|
||||
System.out.println("[Authenticator] " + msg);
|
||||
a = !a;
|
||||
((ConsoleWindow) (Terrarum.game.consoleHandler.getUI())).reset();
|
||||
}
|
||||
else {
|
||||
printUsage(); // thou shalt not pass!
|
||||
}
|
||||
}
|
||||
else {
|
||||
printUsage();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean C() {
|
||||
return B;
|
||||
public boolean b() {
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,7 @@ public class CommandInterpreter {
|
||||
new Zoom().execute(single_command.toStringArray());
|
||||
}
|
||||
else {
|
||||
if (Terrarum.game.auth.C()) {
|
||||
if (Terrarum.game.auth.b()) {
|
||||
ConsoleCommand commandObj = CommandDict.getCommand(
|
||||
single_command.getName().toLowerCase());
|
||||
commandObj.execute(single_command.toStringArray());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.MapDrawer.LightmapRenderer;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
/**
|
||||
@@ -13,13 +14,32 @@ public class SetGlobalLightLevel implements ConsoleCommand {
|
||||
int r = new Integer(args[1]);
|
||||
int g = new Integer(args[2]);
|
||||
int b = new Integer(args[3]);
|
||||
int GL = (r << 16) | (g << 8) | b;
|
||||
char GL = LightmapRenderer.constructRGBFromInt(r, g, b);
|
||||
|
||||
Terrarum.game.map.setGlobalLight(GL);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
new Echo().execute("Wrong number input.");
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
new Echo().execute("Range: 0-" + LightmapRenderer.CHANNEL_MAX + " per channel");
|
||||
}
|
||||
}
|
||||
else if (args.length == 2) {
|
||||
try {
|
||||
char GL = (char) (new Integer(args[1]).intValue());
|
||||
|
||||
if (GL < 0 || GL >= LightmapRenderer.COLOUR_DOMAIN_SIZE) {
|
||||
new Echo().execute("Range: 0-" + (LightmapRenderer.COLOUR_DOMAIN_SIZE - 1));
|
||||
}
|
||||
else {
|
||||
Terrarum.game.map.setGlobalLight(GL);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
new Echo().execute("Wrong number input.");
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
printUsage();
|
||||
@@ -28,6 +48,6 @@ public class SetGlobalLightLevel implements ConsoleCommand {
|
||||
|
||||
@Override
|
||||
public void printUsage() {
|
||||
new Echo().execute("Usage: setgl r g b");
|
||||
new Echo().execute("Usage: setgl [raw_value|r g b]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.ImageFont.GameFontBase;
|
||||
import com.Torvald.Terrarum.LangPack.Lang;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import org.newdawn.slick.SlickException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -17,6 +19,12 @@ public class SetLocale implements ConsoleCommand {
|
||||
try {
|
||||
new Lang();
|
||||
new Echo().execute("Set locale to '" + Terrarum.gameLocale + "'.");
|
||||
|
||||
if ((!prevLocale.contains("cn") && Terrarum.gameLocale.contains("cn"))
|
||||
|| (prevLocale.contains("cn") && !Terrarum.gameLocale.contains("cn"))) {
|
||||
try { ((GameFontBase) Terrarum.gameFontWhite).reloadUnihan(); }
|
||||
catch (SlickException e) { e.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
new Echo().execute("Locale '"
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.Torvald.Terrarum.GameControl;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.Controllable;
|
||||
import com.Torvald.Terrarum.Actors.Player;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapCamera;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapDrawer;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.Terrarum.UserInterface.UIHandler;
|
||||
import org.newdawn.slick.Input;
|
||||
@@ -75,7 +77,16 @@ public class GameController {
|
||||
}
|
||||
|
||||
public static void mousePressed(int button, int x, int y) {
|
||||
int mouseTileX = (int) ((MapCamera.getCameraX() + x / Terrarum.game.screenZoom)
|
||||
/ MapDrawer.TILE_SIZE);
|
||||
int mouseTileY = (int) ((MapCamera.getCameraY() + y / Terrarum.game.screenZoom)
|
||||
/ MapDrawer.TILE_SIZE);
|
||||
|
||||
try {
|
||||
Terrarum.game.map.setTileTerrain(mouseTileX, mouseTileY, (byte) 0);
|
||||
Terrarum.game.map.setTileWall(mouseTileX, mouseTileY, (byte) 0);
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {}
|
||||
}
|
||||
|
||||
public static void mouseReleased(int button, int x, int y) {
|
||||
|
||||
@@ -31,8 +31,6 @@ public class GameMap {
|
||||
public int spawnX;
|
||||
public int spawnY;
|
||||
|
||||
private LinkedList<MapPoint> houseDesignation;
|
||||
|
||||
public static final int WALL = 0;
|
||||
public static final int TERRAIN = 1;
|
||||
public static final int WIRE = 2;
|
||||
@@ -40,7 +38,7 @@ public class GameMap {
|
||||
//public World physWorld = new World( new Vec2(0, -TerrarumMain.game.gravitationalAccel) );
|
||||
//physics
|
||||
private float gravitation;
|
||||
private int globalLight;
|
||||
private char globalLight;
|
||||
private WorldTime worldTime;
|
||||
|
||||
/**
|
||||
@@ -59,7 +57,7 @@ public class GameMap {
|
||||
layerWire = new MapLayer(width, height);
|
||||
terrainDamageCode = new PairedMapLayer(width, height);
|
||||
|
||||
globalLight = 0xFFFFFF;
|
||||
globalLight = (char) 63999;
|
||||
worldTime = new WorldTime();
|
||||
}
|
||||
|
||||
@@ -140,6 +138,18 @@ public class GameMap {
|
||||
return terrainDamageCode.getData(x, y);
|
||||
}
|
||||
|
||||
public void setTileWall(int x, int y, byte tile) {
|
||||
layerWall.data[y][x] = tile;
|
||||
}
|
||||
|
||||
public void setTileTerrain(int x, int y, byte tile) {
|
||||
layerTerrain.data[y][x] = tile;
|
||||
}
|
||||
|
||||
public void setTileWire(int x, int y, byte tile) {
|
||||
layerWire.data[y][x] = tile;
|
||||
}
|
||||
|
||||
public int getTileFrom(int mode, int x, int y) {
|
||||
if (mode == TERRAIN) { return getTileFromTerrain(x, y); }
|
||||
else if (mode == WALL) { return getTileFromWall(x, y); }
|
||||
@@ -161,11 +171,11 @@ public class GameMap {
|
||||
return gravitation;
|
||||
}
|
||||
|
||||
public int getGlobalLight() {
|
||||
public char getGlobalLight() {
|
||||
return globalLight;
|
||||
}
|
||||
|
||||
public void setGlobalLight(int globalLight) {
|
||||
public void setGlobalLight(char globalLight) {
|
||||
this.globalLight = globalLight;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
* Drawing
|
||||
|
||||
- Players can create their own décors (hang on wall), dresses.
|
||||
- Two looms (3-3-2 colour mode, 4096 colour mode)
|
||||
- Two looms (216 colour mode, 4096 colour mode)
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.Torvald.Terrarum.MapDrawer;
|
||||
|
||||
import com.Torvald.ColourUtil.Col40;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.Terrarum.TileProperties.TilePropCodex;
|
||||
import com.jme3.math.FastMath;
|
||||
@@ -17,7 +18,7 @@ public class LightmapRenderer {
|
||||
/**
|
||||
* 8-Bit RGB values
|
||||
*/
|
||||
private static volatile int[][] staticLightMap;
|
||||
private static volatile char[][] staticLightMap;
|
||||
private static boolean lightMapInitialised = false;
|
||||
|
||||
/**
|
||||
@@ -26,6 +27,7 @@ public class LightmapRenderer {
|
||||
private static ArrayList<LightmapLantern> lanterns = new ArrayList<>();
|
||||
|
||||
private static final int AIR = 0;
|
||||
private static final int SUNSTONE = 41; // TODO add sunstone: emits same light as Map.GL. Goes dark at night
|
||||
|
||||
|
||||
private static final int OFFSET_R = 2;
|
||||
@@ -34,18 +36,18 @@ public class LightmapRenderer {
|
||||
|
||||
private static final int TSIZE = MapDrawer.TILE_SIZE;
|
||||
|
||||
/**
|
||||
* Stores current light map as image.
|
||||
* WILL BE PURGED in every single round of light calculation.
|
||||
*/
|
||||
//private static Graphics lightMapGraphicsInstance;
|
||||
|
||||
// color model related vars
|
||||
public static final int MUL = Col40.MUL;
|
||||
public static final int MUL_2 = Col40.MUL_2;
|
||||
public static final int CHANNEL_MAX = Col40.MAX_STEP;
|
||||
public static final float CHANNEL_MAX_FLOAT = (float) CHANNEL_MAX;
|
||||
public static final int COLOUR_DOMAIN_SIZE = Col40.COLOUR_DOMAIN_SIZE;
|
||||
|
||||
public LightmapRenderer() {
|
||||
|
||||
}
|
||||
|
||||
public static void addLantern(int x, int y, int intensity) {
|
||||
public static void addLantern(int x, int y, char intensity) {
|
||||
LightmapLantern thisLantern = new LightmapLantern(x, y, intensity);
|
||||
|
||||
for (int i = lanterns.size() - 1; i >= 0; i--) {
|
||||
@@ -53,7 +55,7 @@ public class LightmapRenderer {
|
||||
// found duplicates
|
||||
if (lanternInList.getX() == x && lanternInList.getY() == y) {
|
||||
// add colour
|
||||
int addedL = addRaw(intensity, lanternInList.getIntensity());
|
||||
char addedL = addRaw(intensity, lanternInList.getIntensity());
|
||||
lanternInList.intensity = addedL;
|
||||
return;
|
||||
}
|
||||
@@ -73,7 +75,7 @@ public class LightmapRenderer {
|
||||
|
||||
public static void renderLightMap() {
|
||||
if (staticLightMap == null) {
|
||||
staticLightMap = new int[Terrarum.game.map.height][Terrarum.game.map.width];
|
||||
staticLightMap = new char[Terrarum.game.map.height][Terrarum.game.map.width];
|
||||
|
||||
if (lightMapInitialised) {
|
||||
throw new RuntimeException("Attempting to re-initialise 'staticLightMap'");
|
||||
@@ -145,7 +147,7 @@ public class LightmapRenderer {
|
||||
for (int x = for_x_start; x < for_x_end; x++) {
|
||||
// smooth
|
||||
if (Terrarum.game.screenZoom >= 1 && ((boolean) Terrarum.game.gameConfig.get("smoothlighting"))) {
|
||||
int thisLightLevel = staticLightMap[y][x];
|
||||
char thisLightLevel = staticLightMap[y][x];
|
||||
if (y > 0 && x < for_x_end && thisLightLevel == 0 && staticLightMap[y - 1][x] == 0) {
|
||||
// coalesce zero intensity blocks to one
|
||||
int zeroLevelCounter = 1;
|
||||
@@ -175,23 +177,25 @@ public class LightmapRenderer {
|
||||
* +-+-+
|
||||
* d
|
||||
*/
|
||||
int a = (y == 0) ? thisLightLevel
|
||||
char a = (y == 0) ? thisLightLevel
|
||||
: (y == Terrarum.game.map.height - 1) ? thisLightLevel
|
||||
: Math.max(staticLightMap[y][x]
|
||||
: max(staticLightMap[y][x]
|
||||
, staticLightMap[y - 1][x]);
|
||||
int d = (y == 0) ? thisLightLevel
|
||||
char d = (y == 0) ? thisLightLevel
|
||||
: (y == Terrarum.game.map.height - 1) ? thisLightLevel
|
||||
: Math.max(staticLightMap[y][x]
|
||||
: max(staticLightMap[y][x]
|
||||
, staticLightMap[y + 1][x]);
|
||||
int b = (x == 0) ? thisLightLevel
|
||||
char b = (x == 0) ? thisLightLevel
|
||||
: (x == Terrarum.game.map.width - 1) ? thisLightLevel
|
||||
: Math.max(staticLightMap[y][x]
|
||||
: max(staticLightMap[y][x]
|
||||
, staticLightMap[y][x - 1]);
|
||||
int c = (x == 0) ? thisLightLevel
|
||||
char c = (x == 0) ? thisLightLevel
|
||||
: (x == Terrarum.game.map.width - 1) ? thisLightLevel
|
||||
: Math.max(staticLightMap[y][x]
|
||||
: max(staticLightMap[y][x]
|
||||
, staticLightMap[y][x + 1]);
|
||||
int[] colourMapItoL = new int[4];
|
||||
char t = staticLightMap[y][x];
|
||||
|
||||
char[] colourMapItoL = new char[4];
|
||||
colourMapItoL[0] = colourLinearMix(a, b);
|
||||
colourMapItoL[1] = colourLinearMix(a, c);
|
||||
colourMapItoL[2] = colourLinearMix(b, d);
|
||||
@@ -199,7 +203,7 @@ public class LightmapRenderer {
|
||||
|
||||
for (int iy = 0; iy < 2; iy++) {
|
||||
for (int ix = 0; ix < 2; ix++) {
|
||||
g.setColor(new Color(colourMapItoL[iy * 2 + ix]));
|
||||
g.setColor(toTargetColour(colourMapItoL[iy * 2 + ix]));
|
||||
|
||||
g.fillRect(
|
||||
Math.round(x * TSIZE * Terrarum.game.screenZoom) + (ix * TSIZE / 2 * Terrarum.game.screenZoom)
|
||||
@@ -223,7 +227,7 @@ public class LightmapRenderer {
|
||||
if (x + sameLevelCounter >= for_x_end) break;
|
||||
}
|
||||
|
||||
g.setColor(new Color(staticLightMap[y][x]));
|
||||
g.setColor(toTargetColour(staticLightMap[y][x]));
|
||||
g.fillRect(
|
||||
Math.round(x * TSIZE * Terrarum.game.screenZoom)
|
||||
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
|
||||
@@ -237,13 +241,17 @@ public class LightmapRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private static int calculate(int x, int y){
|
||||
private static Color toTargetColour(char raw) {
|
||||
return new Col40().createSlickColor(raw);
|
||||
}
|
||||
|
||||
private static char calculate(int x, int y){
|
||||
if (!outOfBounds(x, y)){
|
||||
|
||||
float lightColorR = 1f;
|
||||
float lightColorG = 1f;
|
||||
float lightColorB = 1f;
|
||||
int lightColorInt;
|
||||
char lightColorInt;
|
||||
|
||||
int thisTerrain = Terrarum.game.map.getTileFromTerrain(x, y);
|
||||
int thisWall = Terrarum.game.map.getTileFromWall(x, y);
|
||||
@@ -255,7 +263,7 @@ public class LightmapRenderer {
|
||||
else {
|
||||
// mix light emitter
|
||||
if (TilePropCodex.getProp(thisTerrain).getLuminosity() != 0) {
|
||||
int lum = TilePropCodex.getProp(thisTerrain).getLuminosity();
|
||||
char lum = TilePropCodex.getProp(thisTerrain).getLuminosity();
|
||||
lightColorR = getR(lum);
|
||||
lightColorG = getG(lum);
|
||||
lightColorB = getB(lum);
|
||||
@@ -264,7 +272,7 @@ public class LightmapRenderer {
|
||||
// mix lantern
|
||||
for (LightmapLantern lantern : lanterns) {
|
||||
if (lantern.getX() == x && lantern.getY() == y) {
|
||||
int lum = lantern.getIntensity();
|
||||
char lum = lantern.getIntensity();
|
||||
lightColorR = getR(lum);
|
||||
lightColorG = getG(lum);
|
||||
lightColorB = getB(lum);
|
||||
@@ -277,7 +285,7 @@ public class LightmapRenderer {
|
||||
int tileX = Math.round(Terrarum.game.getPlayer().getHitbox().getPointedX() / TSIZE);
|
||||
int tileY = Math.round(Terrarum.game.getPlayer().getHitbox().getPointedY() / TSIZE)
|
||||
- 1;
|
||||
int lum = Terrarum.game.getPlayer().getLuminance();
|
||||
char lum = Terrarum.game.getPlayer().getLuminance();
|
||||
if (x == tileX && y == tileY) {
|
||||
lightColorR = getR(lum);
|
||||
lightColorG = getG(lum);
|
||||
@@ -286,49 +294,56 @@ public class LightmapRenderer {
|
||||
|
||||
float[] bgrVal = new float[3]; // {B, G, R}
|
||||
|
||||
// test for each R, G, B channel
|
||||
// test for each B, G, R channel
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int brightest = 0;
|
||||
|
||||
//get brightest of nearby 4 tiles
|
||||
int nearby = 0;
|
||||
int nearby = 0b0;
|
||||
findNearbyBrightest:
|
||||
for (int yoff = -1; yoff <= 1; yoff++) {
|
||||
for (int xoff = -1; xoff <= 1; xoff++) {
|
||||
/**
|
||||
* filter for 'v's as:
|
||||
* +-+-+-+
|
||||
* | |v| |
|
||||
* |a|v|a|
|
||||
* +-+-+-+
|
||||
* |v| |v|
|
||||
* +-+-+-+
|
||||
* | |v| |
|
||||
* |a|v|a|
|
||||
* +-+-+-+
|
||||
*/
|
||||
if (xoff != yoff && -xoff != yoff) {
|
||||
if (!outOfMapBounds(x + xoff, y + yoff)) {
|
||||
nearby = getRaw(staticLightMap[y + yoff][x + xoff], i);
|
||||
}
|
||||
|
||||
if (nearby > brightest) {
|
||||
brightest = nearby;
|
||||
}
|
||||
|
||||
if (brightest == 0xFF) break findNearbyBrightest;
|
||||
if (xoff != yoff && -xoff != yoff) { // 'v' tiles
|
||||
if (!outOfMapBounds(x + xoff, y + yoff)) {
|
||||
nearby = getRaw(staticLightMap[y + yoff][x + xoff], i);
|
||||
}
|
||||
}
|
||||
else if (xoff != 0 && yoff != 0) { // 'a' tiles
|
||||
if (!outOfMapBounds(x + xoff, y + yoff)) {
|
||||
nearby = darken((char) getRaw(staticLightMap[y + yoff][x + xoff], i)
|
||||
, 0x3); //mix some to have more 'spreading'
|
||||
// so that light spreads in a shape of an octagon instead of a diamond
|
||||
}
|
||||
}
|
||||
|
||||
if (nearby > brightest) {
|
||||
brightest = nearby;
|
||||
}
|
||||
|
||||
if (brightest == CHANNEL_MAX) break findNearbyBrightest;
|
||||
}
|
||||
}
|
||||
|
||||
//return: brightest - opacity
|
||||
bgrVal[i] = darkenFloat(
|
||||
brightest
|
||||
(char) (brightest)
|
||||
, TilePropCodex.getProp(thisTerrain).getOpacity()
|
||||
);
|
||||
}
|
||||
|
||||
// construct lightColor from bgrVal
|
||||
lightColorInt = constructRGBFromFloat(
|
||||
bgrVal[OFFSET_R] * lightColorR
|
||||
bgrVal[OFFSET_R] * lightColorR
|
||||
, bgrVal[OFFSET_G] * lightColorG
|
||||
, bgrVal[OFFSET_B] * lightColorB
|
||||
);
|
||||
@@ -344,36 +359,41 @@ public class LightmapRenderer {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data Raw channel value [0-255]
|
||||
* @param darken [0-255]
|
||||
* @return darkened data [0-1]
|
||||
* @param data Raw channel value [0-39] per channel
|
||||
* @param darken [0-39] per channel
|
||||
* @return darkened data [0-9] per channel (darken-int divided by 39)
|
||||
*/
|
||||
private static float darkenFloat(int data, int darken) {
|
||||
return (darken(data, darken) / 255f);
|
||||
private static float darkenFloat(char data, int darken) {
|
||||
return (darken(data, darken) / CHANNEL_MAX_FLOAT);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data Raw channel value [0-255]
|
||||
* @param darken [0-255]
|
||||
* @return darkened data [0-255]
|
||||
* @param data Raw channel value [0-39] per channel
|
||||
* @param darken [0-39] per channel
|
||||
* @return darkened data [0-39] per channel
|
||||
*/
|
||||
private static int darken(int data, int darken) {
|
||||
if (darken < 0 || darken > 0xFF) { throw new IllegalArgumentException("darken: out of range"); }
|
||||
private static char darken(char data, int darken) {
|
||||
if (darken < 0 || darken > CHANNEL_MAX) { throw new IllegalArgumentException("darken: out of " +
|
||||
"range"); }
|
||||
|
||||
return clampZero(data - darken);
|
||||
int r = clampZero(getRawR(data) - darken);
|
||||
int g = clampZero(getRawG(data) - darken);
|
||||
int b = clampZero(getRawB(data) - darken);
|
||||
|
||||
return constructRGBFromInt(r, g, b);
|
||||
}
|
||||
|
||||
private static int getRawR(int RGB) {
|
||||
return (RGB >> 16) & 0xFF;
|
||||
public static int getRawR(char RGB) {
|
||||
return RGB / MUL_2;
|
||||
}
|
||||
|
||||
private static int getRawG(int RGB) {
|
||||
return (RGB >> 8) & 0xFF;
|
||||
public static int getRawG(char RGB) {
|
||||
return (RGB % MUL_2) / MUL;
|
||||
}
|
||||
|
||||
private static int getRawB(int RGB) {
|
||||
return RGB & 0xFF;
|
||||
public static int getRawB(char RGB) {
|
||||
return RGB % MUL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -382,24 +402,26 @@ public class LightmapRenderer {
|
||||
* @param offset 2 = R, 1 = G, 0 = B
|
||||
* @return
|
||||
*/
|
||||
private static int getRaw(int RGB, int offset) {
|
||||
if (offset < 0 || offset > 2) throw new IllegalArgumentException("Offset out of range");
|
||||
return (RGB >> (8 * offset)) & 0xFF;
|
||||
public static int getRaw(char RGB, int offset) {
|
||||
if (offset == OFFSET_R) return getRawR(RGB);
|
||||
if (offset == OFFSET_G) return getRawG(RGB);
|
||||
if (offset == OFFSET_B) return getRawB(RGB);
|
||||
else throw new IllegalArgumentException("Channel offset out of range");
|
||||
}
|
||||
|
||||
private static float getR(int rgb) {
|
||||
return getRawR(rgb) / 255f;
|
||||
private static float getR(char rgb) {
|
||||
return getRawR(rgb) / CHANNEL_MAX_FLOAT;
|
||||
}
|
||||
|
||||
private static float getG(int rgb) {
|
||||
return getRawG(rgb) / 255f;
|
||||
private static float getG(char rgb) {
|
||||
return getRawG(rgb) / CHANNEL_MAX_FLOAT;
|
||||
}
|
||||
|
||||
private static float getB(int rgb) {
|
||||
return getRawB(rgb) / 255f;
|
||||
private static float getB(char rgb) {
|
||||
return getRawB(rgb) / CHANNEL_MAX_FLOAT;
|
||||
}
|
||||
|
||||
private static int addRaw(int rgb1, int rgb2) {
|
||||
private static char addRaw(char rgb1, char rgb2) {
|
||||
int newR = clampByte(getRawR(rgb1) + getRawB(rgb2));
|
||||
int newG = clampByte(getRawG(rgb1) + getRawG(rgb2));
|
||||
int newB = clampByte(getRawB(rgb1) + getRawB(rgb2));
|
||||
@@ -407,51 +429,32 @@ public class LightmapRenderer {
|
||||
return constructRGBFromInt(newR, newG, newB);
|
||||
}
|
||||
|
||||
private static int constructRGBFromInt(int r, int g, int b) {
|
||||
if (r < 0 || r > 0xFF) { throw new IllegalArgumentException("Red: out of range"); }
|
||||
if (g < 0 || g > 0xFF) { throw new IllegalArgumentException("Green: out of range"); }
|
||||
if (b < 0 || b > 0xFF) { throw new IllegalArgumentException("Blue: out of range"); }
|
||||
return (r << 16) | (g << 8) | b;
|
||||
public static char constructRGBFromInt(int r, int g, int b) {
|
||||
if (r < 0 || r > CHANNEL_MAX) { throw new IllegalArgumentException("Red: out of range"); }
|
||||
if (g < 0 || g > CHANNEL_MAX) { throw new IllegalArgumentException("Green: out of range"); }
|
||||
if (b < 0 || b > CHANNEL_MAX) { throw new IllegalArgumentException("Blue: out of range"); }
|
||||
return (char) (r * MUL_2 + g * MUL + b);
|
||||
}
|
||||
|
||||
private static int constructRGBFromFloat(float r, float g, float b) {
|
||||
private static char constructRGBFromFloat(float r, float g, float b) {
|
||||
if (r < 0 || r > 1.0f) { throw new IllegalArgumentException("Red: out of range"); }
|
||||
if (g < 0 || g > 1.0f) { throw new IllegalArgumentException("Green: out of range"); }
|
||||
if (b < 0 || b > 1.0f) { throw new IllegalArgumentException("Blue: out of range"); }
|
||||
|
||||
int intR = Math.round(r * 0xFF);
|
||||
int intG = Math.round(g * 0xFF);
|
||||
int intB = Math.round(b * 0xFF);
|
||||
int intR = Math.round(r * CHANNEL_MAX);
|
||||
int intG = Math.round(g * CHANNEL_MAX);
|
||||
int intB = Math.round(b * CHANNEL_MAX);
|
||||
|
||||
return constructRGBFromInt(intR, intG, intB);
|
||||
}
|
||||
|
||||
private static int colourLinearMix(int colA, int colB) {
|
||||
private static char colourLinearMix(char colA, char colB) {
|
||||
int r = (getRawR(colA) + getRawR(colB)) >> 1;
|
||||
int g = (getRawG(colA) + getRawG(colB)) >> 1;
|
||||
int b = (getRawB(colA) + getRawB(colB)) >> 1;
|
||||
return constructRGBFromInt(r, g, b);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param thisTile
|
||||
* @param side1
|
||||
* @param side2
|
||||
* @param corner
|
||||
* @return
|
||||
*/
|
||||
private static int colourQuadraticMix(int thisTile, int side1, int side2, int corner) {
|
||||
int rSide = max(getRawR(side1), getRawR(side2), getRawR(corner) / 2);
|
||||
int r = arithmeticAverage(rSide, getRawR(thisTile));
|
||||
int gSide = max(getRawG(side1), getRawG(side2), getRawG(corner) / 2);
|
||||
int g = arithmeticAverage(gSide, getRawG(thisTile));
|
||||
int bSide = max(getRawG(side1), getRawG(side2), getRawG(corner) / 2);
|
||||
int b = arithmeticAverage(bSide, getRawG(thisTile));
|
||||
|
||||
return constructRGBFromInt(r, g, b);
|
||||
}
|
||||
|
||||
private static int quantise16(int x) {
|
||||
if (x < 0) throw new IllegalArgumentException("positive integer only.");
|
||||
return (x & 0xFFFF_FFF0);
|
||||
@@ -467,12 +470,12 @@ public class LightmapRenderer {
|
||||
return (x << 4);
|
||||
}
|
||||
|
||||
private static int max(int... i) {
|
||||
private static char max(char... i) {
|
||||
Arrays.sort(i);
|
||||
return i[i.length - 1];
|
||||
}
|
||||
|
||||
private static int min(int... i) {
|
||||
private static char min(char... i) {
|
||||
Arrays.sort(i);
|
||||
return i[0];
|
||||
}
|
||||
@@ -494,14 +497,14 @@ public class LightmapRenderer {
|
||||
}
|
||||
|
||||
private static int clampByte(int i) {
|
||||
return (i < 0) ? 0 : (i > 0xFF) ? 0xFF : i;
|
||||
return (i < 0) ? 0 : (i > CHANNEL_MAX) ? CHANNEL_MAX : i;
|
||||
}
|
||||
|
||||
public static int[][] getStaticLightMap() {
|
||||
public static char[][] getStaticLightMap() {
|
||||
return staticLightMap;
|
||||
}
|
||||
|
||||
public static int getValueFromMap(int x, int y) {
|
||||
public static char getValueFromMap(int x, int y) {
|
||||
return staticLightMap[y][x];
|
||||
}
|
||||
|
||||
@@ -550,9 +553,9 @@ public class LightmapRenderer {
|
||||
|
||||
class LightmapLantern {
|
||||
int x, y;
|
||||
int intensity;
|
||||
char intensity;
|
||||
|
||||
public LightmapLantern(int x, int y, int intensity) {
|
||||
public LightmapLantern(int x, int y, char intensity) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.intensity = intensity;
|
||||
@@ -566,7 +569,7 @@ class LightmapLantern {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getIntensity() {
|
||||
public char getIntensity() {
|
||||
return intensity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -892,11 +892,11 @@ public class MapGenerator {
|
||||
int thisTile = map.getTileFromTerrain(x, y);
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
int nearbyTile = -1;
|
||||
try { nearbyTile = map.getTileFromTerrain(x + (i / 3) - 1, y + (i % 3) - 1); }
|
||||
int nearbyWallTile = -1;
|
||||
try { nearbyWallTile = map.getTileFromWall(x + (i % 3) - 1, y + (i / 3) - 1); }
|
||||
catch (ArrayIndexOutOfBoundsException e) {}
|
||||
|
||||
if (i != 4 && thisTile == DIRT && nearbyTile == AIR) {
|
||||
if (i != 4 && thisTile == DIRT && nearbyWallTile == AIR) {
|
||||
map.getTerrainArray()[y][x] = GRASS;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.Torvald.ImageFont.GameFontBase;
|
||||
import com.Torvald.ImageFont.GameFontWhite;
|
||||
import com.Torvald.Terrarum.ConsoleCommand.Authenticator;
|
||||
import com.Torvald.Terrarum.LangPack.Lang;
|
||||
@@ -42,7 +43,7 @@ public class Terrarum extends StateBasedGame {
|
||||
public static String defaultDir;
|
||||
public static String defaultSaveDir;
|
||||
|
||||
public static String gameLocale = "ko";
|
||||
public static String gameLocale = "jp";
|
||||
|
||||
public static Font gameFontWhite;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class TileProp {
|
||||
|
||||
private boolean wallable;
|
||||
|
||||
private int luminosity;
|
||||
private char luminosity;
|
||||
private int drop;
|
||||
|
||||
private boolean fallable;
|
||||
@@ -94,7 +94,7 @@ public class TileProp {
|
||||
* Raw RGB value, without alpha
|
||||
* @return
|
||||
*/
|
||||
public int getLuminosity() {
|
||||
public char getLuminosity() {
|
||||
return luminosity;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class TileProp {
|
||||
*
|
||||
* @param luminosity Raw RGB value, without alpha
|
||||
*/
|
||||
void setLuminosity(int luminosity) {
|
||||
void setLuminosity(char luminosity) {
|
||||
this.luminosity = luminosity;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,14 +49,18 @@ public class TilePropCodex {
|
||||
return tileProps[index];
|
||||
}
|
||||
|
||||
private void setProp(TileProp prop, CSVRecord record) {
|
||||
public static byte getTileID(String name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void setProp(TileProp prop, CSVRecord record) {
|
||||
prop.setName(record.get("name"));
|
||||
|
||||
prop.setId(intVal(record, "id"));
|
||||
|
||||
prop.setOpacity(intVal(record, "opacity"));
|
||||
prop.setStrength(intVal(record, "strength"));
|
||||
prop.setLuminosity(intVal(record, "lumcolor"));
|
||||
prop.setLuminosity((char) intVal(record, "lumcolor"));
|
||||
prop.setDrop(intVal(record, "drop"));
|
||||
prop.setFriction(intVal(record, "friction"));
|
||||
|
||||
@@ -71,11 +75,11 @@ public class TilePropCodex {
|
||||
System.out.println("\t" + prop.getName());
|
||||
}
|
||||
|
||||
private int intVal(CSVRecord rec, String s) {
|
||||
private static int intVal(CSVRecord rec, String s) {
|
||||
return Integer.decode(rec.get(s));
|
||||
}
|
||||
|
||||
private boolean boolVal(CSVRecord rec, String s) {
|
||||
private static boolean boolVal(CSVRecord rec, String s) {
|
||||
return !(intVal(rec, s) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
"id";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"drop";"fall";"friction"
|
||||
# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky
|
||||
"0";"TILE_AIR" ; "4"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "0";"16"
|
||||
"1";"TILE_STONE" ; "32"; "25"; "0"; "N/A"; "1"; "1"; "0"; "1"; "0";"16"
|
||||
"2";"TILE_DIRT" ; "32"; "6"; "0"; "N/A"; "1"; "1"; "0"; "2"; "0";"16"
|
||||
"3";"TILE_GRASS" ; "32"; "6"; "0"; "N/A"; "1"; "1"; "0"; "2"; "0";"16"
|
||||
"4";"TILE_PLANK_NORMAL" ; "32"; "12"; "0"; "N/A"; "1"; "1"; "0"; "4"; "0";"16"
|
||||
"5";"TILE_PLANK_EBONY" ; "32"; "12"; "0"; "N/A"; "1"; "1"; "0"; "5"; "0";"16"
|
||||
"6";"TILE_PLANK_BIRCH" ; "32"; "12"; "0"; "N/A"; "1"; "1"; "0"; "6"; "0";"16"
|
||||
"7";"TILE_PLANK_BLOODROSE" ; "32"; "12"; "0"; "N/A"; "1"; "1"; "0"; "7"; "0";"16"
|
||||
"8";"TILE_TRUNK_NORMAL" ; "32"; "12"; "0"; "N/A"; "1"; "0"; "0"; "8"; "0";"16"
|
||||
"9";"TILE_TRUNK_EBONY" ; "32"; "12"; "0"; "N/A"; "1"; "0"; "0"; "9"; "0";"16"
|
||||
"10";"TILE_TRUNK_BIRCH" ; "32"; "12"; "0"; "N/A"; "1"; "0"; "0"; "10"; "0";"16"
|
||||
"11";"TILE_TRUNK_BLOODROSE" ; "32"; "12"; "0"; "N/A"; "1"; "0"; "0"; "11"; "0";"16"
|
||||
"12";"TILE_STONE" ; "32"; "25"; "0"; "N/A"; "1"; "1"; "0"; "12"; "0";"16"
|
||||
"13";"TILE_SAND" ; "32"; "6"; "0"; "N/A"; "1"; "1"; "0"; "13"; "1";"16"
|
||||
"14";"TILE_GRAVEL" ; "32"; "6"; "0"; "N/A"; "1"; "0"; "0"; "14"; "1";"16"
|
||||
"0";"TILE_AIR" ; "1"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "0";"16"
|
||||
"1";"TILE_STONE" ; "5"; "25"; "0"; "N/A"; "1"; "1"; "0"; "1"; "0";"16"
|
||||
"2";"TILE_DIRT" ; "5"; "6"; "0"; "N/A"; "1"; "1"; "0"; "2"; "0";"16"
|
||||
"3";"TILE_GRASS" ; "5"; "6"; "0"; "N/A"; "1"; "1"; "0"; "2"; "0";"16"
|
||||
"4";"TILE_PLANK_NORMAL" ; "5"; "12"; "0"; "N/A"; "1"; "1"; "0"; "4"; "0";"16"
|
||||
"5";"TILE_PLANK_EBONY" ; "5"; "12"; "0"; "N/A"; "1"; "1"; "0"; "5"; "0";"16"
|
||||
"6";"TILE_PLANK_BIRCH" ; "5"; "12"; "0"; "N/A"; "1"; "1"; "0"; "6"; "0";"16"
|
||||
"7";"TILE_PLANK_BLOODROSE" ; "5"; "12"; "0"; "N/A"; "1"; "1"; "0"; "7"; "0";"16"
|
||||
"8";"TILE_TRUNK_NORMAL" ; "5"; "12"; "0"; "N/A"; "1"; "0"; "0"; "8"; "0";"16"
|
||||
"9";"TILE_TRUNK_EBONY" ; "5"; "12"; "0"; "N/A"; "1"; "0"; "0"; "9"; "0";"16"
|
||||
"10";"TILE_TRUNK_BIRCH" ; "5"; "12"; "0"; "N/A"; "1"; "0"; "0"; "10"; "0";"16"
|
||||
"11";"TILE_TRUNK_BLOODROSE" ; "5"; "12"; "0"; "N/A"; "1"; "0"; "0"; "11"; "0";"16"
|
||||
"12";"TILE_STONE" ; "5"; "25"; "0"; "N/A"; "1"; "1"; "0"; "12"; "0";"16"
|
||||
"13";"TILE_SAND" ; "5"; "6"; "0"; "N/A"; "1"; "1"; "0"; "13"; "1";"16"
|
||||
"14";"TILE_GRAVEL" ; "5"; "6"; "0"; "N/A"; "1"; "0"; "0"; "14"; "1";"16"
|
||||
|
||||
"15";"TILE_ORE_MALACHITE" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "15"; "0";"16"
|
||||
"16";"TILE_ORE_HEMATITE" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "16"; "0";"16"
|
||||
"17";"TILE_ORE_NATURAL_GOLD" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "17"; "0";"16"
|
||||
"18";"TILE_ORE_NATURAL_SILVER" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "18"; "0";"16"
|
||||
"19";"TILE_ORE_RUTILE" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "19"; "0";"16"
|
||||
"20";"TILE_ORE_AURICHALCUMITE" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "20"; "0";"16"
|
||||
"21";"TILE_GEM_RUBY" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "21"; "0";"16"
|
||||
"22";"TILE_GEM_EMERALD" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "22"; "0";"16"
|
||||
"23";"TILE_GEM_SAPPHIRE" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "23"; "0";"16"
|
||||
"24";"TILE_GEM_TOPAZ" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "24"; "0";"16"
|
||||
"25";"TILE_GEM_DIAMOND" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "25"; "0";"16"
|
||||
"26";"TILE_GEM_AMETHYST" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "26"; "0";"16"
|
||||
"15";"TILE_ORE_MALACHITE" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "15"; "0";"16"
|
||||
"16";"TILE_ORE_HEMATITE" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "16"; "0";"16"
|
||||
"17";"TILE_ORE_NATURAL_GOLD" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "17"; "0";"16"
|
||||
"18";"TILE_ORE_NATURAL_SILVER" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "18"; "0";"16"
|
||||
"19";"TILE_ORE_RUTILE" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "19"; "0";"16"
|
||||
"20";"TILE_ORE_AURICHALCUMITE" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "20"; "0";"16"
|
||||
"21";"TILE_GEM_RUBY" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "21"; "0";"16"
|
||||
"22";"TILE_GEM_EMERALD" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "22"; "0";"16"
|
||||
"23";"TILE_GEM_SAPPHIRE" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "23"; "0";"16"
|
||||
"24";"TILE_GEM_TOPAZ" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "24"; "0";"16"
|
||||
"25";"TILE_GEM_DIAMOND" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "25"; "0";"16"
|
||||
"26";"TILE_GEM_AMETHYST" ; "5"; "25"; "0"; "N/A"; "1"; "0"; "0"; "26"; "0";"16"
|
||||
|
||||
"27";"TILE_SNOW" ; "32"; "6"; "0"; "N/A"; "1"; "1"; "0"; "27"; "0";"16"
|
||||
"28";"TILE_ICE_FRAGILE" ; "8"; "1"; "0"; "N/A"; "1"; "0"; "0"; "28"; "0";"16"
|
||||
"29";"TILE_ICE_NATURAL" ; "24"; "25"; "0"; "N/A"; "1"; "1"; "0"; "29"; "0"; "8"
|
||||
"30";"TILE_ICE_CLEAR_MAGICAL" ; "32"; "25"; "0"; "N/A"; "1"; "1"; "855567"; "30"; "0"; "8"
|
||||
"27";"TILE_SNOW" ; "5"; "6"; "0"; "N/A"; "1"; "1"; "0"; "27"; "0";"16"
|
||||
"28";"TILE_ICE_FRAGILE" ; "2"; "1"; "0"; "N/A"; "1"; "0"; "0"; "28"; "0";"16"
|
||||
"29";"TILE_ICE_NATURAL" ; "4"; "25"; "0"; "N/A"; "1"; "1"; "0"; "29"; "0"; "8"
|
||||
"30";"TILE_ICE_CLEAR_MAGICAL" ; "5"; "25"; "0"; "N/A"; "1"; "1"; "4967"; "30"; "0"; "8"
|
||||
# see scandinavian name set female of this tile id!
|
||||
"31";"TILE_PLATFORM_STONE" ; "2"; "0"; "0"; "N/A"; "0"; "0"; "0"; "31"; "0";"16"
|
||||
"32";"TILE_PLATFORM_WOODEN" ; "2"; "0"; "0"; "N/A"; "0"; "0"; "0"; "32"; "0";"16"
|
||||
"33";"TILE_PLATFORM_EBONY" ; "2"; "0"; "0"; "N/A"; "0"; "0"; "0"; "33"; "0";"16"
|
||||
"34";"TILE_PLATFORM_BIRCH" ; "2"; "0"; "0"; "N/A"; "0"; "0"; "0"; "34"; "0";"16"
|
||||
"35";"TILE_PLATFORM_BLOODROSE" ; "2"; "0"; "0"; "N/A"; "0"; "0"; "0"; "35"; "0";"16"
|
||||
"31";"TILE_PLATFORM_STONE" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "31"; "0";"16"
|
||||
"32";"TILE_PLATFORM_WOODEN" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "32"; "0";"16"
|
||||
"33";"TILE_PLATFORM_EBONY" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "33"; "0";"16"
|
||||
"34";"TILE_PLATFORM_BIRCH" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "34"; "0";"16"
|
||||
"35";"TILE_PLATFORM_BLOODROSE" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "35"; "0";"16"
|
||||
|
||||
"36";"TILE_TORCH" ; "0"; "0"; "0"; "N/A"; "0"; "0";"16769997"; "36"; "0";"16"
|
||||
"36";"TILE_TORCH" ; "0"; "0"; "0"; "N/A"; "0"; "0";"63680"; "36"; "0";"16"
|
||||
|
||||
"239";"TILE_WATER" ; "16"; "100"; "1"; "2"; "0"; "0";"15464447"; "239"; "0";"16"
|
||||
"255";"TILE_LAVA" ; "0"; "100"; "1"; "2"; "0"; "0"; "8397312"; "239"; "0";"16"
|
||||
"239";"TILE_WATER" ; "2"; "100"; "1"; "2"; "0"; "0";"59159"; "239"; "0";"16"
|
||||
"255";"TILE_LAVA" ; "0"; "100"; "1"; "2"; "0"; "0";"48320"; "239"; "0";"16"
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 12.
|
@@ -83,7 +83,14 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
|
||||
String lightVal;
|
||||
try {
|
||||
lightVal = Integer.toHexString(LightmapRenderer.getValueFromMap(mouseTileX, mouseTileY)).toUpperCase();
|
||||
char valRaw = LightmapRenderer.getValueFromMap(mouseTileX, mouseTileY);
|
||||
int rawR = LightmapRenderer.getRawR(valRaw);
|
||||
int rawG = LightmapRenderer.getRawG(valRaw);
|
||||
int rawB = LightmapRenderer.getRawB(valRaw);
|
||||
lightVal = String.valueOf((int)valRaw) + " ("
|
||||
+ String.valueOf(rawR) + " "
|
||||
+ String.valueOf(rawG) + " "
|
||||
+ String.valueOf(rawB) + ")";
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
lightVal = "out of bounds";
|
||||
|
||||
@@ -189,7 +189,7 @@ public class ConsoleWindow implements UICanvas {
|
||||
prevCommand = "";
|
||||
commandInputPool = new StringBuffer();
|
||||
|
||||
if (Terrarum.game.auth.C()) sendMessage(Lang.get("DEV_MESSAGE_CONSOLE_CODEX"));
|
||||
if (Terrarum.game.auth.b()) sendMessage(Lang.get("DEV_MESSAGE_CONSOLE_CODEX"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user