mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-09 13:21:51 +09:00
Collision detector fixing on going, hangul combining (johab) font
Former-commit-id: d225fb399ea7ca6c80da1fa35db3c13a1505f1cc Former-commit-id: e218312c567bb7b2ea30961076e8bd24a8f2c131
This commit is contained in:
@@ -98,6 +98,25 @@ public class GameFontBase implements Font {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getHanChosung(int hanIndex) {
|
||||
return hanIndex / (JUNG_COUNT * JONG_COUNT);
|
||||
}
|
||||
|
||||
private int getHanJungseong(int hanIndex) {
|
||||
return hanIndex / (JONG_COUNT) % JUNG_COUNT;
|
||||
}
|
||||
|
||||
private int getHanJongseong(int hanIndex) {
|
||||
return hanIndex % JONG_COUNT;
|
||||
}
|
||||
|
||||
private int getHanChosungShift(int hanIndex) {
|
||||
int jungseongIndex = getHanJungseong(hanIndex);
|
||||
Integer[] jungseongWide = {8, 12, 13, 17, 18, 21};
|
||||
return (Arrays.asList(jungseongWide).contains(jungseongIndex))
|
||||
? 1 : 0;
|
||||
}
|
||||
|
||||
private boolean isAsciiEF(char c) {
|
||||
return (Arrays.asList(asciiEFList).contains(c));
|
||||
}
|
||||
@@ -288,7 +307,8 @@ public class GameFontBase implements Font {
|
||||
public void drawString(float x, float y, String s) {
|
||||
// hangul fonts first
|
||||
hangulSheet.startUse();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
// WANSEONG
|
||||
/*for (int i = 0; i < s.length(); i++) {
|
||||
char ch = s.charAt(i);
|
||||
|
||||
if (isHangul(ch)) {
|
||||
@@ -303,6 +323,53 @@ public class GameFontBase implements Font {
|
||||
, hanPos[1]
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
// JOHAB
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char ch = s.charAt(i);
|
||||
|
||||
if (isHangul(ch)) {
|
||||
int hIndex = ch - 0xAC00;
|
||||
|
||||
int indexCho = getHanChosung(hIndex);
|
||||
int indexJung = getHanJungseong(hIndex);
|
||||
int indexJong = getHanJongseong(hIndex);
|
||||
|
||||
int choRow = getHanChosungShift(hIndex);
|
||||
int jungRow = 2;
|
||||
int jongRow = 3;
|
||||
|
||||
int glyphW = getWidth("" + ch);
|
||||
|
||||
// chosung
|
||||
hangulSheet.renderInUse(
|
||||
Math.round(x
|
||||
+ getWidthSubstr(s, i + 1) - glyphW
|
||||
)
|
||||
, Math.round((H - H_HANGUL) / 2 + y + 1)
|
||||
, indexCho
|
||||
, choRow
|
||||
);
|
||||
// jungseong
|
||||
hangulSheet.renderInUse(
|
||||
Math.round(x
|
||||
+ getWidthSubstr(s, i + 1) - glyphW
|
||||
)
|
||||
, Math.round((H - H_HANGUL) / 2 + y + 1)
|
||||
, indexJung
|
||||
, jungRow
|
||||
);
|
||||
// jongseong
|
||||
hangulSheet.renderInUse(
|
||||
Math.round(x
|
||||
+ getWidthSubstr(s, i + 1) - glyphW
|
||||
)
|
||||
, Math.round((H - H_HANGUL) / 2 + y + 1)
|
||||
, indexJong
|
||||
, jongRow
|
||||
);
|
||||
}
|
||||
}
|
||||
hangulSheet.endUse();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public class GameFontBlack extends GameFontBase {
|
||||
super();
|
||||
|
||||
hangulSheet = new SpriteSheet(
|
||||
"./res/graphics/fonts/han_atlas_black.png"
|
||||
"./res/graphics/fonts/han_johab_black.png"
|
||||
, W_CJK, H_HANGUL
|
||||
);
|
||||
asciiSheet = new SpriteSheet(
|
||||
|
||||
@@ -12,7 +12,7 @@ public class GameFontWhite extends GameFontBase {
|
||||
super();
|
||||
|
||||
hangulSheet = new SpriteSheet(
|
||||
"./res/graphics/fonts/han_atlas.png"
|
||||
"./res/graphics/fonts/han_johab.png"
|
||||
, W_CJK, H_HANGUL
|
||||
);
|
||||
asciiSheet = new SpriteSheet(
|
||||
|
||||
@@ -182,8 +182,14 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
updateNextHitboxFromVelo();
|
||||
|
||||
|
||||
updateHorizontalPos();
|
||||
updateVerticalPos();
|
||||
if (Math.abs(veloX) < 0.5) {
|
||||
updateVerticalPos();
|
||||
updateHorizontalPos();
|
||||
}
|
||||
else {
|
||||
updateHorizontalPos();
|
||||
updateVerticalPos();
|
||||
}
|
||||
updateHitboxX();
|
||||
updateHitboxY();
|
||||
|
||||
@@ -358,7 +364,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
} while (newXOff < TSIZE && colliding);
|
||||
|
||||
float newX = nextHitbox.getPosX() + newXOff;
|
||||
nextHitbox.setPosition(newX, newY);
|
||||
nextHitbox.setPosition(newX + 1, newY);
|
||||
}
|
||||
|
||||
private boolean isColliding(int side) {
|
||||
|
||||
@@ -62,7 +62,7 @@ public class PBFSigrid {
|
||||
|
||||
p.actorValue.set("luminosity", 22819);
|
||||
|
||||
p.setHitboxDimension(18, 47, 8, 0);
|
||||
p.setHitboxDimension(18, 46, 8, 0);
|
||||
|
||||
p.inventory = new ActorInventory(0x7FFFFFFF, true);
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
* @param absAxisVal (set AXIS_POSMAX if keyboard controlled)
|
||||
*/
|
||||
private void walkHorizontal(boolean left, float absAxisVal) {
|
||||
if ((!super.isWalledLeft() && left) || (!super.isWalledRight() && !left)) {
|
||||
//if ((!super.isWalledLeft() && left) || (!super.isWalledRight() && !left)) {
|
||||
readonly_totalX = super.getVeloX()
|
||||
+
|
||||
actorValue.getAsFloat("accel")
|
||||
@@ -132,7 +132,7 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
// Heading flag
|
||||
if (left) walkHeading = LEFT;
|
||||
else walkHeading = RIGHT;
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Terrarum extends StateBasedGame {
|
||||
public static String defaultDir;
|
||||
public static String defaultSaveDir;
|
||||
|
||||
public static String gameLocale = "isIC";
|
||||
public static String gameLocale = ""; // locale override
|
||||
|
||||
public static Font gameFontWhite;
|
||||
|
||||
@@ -70,6 +70,22 @@ public class Terrarum extends StateBasedGame {
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// TODO if config language is not defined
|
||||
if (gameLocale.length() < 2) { // get system language if not overridden
|
||||
String lan = System.getProperty("user.language");
|
||||
String country = System.getProperty("user.country");
|
||||
|
||||
// exception handling
|
||||
if (lan.equals("en")) country = "US";
|
||||
else if (lan.equals("fr")) country = "FR";
|
||||
else if (lan.equals("de")) country = "DE";
|
||||
else if (lan.equals("ko")) country = "KR";
|
||||
|
||||
gameLocale = lan + country;
|
||||
}
|
||||
|
||||
System.out.println("[Terrarum] Locale: " + gameLocale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user