mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 10:04:05 +09:00
Joise, Kotlin (it's working at least)
Former-commit-id: d5be0e95ba259d566d6d5d20eb576010a149ae7d Former-commit-id: 9502c7cd7e738147e31d2e9824e48bea24d00abf
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,18 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-31.
|
||||
*/
|
||||
public interface Actor {
|
||||
|
||||
void update(GameContainer gc, int delta_t);
|
||||
|
||||
/**
|
||||
* Valid RefID is equal to or greater than 32768.
|
||||
* @return Reference ID. (32768-0x7FFF_FFFF_FFFF_FFFF)
|
||||
*/
|
||||
long getRefID();
|
||||
}
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.Terrarum.GameItem.InventoryItem;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-31.
|
||||
*/
|
||||
public interface CanBeStoredAsItem {
|
||||
|
||||
void attachItemData();
|
||||
|
||||
float getItemWeight();
|
||||
|
||||
void stopUpdateAndDraw();
|
||||
|
||||
void resumeUpdateAndDraw();
|
||||
|
||||
InventoryItem getItemData();
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.spriteAnimation.SpriteAnimation;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Input;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-31.
|
||||
*/
|
||||
public interface Controllable {
|
||||
|
||||
void processInput(Input input);
|
||||
|
||||
void keyPressed(int key, char c);
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,137 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.JsonFetcher;
|
||||
import com.Torvald.Rand.Fudge3;
|
||||
import com.Torvald.Rand.HQRNG;
|
||||
import com.Torvald.Terrarum.LangPack.Lang;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.newdawn.slick.SlickException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-05.
|
||||
*/
|
||||
public class CreatureFactory {
|
||||
|
||||
private static final String JSONPATH = "./res/raw/";
|
||||
|
||||
public ActorWithBody build(String jsonFileName) throws IOException, SlickException {
|
||||
JsonObject jsonObj = JsonFetcher.readJson(JSONPATH + jsonFileName);
|
||||
ActorWithBody actor = new ActorWithBody();
|
||||
|
||||
|
||||
String[] elementsString = {
|
||||
"racename"
|
||||
, "racenameplural"
|
||||
};
|
||||
|
||||
String[] elementsFloat = {
|
||||
"baseheight"
|
||||
, "basemass"
|
||||
, "accel"
|
||||
, "toolsize"
|
||||
, "encumbrance"
|
||||
};
|
||||
|
||||
String[] elementsFloatVariable = {
|
||||
"strength"
|
||||
, "speed"
|
||||
, "jumppower"
|
||||
, "scale"
|
||||
, "speed"
|
||||
};
|
||||
|
||||
String[] elementsBoolean = {
|
||||
"intelligent"
|
||||
};
|
||||
|
||||
String[] elementsMultiplyFromOne = {
|
||||
"physiquemult"
|
||||
};
|
||||
|
||||
|
||||
setAVStrings(actor, elementsString, jsonObj);
|
||||
setAVFloats(actor, elementsFloat, jsonObj);
|
||||
setAVFloatsVariable(actor, elementsFloatVariable, jsonObj);
|
||||
setAVMultiplyFromOne(actor, elementsMultiplyFromOne, jsonObj);
|
||||
setAVBooleans(actor, elementsBoolean, jsonObj);
|
||||
|
||||
actor.actorValue.set("accel", Player.WALK_ACCEL_BASE);
|
||||
actor.actorValue.set("accelmult", 1f);
|
||||
|
||||
actor.inventory = new ActorInventory((int) actor.actorValue.get("encumberance"), true);
|
||||
|
||||
return actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and set actor values that have 'variable' appended. E.g. strength
|
||||
* @param p
|
||||
* @param elemSet
|
||||
* @param jsonObject
|
||||
*/
|
||||
private void setAVFloatsVariable(ActorWithBody p, String[] elemSet, JsonObject jsonObject) {
|
||||
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()).rollForArray();
|
||||
// get multiplier from json. Assuming percentile
|
||||
int multiplier = jsonObject.get(s + "variable").getAsJsonArray().get(varSelected).getAsInt();
|
||||
float realValue = baseValue * multiplier / 100f;
|
||||
|
||||
p.actorValue.set(s, realValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and set string actor values
|
||||
* @param p
|
||||
* @param elemSet
|
||||
* @param jsonObject
|
||||
*/
|
||||
private void setAVStrings(ActorWithBody p, String[] elemSet, JsonObject jsonObject) {
|
||||
for (String s : elemSet) {
|
||||
String key = jsonObject.get(s).getAsString();
|
||||
p.actorValue.set(s, Lang.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and set float actor values
|
||||
* @param p
|
||||
* @param elemSet
|
||||
* @param jsonObject
|
||||
*/
|
||||
private void setAVFloats(ActorWithBody p, String[] elemSet, JsonObject jsonObject) {
|
||||
for (String s : elemSet) {
|
||||
p.actorValue.set(s, jsonObject.get(s).getAsFloat());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and set actor values that should multiplier be applied to the base value of 1.
|
||||
* E.g. physiquemult
|
||||
* @param p
|
||||
* @param elemSet
|
||||
* @param jsonObject
|
||||
*/
|
||||
private void setAVMultiplyFromOne(ActorWithBody p, String[] elemSet, JsonObject jsonObject) {
|
||||
for (String s : elemSet) {
|
||||
float baseValue = 1f;
|
||||
// roll fudge dice and get value [-3, 3] as [0, 6]
|
||||
int varSelected = new Fudge3(new HQRNG()).rollForArray();
|
||||
// get multiplier from json. Assuming percentile
|
||||
int multiplier = jsonObject.get(s).getAsJsonArray().get(varSelected).getAsInt();
|
||||
float realValue = baseValue * multiplier / 100f;
|
||||
|
||||
p.actorValue.set(s, realValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAVBooleans(ActorWithBody p, String[] elemSet, JsonObject jsonObject) {
|
||||
for (String s : elemSet) {
|
||||
p.actorValue.set(s, jsonObject.get(s).getAsBoolean());
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.Faction.Faction;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-15.
|
||||
*/
|
||||
public interface Factionable {
|
||||
|
||||
void assignFaction(Faction f);
|
||||
void unassignFaction(Faction f);
|
||||
HashSet<Faction> getAssignedFactions();
|
||||
void clearFactionAssigning();
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-25.
|
||||
*/
|
||||
public interface Glowing {
|
||||
|
||||
void drawGlow(GameContainer gc, Graphics g);
|
||||
|
||||
void updateGlowSprite(GameContainer gc, int delta_t);
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -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();
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-19.
|
||||
*/
|
||||
public interface Luminous {
|
||||
|
||||
void setLuminance(char RGB);
|
||||
char getLuminance();
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,152 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.AI.ActorAI;
|
||||
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.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-31.
|
||||
*/
|
||||
public class NPCIntelligentBase extends ActorWithBody implements AIControlled, Pocketed, CanBeStoredAsItem,
|
||||
Factionable, Landholder {
|
||||
|
||||
private InventoryItem itemData; // keep it for extendibility, like Carriers in SC1
|
||||
private transient ActorAI ai;
|
||||
private ActorInventory inventory;
|
||||
|
||||
private HashSet<Faction> factionSet = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Absolute tile index. index(x, y) = y * map.width + x <br />
|
||||
* The arraylist will be saved in JSON format with GSON.
|
||||
*/
|
||||
private ArrayList<Integer> houseTiles = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void assignFaction(Faction f) {
|
||||
factionSet.add(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unassignFaction(Faction f) {
|
||||
factionSet.remove(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<Faction> getAssignedFactions() {
|
||||
return factionSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFactionAssigning() {
|
||||
factionSet.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachItemData() {
|
||||
itemData = new InventoryItem() {
|
||||
@Override
|
||||
public long getItemID() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void effectWhileInPocket(GameContainer gc, int delta_t) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void effectWhenPickedUp(GameContainer gc, int delta_t) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void primaryUse(GameContainer gc, int delta_t) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void secondaryUse(GameContainer gc, int delta_t) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void effectWhenThrownAway(GameContainer gc, int delta_t) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getItemWeight() {
|
||||
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);
|
||||
super.setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resumeUpdateAndDraw() {
|
||||
super.setUpdate(true);
|
||||
super.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryItem getItemData() {
|
||||
return itemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActorInventory getInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void overwriteInventory(ActorInventory inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachAI(ActorAI ai) {
|
||||
this.ai = ai;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,104 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.JsonFetcher;
|
||||
import com.Torvald.Terrarum.Actors.Faction.Faction;
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.spriteAnimation.SpriteAnimation;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.lwjgl.Sys;
|
||||
import org.newdawn.slick.SlickException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-03.
|
||||
*/
|
||||
public class PFSigrid {
|
||||
|
||||
private static String FACTION_PATH = "./res/raw/";
|
||||
|
||||
public Player build() throws SlickException {
|
||||
Player p = new Player();
|
||||
|
||||
p.sprite = new SpriteAnimation();
|
||||
p.sprite.setDimension(28, 51);
|
||||
p.sprite.setSpriteImage("res/graphics/sprites/test_player.png");
|
||||
p.sprite.setDelay(200);
|
||||
p.sprite.setRowsAndFrames(1, 1);
|
||||
p.sprite.setAsVisible();
|
||||
p.sprite.composeSprite();
|
||||
|
||||
p.spriteGlow = new SpriteAnimation();
|
||||
p.spriteGlow.setDimension(28, 51);
|
||||
p.spriteGlow.setSpriteImage("res/graphics/sprites/test_player_glow.png");
|
||||
p.spriteGlow.setDelay(200);
|
||||
p.spriteGlow.setRowsAndFrames(1, 1);
|
||||
p.spriteGlow.setAsVisible();
|
||||
p.spriteGlow.composeSprite();
|
||||
|
||||
p.actorValue = new ActorValue();
|
||||
p.actorValue.set("scale", 1.0f);
|
||||
p.actorValue.set("speed", 4.0f);
|
||||
p.actorValue.set("speedmult", 1.0f);
|
||||
p.actorValue.set("accel", Player.WALK_ACCEL_BASE);
|
||||
p.actorValue.set("accelmult", 1.0f);
|
||||
|
||||
p.actorValue.set("jumppower", 5f);
|
||||
|
||||
p.actorValue.set("basemass", 80f);
|
||||
|
||||
p.actorValue.set("physiquemult", 1); // Constant 1.0 for player, meant to be used by random mobs
|
||||
/**
|
||||
* fixed value, or 'base value', from creature strength of Dwarf Fortress.
|
||||
* Human race uses 1000. (see CreatureHuman.json)
|
||||
*/
|
||||
p.actorValue.set("strength", 1414);
|
||||
p.actorValue.set("encumbrance", 1000);
|
||||
|
||||
p.actorValue.set("name", "Sigrid");
|
||||
|
||||
p.actorValue.set("intelligent", true);
|
||||
|
||||
p.actorValue.set("luminosity", 22819);
|
||||
|
||||
p.actorValue.set("selectedtile", 16);
|
||||
|
||||
p.setHitboxDimension(18, 46, 8, 0);
|
||||
|
||||
p.setInventory(new ActorInventory(0x7FFFFFFF, true));
|
||||
|
||||
p.setPosition(4096 * 16, 300 * 16);
|
||||
|
||||
p.assignFaction(loadFactioningData("FactionSigrid.json"));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
private Faction loadFactioningData(String filename) {
|
||||
JsonObject jsonObject = null;
|
||||
try {
|
||||
jsonObject = JsonFetcher.readJson(FACTION_PATH + filename);
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
Faction faction = new Faction(jsonObject.get("factionname").getAsString());
|
||||
|
||||
jsonObject.get("factionamicable").getAsJsonArray().forEach(
|
||||
jobj -> faction.addFactionAmicable(jobj.getAsString())
|
||||
);
|
||||
jsonObject.get("factionneutral").getAsJsonArray().forEach(
|
||||
jobj -> faction.addFactionNeutral(jobj.getAsString())
|
||||
);
|
||||
jsonObject.get("factionhostile").getAsJsonArray().forEach(
|
||||
jobj -> faction.addFactionHostile(jobj.getAsString())
|
||||
);
|
||||
jsonObject.get("factionfearful").getAsJsonArray().forEach(
|
||||
jobj -> faction.addFactionFearful(jobj.getAsString())
|
||||
);
|
||||
|
||||
return faction;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
*/
|
||||
public class PhysTestBall extends ActorWithBody {
|
||||
|
||||
public PhysTestBall() {
|
||||
super();
|
||||
setHitboxDimension(16, 16, 0, 0);
|
||||
setVisible(true);
|
||||
setMass(10f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBody(GameContainer gc, Graphics g) {
|
||||
g.setColor(Color.orange);
|
||||
g.fillOval(
|
||||
getHitbox().getPosX()
|
||||
, getHitbox().getPosY()
|
||||
, getHitbox().getWidth()
|
||||
, getHitbox().getHeight()
|
||||
);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,571 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.Faction.Faction;
|
||||
import com.Torvald.Terrarum.GameControl.EnumKeyFunc;
|
||||
import com.Torvald.Terrarum.GameControl.KeyMap;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapDrawer;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.spriteAnimation.SpriteAnimation;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import org.lwjgl.input.Controller;
|
||||
import org.lwjgl.input.Controllers;
|
||||
import org.newdawn.slick.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-31.
|
||||
*/
|
||||
public class Player extends ActorWithBody implements Controllable, Pocketed, Factionable, Luminous {
|
||||
|
||||
public transient @Nullable Controllable vehicleRiding;
|
||||
|
||||
int jumpCounter = 0;
|
||||
int walkPowerCounter = 0;
|
||||
private transient final int MAX_JUMP_LENGTH = 17; // use 17; in internal frames
|
||||
/**
|
||||
* experimental value.
|
||||
*/
|
||||
// private transient final float JUMP_ACCELERATION_MOD = ???f / 10000f; //quadratic mode
|
||||
private transient final float JUMP_ACCELERATION_MOD = 170f / 10000f; //linear mode
|
||||
private transient final int WALK_FRAMES_TO_MAX_ACCEL = 6;
|
||||
|
||||
public float readonly_totalX = 0, readonly_totalY = 0;
|
||||
|
||||
boolean jumping = false;
|
||||
|
||||
@NotNull int walkHeading;
|
||||
|
||||
private transient final int LEFT = 1;
|
||||
private transient final int RIGHT = 2;
|
||||
|
||||
private transient final int KEY_NULL = -1;
|
||||
private transient int prevHMoveKey = KEY_NULL;
|
||||
private transient int prevVMoveKey = KEY_NULL;
|
||||
|
||||
static transient final float ACCEL_MULT_IN_FLIGHT = 0.48f;
|
||||
static transient final float WALK_STOP_ACCEL = 0.32f;
|
||||
static transient final float WALK_ACCEL_BASE = 0.32f;
|
||||
|
||||
private boolean noClip = false;
|
||||
|
||||
public static transient final long PLAYER_REF_ID = 0x51621D;
|
||||
|
||||
private transient final float AXIS_POSMAX = 1.0f;
|
||||
private transient final int GAMEPAD_JUMP = 5;
|
||||
|
||||
private transient final int TSIZE = MapDrawer.TILE_SIZE;
|
||||
|
||||
private HashSet<Faction> factionSet = new HashSet<>();
|
||||
|
||||
private transient final int BASE_DENSITY = 1020;
|
||||
|
||||
|
||||
/**
|
||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.). <br />
|
||||
*
|
||||
* <strong>Use PlayerBuildFactory to build player!</strong>
|
||||
*
|
||||
* @throws SlickException
|
||||
*/
|
||||
public Player() throws SlickException {
|
||||
super();
|
||||
referenceID = PLAYER_REF_ID;
|
||||
setVisible(true);
|
||||
super.setDensity(BASE_DENSITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(GameContainer gc, int delta_t) {
|
||||
if (vehicleRiding instanceof Player) throw new RuntimeException("Attempted to 'ride' " +
|
||||
"player object.");
|
||||
|
||||
updatePhysicalInfos();
|
||||
super.update(gc, delta_t);
|
||||
|
||||
updateSprite(delta_t);
|
||||
|
||||
updateMovementControl();
|
||||
|
||||
if (noClip) { super.setGrounded(true); }
|
||||
|
||||
}
|
||||
|
||||
private void updatePhysicalInfos() {
|
||||
super.setScale(actorValue.getAsFloat("scale"));
|
||||
super.setMass(actorValue.getAsFloat("basemass")
|
||||
* FastMath.pow(super.getScale(), 3));
|
||||
if (super.getElasticity() != 0) super.setElasticity(0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param left (even if the game is joypad controlled, you must give valid value)
|
||||
* @param absAxisVal (set AXIS_POSMAX if keyboard controlled)
|
||||
*/
|
||||
private void walkHorizontal(boolean left, float absAxisVal) {
|
||||
//if ((!super.isWalledLeft() && left) || (!super.isWalledRight() && !left)) {
|
||||
readonly_totalX = super.getVeloX()
|
||||
+
|
||||
actorValue.getAsFloat("accel")
|
||||
* actorValue.getAsFloat("accelmult")
|
||||
* FastMath.sqrt(super.getScale())
|
||||
* applyAccelRealism(walkPowerCounter)
|
||||
* (left ? -1 : 1)
|
||||
* absAxisVal;
|
||||
|
||||
super.setVeloX(readonly_totalX);
|
||||
|
||||
if (walkPowerCounter < WALK_FRAMES_TO_MAX_ACCEL) {
|
||||
walkPowerCounter += 1;
|
||||
}
|
||||
|
||||
// Clamp veloX
|
||||
super.setVeloX(
|
||||
absClamp(super.getVeloX()
|
||||
, actorValue.getAsFloat("speed")
|
||||
* actorValue.getAsFloat("speedmult")
|
||||
* FastMath.sqrt(super.getScale())
|
||||
)
|
||||
);
|
||||
|
||||
// Heading flag
|
||||
if (left) walkHeading = LEFT;
|
||||
else walkHeading = RIGHT;
|
||||
//}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param up (even if the game is joypad controlled, you must give valid value)
|
||||
* @param absAxisVal (set AXIS_POSMAX if keyboard controlled)
|
||||
*/
|
||||
private void walkVertical(boolean up, float absAxisVal) {
|
||||
readonly_totalY = super.getVeloY()
|
||||
+
|
||||
actorValue.getAsFloat("accel")
|
||||
* actorValue.getAsFloat("accelmult")
|
||||
* FastMath.sqrt(super.getScale())
|
||||
* applyAccelRealism(walkPowerCounter)
|
||||
* (up ? -1 : 1)
|
||||
* absAxisVal;
|
||||
|
||||
super.setVeloY(readonly_totalY);
|
||||
|
||||
if (walkPowerCounter < WALK_FRAMES_TO_MAX_ACCEL) {
|
||||
walkPowerCounter += 1;
|
||||
}
|
||||
|
||||
// Clamp veloX
|
||||
super.setVeloY(
|
||||
absClamp(super.getVeloY()
|
||||
, actorValue.getAsFloat("speed")
|
||||
* actorValue.getAsFloat("speedmult")
|
||||
* FastMath.sqrt(super.getScale())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* For realistic accelerating while walking.
|
||||
*
|
||||
* Naïve 'veloX += 3' is actually like:
|
||||
*
|
||||
* a
|
||||
* | ------------
|
||||
* |
|
||||
* |
|
||||
* 0+------············ t
|
||||
*
|
||||
* which is unrealistic, so this method tries to introduce some realism by doing:
|
||||
*
|
||||
* a
|
||||
* | ------------
|
||||
* | ---
|
||||
* | -
|
||||
* | ---
|
||||
* 0+----··················· t
|
||||
*
|
||||
*
|
||||
* @param x
|
||||
*/
|
||||
private float applyAccelRealism(int x) {
|
||||
return 0.5f + 0.5f * -FastMath.cos(10 * x / (WALK_FRAMES_TO_MAX_ACCEL * FastMath.PI));
|
||||
}
|
||||
|
||||
private void walkHStop() {
|
||||
if (super.getVeloX() > 0) {
|
||||
super.setVeloX(super.getVeloX()
|
||||
-
|
||||
actorValue.getAsFloat("accel")
|
||||
* actorValue.getAsFloat("accelmult")
|
||||
* FastMath.sqrt(super.getScale())
|
||||
);
|
||||
|
||||
// compensate overshoot
|
||||
if (super.getVeloX() < 0)
|
||||
super.setVeloX(0);
|
||||
}
|
||||
else if (super.getVeloX() < 0) {
|
||||
super.setVeloX(super.getVeloX()
|
||||
+
|
||||
actorValue.getAsFloat("accel")
|
||||
* actorValue.getAsFloat("accelmult")
|
||||
* FastMath.sqrt(super.getScale())
|
||||
);
|
||||
|
||||
// compensate overshoot
|
||||
if (super.getVeloX() > 0)
|
||||
super.setVeloX(0);
|
||||
}
|
||||
else {
|
||||
super.setVeloX(0);
|
||||
}
|
||||
|
||||
walkPowerCounter = 0;
|
||||
}
|
||||
|
||||
private void walkVStop() {
|
||||
if (super.getVeloY() > 0) {
|
||||
super.setVeloY(super.getVeloY()
|
||||
-
|
||||
WALK_STOP_ACCEL
|
||||
* actorValue.getAsFloat("accelmult")
|
||||
* FastMath.sqrt(super.getScale())
|
||||
);
|
||||
|
||||
// compensate overshoot
|
||||
if (super.getVeloY() < 0)
|
||||
super.setVeloY(0);
|
||||
}
|
||||
else if (super.getVeloY() < 0) {
|
||||
super.setVeloY(super.getVeloY()
|
||||
+
|
||||
WALK_STOP_ACCEL
|
||||
* actorValue.getAsFloat("accelmult")
|
||||
* FastMath.sqrt(super.getScale())
|
||||
);
|
||||
|
||||
// compensate overshoot
|
||||
if (super.getVeloY() > 0)
|
||||
super.setVeloY(0);
|
||||
}
|
||||
else {
|
||||
super.setVeloY(0);
|
||||
}
|
||||
|
||||
walkPowerCounter = 0;
|
||||
}
|
||||
|
||||
private void updateMovementControl() {
|
||||
if (!noClip) {
|
||||
if (super.isGrounded()) {
|
||||
actorValue.set("accelmult", 1f);
|
||||
} else {
|
||||
actorValue.set("accelmult", ACCEL_MULT_IN_FLIGHT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
actorValue.set("accelmult", 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public void processInput(Input input) {
|
||||
Controller gamepad = null;
|
||||
float axisX = 0, axisY = 0, axisRX = 0, axisRY = 0;
|
||||
if (Terrarum.hasController) {
|
||||
gamepad = Controllers.getController(0);
|
||||
axisX = gamepad.getAxisValue(0);
|
||||
axisY = gamepad.getAxisValue(1);
|
||||
axisRX = gamepad.getAxisValue(2);
|
||||
axisRY = gamepad.getAxisValue(3);
|
||||
|
||||
if (Math.abs(axisX) < Terrarum.CONTROLLER_DEADZONE) axisX = 0;
|
||||
if (Math.abs(axisY) < Terrarum.CONTROLLER_DEADZONE) axisY = 0;
|
||||
if (Math.abs(axisRX) < Terrarum.CONTROLLER_DEADZONE) axisRX = 0;
|
||||
if (Math.abs(axisRY) < Terrarum.CONTROLLER_DEADZONE) axisRY = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* L-R stop
|
||||
*/
|
||||
if (Terrarum.hasController) {
|
||||
if (axisX == 0) {
|
||||
walkHStop();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ↑F, ↑S
|
||||
if (!isFuncDown(input, EnumKeyFunc.MOVE_LEFT)
|
||||
&& !isFuncDown(input, EnumKeyFunc.MOVE_RIGHT)) {
|
||||
walkHStop();
|
||||
prevHMoveKey = KEY_NULL;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* U-D stop
|
||||
*/
|
||||
if (Terrarum.hasController) {
|
||||
if (axisY == 0) {
|
||||
walkVStop();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ↑E
|
||||
// ↑D
|
||||
if (isNoClip()
|
||||
&& !isFuncDown(input, EnumKeyFunc.MOVE_UP)
|
||||
&& !isFuncDown(input, EnumKeyFunc.MOVE_DOWN)) {
|
||||
walkVStop();
|
||||
prevVMoveKey = KEY_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Left/Right movement
|
||||
*/
|
||||
|
||||
if (Terrarum.hasController) {
|
||||
if (axisX != 0) {
|
||||
walkHorizontal(axisX < 0, AXIS_POSMAX);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ↑F, ↓S
|
||||
if (isFuncDown(input, EnumKeyFunc.MOVE_RIGHT)
|
||||
&& !isFuncDown(input, EnumKeyFunc.MOVE_LEFT)) {
|
||||
walkHorizontal(false, AXIS_POSMAX);
|
||||
prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_RIGHT);
|
||||
}
|
||||
// ↓F, ↑S
|
||||
else if (isFuncDown(input, EnumKeyFunc.MOVE_LEFT)
|
||||
&& !isFuncDown(input, EnumKeyFunc.MOVE_RIGHT)) {
|
||||
walkHorizontal(true, AXIS_POSMAX);
|
||||
prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT);
|
||||
}
|
||||
// ↓F, ↓S
|
||||
else if (isFuncDown(input, EnumKeyFunc.MOVE_LEFT)
|
||||
&& isFuncDown(input, EnumKeyFunc.MOVE_RIGHT)) {
|
||||
if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) {
|
||||
walkHorizontal(false, AXIS_POSMAX);
|
||||
prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_RIGHT);
|
||||
}
|
||||
else if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_RIGHT)) {
|
||||
walkHorizontal(true, AXIS_POSMAX);
|
||||
prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Up/Down movement
|
||||
*/
|
||||
if (noClip) {
|
||||
if (Terrarum.hasController) {
|
||||
if (axisY != 0) {
|
||||
walkVertical(axisY > 0, AXIS_POSMAX);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ↑E
|
||||
// ↓D
|
||||
if (isFuncDown(input, EnumKeyFunc.MOVE_DOWN)
|
||||
&& !isFuncDown(input, EnumKeyFunc.MOVE_UP)) {
|
||||
walkVertical(false, AXIS_POSMAX);
|
||||
prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_DOWN);
|
||||
}
|
||||
// ↓E
|
||||
// ↑D
|
||||
else if (isFuncDown(input, EnumKeyFunc.MOVE_UP)
|
||||
&& !isFuncDown(input, EnumKeyFunc.MOVE_DOWN)) {
|
||||
walkVertical(true, AXIS_POSMAX);
|
||||
prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP);
|
||||
}
|
||||
// ↓E
|
||||
// ↓D
|
||||
else if (isFuncDown(input, EnumKeyFunc.MOVE_UP)
|
||||
&& isFuncDown(input, EnumKeyFunc.MOVE_DOWN)) {
|
||||
if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) {
|
||||
walkVertical(false, AXIS_POSMAX);
|
||||
prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_DOWN);
|
||||
}
|
||||
else if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_DOWN)) {
|
||||
walkVertical(true, AXIS_POSMAX);
|
||||
prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Jump control
|
||||
*/
|
||||
if (isFuncDown(input, EnumKeyFunc.JUMP)
|
||||
|| (Terrarum.hasController && gamepad.isButtonPressed(GAMEPAD_JUMP))) {
|
||||
if (!noClip) {
|
||||
if (super.isGrounded()) {
|
||||
jumping = true;
|
||||
}
|
||||
jump();
|
||||
}
|
||||
else {
|
||||
walkVertical(true, AXIS_POSMAX);
|
||||
}
|
||||
}
|
||||
else {
|
||||
jumping = false;
|
||||
jumpCounter = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void keyPressed(int key, char c) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See ./work_files/Jump\ power\ by\ pressing\ time.gcx
|
||||
*/
|
||||
private void jump() {
|
||||
if (jumping) {
|
||||
float len = MAX_JUMP_LENGTH;
|
||||
float pwr = actorValue.getAsFloat("jumppower");
|
||||
|
||||
// increment jump counter
|
||||
if (jumpCounter < len) jumpCounter += 1;
|
||||
// quadratic time (convex) mode
|
||||
/*
|
||||
float sumT = (jumpCounter * (jumpCounter + 1)) / 2f;
|
||||
float timedJumpCharge = ((len + 1) / 2f) - (sumT / len);
|
||||
if (timedJumpCharge < 0) timedJumpCharge = 0;
|
||||
|
||||
float jumpAcc = pwr * timedJumpCharge * JUMP_ACCELERATION_MOD;
|
||||
|
||||
super.setVeloY(super.getVeloY()
|
||||
- jumpAcc
|
||||
);
|
||||
*/
|
||||
|
||||
// linear time mode
|
||||
float init = (len + 1) / 2f;
|
||||
float timedJumpCharge = init - (init / len) * jumpCounter;
|
||||
if (timedJumpCharge < 0) timedJumpCharge = 0;
|
||||
|
||||
float jumpAcc = pwr * timedJumpCharge * JUMP_ACCELERATION_MOD
|
||||
* FastMath.sqrt(getScale());
|
||||
|
||||
super.setVeloY(super.getVeloY()
|
||||
- jumpAcc
|
||||
);
|
||||
|
||||
// concave mode?
|
||||
}
|
||||
|
||||
// for mob AI:
|
||||
//super.setVeloY(super.getVeloY()
|
||||
// -
|
||||
// pwr * FastMath.sqrt(super.getScale())
|
||||
//);
|
||||
}
|
||||
|
||||
private float jumpFuncLin(float pwr, float len) {
|
||||
return -(pwr / len) * jumpCounter;
|
||||
}
|
||||
|
||||
private float jumpFuncSqu(float pwr, float len) {
|
||||
return (pwr / (len * len))
|
||||
* (jumpCounter - len)
|
||||
* (jumpCounter - len) // square
|
||||
- pwr;
|
||||
}
|
||||
|
||||
private float jumpFuncExp(float pwr, float len) {
|
||||
float a = FastMath.pow(pwr + 1, 1 / len);
|
||||
return -FastMath.pow(a, len) + 1;
|
||||
}
|
||||
|
||||
private boolean isFuncDown(Input input, EnumKeyFunc fn) {
|
||||
return input.isKeyDown(KeyMap.getKeyCode(fn));
|
||||
}
|
||||
|
||||
private float absClamp(float i, float ceil) {
|
||||
if (i > 0)
|
||||
return (i > ceil) ? ceil : i;
|
||||
else if (i < 0)
|
||||
return (-i > ceil) ? -ceil : i;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void updateSprite(int delta_t) {
|
||||
sprite.update(delta_t);
|
||||
if (spriteGlow != null) {
|
||||
spriteGlow.update(delta_t);
|
||||
}
|
||||
|
||||
if (super.isGrounded()) {
|
||||
if (walkHeading == LEFT) {
|
||||
sprite.flip(true, false);
|
||||
if (spriteGlow != null) {
|
||||
spriteGlow.flip(true, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sprite.flip(false, false);
|
||||
if (spriteGlow != null) {
|
||||
spriteGlow.flip(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNoClip() {
|
||||
return noClip;
|
||||
}
|
||||
|
||||
public void setNoClip(boolean b) {
|
||||
noClip = b;
|
||||
}
|
||||
|
||||
public ActorValue getActorValue() {
|
||||
return actorValue;
|
||||
}
|
||||
|
||||
public SpriteAnimation getSpriteGlow() {
|
||||
return spriteGlow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignFaction(Faction f) {
|
||||
factionSet.add(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unassignFaction(Faction f) {
|
||||
factionSet.remove(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<Faction> getAssignedFactions() {
|
||||
return factionSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFactionAssigning() {
|
||||
factionSet.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLuminance(char RGB) {
|
||||
actorValue.set("luminosity", (int) RGB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getLuminance() {
|
||||
return actorValue.hasKey("luminosity") ?
|
||||
(char) actorValue.getAsInt("luminosity") : 0;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,46 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.spriteAnimation.SpriteAnimation;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-14.
|
||||
*/
|
||||
public class PlayerDebugger {
|
||||
|
||||
private Actor actor;
|
||||
|
||||
public PlayerDebugger(Actor actor) {
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
if (actor instanceof Player) {
|
||||
return (Player) actor;
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates for Player instances
|
||||
*/
|
||||
|
||||
public float baseHitboxW() { return getPlayer().getBaseHitboxW(); }
|
||||
public float baseHitboxH() { return getPlayer().getBaseHitboxH(); }
|
||||
public float hitboxTranslateX() { return getPlayer().getHitboxTranslateX(); }
|
||||
public float hitboxTranslateY() { return getPlayer().getHitboxTranslateY(); }
|
||||
public float veloX() { return getPlayer().getVeloX(); }
|
||||
public float veloY() { return getPlayer().getVeloY(); }
|
||||
public int baseSpriteWidth() { return getPlayer().baseSpriteWidth; }
|
||||
public int baseSpriteHeight() { return getPlayer().baseSpriteHeight; }
|
||||
public SpriteAnimation sprite() { return getPlayer().sprite; }
|
||||
public float scale() { return getPlayer().getScale(); }
|
||||
public Hitbox hitbox() { return getPlayer().getHitbox(); }
|
||||
public Hitbox nextHitbox() { return getPlayer().getNextHitbox(); }
|
||||
public boolean grounded() { return getPlayer().getGrounded(); }
|
||||
public ActorValue actorValue() { return getPlayer().getActorValue(); }
|
||||
public float mass() { return getPlayer().getMass(); }
|
||||
public boolean noClip() { return getPlayer().isNoClip(); }
|
||||
public int eventMoving() { return getPlayer().eventMoving; }
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-25.
|
||||
*/
|
||||
public interface Visible {
|
||||
|
||||
void drawBody(GameContainer gc, Graphics g);
|
||||
|
||||
void updateBodySprite(GameContainer gc, int delta_t);
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -60,13 +60,29 @@
|
||||
"13"; "12";"TILE_ILLUMINATOR_GREY_LIGHT"; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "47589"; "13"; "12"; "0";"16"
|
||||
"13"; "13";"TILE_ILLUMINATOR_GREY_MED"; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "29538"; "13"; "13"; "0";"16"
|
||||
"13"; "14";"TILE_ILLUMINATOR_GREY_DARK"; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "16410"; "13"; "14"; "0";"16"
|
||||
"13"; "15";"TILE_ILLUMINATOR_BLACK" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "4923"; "13"; "15"; "0";"16"
|
||||
"14"; "0";"TILE_SANDSTONE" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "14"; "0"; "0";"16"
|
||||
"14"; "1";"TILE_SANDSTONE_WHITE" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "14"; "1"; "0";"16"
|
||||
"14"; "2";"TILE_SANDSTONE_RED" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "14"; "2"; "0";"16"
|
||||
"14"; "3";"TILE_SANDSTONE_DESERT" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "14"; "3"; "0";"16"
|
||||
"14"; "4";"TILE_SANDSTONE_BLACK" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "14"; "4"; "0";"16"
|
||||
"14"; "5";"TILE_SANDSTONE_BLACK" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "14"; "5"; "0";"16"
|
||||
"13"; "15";"TILE_ILLUMINATOR_BLACK" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "27239"; "13"; "15"; "0";"16"
|
||||
"14"; "0";"TILE_ILLUMINATOR_WHITE" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "0"; "0";"16"
|
||||
"14"; "1";"TILE_ILLUMINATOR_YELLOW" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "1"; "0";"16"
|
||||
"14"; "2";"TILE_ILLUMINATOR_ORANGE" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "2"; "0";"16"
|
||||
"14"; "3";"TILE_ILLUMINATOR_RED" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "3"; "0";"16"
|
||||
"14"; "4";"TILE_ILLUMINATOR_FUCHSIA" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "4"; "0";"16"
|
||||
"14"; "5";"TILE_ILLUMINATOR_PURPLE" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "5"; "0";"16"
|
||||
"14"; "6";"TILE_ILLUMINATOR_BLUE" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "6"; "0";"16"
|
||||
"14"; "7";"TILE_ILLUMINATOR_CYAN" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "7"; "0";"16"
|
||||
"14"; "8";"TILE_ILLUMINATOR_GREEN" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "8"; "0";"16"
|
||||
"14"; "9";"TILE_ILLUMINATOR_GREEN_DARK"; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "9"; "0";"16"
|
||||
"14"; "10";"TILE_ILLUMINATOR_BROWN" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "10"; "0";"16"
|
||||
"14"; "11";"TILE_ILLUMINATOR_TAN" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "11"; "0";"16"
|
||||
"14"; "12";"TILE_ILLUMINATOR_GREY_LIGHT"; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "12"; "0";"16"
|
||||
"14"; "13";"TILE_ILLUMINATOR_GREY_MED"; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "13"; "0";"16"
|
||||
"14"; "14";"TILE_ILLUMINATOR_GREY_DARK"; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "14"; "0";"16"
|
||||
"14"; "15";"TILE_ILLUMINATOR_BLACK" ; "0"; "0"; "N/A"; "0"; "0"; "1"; "1"; "0"; "13"; "15"; "0";"16"
|
||||
"15"; "0";"TILE_SANDSTONE" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "15"; "0"; "0";"16"
|
||||
"15"; "1";"TILE_SANDSTONE_WHITE" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "15"; "1"; "0";"16"
|
||||
"15"; "2";"TILE_SANDSTONE_RED" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "15"; "2"; "0";"16"
|
||||
"15"; "3";"TILE_SANDSTONE_DESERT" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "15"; "3"; "0";"16"
|
||||
"15"; "4";"TILE_SANDSTONE_BLACK" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "15"; "4"; "0";"16"
|
||||
"15"; "5";"TILE_SANDSTONE_BLACK" ; "8205"; "25";"1900"; "0"; "0"; "1"; "1"; "0"; "15"; "5"; "0";"16"
|
||||
"254"; "0";"TILE_WATER" ; "6522"; "100";"1000"; "1"; "12"; "0"; "0"; "0"; "N/A"; "N/A"; "0";"16"
|
||||
"254"; "1";"TILE_WATER" ; "6522"; "100";"1000"; "1"; "12"; "0"; "0"; "0"; "N/A"; "N/A"; "0";"16"
|
||||
"254"; "2";"TILE_WATER" ; "6522"; "100";"1000"; "1"; "12"; "0"; "0"; "0"; "N/A"; "N/A"; "0";"16"
|
||||
@@ -111,6 +127,8 @@
|
||||
|
||||
# Magical ice: theoretical __metallic__ ice that might form under super-high pressure (> 5 TPa). Its density is a wild guess.
|
||||
|
||||
# Off illuminator: NO OPACITY! this is intended!
|
||||
|
||||
# References:
|
||||
# * Density of various woods : http://www.engineeringtoolbox.com/wood-density-d_40.html
|
||||
# * Density of various phases of ice : http://www1.lsbu.ac.uk/water/ice_phases.html
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 18.
|
@@ -0,0 +1,220 @@
|
||||
package com.Torvald.Terrarum.UserInterface;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.PlayerDebugger;
|
||||
import com.Torvald.Terrarum.Actors.Hitbox;
|
||||
import com.Torvald.Terrarum.GameMap.PairedMapLayer;
|
||||
import com.Torvald.Terrarum.LangPack.Lang;
|
||||
import com.Torvald.Terrarum.MapDrawer.LightmapRenderer;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapDrawer;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapCamera;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Input;
|
||||
|
||||
import java.util.Formatter;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-19.
|
||||
*/
|
||||
public class BasicDebugInfoWindow implements UICanvas {
|
||||
|
||||
private static PlayerDebugger playerDbg;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
/**
|
||||
* Call AFTER player constuction!
|
||||
*/
|
||||
public BasicDebugInfoWindow() {
|
||||
width = Terrarum.WIDTH;
|
||||
height = Terrarum.HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GameContainer gc, Graphics g) {
|
||||
if (playerDbg == null) {
|
||||
playerDbg = new PlayerDebugger(Terrarum.game.getPlayer());
|
||||
}
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Formatter formatter = new Formatter(sb);
|
||||
|
||||
int mouseTileX = (int) ((MapCamera.getCameraX() + gc.getInput().getMouseX() / Terrarum.game.screenZoom)
|
||||
/ MapDrawer.TILE_SIZE);
|
||||
int mouseTileY = (int) ((MapCamera.getCameraY() + gc.getInput().getMouseY() / Terrarum.game.screenZoom)
|
||||
/ MapDrawer.TILE_SIZE);
|
||||
|
||||
g.setColor(Color.white);
|
||||
|
||||
Hitbox hitbox = playerDbg.hitbox();
|
||||
Hitbox nextHitbox = playerDbg.nextHitbox();
|
||||
|
||||
printLine(g, 1, "posX : "
|
||||
+ String.valueOf(hitbox.getPointedX())
|
||||
+ " ("
|
||||
+ String.valueOf((int) (hitbox.getPointedX() / MapDrawer.TILE_SIZE))
|
||||
+ ")"
|
||||
);
|
||||
printLine(g, 2, "posY : "
|
||||
+ String.valueOf(hitbox.getPointedY())
|
||||
+ " ("
|
||||
+ String.valueOf((int) (hitbox.getPointedY() / MapDrawer.TILE_SIZE))
|
||||
+ ")"
|
||||
);
|
||||
printLine(g, 3, "veloX : " + String.valueOf(playerDbg.veloX()));
|
||||
printLine(g, 4, "veloY : " + String.valueOf(playerDbg.veloY()));
|
||||
printLine(g, 5, "grounded : " + String.valueOf(playerDbg.grounded()));
|
||||
printLine(g, 6, "noClip : " + String.valueOf(playerDbg.noClip()));
|
||||
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);
|
||||
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";
|
||||
mtX = "---";
|
||||
mtY = "---";
|
||||
}
|
||||
printLine(g, 8, "light at cursor : " + lightVal
|
||||
);
|
||||
|
||||
String tileNo;
|
||||
try {
|
||||
int tileNumRaw = Terrarum.game.map.getTileFromTerrain(mouseTileX, mouseTileY);
|
||||
int tilenum = tileNumRaw / PairedMapLayer.RANGE;
|
||||
int tiledmg = tileNumRaw % PairedMapLayer.RANGE;
|
||||
tileNo = tilenum + ":" + tiledmg;
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
tileNo = "-";
|
||||
}
|
||||
printLine(g, 9, "tile : " + tileNo + " (" + mtX + ", " + mtY + ")");
|
||||
|
||||
/**
|
||||
* Second column
|
||||
*/
|
||||
|
||||
int collisonFlag = playerDbg.eventMoving();
|
||||
printLineColumn(g, 2, 1, "Vsync : " + Terrarum.appgc.isVSyncRequested());
|
||||
printLineColumn(g, 2, 2, "Env colour temp : " + MapDrawer.getColTemp());
|
||||
|
||||
/**
|
||||
* On screen
|
||||
*/
|
||||
|
||||
// Memory allocation
|
||||
long memInUse = Terrarum.game.memInUse;
|
||||
long totalVMMem = Terrarum.game.totalVMMem;
|
||||
|
||||
g.setColor(new Color(0xFF7F00));
|
||||
g.drawString(
|
||||
Lang.get("DEV_MEMORY_SHORT_CAP")
|
||||
+ " : "
|
||||
+ formatter.format(
|
||||
Lang.get("DEV_MEMORY_A_OF_B")
|
||||
, memInUse
|
||||
, totalVMMem
|
||||
)
|
||||
, Terrarum.WIDTH - 200, line(1)
|
||||
);
|
||||
|
||||
// Hitbox
|
||||
float zoom = Terrarum.game.screenZoom;
|
||||
g.setColor(new Color(0x007f00));
|
||||
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) * zoom
|
||||
- MapCamera.getCameraX() * zoom
|
||||
, (hitbox.getPointedY() - 1) * zoom
|
||||
- MapCamera.getCameraY() * zoom
|
||||
, 3
|
||||
, 3
|
||||
);
|
||||
g.drawString(
|
||||
Lang.get("DEV_COLOUR_LEGEND_GREEN")
|
||||
+ " : hitbox", Terrarum.WIDTH - 200
|
||||
, line(2)
|
||||
);
|
||||
|
||||
// Next hitbox
|
||||
g.setColor(Color.blue);
|
||||
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) * zoom
|
||||
- MapCamera.getCameraX() * zoom
|
||||
, (nextHitbox.getPointedY() - 1) * zoom
|
||||
- MapCamera.getCameraY() * zoom
|
||||
, 3
|
||||
, 3
|
||||
);
|
||||
g.drawString(
|
||||
Lang.get("DEV_COLOUR_LEGEND_BLUE")
|
||||
+ " : nextHitbox", Terrarum.WIDTH - 200
|
||||
, line(3)
|
||||
);
|
||||
}
|
||||
|
||||
private static void printLine(Graphics g, int l, String s) {
|
||||
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) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processInput(Input input) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
package com.Torvald.Terrarum.UserInterface;
|
||||
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Input;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-31. <br>
|
||||
*/
|
||||
public interface UICanvas {
|
||||
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
|
||||
void update(GameContainer gc, int delta_t);
|
||||
|
||||
void render(GameContainer gc, Graphics g);
|
||||
|
||||
void processInput(Input input);
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
package com.Torvald.Terrarum.UserInterface;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-06.
|
||||
*/
|
||||
public interface UIClickable {
|
||||
|
||||
void mouseMoved(int oldx, int oldy, int newx, int newy);
|
||||
|
||||
void mouseDragged(int oldx, int oldy, int newx, int newy);
|
||||
|
||||
void mousePressed(int button, int x, int y);
|
||||
|
||||
void mouseReleased(int button, int x, int y);
|
||||
|
||||
void mouseWheelMoved(int change);
|
||||
|
||||
void controllerButtonPressed(int controller, int button);
|
||||
|
||||
void controllerButtonReleased(int controller, int button);
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
package com.Torvald.Terrarum.UserInterface;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-06.
|
||||
*/
|
||||
public interface UITypable {
|
||||
|
||||
void keyPressed(int key, char c);
|
||||
|
||||
void keyReleased(int key, char c);
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
BIN
out/production/Terrarum_renewed/com/sudoplay/joise/Joise.class
Normal file
BIN
out/production/Terrarum_renewed/com/sudoplay/joise/Joise.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user