mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-15 08:06:06 +09:00
Redone collision detection. FIXME: Jump to teleport to ceiling (erratic behaviour on negative facing), nameset in CSV, documentation for RAWs, unicode punctuations in font, environmental colour overlaying (mux) in MapDrawer, actor luminosity is now actorvalue, camera now will center to center of the player, test tile remove and place,
Former-commit-id: 890f8a703f9f9f5a6b6a7c26b2f5d9928d63cf40 Former-commit-id: 9b9d5afd32871cc791d525ff2aafe693205d8c54
This commit is contained in:
@@ -21,6 +21,7 @@ public class GameFontBase implements Font {
|
||||
static SpriteSheet cyrilic;
|
||||
static SpriteSheet cyrilicEF;
|
||||
static SpriteSheet fullwidthForms;
|
||||
static SpriteSheet uniPunct;
|
||||
|
||||
static final int JUNG_COUNT = 21;
|
||||
static final int JONG_COUNT = 28;
|
||||
@@ -46,6 +47,7 @@ public class GameFontBase implements Font {
|
||||
static final int SHEET_CYRILIC_EM = 9;
|
||||
static final int SHEET_CYRILIC_EF = 10;
|
||||
static final int SHEET_FW_UNI = 11;
|
||||
static final int SHEET_UNI_PUNCT = 12;
|
||||
|
||||
static SpriteSheet[] sheetKey;
|
||||
static final Character[] asciiEFList = {
|
||||
@@ -139,9 +141,15 @@ public class GameFontBase implements Font {
|
||||
}
|
||||
|
||||
private boolean isFullwidthUni(char c) {
|
||||
return (c >= 0xFF00 && c < 0xFF60);
|
||||
return (c >= 0xFF00 && c < 0xFF20);
|
||||
}
|
||||
|
||||
private boolean isUniPunct(char c) {
|
||||
return (c >= 0x2000 && c < 0x2070);
|
||||
}
|
||||
|
||||
/** */
|
||||
|
||||
private int asciiEFindexX(char c) {
|
||||
return (Arrays.asList(asciiEFList).indexOf(c) % 16);
|
||||
}
|
||||
@@ -214,6 +222,14 @@ public class GameFontBase implements Font {
|
||||
return (c - 0xFF00) / 16;
|
||||
}
|
||||
|
||||
private int uniPunctIndexX(char c) {
|
||||
return (c - 0x2000) % 16;
|
||||
}
|
||||
|
||||
private int uniPunctIndexY(char c) {
|
||||
return (c - 0x2000) / 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(String s) {
|
||||
return getWidthSubstr(s, s.length());
|
||||
@@ -269,12 +285,7 @@ public class GameFontBase implements Font {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawString(float v, float v1, String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawString(float x, float y, String s, Color color) {
|
||||
public void drawString(float x, float y, String s) {
|
||||
// hangul fonts first
|
||||
hangulSheet.startUse();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
@@ -368,6 +379,10 @@ public class GameFontBase implements Font {
|
||||
sheetX = fullwidthUniIndexX(ch);
|
||||
sheetY = fullwidthUniIndexY(ch);
|
||||
break;
|
||||
case SHEET_UNI_PUNCT:
|
||||
sheetX = uniPunctIndexX(ch);
|
||||
sheetY = uniPunctIndexY(ch);
|
||||
break;
|
||||
default:
|
||||
sheetX = ch % 16;
|
||||
sheetY = ch / 16;
|
||||
@@ -378,11 +393,11 @@ public class GameFontBase implements Font {
|
||||
int glyphW = getWidth("" + ch);
|
||||
sheetKey[prevInstance].renderInUse(
|
||||
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)
|
||||
// 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 :
|
||||
(prevInstance == SHEET_FW_UNI) ? (H - H_HANGUL) / 2 : 0)
|
||||
+ ((prevInstance == SHEET_CJK_PUNCT) ? -1 :
|
||||
(prevInstance == SHEET_FW_UNI) ? (H - H_HANGUL) / 2 : 0)
|
||||
, sheetX
|
||||
, sheetY
|
||||
);
|
||||
@@ -403,6 +418,11 @@ public class GameFontBase implements Font {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawString(float x, float y, String s, Color color) {
|
||||
drawString(x, y, s);
|
||||
}
|
||||
|
||||
private int getSheetType(char c) {
|
||||
// EFs
|
||||
if (isAsciiEF(c)) return SHEET_ASCII_EF;
|
||||
@@ -416,6 +436,7 @@ public class GameFontBase implements Font {
|
||||
else if (isAscii(c)) return SHEET_ASCII_EM;
|
||||
else if (isExtA(c)) return SHEET_EXTA_EM;
|
||||
else if (isCyrilic(c)) return SHEET_CYRILIC_EM;
|
||||
else if (isUniPunct(c)) return SHEET_UNI_PUNCT;
|
||||
// fixed width punctuations
|
||||
else if (isCJKPunct(c)) return SHEET_CJK_PUNCT;
|
||||
else if (isFullwidthUni(c)) return SHEET_FW_UNI;
|
||||
@@ -423,9 +444,22 @@ public class GameFontBase implements Font {
|
||||
else return SHEET_ASCII_EM; // fallback
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw part of a string to the screen. Note that this will still position the text as though
|
||||
* it's part of the bigger string.
|
||||
* @param x
|
||||
* @param y
|
||||
* @param s
|
||||
* @param color
|
||||
* @param startIndex
|
||||
* @param endIndex
|
||||
*/
|
||||
@Override
|
||||
public void drawString(float v, float v1, String s, Color color, int i, int i1) {
|
||||
|
||||
public void drawString(float x, float y, String s, Color color, int startIndex, int endIndex) {
|
||||
String unprintedHead = s.substring(0, startIndex);
|
||||
String printedBody = s.substring(startIndex, endIndex);
|
||||
int xoff = getWidth(unprintedHead);
|
||||
drawString(x + xoff, y, printedBody, color);
|
||||
}
|
||||
|
||||
public void reloadUnihan() throws SlickException {
|
||||
|
||||
@@ -62,6 +62,10 @@ public class GameFontWhite extends GameFontBase {
|
||||
"./res/graphics/fonts/fullwidth_forms.png"
|
||||
, W_UNIHAN, H_UNIHAN
|
||||
);
|
||||
uniPunct = new SpriteSheet(
|
||||
"./res/graphics/fonts/unipunct.png"
|
||||
, W_LATIN_WIDE, H
|
||||
);
|
||||
|
||||
SpriteSheet[] shk = {
|
||||
asciiSheet
|
||||
@@ -76,6 +80,7 @@ public class GameFontWhite extends GameFontBase {
|
||||
, cyrilic
|
||||
, cyrilicEF
|
||||
, fullwidthForms
|
||||
, uniPunct
|
||||
};
|
||||
sheetKey = shk;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,22 @@ public class FudgeDice {
|
||||
return diceResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll dice and get result, for array index
|
||||
* @return Normal distributed integer [0 , N] for N = 2 × DiceCounts + 1. 0 is the most frequent return.
|
||||
*/
|
||||
public int rollForArray() {
|
||||
return roll() + diceCounts;
|
||||
}
|
||||
|
||||
public int getDiceCounts() {
|
||||
return diceCounts;
|
||||
}
|
||||
|
||||
public int getSizeOfProbabilityRange() {
|
||||
return 2 * diceCounts + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer randomly picked from {-1, 0, 1}
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.Torvald.Terrarum.Actors;
|
||||
import com.Torvald.Rand.HQRNG;
|
||||
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;
|
||||
@@ -58,7 +59,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
private volatile float mass = 1f;
|
||||
|
||||
private static final int TSIZE = MapDrawer.TILE_SIZE;
|
||||
private static final int AUTO_CLIMB_RATE = TSIZE / 4;
|
||||
private static int AUTO_CLIMB_RATE = TSIZE / 8;
|
||||
|
||||
/**
|
||||
* Gravitational Constant G. Load from GameMap.
|
||||
@@ -86,7 +87,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
|
||||
private final int UD_COMPENSATOR_MAX = TSIZE;
|
||||
private final int LR_COMPENSATOR_MAX = TSIZE;
|
||||
private final int TILE_CLIMB_RATE = 4;
|
||||
private final int TILE_AUTOCLIMB_RATE = 4;
|
||||
|
||||
/**
|
||||
* A constant to make falling faster so that the game is more playable
|
||||
@@ -95,11 +96,24 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
|
||||
long referenceID;
|
||||
|
||||
private final int EVENT_COLLIDE_TOP = 0;
|
||||
private final int EVENT_COLLIDE_RIGHT = 1;
|
||||
private final int EVENT_COLLIDE_BOTTOM = 2;
|
||||
private final int EVENT_COLLIDE_LEFT = 3;
|
||||
private final int EVENT_COLLIDE_NONE = -1;
|
||||
|
||||
int collisionEvent = EVENT_COLLIDE_NONE; // cannot collide both X-axis and Y-axis, or else jump control breaks up.
|
||||
|
||||
/**
|
||||
* in milliseconds
|
||||
*/
|
||||
public final int COOLTIME = 500;
|
||||
|
||||
/**
|
||||
* Give new random ReferenceID and initialise ActorValue
|
||||
*/
|
||||
public ActorWithBody() {
|
||||
referenceID = new HQRNG(0x7E22A211AAL).nextLong();
|
||||
referenceID = new HQRNG().nextLong();
|
||||
actorValue = new ActorValue();
|
||||
}
|
||||
|
||||
@@ -152,8 +166,9 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
baseSpriteHeight = sprite.getHeight();
|
||||
baseSpriteWidth = sprite.getWidth();
|
||||
gravitation = Terrarum.game.map.getGravitation();
|
||||
AUTO_CLIMB_RATE = (int) Math.min(TSIZE / 8 * FastMath.sqrt(scale), TSIZE);
|
||||
|
||||
if (!playerNoClip()) {
|
||||
if (!isPlayerNoClip()) {
|
||||
applyGravitation();
|
||||
}
|
||||
|
||||
@@ -162,16 +177,21 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
if (veloY > VELO_HARD_LIMIT) veloY = VELO_HARD_LIMIT;
|
||||
|
||||
// Set 'next' positions to fiddle with
|
||||
updateNextHitboxY();
|
||||
updateVerticalPos();
|
||||
clampNextHitbox();
|
||||
updateHitboxY();
|
||||
// updateNextHitboxYFromVelo();
|
||||
// updateNextHitboxXFromVelo();
|
||||
updateNextHitboxFromVelo();
|
||||
|
||||
updateNextHitboxX();
|
||||
updateHorizontalPos();
|
||||
clampNextHitbox();
|
||||
|
||||
// do horizontal collision detection first!
|
||||
// updateHorizontalPos();
|
||||
updateHitboxX();
|
||||
|
||||
|
||||
updateVerticalPos();
|
||||
updateHitboxY();
|
||||
|
||||
|
||||
clampNextHitbox();
|
||||
clampHitbox();
|
||||
}
|
||||
}
|
||||
@@ -182,8 +202,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
* Apply only if not grounded; normal force is not implemented (and redundant)
|
||||
* so we manually reset G to zero (not applying G. force) if grounded.
|
||||
*/
|
||||
// FIXME abnormal jump behaviour if mass == 1, same thing happens if mass == 0 but zero mass
|
||||
// is invalid anyway.
|
||||
// FIXME abnormal jump behaviour if mass == 1, same thing happens if mass == 0 (but zero mass is invalid anyway).
|
||||
private void applyGravitation() {
|
||||
if (!isGrounded()) {
|
||||
/**
|
||||
@@ -205,84 +224,101 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
}
|
||||
|
||||
private void updateVerticalPos() {
|
||||
if (!playerNoClip()) {
|
||||
if (collidedBottomAndAdjusted()) {
|
||||
grounded = true;
|
||||
veloY = 0;
|
||||
if (!isPlayerNoClip()) {
|
||||
// check downward
|
||||
if (veloY >= 0) { // use TERNARY for L/R!
|
||||
// order of the if-elseif chain is IMPORTANT
|
||||
if (isColliding(CONTACT_AREA_BOTTOM)) {
|
||||
adjustHitBottom();
|
||||
veloY = 0;
|
||||
grounded = true;
|
||||
}
|
||||
else if (isColliding(CONTACT_AREA_BOTTOM, 0, 1)) {
|
||||
veloY = 0;
|
||||
grounded = true;
|
||||
}
|
||||
else {
|
||||
grounded = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (veloY < 0) {
|
||||
grounded = false;
|
||||
}
|
||||
|
||||
if (collidedTopAndAdjusted()) {
|
||||
veloY = 0;
|
||||
// order of the if-elseif chain is IMPORTANT
|
||||
if (isColliding(CONTACT_AREA_TOP)) {
|
||||
adjustHitTop();
|
||||
veloY = 0;
|
||||
}
|
||||
else if (isColliding(CONTACT_AREA_TOP, 0, -1)) {
|
||||
veloY = 0; // for reversed gravity
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean collidedBottomAndAdjusted() {
|
||||
if (getContactArea(CONTACT_AREA_BOTTOM, 0, 1) == 0) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* seemingly adjusted and one pixel below has ground
|
||||
*
|
||||
* seemingly adjusted: adjustHitBottom sets position one pixel above the ground
|
||||
* (stepping on ground in-game look, as the sprite render is one pixel offseted to Y)
|
||||
*/
|
||||
else if (getContactArea(CONTACT_AREA_BOTTOM, 0, 1) > 0
|
||||
&& getContactArea(CONTACT_AREA_BOTTOM, 0, 0) == 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
adjustHitBottom();
|
||||
return true;
|
||||
}
|
||||
private void adjustHitBottom() {
|
||||
float newX = nextHitbox.getPointedX();
|
||||
// int-ify posY of nextHitbox
|
||||
nextHitbox.setPositionYFromPoint( FastMath.floor(nextHitbox.getPointedY()) );
|
||||
|
||||
int newYOff = 0; // always positive
|
||||
|
||||
boolean colliding;
|
||||
do {
|
||||
colliding = isColliding(CONTACT_AREA_BOTTOM, 0, -newYOff);
|
||||
newYOff += 1;
|
||||
} while (colliding);
|
||||
|
||||
float newY = nextHitbox.getPointedY() - newYOff;
|
||||
nextHitbox.setPositionFromPoint(newX, newY + 1);
|
||||
}
|
||||
|
||||
boolean collidedTopAndAdjusted() {
|
||||
if (getContactArea(CONTACT_AREA_TOP, 0, -1) == 0) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* seemingly adjusted and one pixel below has ground
|
||||
*
|
||||
* seemingly adjusted: adjustHitBottom sets position one pixel above the ground
|
||||
* (stepping on ground in-game look, as the sprite render is one pixel offseted to Y)
|
||||
*/
|
||||
else if (getContactArea(CONTACT_AREA_TOP, 0, -1) > 0
|
||||
&& getContactArea(CONTACT_AREA_TOP, 0, 0) == 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
adjustHitTop();
|
||||
return true;
|
||||
}
|
||||
private void adjustHitTop() { // FIXME jump to teleport to ceiling
|
||||
float newX = nextHitbox.getPointedX();
|
||||
// int-ify posY of nextHitbox
|
||||
nextHitbox.setPositionY( FastMath.floor(nextHitbox.getPosY()) );
|
||||
|
||||
int newYOff = 0; // always positive
|
||||
|
||||
boolean colliding;
|
||||
do {
|
||||
colliding = isColliding(CONTACT_AREA_TOP, 0, newYOff);
|
||||
newYOff += 1;
|
||||
} while (colliding);
|
||||
|
||||
float newY = nextHitbox.getPosY() + newYOff;
|
||||
nextHitbox.setPositionFromPoint(newX, newY - 1);
|
||||
}
|
||||
|
||||
private void updateHorizontalPos() {
|
||||
if (!playerNoClip()) {
|
||||
if (collidedRightAndAdjusted()) { // treat as 'event--collided right'
|
||||
if (!isPlayerNoClip()) {
|
||||
resetCollisionEventFlag();
|
||||
collidedRightAndAdjusted();
|
||||
|
||||
if (collisionEvent == EVENT_COLLIDE_RIGHT) {
|
||||
veloX = 0;
|
||||
walledRight = true;
|
||||
|
||||
// TODO remove above two lines and implement tile climb (multi-frame calculation.)
|
||||
// Use variable TILE_CLIMB_RATE
|
||||
}
|
||||
else if (collidedLeftAndAdjusted()) { // treat as 'event--collided left'
|
||||
|
||||
collidedLeftAndAdjusted();
|
||||
|
||||
if (collisionEvent == EVENT_COLLIDE_LEFT) {
|
||||
veloX = 0;
|
||||
walledLeft = true;
|
||||
}
|
||||
else {
|
||||
|
||||
if (collisionEvent != EVENT_COLLIDE_LEFT && collisionEvent != EVENT_COLLIDE_RIGHT) {
|
||||
walledRight = false;
|
||||
walledLeft = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean collidedRightAndAdjusted() {
|
||||
if (getContactArea(CONTACT_AREA_RIGHT, 1, 0) == 0) {
|
||||
return false;
|
||||
void collidedRightAndAdjusted() {
|
||||
if (getContactingArea(CONTACT_AREA_RIGHT, 1, 0) == 0) {
|
||||
resetCollisionEventFlag();
|
||||
}
|
||||
/**
|
||||
* seemingly adjusted and one pixel below has ground
|
||||
@@ -290,19 +326,19 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
* seemingly adjusted: adjustHitBottom sets position one pixel above the ground
|
||||
* (stepping on ground in-game look, as the sprite render is one pixel offseted to Y)
|
||||
*/
|
||||
else if (getContactArea(CONTACT_AREA_RIGHT, 1, 0) > 0
|
||||
&& getContactArea(CONTACT_AREA_RIGHT, 0, 0) == 0) {
|
||||
return true;
|
||||
else if (getContactingArea(CONTACT_AREA_RIGHT, 1, 0) > 0
|
||||
&& getContactingArea(CONTACT_AREA_RIGHT, 0, 0) == 0) {
|
||||
collisionEvent = EVENT_COLLIDE_RIGHT;
|
||||
}
|
||||
else {
|
||||
adjustHitRight();
|
||||
return true;
|
||||
collisionEvent = EVENT_COLLIDE_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
boolean collidedLeftAndAdjusted() {
|
||||
if (getContactArea(CONTACT_AREA_LEFT, -1, 0) == 0) {
|
||||
return false;
|
||||
void collidedLeftAndAdjusted() {
|
||||
if (getContactingArea(CONTACT_AREA_LEFT, -1, 0) == 0) {
|
||||
resetCollisionEventFlag();
|
||||
}
|
||||
/**
|
||||
* seemingly adjusted and one pixel below has ground
|
||||
@@ -310,95 +346,19 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
* seemingly adjusted: adjustHitBottom sets position one pixel above the ground
|
||||
* (stepping on ground in-game look, as the sprite render is one pixel offseted to Y)
|
||||
*/
|
||||
else if (getContactArea(CONTACT_AREA_LEFT, -1, 0) > 0
|
||||
&& getContactArea(CONTACT_AREA_LEFT, 0, 0) == 0) {
|
||||
return true;
|
||||
else if (getContactingArea(CONTACT_AREA_LEFT, -1, 0) > 0
|
||||
&& getContactingArea(CONTACT_AREA_LEFT, 0, 0) == 0) {
|
||||
collisionEvent = EVENT_COLLIDE_LEFT;
|
||||
}
|
||||
else {
|
||||
adjustHitLeft();
|
||||
return true;
|
||||
collisionEvent = EVENT_COLLIDE_LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNextHitboxX() {
|
||||
nextHitbox.set(
|
||||
hitbox.getPosX() + veloX
|
||||
, hitbox.getPosY()
|
||||
, baseHitboxW * scale
|
||||
, baseHitboxH * scale
|
||||
);
|
||||
}
|
||||
|
||||
private void updateNextHitboxY() {
|
||||
nextHitbox.set(
|
||||
hitbox.getPosX()
|
||||
, hitbox.getPosY() + veloY
|
||||
, baseHitboxW * scale
|
||||
, baseHitboxH * scale
|
||||
);
|
||||
}
|
||||
|
||||
private void updateHitboxX() {
|
||||
hitbox.set(
|
||||
nextHitbox.getPosX()
|
||||
, hitbox.getPosY()
|
||||
, baseHitboxW * scale
|
||||
, baseHitboxH * scale
|
||||
);
|
||||
}
|
||||
|
||||
private void updateHitboxY() {
|
||||
hitbox.set(
|
||||
hitbox.getPosX()
|
||||
, nextHitbox.getPosY()
|
||||
, baseHitboxW * scale
|
||||
, baseHitboxH * scale
|
||||
);
|
||||
}
|
||||
|
||||
private void adjustHitBottom() {
|
||||
int tY = 0;
|
||||
int contactArea = getContactArea(CONTACT_AREA_BOTTOM, 0, 0);
|
||||
for (int lim = 0; lim < UD_COMPENSATOR_MAX; lim++) {
|
||||
/**
|
||||
* get contact area and move up and get again.
|
||||
* keep track of this value, and some point they will be set as lowest
|
||||
* and become static. The very point where the value first became lowest
|
||||
* is the value what we want.
|
||||
*/
|
||||
int newContactArea = getContactArea(CONTACT_AREA_BOTTOM, 0, -lim);
|
||||
|
||||
if (newContactArea < contactArea) {
|
||||
tY = -lim;
|
||||
}
|
||||
contactArea = newContactArea;
|
||||
}
|
||||
nextHitbox.setPositionYFromPoint(FastMath.ceil(nextHitbox.getPointedY() + tY));
|
||||
}
|
||||
|
||||
private void adjustHitTop() {
|
||||
int tY = 0;
|
||||
int contactArea = getContactArea(CONTACT_AREA_TOP, 0, 0);
|
||||
for (int lim = 0; lim < UD_COMPENSATOR_MAX; lim++) {
|
||||
/**
|
||||
* get contact area and move up and get again.
|
||||
* keep track of this value, and some point they will be set as lowest
|
||||
* and become static. The very point where the value first became lowest
|
||||
* is the value what we want.
|
||||
*/
|
||||
int newContactArea = getContactArea(CONTACT_AREA_TOP, 0, lim);
|
||||
|
||||
if (newContactArea < contactArea) {
|
||||
tY = lim;
|
||||
}
|
||||
contactArea = newContactArea;
|
||||
}
|
||||
nextHitbox.setPositionYFromPoint(FastMath.floor(nextHitbox.getPointedY() + tY));
|
||||
}
|
||||
|
||||
private void adjustHitRight() {
|
||||
int tX = 0;
|
||||
int contactArea = getContactArea(CONTACT_AREA_RIGHT, 0, 0);
|
||||
int contactArea = getContactingArea(CONTACT_AREA_RIGHT, 0, 0);
|
||||
for (int lim = 0; lim < LR_COMPENSATOR_MAX; lim++) {
|
||||
/**
|
||||
* get contact area and move up and get again.
|
||||
@@ -406,7 +366,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
* and become static. The very point where the value first became lowest
|
||||
* is the value what we want.
|
||||
*/
|
||||
int newContactArea = getContactArea(CONTACT_AREA_RIGHT, -lim, 0);
|
||||
int newContactArea = getContactingArea(CONTACT_AREA_RIGHT, -lim, 0);
|
||||
|
||||
if (newContactArea < contactArea) {
|
||||
tX = -lim;
|
||||
@@ -424,7 +384,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
|
||||
private void adjustHitLeft() {
|
||||
int tX = 0;
|
||||
int contactArea = getContactArea(CONTACT_AREA_LEFT, 0, 0);
|
||||
int contactArea = getContactingArea(CONTACT_AREA_LEFT, 0, 0);
|
||||
for (int lim = 0; lim < LR_COMPENSATOR_MAX; lim++) {
|
||||
/**
|
||||
* get contact area and move up and get again.
|
||||
@@ -432,7 +392,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
* and become static. The very point where the value first became lowest
|
||||
* is the value what we want.
|
||||
*/
|
||||
int newContactArea = getContactArea(CONTACT_AREA_LEFT, lim, 0);
|
||||
int newContactArea = getContactingArea(CONTACT_AREA_LEFT, lim, 0);
|
||||
|
||||
if (newContactArea < contactArea) {
|
||||
tX = lim;
|
||||
@@ -441,14 +401,26 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
}
|
||||
//nextHitbox.setPositionYFromPoint(nextHitbox.getPointedX() + tX);
|
||||
nextHitbox.set(
|
||||
FastMath.floor(nextHitbox.getPosX() + tX)
|
||||
FastMath.floor(nextHitbox.getPosX() + tX + 1)
|
||||
, nextHitbox.getPosY()
|
||||
, nextHitbox.getWidth()
|
||||
, nextHitbox.getHeight()
|
||||
);
|
||||
}
|
||||
|
||||
private int getContactArea(int side, int translateX, int translateY) {
|
||||
private boolean isColliding(int side) {
|
||||
return getContactingArea(side) > 0;
|
||||
}
|
||||
|
||||
private boolean isColliding(int side, int tx, int ty) {
|
||||
return getContactingArea(side, tx, ty) > 0;
|
||||
}
|
||||
|
||||
private int getContactingArea(int side) {
|
||||
return getContactingArea(side, 0, 0);
|
||||
}
|
||||
|
||||
private int getContactingArea(int side, int translateX, int translateY) {
|
||||
int contactAreaCounter = 0;
|
||||
for (int i = 0
|
||||
; i < Math.round((side % 2 == 0) ? nextHitbox.getWidth() : nextHitbox.getHeight())
|
||||
@@ -484,7 +456,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
}
|
||||
|
||||
// evaluate
|
||||
if (Terrarum.game.map.getTileFromTerrain(tileX, tileY) > 0) {
|
||||
if (TilePropCodex.getProp(Terrarum.game.map.getTileFromTerrain(tileX, tileY)).isSolid()) {
|
||||
contactAreaCounter += 1;
|
||||
}
|
||||
}
|
||||
@@ -492,6 +464,10 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
return contactAreaCounter;
|
||||
}
|
||||
|
||||
private void resetCollisionEventFlag() {
|
||||
collisionEvent = EVENT_COLLIDE_NONE;
|
||||
}
|
||||
|
||||
private void clampHitbox() {
|
||||
hitbox.setPositionFromPoint(
|
||||
clampW(hitbox.getPointedX())
|
||||
@@ -506,6 +482,50 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
);
|
||||
}
|
||||
|
||||
private void updateNextHitboxXFromVelo() {
|
||||
nextHitbox.set(
|
||||
hitbox.getPosX() + veloX
|
||||
, hitbox.getPosY()
|
||||
, baseHitboxW * scale
|
||||
, baseHitboxH * scale
|
||||
);
|
||||
}
|
||||
|
||||
private void updateNextHitboxYFromVelo() {
|
||||
nextHitbox.set(
|
||||
hitbox.getPosX()
|
||||
, hitbox.getPosY() + veloY
|
||||
, baseHitboxW * scale
|
||||
, baseHitboxH * scale
|
||||
);
|
||||
}
|
||||
|
||||
private void updateNextHitboxFromVelo() {
|
||||
nextHitbox.set(
|
||||
hitbox.getPosX() + veloX
|
||||
, hitbox.getPosY() + veloY
|
||||
, baseHitboxW * scale
|
||||
, baseHitboxH * scale
|
||||
);
|
||||
}
|
||||
|
||||
private void updateHitboxX() {
|
||||
hitbox.setDimension(
|
||||
nextHitbox.getWidth()
|
||||
, nextHitbox.getHeight()
|
||||
);
|
||||
hitbox.setPositionX(nextHitbox.getPosX());
|
||||
}
|
||||
|
||||
private void updateHitboxY() {
|
||||
hitbox.setDimension(
|
||||
nextHitbox.getWidth()
|
||||
, nextHitbox.getHeight()
|
||||
);
|
||||
hitbox.setPositionY(nextHitbox.getPosY());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawGlow(GameContainer gc, Graphics g) {
|
||||
if (visible && spriteGlow != null) {
|
||||
@@ -624,7 +644,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean playerNoClip() {
|
||||
private boolean isPlayerNoClip() {
|
||||
return (this instanceof Player && ((Player) this).isNoClip());
|
||||
}
|
||||
|
||||
@@ -744,7 +764,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
this.update = update;
|
||||
}
|
||||
|
||||
private int clampMulOfTSize(float v) {
|
||||
return (Math.round(v) / TSIZE) * TSIZE;
|
||||
private int quantiseTSize(float v) {
|
||||
return FastMath.floor(v / TSIZE) * TSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class CreatureBuildFactory {
|
||||
for (String s : elemSet) {
|
||||
float baseValue = jsonObject.get(s).getAsFloat();
|
||||
// roll fudge dice and get value [-3, 3] as [0, 6]
|
||||
int varSelected = new Fudge3(new HQRNG()).roll() + 3;
|
||||
int varSelected = new Fudge3(new HQRNG()).rollForArray();
|
||||
// get multiplier from json. Assuming percentile
|
||||
int multiplier = jsonObject.get(s + "variable").getAsJsonArray().get(varSelected).getAsInt();
|
||||
float realValue = baseValue * multiplier / 100f;
|
||||
@@ -121,7 +121,7 @@ public class CreatureBuildFactory {
|
||||
for (String s : elemSet) {
|
||||
float baseValue = 1f;
|
||||
// roll fudge dice and get value [-3, 3] as [0, 6]
|
||||
int varSelected = new Fudge3(new HQRNG()).roll() + 3;
|
||||
int varSelected = new Fudge3(new HQRNG()).rollForArray();
|
||||
// get multiplier from json. Assuming percentile
|
||||
int multiplier = jsonObject.get(s).getAsJsonArray().get(varSelected).getAsInt();
|
||||
float realValue = baseValue * multiplier / 100f;
|
||||
|
||||
@@ -11,17 +11,12 @@ public class Hitbox {
|
||||
private Point2f hitboxEnd;
|
||||
private float width;
|
||||
private float height;
|
||||
private float pointX;
|
||||
private float pointY;
|
||||
|
||||
public Hitbox(float x1, float y1, float width, float height) {
|
||||
hitboxStart = new Point2f(x1, y1);
|
||||
hitboxEnd = new Point2f(x1 + width, y1 + height);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
pointX = x1 + (width / 2);
|
||||
pointY = y1 + height;
|
||||
}
|
||||
|
||||
public Point2f getHitboxStart() {
|
||||
@@ -45,7 +40,7 @@ public class Hitbox {
|
||||
* @return pointX
|
||||
*/
|
||||
public float getPointedX() {
|
||||
return pointX;
|
||||
return hitboxStart.getX() + (width / 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +48,7 @@ public class Hitbox {
|
||||
* @return pointY
|
||||
*/
|
||||
public float getPointedY() {
|
||||
return pointY;
|
||||
return hitboxEnd.getY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,30 +63,45 @@ public class Hitbox {
|
||||
hitboxEnd = new Point2f(x1 + width, y1 + height);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
pointX = x1 + (width / 2);
|
||||
pointY = y1 + height;
|
||||
public void setPosition(float x1, float y1) {
|
||||
hitboxStart = new Point2f(x1, y1);
|
||||
hitboxEnd = new Point2f(x1 + width, y1 + height);
|
||||
}
|
||||
|
||||
public void setPositionX(float x) {
|
||||
setPosition(x, getPosY());
|
||||
}
|
||||
|
||||
public void setPositionY(float y) {
|
||||
setPosition(getPosX(), y);
|
||||
}
|
||||
|
||||
public void setPositionFromPoint(float x1, float y1) {
|
||||
hitboxStart = new Point2f(x1 - (width / 2), y1 - height);
|
||||
hitboxEnd = new Point2f(hitboxStart.getX() + width, hitboxStart.getY() + height);
|
||||
pointX = x1;
|
||||
pointY = y1;
|
||||
}
|
||||
|
||||
public void setPositionXFromPoint(float x1) {
|
||||
float y1 = pointY;
|
||||
hitboxStart = new Point2f(x1 - (width / 2), y1 - height);
|
||||
hitboxEnd = new Point2f(hitboxStart.getX() + width, hitboxStart.getY() + height);
|
||||
pointX = x1;
|
||||
public void setPositionXFromPoint(float x) {
|
||||
setPositionFromPoint(x, getPointedY());
|
||||
}
|
||||
|
||||
public void setPositionYFromPoint(float y1) {
|
||||
float x1 = pointX;
|
||||
hitboxStart = new Point2f(x1 - (width / 2), y1 - height);
|
||||
hitboxEnd = new Point2f(hitboxStart.getX() + width, hitboxStart.getY() + height);
|
||||
pointY = y1;
|
||||
public void setPositionYFromPoint(float y) {
|
||||
setPositionFromPoint(getPointedX(), y);
|
||||
}
|
||||
|
||||
public void translatePosX(float d) {
|
||||
setPositionX(getPosX() + d);
|
||||
}
|
||||
|
||||
public void translatePosY(float d) {
|
||||
setPositionY(getPosY() + d);
|
||||
}
|
||||
|
||||
public void setDimension(float w, float h) {
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,4 +119,12 @@ public class Hitbox {
|
||||
public float getPosY() {
|
||||
return hitboxStart.getY();
|
||||
}
|
||||
|
||||
public float getCenteredX() {
|
||||
return (hitboxStart.getX() + hitboxEnd.getX()) * 0.5f;
|
||||
}
|
||||
|
||||
public float getCenteredY() {
|
||||
return (hitboxStart.getY() + hitboxEnd.getY()) * 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ public class PBFSigrid {
|
||||
|
||||
p.actorValue.set("intelligent", true);
|
||||
|
||||
p.actorValue.set("luminosity", 22819);
|
||||
|
||||
p.setHitboxDimension(17, 46, 9, 0);
|
||||
|
||||
p.inventory = new ActorInventory(0x7FFFFFFF, true);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
private int prevVMoveKey = -1;
|
||||
private final int KEY_NULL = -1;
|
||||
|
||||
static final float ACCEL_MULT_IN_FLIGHT = 0.22f;
|
||||
static final float ACCEL_MULT_IN_FLIGHT = 0.48f;
|
||||
static final float WALK_STOP_ACCEL = 0.32f;
|
||||
static final float WALK_ACCEL_BASE = 0.32f;
|
||||
|
||||
@@ -59,10 +59,9 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
|
||||
private final int TSIZE = MapDrawer.TILE_SIZE;
|
||||
|
||||
private char LUMINANCE_RGB = 31399;
|
||||
|
||||
private HashSet<Faction> factionSet = new HashSet<>();
|
||||
|
||||
|
||||
/**
|
||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.). <br />
|
||||
*
|
||||
@@ -452,7 +451,8 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
float timedJumpCharge = init - (init / len) * jumpCounter;
|
||||
if (timedJumpCharge < 0) timedJumpCharge = 0;
|
||||
|
||||
float jumpAcc = pwr * timedJumpCharge * JUMP_ACCELERATION_MOD;
|
||||
float jumpAcc = pwr * timedJumpCharge * JUMP_ACCELERATION_MOD
|
||||
* FastMath.sqrt(getScale());
|
||||
|
||||
super.setVeloY(super.getVeloY()
|
||||
- jumpAcc
|
||||
@@ -567,11 +567,12 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
|
||||
@Override
|
||||
public void setLuminance(char RGB) {
|
||||
LUMINANCE_RGB = RGB;
|
||||
actorValue.set("luminosity", (int) RGB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getLuminance() {
|
||||
return LUMINANCE_RGB;
|
||||
return actorValue.hasKey("luminosity") ?
|
||||
(char) actorValue.getAsInt("luminosity") : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PlayerDebugger {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Delegates for Player instances
|
||||
*/
|
||||
|
||||
@@ -42,4 +42,5 @@ public class PlayerDebugger {
|
||||
public ActorValue actorValue() { return getPlayer().getActorValue(); }
|
||||
public float mass() { return getPlayer().getMass(); }
|
||||
public boolean noClip() { return getPlayer().isNoClip(); }
|
||||
public int collisionEvent() { return getPlayer().collisionEvent; }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
@@ -30,6 +32,7 @@ public class CommandDict {
|
||||
dict.put("gsontest", new GsonTest());
|
||||
dict.put("setgl", new SetGlobalLightLevel());
|
||||
dict.put("getfaction", new GetFactioning());
|
||||
dict.put("auth", Terrarum.game.auth);
|
||||
}
|
||||
|
||||
public static ConsoleCommand getCommand(String commandName) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.Torvald.Terrarum.LangPack.Lang;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Formatter;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -13,26 +14,16 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class CommandInterpreter {
|
||||
|
||||
private static String[] commandsAvailableWOAuth = {"auth", "qqq", "zoom", "setlocale", "getlocale"};
|
||||
|
||||
public static void execute(String command) {
|
||||
CommandInput[] cmd = parse(command);
|
||||
|
||||
for (CommandInput single_command : cmd) {
|
||||
ConsoleCommand commandObj = null;
|
||||
try {
|
||||
if (single_command.getName().equalsIgnoreCase("auth")) {
|
||||
Terrarum.game.auth.execute(single_command.toStringArray());
|
||||
}
|
||||
else if (single_command.getName().equalsIgnoreCase("qqq")) {
|
||||
new QuitApp().execute(single_command.toStringArray());
|
||||
}
|
||||
else if (single_command.getName().equalsIgnoreCase("zoom")) {
|
||||
new Zoom().execute(single_command.toStringArray());
|
||||
}
|
||||
else if (single_command.getName().equalsIgnoreCase("setlocale")) {
|
||||
new SetLocale().execute(single_command.toStringArray());
|
||||
}
|
||||
else if (single_command.getName().equalsIgnoreCase("getlocale")) {
|
||||
new GetLocale().execute(single_command.toStringArray());
|
||||
if (Arrays.asList(commandsAvailableWOAuth).contains(single_command.getName().toLowerCase())) {
|
||||
commandObj = CommandDict.getCommand(single_command.getName().toLowerCase());
|
||||
}
|
||||
else {
|
||||
if (Terrarum.game.auth.b()) {
|
||||
@@ -41,20 +32,26 @@ public class CommandInterpreter {
|
||||
);
|
||||
}
|
||||
else {
|
||||
System.out.println("ee1");
|
||||
throw new NullPointerException(); // if not authorised, say "Unknown command"
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
echoUnknownCmd(single_command.getName());
|
||||
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (commandObj != null)
|
||||
if (commandObj != null) {
|
||||
commandObj.execute(single_command.toStringArray());
|
||||
}
|
||||
else {
|
||||
echoUnknownCmd(single_command.getName());
|
||||
System.out.println("ee3");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("[CommandInterpreter] ");
|
||||
System.out.println("[CommandInterpreter] :");
|
||||
e.printStackTrace();
|
||||
new Echo().execute(Lang.get("ERROR_GENERIC_TEXT"));
|
||||
}
|
||||
|
||||
@@ -15,30 +15,43 @@ public class GetAV implements ConsoleCommand {
|
||||
public void execute(String[] args) {
|
||||
Echo echo = new Echo();
|
||||
|
||||
if (args.length == 1) {
|
||||
// print all actorvalue of player
|
||||
ActorValue av = Terrarum.game.getPlayer().getActorValue();
|
||||
Set keyset = av.getKeySet();
|
||||
try {
|
||||
if (args.length == 1) {
|
||||
// print all actorvalue of player
|
||||
ActorValue av = Terrarum.game.getPlayer().getActorValue();
|
||||
Set keyset = av.getKeySet();
|
||||
|
||||
keyset.forEach(
|
||||
elem -> echo.execute(elem + " = " + av.get((String)elem))
|
||||
);
|
||||
keyset.forEach(
|
||||
elem -> echo.execute(elem + " = " + av.get((String) elem))
|
||||
);
|
||||
|
||||
}
|
||||
else if (args.length != 3 && args.length != 2) {
|
||||
printUsage();
|
||||
}
|
||||
else if (args.length == 2) {
|
||||
echo.execute("player." + args[1] + " = "
|
||||
+ Terrarum.game.getPlayer().getActorValue().get(args[1])
|
||||
+ " ("
|
||||
+ Terrarum.game.getPlayer().getActorValue().get(args[1]).getClass()
|
||||
.getSimpleName()
|
||||
+ ")"
|
||||
);
|
||||
}
|
||||
else if (args.length == 3) {
|
||||
}
|
||||
else if (args.length != 3 && args.length != 2) {
|
||||
printUsage();
|
||||
}
|
||||
else if (args.length == 2) {
|
||||
echo.execute("player." + args[1] + " = "
|
||||
+ Terrarum.game.getPlayer().getActorValue().get(args[1])
|
||||
+ " ("
|
||||
+ Terrarum.game.getPlayer().getActorValue().get(args[1]).getClass()
|
||||
.getSimpleName()
|
||||
+ ")"
|
||||
);
|
||||
}
|
||||
else if (args.length == 3) {
|
||||
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
if (args.length == 2) {
|
||||
echo.execute(args[1] + ": actor value does not exist.");
|
||||
}
|
||||
else if (args.length == 3) {
|
||||
echo.execute(args[2] + ": actor value does not exist.");
|
||||
}
|
||||
else {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,17 +27,24 @@ class SetAV implements ConsoleCommand {
|
||||
else if (args.length == 3) {
|
||||
Object val;
|
||||
|
||||
try { val = new Float(args[2]); } // try for number
|
||||
try {
|
||||
val = new Integer(args[2]); // try for integer
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
|
||||
if (args[2].toLowerCase() == "true") {
|
||||
val = new Boolean(true);
|
||||
try {
|
||||
val = new Float(args[2]); // try for float
|
||||
}
|
||||
else if (args[2].toLowerCase() == "false") {
|
||||
val = new Boolean(false);
|
||||
}
|
||||
else {
|
||||
val = new String(args[2]); // string if not number
|
||||
catch (NumberFormatException ee) {
|
||||
if (args[2].equalsIgnoreCase("true")) {
|
||||
val = new Boolean(true);
|
||||
}
|
||||
else if (args[2].equalsIgnoreCase("false")) {
|
||||
val = new Boolean(false);
|
||||
}
|
||||
else {
|
||||
val = new String(args[2]); // string if not number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,11 +140,17 @@ public class Game extends BasicGameState {
|
||||
public void update(GameContainer gc, StateBasedGame sbg, int delta_t) {
|
||||
setAppTitle();
|
||||
|
||||
GameController.processInput(gc.getInput());
|
||||
KeyToggler.update(gc);
|
||||
|
||||
TileStat.update();
|
||||
|
||||
/** Placed before actor update to give some dynamic view of player on screen,
|
||||
* or else player will always stay same spot, which is somewhat dull.
|
||||
*/
|
||||
MapDrawer.update(gc, delta_t);
|
||||
MapCamera.update(gc, delta_t);
|
||||
|
||||
GameController.processInput(gc.getInput());
|
||||
|
||||
actorContainer.forEach(actor -> actor.update(gc, delta_t));
|
||||
actorContainer.forEach(
|
||||
actor -> {
|
||||
@@ -159,11 +165,7 @@ public class Game extends BasicGameState {
|
||||
|
||||
uiContainer.forEach(ui -> ui.update(gc, delta_t));
|
||||
|
||||
KeyToggler.update(gc);
|
||||
|
||||
//bulletin.update(gc, delta_t);
|
||||
|
||||
TileStat.update();
|
||||
}
|
||||
|
||||
private void setAppTitle() {
|
||||
@@ -205,9 +207,10 @@ public class Game extends BasicGameState {
|
||||
MapDrawer.render(gc, g);
|
||||
|
||||
LightmapRenderer.renderLightMap();
|
||||
|
||||
setBlendModeMul();
|
||||
MapDrawer.drawEnvOverlay(g);
|
||||
LightmapRenderer.draw(g);
|
||||
// MapDrawer.drawEnvOverlay(g);
|
||||
setBlendModeNormal();
|
||||
|
||||
uiContainer.forEach(ui -> ui.render(gc, g));
|
||||
@@ -224,7 +227,7 @@ public class Game extends BasicGameState {
|
||||
int gradMapWidth = GRADIENT_IMAGE.getWidth();
|
||||
int phase = Math.round((timeSec / WorldTime.DAY_LENGTH) * gradMapWidth);
|
||||
|
||||
//update in every 60 frames
|
||||
//update in every INTERNAL_FRAME frames
|
||||
colourTable[0] = GRADIENT_IMAGE.getColor(phase, 0);
|
||||
colourTable[1] = GRADIENT_IMAGE.getColor(phase, 1);
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ 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.TileProperties.TileNameCode;
|
||||
import com.Torvald.Terrarum.TileProperties.TilePropCodex;
|
||||
import com.Torvald.Terrarum.UserInterface.UIHandler;
|
||||
import org.newdawn.slick.Input;
|
||||
|
||||
@@ -38,6 +40,30 @@ public class GameController {
|
||||
else {
|
||||
Terrarum.game.consoleHandler.processInput(input);
|
||||
}
|
||||
|
||||
|
||||
int mouseTileX = (int) ((MapCamera.getCameraX() + input.getMouseX() / Terrarum.game.screenZoom)
|
||||
/ MapDrawer.TILE_SIZE);
|
||||
int mouseTileY = (int) ((MapCamera.getCameraY() + input.getMouseY() / Terrarum.game.screenZoom)
|
||||
/ MapDrawer.TILE_SIZE);
|
||||
|
||||
if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
|
||||
// test tile remove
|
||||
try {
|
||||
Terrarum.game.map.setTileTerrain(mouseTileX, mouseTileY, TileNameCode.AIR);
|
||||
Terrarum.game.map.setTileWall(mouseTileX, mouseTileY, TileNameCode.AIR);
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
}
|
||||
else if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) {
|
||||
// test tile place
|
||||
try {
|
||||
Terrarum.game.map.setTileTerrain(mouseTileX, mouseTileY, TileNameCode.ICE_MAGICAL);
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void keyPressed(int key, char c) {
|
||||
@@ -77,16 +103,7 @@ 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) {
|
||||
|
||||
@@ -36,8 +36,14 @@ public class KVHashtable {
|
||||
return hashtable.get(key.toLowerCase());
|
||||
}
|
||||
|
||||
public int getAsInt(String key) {
|
||||
return (int) get(key);
|
||||
}
|
||||
|
||||
public float getAsFloat(String key) {
|
||||
return (float) get(key);
|
||||
Object value = get(key);
|
||||
if (value instanceof Integer) return ((Integer) value).floatValue();
|
||||
else return (float) value;
|
||||
}
|
||||
|
||||
public String getAsString(String key) {
|
||||
@@ -48,6 +54,10 @@ public class KVHashtable {
|
||||
return (boolean) get(key);
|
||||
}
|
||||
|
||||
public boolean hasKey(String key) {
|
||||
return hashtable.containsKey(key);
|
||||
}
|
||||
|
||||
public Set getKeySet() {
|
||||
return hashtable.keySet();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class Lang {
|
||||
|
||||
private static final String PATH_TO_CSV = "./res/locales/";
|
||||
private static final String CSV_MAIN = "polyglot.csv";
|
||||
private static final String NAMESET_PREFIX = "nameset_";
|
||||
|
||||
private static final int[] HANGUL_POST_INDEX_ALPH = { // 0: 는, 가, ... 1: 은, 이, ...
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
@@ -57,7 +58,7 @@ public class Lang {
|
||||
FilenameFilter filter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.contains(".csv") && !name.contains(CSV_MAIN);
|
||||
return name.contains(".csv") && !name.contains(CSV_MAIN) && !name.contains(NAMESET_PREFIX);
|
||||
}
|
||||
};
|
||||
for (String csvfilename : file.list(filter)) {
|
||||
|
||||
@@ -133,16 +133,16 @@ public class MapCamera {
|
||||
public static void update(GameContainer gc, int delta_t) {
|
||||
Player player = Terrarum.game.getPlayer();
|
||||
|
||||
renderWidth = FastMath.ceil(Terrarum.WIDTH / Terrarum.game.screenZoom);
|
||||
renderWidth = FastMath.ceil(Terrarum.WIDTH / Terrarum.game.screenZoom); // div, not mul
|
||||
renderHeight = FastMath.ceil(Terrarum.HEIGHT / Terrarum.game.screenZoom);
|
||||
|
||||
// position - (WH / 2)
|
||||
cameraX = clamp(
|
||||
Math.round(player.getNextHitbox().getPointedX() - (renderWidth / 2))
|
||||
Math.round(player.getHitbox().getCenteredX() - (renderWidth / 2))
|
||||
, map.width * TSIZE - renderWidth
|
||||
);
|
||||
cameraY = clamp(
|
||||
Math.round(player.getNextHitbox().getPointedY() - (renderHeight / 2))
|
||||
Math.round(player.getHitbox().getCenteredY() - (renderHeight / 2))
|
||||
, map.height * TSIZE - renderHeight
|
||||
);
|
||||
}
|
||||
@@ -311,19 +311,19 @@ public class MapCamera {
|
||||
}
|
||||
}
|
||||
|
||||
private static int div16(int x) {
|
||||
public static int div16(int x) {
|
||||
return (x & 0x7FFF_FFFF) >> 4;
|
||||
}
|
||||
|
||||
private static int mod16(int x) {
|
||||
public static int mod16(int x) {
|
||||
return x & 0b1111;
|
||||
}
|
||||
|
||||
private static int quantise16(int x) {
|
||||
public static int quantise16(int x) {
|
||||
return (x & 0xFFFF_FFF0);
|
||||
}
|
||||
|
||||
private static int clampW(int x) {
|
||||
public static int clampW(int x) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -335,7 +335,7 @@ public class MapCamera {
|
||||
}
|
||||
}
|
||||
|
||||
private static int clampH(int x) {
|
||||
public static int clampH(int x) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -347,7 +347,7 @@ public class MapCamera {
|
||||
}
|
||||
}
|
||||
|
||||
private static int clampWTile(int x) {
|
||||
public static int clampWTile(int x) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ public class MapCamera {
|
||||
}
|
||||
}
|
||||
|
||||
private static int clampHTile(int x) {
|
||||
public static int clampHTile(int x) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -371,7 +371,7 @@ public class MapCamera {
|
||||
}
|
||||
}
|
||||
|
||||
private static int clamp(int x, int lim) {
|
||||
public static int clamp(int x, int lim) {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.Torvald.Terrarum.MapDrawer;
|
||||
import com.Torvald.Terrarum.*;
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.GameMap.GameMap;
|
||||
import com.Torvald.Terrarum.TileProperties.TileNameCode;
|
||||
import com.Torvald.Terrarum.TileStat.TileStat;
|
||||
import com.jme3.math.FastMath;
|
||||
import org.newdawn.slick.*;
|
||||
import org.newdawn.slick.geom.Rectangle;
|
||||
|
||||
@@ -11,22 +14,20 @@ import org.newdawn.slick.geom.Rectangle;
|
||||
*/
|
||||
public class MapDrawer {
|
||||
|
||||
private static SpriteSheet mapTileMap;
|
||||
private static SpriteSheet wallTileMap;
|
||||
|
||||
public static final int TILE_SIZE = 16;
|
||||
public static final int ENVCOLOUR_MAX = 128;
|
||||
|
||||
private static int envmap = 64;
|
||||
private static Rectangle envOverlay;
|
||||
private static Image envOverlayColourmap;
|
||||
|
||||
public MapDrawer(GameMap map) throws SlickException {
|
||||
mapTileMap = new SpriteSheet("./res/graphics/terrain/terrain.png", TILE_SIZE, TILE_SIZE);
|
||||
wallTileMap = new SpriteSheet("./res/graphics/terrain/wall.png", TILE_SIZE, TILE_SIZE);
|
||||
private static final int ENV_COLTEMP_LOWEST = 5500;
|
||||
private static final int ENV_COLTEMP_HIGHEST = 7500;
|
||||
|
||||
private static int colTemp;
|
||||
|
||||
public MapDrawer(GameMap map) throws SlickException {
|
||||
new MapCamera(map);
|
||||
|
||||
envOverlayColourmap = new Image("./res/graphics/black_body_col_1000_40000_K.png");
|
||||
|
||||
System.gc();
|
||||
}
|
||||
|
||||
@@ -37,13 +38,51 @@ public class MapDrawer {
|
||||
}
|
||||
|
||||
public static void drawEnvOverlay(Graphics g) {
|
||||
envOverlay.setX(MapCamera.getCameraX() * Terrarum.game.screenZoom);
|
||||
envOverlay.setY(MapCamera.getCameraY() * Terrarum.game.screenZoom);
|
||||
envOverlay.setSize(Terrarum.WIDTH * Terrarum.game.screenZoom
|
||||
, Terrarum.HEIGHT * Terrarum.game.screenZoom
|
||||
int onscreen_tiles_max = FastMath.ceil(Terrarum.HEIGHT * Terrarum.WIDTH / FastMath.sqr(TILE_SIZE))
|
||||
* 2;
|
||||
float onscreen_tiles_cap = onscreen_tiles_max / 4f;
|
||||
float onscreen_cold_tiles = TileStat.getCount(
|
||||
TileNameCode.ICE_MAGICAL
|
||||
, TileNameCode.ICE_FRAGILE
|
||||
, TileNameCode.ICE_NATURAL
|
||||
, TileNameCode.SNOW
|
||||
);
|
||||
|
||||
colTemp = colTempLinearFunc((onscreen_cold_tiles / onscreen_tiles_cap));
|
||||
float zoom = Terrarum.game.screenZoom;
|
||||
|
||||
g.setColor(getColourFromMap(colTemp));
|
||||
g.fillRect(MapCamera.getCameraX() * zoom
|
||||
, MapCamera.getCameraY() * zoom
|
||||
, Terrarum.WIDTH * ((zoom < 1) ? 1f / zoom : zoom)
|
||||
, Terrarum.HEIGHT * ((zoom < 1) ? 1f / zoom : zoom)
|
||||
);
|
||||
|
||||
// Color[] colourTable = getGradientColour(WorldTime.elapsedSeconds());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x [-1 , 1], 0 for 6500K (median of ENV_COLTEMP_HIGHEST and ENV_COLTEMP_LOWEST)
|
||||
* @return
|
||||
*/
|
||||
private static int colTempLinearFunc(float x) {
|
||||
int colTempMedian = (ENV_COLTEMP_HIGHEST + ENV_COLTEMP_LOWEST) / 2;
|
||||
|
||||
return Math.round((ENV_COLTEMP_HIGHEST - ENV_COLTEMP_LOWEST) / 2 * FastMath.clamp(x, -1f, 1f)
|
||||
+ colTempMedian);
|
||||
}
|
||||
|
||||
private static Color getColourFromMap(int K) {
|
||||
return envOverlayColourmap.getColor(colTempToImagePos(K), 0);
|
||||
}
|
||||
|
||||
private static int colTempToImagePos(int K) {
|
||||
if (K < 1000 || K >= 40000) throw new IllegalArgumentException("K: out of range. (" + K + ")");
|
||||
return (K - 1000) / 10;
|
||||
}
|
||||
|
||||
public static int getColTemp() {
|
||||
return colTemp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Terrarum extends StateBasedGame {
|
||||
public static String defaultDir;
|
||||
public static String defaultSaveDir;
|
||||
|
||||
public static String gameLocale = "jaJP";
|
||||
public static String gameLocale = "isIC";
|
||||
|
||||
public static Font gameFontWhite;
|
||||
|
||||
|
||||
@@ -51,10 +51,6 @@ public class TilePropCodex {
|
||||
return tileProps[index];
|
||||
}
|
||||
|
||||
public static byte getTileID(String name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void setProp(TileProp prop, CSVRecord record) {
|
||||
prop.setName(record.get("name"));
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"27";"TILE_SNOW" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "27"; "0";"16"
|
||||
"28";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "N/A"; "1"; "0"; "0"; "28"; "0";"16"
|
||||
"29";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "N/A"; "1"; "1"; "0"; "29"; "0"; "8"
|
||||
"30";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "N/A"; "1"; "1";"14949"; "30"; "0"; "8"
|
||||
"30";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "5009"; "30"; "0"; "8"
|
||||
# see scandinavian name set female of this tile id!
|
||||
"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"
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 12.
|
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"0": {
|
||||
"name": "TILE_AIR",
|
||||
"opacity": 0,
|
||||
"strength": 0,
|
||||
"isFluid": 0,
|
||||
"fluidViscocity": 0,
|
||||
"drop": "__null",
|
||||
"isSolid": 0,
|
||||
"isAlsoWall": 0
|
||||
},
|
||||
"1": {
|
||||
"name": "TILE_STONE",
|
||||
"opacity": 8,
|
||||
"strength": 25,
|
||||
"isFluid": 0,
|
||||
"fluidViscocity": 0,
|
||||
"drop": "item.stone",
|
||||
"isSolid": 0,
|
||||
"isAlsoWall": 0
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.Torvald.Terrarum.TileStat;
|
||||
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.Actors.Player;
|
||||
import com.Torvald.Terrarum.GameMap.GameMap;
|
||||
import com.Torvald.Terrarum.GameMap.MapLayer;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapCamera;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapDrawer;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.jme3.math.FastMath;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -14,30 +17,72 @@ public class TileStat {
|
||||
|
||||
private static short[] tilestat = new short[MapLayer.TILES_SUPPORTED];
|
||||
|
||||
private static final int TSIZE = MapDrawer.TILE_SIZE;
|
||||
|
||||
/**
|
||||
* Update tile stats from tiles on screen
|
||||
*/
|
||||
public static void update() {
|
||||
Arrays.fill(tilestat, (short) 0);
|
||||
|
||||
int for_x_start = MapCamera.getRenderStartX();
|
||||
int for_y_start = MapCamera.getRenderStartY();
|
||||
int for_x_end = MapCamera.getRenderEndX();
|
||||
int for_y_end = MapCamera.getRenderEndY();
|
||||
// Get stats on no-zoomed screen area. In other words, will behave as if screen zoom were 1.0
|
||||
// no matter how the screen is zoomed.
|
||||
GameMap map = Terrarum.game.map;
|
||||
Player player = Terrarum.game.getPlayer();
|
||||
|
||||
float zoom = Terrarum.game.screenZoom;
|
||||
|
||||
int renderWidth = FastMath.ceil(Terrarum.WIDTH);
|
||||
int renderHeight = FastMath.ceil(Terrarum.HEIGHT);
|
||||
|
||||
int noZoomCameraX = MapCamera.clamp(
|
||||
Math.round(player.getHitbox().getPointedX() - (renderWidth / 2))
|
||||
, map.width * TSIZE - renderWidth
|
||||
);
|
||||
int noZoomCameraY = MapCamera.clamp(
|
||||
Math.round(player.getHitbox().getPointedY() - (renderHeight / 2))
|
||||
, map.height * TSIZE - renderHeight
|
||||
);
|
||||
|
||||
int for_x_start = MapCamera.div16(noZoomCameraX);
|
||||
int for_y_start = MapCamera.div16(noZoomCameraY);
|
||||
int for_y_end = MapCamera.clampHTile(for_y_start + MapCamera.div16(renderHeight) + 2);
|
||||
int for_x_end = MapCamera.clampWTile(for_x_start + MapCamera.div16(renderWidth) + 2);
|
||||
|
||||
for (int y = for_y_start; y < for_y_end; y++) {
|
||||
for (int x = for_x_start; x < for_x_end; x++) {
|
||||
int tileWall = Terrarum.game.map.getTileFromWall(x, y);
|
||||
int tileTerrain = Terrarum.game.map.getTileFromTerrain(x, y);
|
||||
int tileWall = map.getTileFromWall(x, y);
|
||||
int tileTerrain = map.getTileFromTerrain(x, y);
|
||||
tilestat[tileWall] += 1;
|
||||
tilestat[tileTerrain] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getCount(byte... tile) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < tile.length; i++) {
|
||||
int newArgs = Byte.toUnsignedInt(tile[i]);
|
||||
sum += Short.toUnsignedInt(tilestat[ newArgs ]);
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
public static int getCount(int... tile) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < tile.length; i++) {
|
||||
sum += Short.toUnsignedInt(tilestat[tile[i]]);
|
||||
sum += Short.toUnsignedInt(tilestat[ tile[i] ]);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return copy of the stat data
|
||||
*/
|
||||
public static short[] getStatCopy() {
|
||||
return Arrays.copyOf(tilestat, MapLayer.TILES_SUPPORTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
printLine(g, 7, "mass : " + String.valueOf(playerDbg.mass()) + " [kg]");
|
||||
|
||||
String lightVal;
|
||||
String mtX = String.valueOf(mouseTileX), mtY = String.valueOf(mouseTileY);
|
||||
try {
|
||||
char valRaw = LightmapRenderer.getValueFromMap(mouseTileX, mouseTileY);
|
||||
int rawR = LightmapRenderer.getRawR(valRaw);
|
||||
@@ -84,8 +85,11 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
lightVal = "out of bounds";
|
||||
mtX = "---";
|
||||
mtY = "---";
|
||||
}
|
||||
printLine(g, 8, "light at cursor : " + lightVal);
|
||||
printLine(g, 8, "light at cursor : " + lightVal
|
||||
);
|
||||
|
||||
String tileNo;
|
||||
try {
|
||||
@@ -94,7 +98,21 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
tileNo = "out of bounds";
|
||||
}
|
||||
printLine(g, 9, "tile : " + tileNo);
|
||||
printLine(g, 9, "tile : " + tileNo + " (" + mtX + ", " + mtY + ")");
|
||||
|
||||
/**
|
||||
* Second column
|
||||
*/
|
||||
|
||||
String[] collisionFlagKey = {"top", "right", "bottom", "left"};
|
||||
int collisonFlag = playerDbg.collisionEvent();
|
||||
printLineColumn(g, 2, 1, "CollisionFlag : "
|
||||
+ ((collisonFlag == -1) ? "none" : collisionFlagKey[collisonFlag]));
|
||||
printLineColumn(g, 2, 2, "Env colour temp : " + MapDrawer.getColTemp());
|
||||
|
||||
/**
|
||||
* On screen
|
||||
*/
|
||||
|
||||
// Memory allocation
|
||||
long memInUse = Terrarum.game.memInUse;
|
||||
@@ -113,20 +131,21 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
);
|
||||
|
||||
// Hitbox
|
||||
float zoom = Terrarum.game.screenZoom;
|
||||
g.setColor(new Color(0x007f00));
|
||||
g.drawRect(hitbox.getHitboxStart().getX()
|
||||
- MapCamera.getCameraX()
|
||||
, hitbox.getHitboxStart().getY()
|
||||
- MapCamera.getCameraY()
|
||||
, hitbox.getWidth()
|
||||
, hitbox.getHeight()
|
||||
g.drawRect(hitbox.getHitboxStart().getX() * zoom
|
||||
- MapCamera.getCameraX() * zoom
|
||||
, hitbox.getHitboxStart().getY() * zoom
|
||||
- MapCamera.getCameraY() * zoom
|
||||
, hitbox.getWidth() * zoom
|
||||
, hitbox.getHeight() * zoom
|
||||
);
|
||||
// ...and its point
|
||||
g.fillRect(
|
||||
hitbox.getPointedX() - 1
|
||||
- MapCamera.getCameraX()
|
||||
, hitbox.getPointedY() - 1
|
||||
- MapCamera.getCameraY()
|
||||
(hitbox.getPointedX() - 1) * zoom
|
||||
- MapCamera.getCameraX() * zoom
|
||||
, (hitbox.getPointedY() - 1) * zoom
|
||||
- MapCamera.getCameraY() * zoom
|
||||
, 3
|
||||
, 3
|
||||
);
|
||||
@@ -138,19 +157,19 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
|
||||
// Next hitbox
|
||||
g.setColor(Color.blue);
|
||||
g.drawRect(nextHitbox.getHitboxStart().getX()
|
||||
- MapCamera.getCameraX()
|
||||
, nextHitbox.getHitboxStart().getY()
|
||||
- MapCamera.getCameraY()
|
||||
, nextHitbox.getWidth()
|
||||
, nextHitbox.getHeight()
|
||||
g.drawRect(nextHitbox.getHitboxStart().getX() * zoom
|
||||
- MapCamera.getCameraX() * zoom
|
||||
, nextHitbox.getHitboxStart().getY() * zoom
|
||||
- MapCamera.getCameraY() * zoom
|
||||
, nextHitbox.getWidth() * zoom
|
||||
, nextHitbox.getHeight() * zoom
|
||||
);
|
||||
// ...and its point
|
||||
g.fillRect(
|
||||
nextHitbox.getPointedX() - 1
|
||||
- MapCamera.getCameraX()
|
||||
, nextHitbox.getPointedY() - 1
|
||||
- MapCamera.getCameraY()
|
||||
(nextHitbox.getPointedX() - 1) * zoom
|
||||
- MapCamera.getCameraX() * zoom
|
||||
, (nextHitbox.getPointedY() - 1) * zoom
|
||||
- MapCamera.getCameraY() * zoom
|
||||
, 3
|
||||
, 3
|
||||
);
|
||||
@@ -165,10 +184,18 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
g.drawString(s, 20, line(l));
|
||||
}
|
||||
|
||||
private static void printLineColumn(Graphics g, int col, int row, String s) {
|
||||
g.drawString(s, 20 + column(col), line(row));
|
||||
}
|
||||
|
||||
private static int line(int i) {
|
||||
return i * 20;
|
||||
}
|
||||
|
||||
private static int column(int i) {
|
||||
return (250 * (i - 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(GameContainer gc, int delta_t) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user