mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
Converted Terrarum.Game to be a GameState of Slick
Former-commit-id: 6a3b2626d8db5209a2578c6924ee12cfaa5f1f79 Former-commit-id: 33caf533fbf4dc126c54120c7b1da6830106c8ae
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.
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.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 60 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 79 KiB |
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"racename" : "CONTEXT_RACE_HUMAN",
|
||||
"racenameplural" : "CONTEXT_RACE_HUMAN_PLURAL",
|
||||
"ethnicgroup" : "human",
|
||||
"baseheight" : 40,
|
||||
"basemass" : 60.0,
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.Rand.HighQualityRandom;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.Terrarum.Game;
|
||||
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;
|
||||
@@ -65,8 +65,8 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
* meter to pixel : 24/FPS
|
||||
*/
|
||||
private final float METER = 24f;
|
||||
private final float SI_TO_GAME_ACC = METER / (Terrarum.TARGET_FPS * Terrarum.TARGET_FPS);
|
||||
private final float SI_TO_GAME_VEL = METER / Terrarum.TARGET_FPS;
|
||||
private final float SI_TO_GAME_ACC = METER / (Terrarum.game.TARGET_FPS * Terrarum.game.TARGET_FPS);
|
||||
private final float SI_TO_GAME_VEL = METER / Terrarum.game.TARGET_FPS;
|
||||
private float gravitation;
|
||||
private final float DRAG_COEFF = 1f;
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
*/
|
||||
baseSpriteHeight = sprite.getHeight();
|
||||
baseSpriteWidth = sprite.getWidth();
|
||||
gravitation = Game.map.getGravitation();
|
||||
gravitation = Terrarum.game.map.getGravitation();
|
||||
|
||||
if (!playerNoClip()) {
|
||||
applyGravitation();
|
||||
@@ -225,7 +225,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
if (feetTileX < 0) feetTileX = 0;
|
||||
if (feetTileY < 0) feetTileY = 0;
|
||||
|
||||
int feetTile = Game.map.getTileFromTerrain(feetTileX, feetTileY);
|
||||
int feetTile = Terrarum.game.map.getTileFromTerrain(feetTileX, feetTileY);
|
||||
|
||||
if (feetTile != 0) {
|
||||
nextHitbox.setPositionYFromPoint(
|
||||
@@ -312,8 +312,8 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (x >= Game.map.width * TSIZE) {
|
||||
return Game.map.width * TSIZE - 1;
|
||||
else if (x >= Terrarum.game.map.width * TSIZE) {
|
||||
return Terrarum.game.map.width * TSIZE - 1;
|
||||
}
|
||||
else {
|
||||
return x;
|
||||
@@ -324,8 +324,8 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (x >= Game.map.height * TSIZE) {
|
||||
return Game.map.height * TSIZE - 1;
|
||||
else if (x >= Terrarum.game.map.height * TSIZE) {
|
||||
return Terrarum.game.map.height * TSIZE - 1;
|
||||
}
|
||||
else {
|
||||
return x;
|
||||
@@ -336,8 +336,8 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (x >= Game.map.width) {
|
||||
return Game.map.width - 1;
|
||||
else if (x >= Terrarum.game.map.width) {
|
||||
return Terrarum.game.map.width - 1;
|
||||
}
|
||||
else {
|
||||
return x;
|
||||
@@ -348,8 +348,8 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (x >= Game.map.height) {
|
||||
return Game.map.height - 1;
|
||||
else if (x >= Terrarum.game.map.height) {
|
||||
return Terrarum.game.map.height - 1;
|
||||
}
|
||||
else {
|
||||
return x;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.Torvald.Terrarum.Actors;
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.GameControl.EnumKeyFunc;
|
||||
import com.Torvald.Terrarum.GameControl.KeyMap;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.spriteAnimation.SpriteAnimation;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
@@ -39,6 +40,8 @@ public class Player extends ActorWithBody implements Controllable, Pocketed {
|
||||
|
||||
private boolean noClip = false;
|
||||
|
||||
public final long PLAYER_REF_ID = 0x51621D;
|
||||
|
||||
/**
|
||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.). <br />
|
||||
*
|
||||
@@ -48,7 +51,7 @@ public class Player extends ActorWithBody implements Controllable, Pocketed {
|
||||
*/
|
||||
public Player() throws SlickException {
|
||||
super();
|
||||
referenceID = Game.PLAYER_REF_ID;
|
||||
referenceID = PLAYER_REF_ID;
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.Terrarum.UserInterface.ConsoleWindow;
|
||||
|
||||
/**
|
||||
@@ -9,12 +10,12 @@ import com.Torvald.Terrarum.UserInterface.ConsoleWindow;
|
||||
class Echo implements ConsoleCommand {
|
||||
@Override
|
||||
public void execute(String[] args) {
|
||||
((ConsoleWindow) Game.consoleHandler.getUI())
|
||||
((ConsoleWindow) Terrarum.game.consoleHandler.getUI())
|
||||
.sendMessage(args.toString());
|
||||
}
|
||||
|
||||
public void execute(String single_line) {
|
||||
((ConsoleWindow) Game.consoleHandler.getUI())
|
||||
((ConsoleWindow) Terrarum.game.consoleHandler.getUI())
|
||||
.sendMessage(single_line);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,9 +58,9 @@ public class ExportMap implements ConsoleCommand {
|
||||
if (args.length == 2) {
|
||||
buildColorTable();
|
||||
|
||||
mapData = new byte[Game.map.width * Game.map.height * 3];
|
||||
mapData = new byte[Terrarum.game.map.width * Terrarum.game.map.height * 3];
|
||||
|
||||
for (byte tile : Game.map.getLayerTerrain()) {
|
||||
for (byte tile : Terrarum.game.map.getLayerTerrain()) {
|
||||
byte[] colArray = colorTable.getOrDefault(tile, new Col12(0xFFF))
|
||||
.toByteArray();
|
||||
|
||||
@@ -82,9 +82,9 @@ public class ExportMap implements ConsoleCommand {
|
||||
DataBuffer buffer = new DataBufferByte(mapData, mapData.length);
|
||||
WritableRaster raster = Raster.createInterleavedRaster(
|
||||
buffer
|
||||
, Game.map.width
|
||||
, Game.map.height
|
||||
, 3 * Game.map.width
|
||||
, Terrarum.game.map.width
|
||||
, Terrarum.game.map.height
|
||||
, 3 * Terrarum.game.map.width
|
||||
, 3
|
||||
, bandOffsets
|
||||
, null);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.ActorValue;
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
@@ -16,7 +17,7 @@ public class GetAV implements ConsoleCommand {
|
||||
|
||||
if (args.length == 1) {
|
||||
// print all actorvalue of player
|
||||
ActorValue av = Game.getPlayer().getActorValue();
|
||||
ActorValue av = Terrarum.game.getPlayer().getActorValue();
|
||||
Set keyset = av.getKeySet();
|
||||
|
||||
keyset.forEach(
|
||||
@@ -29,7 +30,7 @@ public class GetAV implements ConsoleCommand {
|
||||
}
|
||||
else if (args.length == 2) {
|
||||
echo.execute("player." + args[1] + ": "
|
||||
+ Game.getPlayer().getActorValue().get(args[1])
|
||||
+ Terrarum.game.getPlayer().getActorValue().get(args[1])
|
||||
);
|
||||
}
|
||||
else if (args.length == 3) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-15.
|
||||
@@ -33,7 +34,7 @@ class SetAV implements ConsoleCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Game.getPlayer().getActorValue().set(args[1], val);
|
||||
Terrarum.game.getPlayer().getActorValue().set(args[1], val);
|
||||
echo.execute("Set " + args[1] + " to " + val);
|
||||
}
|
||||
else if (args.length == 4) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.LangPack.Lang;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.Terrarum.UserInterface.Bulletin;
|
||||
|
||||
/**
|
||||
@@ -29,6 +30,6 @@ public class SetBulletin implements ConsoleCommand {
|
||||
* @param message real message
|
||||
*/
|
||||
public void send(String[] message) {
|
||||
((Bulletin) (Game.bulletin.getUI())).sendBulletin(message);
|
||||
((Bulletin) (Terrarum.game.bulletin.getUI())).sendBulletin(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapDrawer;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-24.
|
||||
@@ -25,7 +26,7 @@ public class TeleportPlayer implements ConsoleCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Game.getPlayer().setPosition(x, y);
|
||||
Terrarum.game.getPlayer().setPosition(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-19.
|
||||
@@ -8,9 +9,9 @@ import com.Torvald.Terrarum.Game;
|
||||
public class ToggleNoClip implements ConsoleCommand {
|
||||
@Override
|
||||
public void execute(String[] args) {
|
||||
boolean status = Game.getPlayer().isNoClip();
|
||||
boolean status = Terrarum.game.getPlayer().isNoClip();
|
||||
|
||||
Game.getPlayer().setNoClip(!status);
|
||||
Terrarum.game.getPlayer().setNoClip(!status);
|
||||
new Echo().execute("Set no-clip status to " + String.valueOf(!status));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-25.
|
||||
@@ -19,14 +20,14 @@ public class Zoom implements ConsoleCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (zoom < Game.ZOOM_MIN) {
|
||||
zoom = Game.ZOOM_MIN;
|
||||
if (zoom < Terrarum.game.ZOOM_MIN) {
|
||||
zoom = Terrarum.game.ZOOM_MIN;
|
||||
}
|
||||
else if (zoom > Game.ZOOM_MAX) {
|
||||
zoom = Game.ZOOM_MAX;
|
||||
else if (zoom > Terrarum.game.ZOOM_MAX) {
|
||||
zoom = Terrarum.game.ZOOM_MAX;
|
||||
}
|
||||
|
||||
Game.screenZoom = zoom;
|
||||
Terrarum.game.screenZoom = zoom;
|
||||
|
||||
System.gc();
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.Torvald.Terrarum;
|
||||
|
||||
import com.Torvald.ImageFont.GameFontWhite;
|
||||
import com.Torvald.Rand.HighQualityRandom;
|
||||
import com.Torvald.Terrarum.Actors.*;
|
||||
import com.Torvald.Terrarum.ConsoleCommand.CommandDict;
|
||||
import com.Torvald.Terrarum.GameControl.GameController;
|
||||
import com.Torvald.Terrarum.GameControl.KeyMap;
|
||||
import com.Torvald.Terrarum.GameControl.KeyToggler;
|
||||
import com.Torvald.Terrarum.GameMap.GameMap;
|
||||
import com.Torvald.Terrarum.MapDrawer.LightmapRenderer;
|
||||
@@ -18,45 +20,61 @@ import org.newdawn.slick.*;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.fills.GradientFill;
|
||||
import org.newdawn.slick.geom.Rectangle;
|
||||
import org.newdawn.slick.state.BasicGameState;
|
||||
import org.newdawn.slick.state.StateBasedGame;
|
||||
import shader.Shader;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-30.
|
||||
*/
|
||||
public class Game {
|
||||
public class Game extends BasicGameState {
|
||||
|
||||
static int game_mode = 0;
|
||||
public static final int TARGET_FPS = 50;
|
||||
/**
|
||||
* To be used with render, to achieve smooth frame drawing
|
||||
*
|
||||
* TARGET_INTERNAL_FPS > TARGET_FPS for smooth frame drawing
|
||||
*/
|
||||
public static final int TARGET_INTERNAL_FPS = 100;
|
||||
public static long memInUse;
|
||||
public static long totalVMMem;
|
||||
int game_mode = 0;
|
||||
|
||||
public static GameConfig gameConfig;
|
||||
public GameConfig gameConfig;
|
||||
|
||||
public static GameMap map;
|
||||
public GameMap map;
|
||||
|
||||
public static LinkedList<Actor> actorContainer = new LinkedList<>();
|
||||
public static LinkedList<UIHandler> uiContainer = new LinkedList<>();
|
||||
public LinkedList<Actor> actorContainer = new LinkedList<>();
|
||||
public LinkedList<UIHandler> uiContainer = new LinkedList<>();
|
||||
|
||||
public static UIHandler consoleHandler;
|
||||
public static UIHandler debugWindow;
|
||||
public static UIHandler bulletin;
|
||||
public UIHandler consoleHandler;
|
||||
public UIHandler debugWindow;
|
||||
public UIHandler bulletin;
|
||||
|
||||
@NotNull
|
||||
static Player player;
|
||||
Player player;
|
||||
|
||||
public static final long PLAYER_REF_ID = 0x51621D;
|
||||
private Image GRADIENT_IMAGE;
|
||||
private Rectangle skyBox;
|
||||
|
||||
private static Image GRADIENT_IMAGE;
|
||||
private static Rectangle skyBox;
|
||||
public float screenZoom = 1.0f;
|
||||
public final float ZOOM_MAX = 2.0f;
|
||||
public final float ZOOM_MIN = 0.25f;
|
||||
|
||||
public static float screenZoom = 1.0f;
|
||||
public static final float ZOOM_MAX = 2.0f;
|
||||
public static final float ZOOM_MIN = 0.25f;
|
||||
|
||||
private static Shader shader12BitCol;
|
||||
private static Shader shaderBlurH;
|
||||
private static Shader shaderBlurV;
|
||||
private Shader shader12BitCol;
|
||||
private Shader shaderBlurH;
|
||||
private Shader shaderBlurV;
|
||||
|
||||
public Game() throws SlickException {
|
||||
new GameController();
|
||||
KeyMap.build();
|
||||
GameController.setKeyMap(new KeyMap());
|
||||
|
||||
|
||||
|
||||
gameConfig = new GameConfig();
|
||||
gameConfig.addKey("smoothlighting", true);
|
||||
|
||||
@@ -113,11 +131,19 @@ public class Game {
|
||||
uiContainer.add(msgtest);
|
||||
}
|
||||
|
||||
public static Player getPlayer() {
|
||||
@Override
|
||||
public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws
|
||||
SlickException {
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public static void update(GameContainer gc, int delta_t) {
|
||||
@Override
|
||||
public void update(GameContainer gc, StateBasedGame sbg, int delta_t) {
|
||||
setAppTitle();
|
||||
|
||||
MapDrawer.update(gc, delta_t);
|
||||
|
||||
GameController.processInput(gc.getInput());
|
||||
@@ -143,7 +169,23 @@ public class Game {
|
||||
TileStat.update();
|
||||
}
|
||||
|
||||
public static void render(GameContainer gc, Graphics g) {
|
||||
private void setAppTitle() {
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
memInUse = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() >> 20;
|
||||
totalVMMem = runtime.maxMemory() >> 20;
|
||||
|
||||
Terrarum.appgc.setTitle(
|
||||
"Simple Slick Game — FPS: "
|
||||
+ Terrarum.appgc.getFPS() + " ("
|
||||
+ String.valueOf(TARGET_INTERNAL_FPS)
|
||||
+ ") — "
|
||||
+ String.valueOf(memInUse) + "M / "
|
||||
+ String.valueOf(totalVMMem) + "M"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) {
|
||||
// shader12BitCol.setUniformIntVariable("pixelSize", 1);
|
||||
// shader12BitCol.startShader();
|
||||
// shaderBlurH.startShader();
|
||||
@@ -191,7 +233,7 @@ public class Game {
|
||||
//bulletin.render(gc, g);
|
||||
}
|
||||
|
||||
private static Color[] getGradientColour(int timeSec) {
|
||||
private Color[] getGradientColour(int timeSec) {
|
||||
Color[] colourTable = new Color[2];
|
||||
|
||||
int gradMapWidth = GRADIENT_IMAGE.getWidth();
|
||||
@@ -204,7 +246,48 @@ public class Game {
|
||||
return colourTable;
|
||||
}
|
||||
|
||||
private static void drawSkybox(Graphics g) {
|
||||
public void keyPressed(int key, char c) {
|
||||
GameController.keyPressed(key, c);
|
||||
}
|
||||
|
||||
public void keyReleased(int key, char c) {
|
||||
GameController.keyReleased(key, c);
|
||||
}
|
||||
|
||||
public void mouseMoved(int oldx, int oldy, int newx, int newy) {
|
||||
GameController.mouseMoved(oldx, oldy, newx, newy);
|
||||
}
|
||||
|
||||
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
|
||||
GameController.mouseDragged(oldx, oldy, newx, newy);
|
||||
}
|
||||
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
GameController.mousePressed(button, x, y);
|
||||
}
|
||||
|
||||
public void mouseReleased(int button, int x, int y) {
|
||||
GameController.mouseReleased(button, x, y);
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(int change) {
|
||||
GameController.mouseWheelMoved(change);
|
||||
}
|
||||
|
||||
public void controllerButtonPressed(int controller, int button) {
|
||||
GameController.controllerButtonPressed(controller, button);
|
||||
}
|
||||
|
||||
public void controllerButtonReleased(int controller, int button) {
|
||||
GameController.controllerButtonReleased(controller, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID() {
|
||||
return Terrarum.SCENE_ID_GAME;
|
||||
}
|
||||
|
||||
private void drawSkybox(Graphics g) {
|
||||
Color[] colourTable = getGradientColour(WorldTime.elapsedSeconds());
|
||||
GradientFill skyColourFill = new GradientFill(0, 0, colourTable[0], 0, Terrarum.HEIGHT, colourTable[1]);
|
||||
g.fill(skyBox, skyColourFill);
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.Torvald.Terrarum.GameControl;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.Controllable;
|
||||
import com.Torvald.Terrarum.Actors.Player;
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.Torvald.Terrarum.UserInterface.UIHandler;
|
||||
import org.newdawn.slick.Input;
|
||||
|
||||
@@ -13,11 +13,8 @@ public class GameController {
|
||||
|
||||
private static KeyMap keyMap;
|
||||
|
||||
private static Player player;
|
||||
private static Controllable playerVehicle;
|
||||
|
||||
public GameController() {
|
||||
player = Game.getPlayer();
|
||||
|
||||
}
|
||||
|
||||
public static void setKeyMap(KeyMap map) {
|
||||
@@ -25,41 +22,41 @@ public class GameController {
|
||||
}
|
||||
|
||||
public static void processInput(Input input) {
|
||||
if (!Game.consoleHandler.isTakingControl()) {
|
||||
if (playerVehicle != null) {
|
||||
playerVehicle.processInput(input);
|
||||
if (!Terrarum.game.consoleHandler.isTakingControl()) {
|
||||
if (Terrarum.game.getPlayer().vehicleRiding != null) {
|
||||
Terrarum.game.getPlayer().vehicleRiding.processInput(input);
|
||||
}
|
||||
|
||||
player.processInput(input);
|
||||
Terrarum.game.getPlayer().processInput(input);
|
||||
|
||||
for (UIHandler ui : Game.uiContainer) {
|
||||
for (UIHandler ui : Terrarum.game.uiContainer) {
|
||||
ui.processInput(input);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Game.consoleHandler.processInput(input);
|
||||
Terrarum.game.consoleHandler.processInput(input);
|
||||
}
|
||||
}
|
||||
|
||||
public static void keyPressed(int key, char c) {
|
||||
if (keyPressedByCode(key, EnumKeyFunc.UI_CONSOLE)) {
|
||||
Game.consoleHandler.toggleOpening();
|
||||
Terrarum.game.consoleHandler.toggleOpening();
|
||||
}
|
||||
else if (keyPressedByCode(key, EnumKeyFunc.UI_BASIC_INFO)) {
|
||||
Game.debugWindow.toggleOpening();
|
||||
Terrarum.game.debugWindow.toggleOpening();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!Game.consoleHandler.isTakingControl()) {
|
||||
if (playerVehicle != null) {
|
||||
playerVehicle.keyPressed(key, c);
|
||||
if (!Terrarum.game.consoleHandler.isTakingControl()) {
|
||||
if (Terrarum.game.getPlayer().vehicleRiding != null) {
|
||||
Terrarum.game.getPlayer().vehicleRiding.keyPressed(key, c);
|
||||
}
|
||||
|
||||
player.keyPressed(key, c);
|
||||
Terrarum.game.getPlayer().keyPressed(key, c);
|
||||
}
|
||||
else {
|
||||
Game.consoleHandler.keyPressed(key, c);
|
||||
Terrarum.game.consoleHandler.keyPressed(key, c);
|
||||
}
|
||||
|
||||
//System.out.println(String.valueOf(key) + ", " + String.valueOf(c));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.Torvald.Terrarum.MapDrawer;
|
||||
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import com.jme3.math.FastMath;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.Graphics;
|
||||
@@ -15,7 +16,8 @@ public class LightmapRenderer {
|
||||
/**
|
||||
* 8-Bit RGB values
|
||||
*/
|
||||
private static int[][] staticLightMap = new int[Game.map.height][Game.map.width];
|
||||
private static int[][] staticLightMap;
|
||||
private static boolean lightMapInitialised = false;
|
||||
|
||||
/**
|
||||
* For entities that emits light (e.g. Player with shine potion)
|
||||
@@ -55,6 +57,16 @@ public class LightmapRenderer {
|
||||
}
|
||||
|
||||
public static void renderLightMap() {
|
||||
if (staticLightMap == null) {
|
||||
staticLightMap = new int[Terrarum.game.map.height][Terrarum.game.map.width];
|
||||
|
||||
if (lightMapInitialised) {
|
||||
throw new RuntimeException("Attempting to re-initialise 'staticLightMap'");
|
||||
}
|
||||
|
||||
lightMapInitialised = true;
|
||||
}
|
||||
|
||||
|
||||
int for_y_start = div16(MapCamera.getCameraY());
|
||||
int for_x_start = div16(MapCamera.getCameraX());
|
||||
@@ -117,7 +129,7 @@ public class LightmapRenderer {
|
||||
for (int y = for_y_start; y < for_y_end; y++) {
|
||||
for (int x = for_x_start; x < for_x_end; x++) {
|
||||
// smooth
|
||||
if (Game.screenZoom >= 1 && ((boolean) Game.gameConfig.get("smoothlighting"))) {
|
||||
if (Terrarum.game.screenZoom >= 1 && ((boolean) Terrarum.game.gameConfig.get("smoothlighting"))) {
|
||||
int thisLightLevel = staticLightMap[y][x];
|
||||
if (y > 0 && x < for_x_end && thisLightLevel == 0 && staticLightMap[y - 1][x] == 0) {
|
||||
// coalesce zero intensity blocks to one
|
||||
@@ -131,10 +143,10 @@ public class LightmapRenderer {
|
||||
|
||||
g.setColor(new Color(0));
|
||||
g.fillRect(
|
||||
Math.round(x * TSIZE * Game.screenZoom)
|
||||
, Math.round(y * TSIZE * Game.screenZoom)
|
||||
, FastMath.ceil(TSIZE * Game.screenZoom) * zeroLevelCounter
|
||||
, FastMath.ceil(TSIZE * Game.screenZoom)
|
||||
Math.round(x * TSIZE * Terrarum.game.screenZoom)
|
||||
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
|
||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom) * zeroLevelCounter
|
||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
|
||||
);
|
||||
|
||||
x += (zeroLevelCounter - 1);
|
||||
@@ -149,19 +161,19 @@ public class LightmapRenderer {
|
||||
* d
|
||||
*/
|
||||
int a = (y == 0) ? thisLightLevel
|
||||
: (y == Game.map.height - 1) ? thisLightLevel
|
||||
: (y == Terrarum.game.map.height - 1) ? thisLightLevel
|
||||
: Math.max(staticLightMap[y][x]
|
||||
, staticLightMap[y - 1][x]);
|
||||
int d = (y == 0) ? thisLightLevel
|
||||
: (y == Game.map.height - 1) ? thisLightLevel
|
||||
: (y == Terrarum.game.map.height - 1) ? thisLightLevel
|
||||
: Math.max(staticLightMap[y][x]
|
||||
, staticLightMap[y + 1][x]);
|
||||
int b = (x == 0) ? thisLightLevel
|
||||
: (x == Game.map.width - 1) ? thisLightLevel
|
||||
: (x == Terrarum.game.map.width - 1) ? thisLightLevel
|
||||
: Math.max(staticLightMap[y][x]
|
||||
, staticLightMap[y][x - 1]);
|
||||
int c = (x == 0) ? thisLightLevel
|
||||
: (x == Game.map.width - 1) ? thisLightLevel
|
||||
: (x == Terrarum.game.map.width - 1) ? thisLightLevel
|
||||
: Math.max(staticLightMap[y][x]
|
||||
, staticLightMap[y][x + 1]);
|
||||
int[] colourMapItoL = new int[4];
|
||||
@@ -175,10 +187,10 @@ public class LightmapRenderer {
|
||||
g.setColor(new Color(colourMapItoL[iy * 2 + ix]));
|
||||
|
||||
g.fillRect(
|
||||
Math.round(x * TSIZE * Game.screenZoom) + (ix * TSIZE / 2 * Game.screenZoom)
|
||||
, Math.round(y * TSIZE * Game.screenZoom) + (iy * TSIZE / 2 * Game.screenZoom)
|
||||
, FastMath.ceil(TSIZE * Game.screenZoom / 2)
|
||||
, FastMath.ceil(TSIZE * Game.screenZoom / 2)
|
||||
Math.round(x * TSIZE * Terrarum.game.screenZoom) + (ix * TSIZE / 2 * Terrarum.game.screenZoom)
|
||||
, Math.round(y * TSIZE * Terrarum.game.screenZoom) + (iy * TSIZE / 2 * Terrarum.game.screenZoom)
|
||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom / 2)
|
||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom / 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -198,10 +210,10 @@ public class LightmapRenderer {
|
||||
|
||||
g.setColor(new Color(staticLightMap[y][x]));
|
||||
g.fillRect(
|
||||
Math.round(x * TSIZE * Game.screenZoom)
|
||||
, Math.round(y * TSIZE * Game.screenZoom)
|
||||
, FastMath.ceil(TSIZE * Game.screenZoom) * sameLevelCounter
|
||||
, FastMath.ceil(TSIZE * Game.screenZoom)
|
||||
Math.round(x * TSIZE * Terrarum.game.screenZoom)
|
||||
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
|
||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom) * sameLevelCounter
|
||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
|
||||
);
|
||||
|
||||
x += (sameLevelCounter - 1);
|
||||
@@ -213,8 +225,8 @@ public class LightmapRenderer {
|
||||
private static void calculateAndSet(int x, int y){
|
||||
if (!outOfBounds(x, y)){
|
||||
|
||||
byte[][] layerTerrain = Game.map.getTerrainArray();
|
||||
byte[][] layerWall = Game.map.getWallArray();
|
||||
byte[][] layerTerrain = Terrarum.game.map.getTerrainArray();
|
||||
byte[][] layerWall = Terrarum.game.map.getWallArray();
|
||||
int lightColor;
|
||||
|
||||
int thisTerrain = layerTerrain[y][x];
|
||||
@@ -387,7 +399,7 @@ public class LightmapRenderer {
|
||||
}
|
||||
|
||||
private static boolean outOfBounds(int x, int y){
|
||||
return ( x < 0 || y < 0 || x >= Game.map.width || y >= Game.map.height);
|
||||
return ( x < 0 || y < 0 || x >= Terrarum.game.map.width || y >= Terrarum.game.map.height);
|
||||
}
|
||||
|
||||
private static boolean outOfMapBounds(int x, int y){
|
||||
@@ -421,8 +433,8 @@ public class LightmapRenderer {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (x > Game.map.width) {
|
||||
return Game.map.width;
|
||||
else if (x > Terrarum.game.map.width) {
|
||||
return Terrarum.game.map.width;
|
||||
}
|
||||
else {
|
||||
return x;
|
||||
@@ -433,8 +445,8 @@ public class LightmapRenderer {
|
||||
if (x < 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (x > Game.map.height) {
|
||||
return Game.map.height;
|
||||
else if (x > Terrarum.game.map.height) {
|
||||
return Terrarum.game.map.height;
|
||||
}
|
||||
else {
|
||||
return x;
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.Arrays;
|
||||
public class MapCamera {
|
||||
|
||||
private static GameMap map;
|
||||
private static Player player;
|
||||
|
||||
private static int cameraX = 0;
|
||||
private static int cameraY = 0;
|
||||
@@ -94,7 +93,6 @@ public class MapCamera {
|
||||
*/
|
||||
public MapCamera(GameMap map, int tileSize) throws SlickException {
|
||||
this.map = map;
|
||||
player = Game.getPlayer();
|
||||
|
||||
tilesWall = new SpriteSheet("./res/graphics/terrain/wall.png"
|
||||
, TSIZE
|
||||
@@ -118,8 +116,10 @@ public class MapCamera {
|
||||
}
|
||||
|
||||
public static void update(GameContainer gc, int delta_t) {
|
||||
renderWidth = FastMath.ceil(Terrarum.WIDTH / Game.screenZoom);
|
||||
renderHeight = FastMath.ceil(Terrarum.HEIGHT / Game.screenZoom);
|
||||
Player player = Terrarum.game.getPlayer();
|
||||
|
||||
renderWidth = FastMath.ceil(Terrarum.WIDTH / Terrarum.game.screenZoom);
|
||||
renderHeight = FastMath.ceil(Terrarum.HEIGHT / Terrarum.game.screenZoom);
|
||||
|
||||
// position - (WH / 2)
|
||||
cameraX = clamp(
|
||||
@@ -259,7 +259,7 @@ public class MapCamera {
|
||||
}
|
||||
|
||||
private static void drawTile(int mode, int tilewisePosX, int tilewisePosY, int sheetX, int sheetY) {
|
||||
if (Game.screenZoom == 1) {
|
||||
if (Terrarum.game.screenZoom == 1) {
|
||||
tilesetBook[mode].renderInUse(
|
||||
FastMath.floor(tilewisePosX * TSIZE)
|
||||
, FastMath.floor(tilewisePosY * TSIZE)
|
||||
@@ -272,10 +272,10 @@ public class MapCamera {
|
||||
sheetX
|
||||
, sheetY
|
||||
).drawEmbedded(
|
||||
Math.round(tilewisePosX * TSIZE * Game.screenZoom)
|
||||
, Math.round(tilewisePosY * TSIZE * Game.screenZoom)
|
||||
, FastMath.ceil(TSIZE * Game.screenZoom)
|
||||
, FastMath.ceil(TSIZE * Game.screenZoom)
|
||||
Math.round(tilewisePosX * TSIZE * Terrarum.game.screenZoom)
|
||||
, Math.round(tilewisePosY * TSIZE * Terrarum.game.screenZoom)
|
||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
|
||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,6 @@ public class MapDrawer {
|
||||
|
||||
new MapCamera(map, TILE_SIZE);
|
||||
|
||||
Rectangle envOverlay = new Rectangle(
|
||||
MapCamera.getCameraX() * Game.screenZoom
|
||||
, MapCamera.getCameraY() * Game.screenZoom
|
||||
, Terrarum.WIDTH
|
||||
, Terrarum.HEIGHT
|
||||
);
|
||||
|
||||
System.gc();
|
||||
}
|
||||
|
||||
@@ -46,10 +39,10 @@ public class MapDrawer {
|
||||
}
|
||||
|
||||
public static void drawEnvOverlay(Graphics g) {
|
||||
envOverlay.setX(MapCamera.getCameraX() * Game.screenZoom);
|
||||
envOverlay.setY(MapCamera.getCameraY() * Game.screenZoom);
|
||||
envOverlay.setSize(Terrarum.WIDTH * Game.screenZoom
|
||||
, Terrarum.HEIGHT * Game.screenZoom
|
||||
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
|
||||
);
|
||||
|
||||
// Color[] colourTable = getGradientColour(WorldTime.elapsedSeconds());
|
||||
|
||||
@@ -6,32 +6,22 @@ import java.lang.management.ManagementFactory;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.Torvald.ImageFont.GameFontBase;
|
||||
import com.Torvald.ImageFont.GameFontBlack;
|
||||
import com.Torvald.ImageFont.GameFontWhite;
|
||||
import com.Torvald.Terrarum.Actors.PlayerBuildFactory;
|
||||
import com.Torvald.Terrarum.GameControl.GameController;
|
||||
import com.Torvald.Terrarum.GameControl.KeyMap;
|
||||
import com.Torvald.Terrarum.LangPack.Lang;
|
||||
import org.newdawn.slick.*;
|
||||
import org.newdawn.slick.state.StateBasedGame;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-30.
|
||||
*/
|
||||
public class Terrarum extends BasicGame {
|
||||
public class Terrarum extends StateBasedGame {
|
||||
|
||||
public static AppGameContainer appgc;
|
||||
public static final int WIDTH = 960;
|
||||
public static final int HEIGHT = 720;
|
||||
private static Game game;
|
||||
public static final int TARGET_FPS = 50;
|
||||
|
||||
/**
|
||||
* To be used with render, to achieve smooth frame drawing
|
||||
*
|
||||
* TARGET_INTERNAL_FPS > TARGET_FPS for smooth frame drawing
|
||||
*/
|
||||
public static final int TARGET_INTERNAL_FPS = 100;
|
||||
public static Game game;
|
||||
|
||||
public static String OSName;
|
||||
public static String OSVersion;
|
||||
@@ -43,15 +33,12 @@ public class Terrarum extends BasicGame {
|
||||
|
||||
public static Font gameFontWhite;
|
||||
|
||||
public static long memInUse;
|
||||
public static long totalVMMem;
|
||||
public static final int SCENE_ID_HOME = 1;
|
||||
public static final int SCENE_ID_GAME = 3;
|
||||
|
||||
public Terrarum(String gamename) {
|
||||
public Terrarum(String gamename) throws SlickException {
|
||||
super(gamename);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(GameContainer gc) throws SlickException {
|
||||
getDefaultDirectory();
|
||||
createDirs();
|
||||
try {
|
||||
@@ -61,75 +48,14 @@ public class Terrarum extends BasicGame {
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
game = new Game();
|
||||
|
||||
new GameController();
|
||||
KeyMap.build();
|
||||
GameController.setKeyMap(new KeyMap());
|
||||
|
||||
@Override
|
||||
public void initStatesList(GameContainer gameContainer) throws SlickException {
|
||||
gameFontWhite = new GameFontWhite();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(GameContainer gc, int delta_t) throws SlickException{
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
memInUse = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() >> 20;
|
||||
totalVMMem = runtime.maxMemory() >> 20;
|
||||
|
||||
appgc.setTitle(
|
||||
"Simple Slick Game — FPS: "
|
||||
+ appgc.getFPS() + " ("
|
||||
+ String.valueOf(TARGET_INTERNAL_FPS)
|
||||
+ ") — "
|
||||
+ String.valueOf(memInUse) + "M / "
|
||||
+ String.valueOf(totalVMMem) + "M"
|
||||
);
|
||||
Game.update(gc, delta_t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GameContainer gc, Graphics g) throws SlickException
|
||||
{
|
||||
Game.render(gc, g);
|
||||
}
|
||||
|
||||
public void keyPressed(int key, char c) {
|
||||
GameController.keyPressed(key, c);
|
||||
}
|
||||
|
||||
public void keyReleased(int key, char c) {
|
||||
GameController.keyReleased(key, c);
|
||||
}
|
||||
|
||||
public void mouseMoved(int oldx, int oldy, int newx, int newy) {
|
||||
GameController.mouseMoved(oldx, oldy, newx, newy);
|
||||
}
|
||||
|
||||
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
|
||||
GameController.mouseDragged(oldx, oldy, newx, newy);
|
||||
}
|
||||
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
GameController.mousePressed(button, x, y);
|
||||
}
|
||||
|
||||
public void mouseReleased(int button, int x, int y) {
|
||||
GameController.mouseReleased(button, x, y);
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(int change) {
|
||||
GameController.mouseWheelMoved(change);
|
||||
}
|
||||
|
||||
public void controllerButtonPressed(int controller, int button) {
|
||||
GameController.controllerButtonPressed(controller, button);
|
||||
}
|
||||
|
||||
public void controllerButtonReleased(int controller, int button) {
|
||||
GameController.controllerButtonReleased(controller, button);
|
||||
game = new Game();
|
||||
addState(game);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
@@ -138,11 +64,11 @@ public class Terrarum extends BasicGame {
|
||||
{
|
||||
appgc = new AppGameContainer(new Terrarum("Terrarum"));
|
||||
appgc.setDisplayMode(WIDTH, HEIGHT, false);
|
||||
appgc.setTargetFrameRate(TARGET_INTERNAL_FPS);
|
||||
appgc.setTargetFrameRate(Game.TARGET_INTERNAL_FPS);
|
||||
appgc.setVSync(true);
|
||||
appgc.setShowFPS(false);
|
||||
appgc.setUpdateOnlyWhenVisible(false);
|
||||
appgc.setMaximumLogicUpdateInterval(1000 / TARGET_INTERNAL_FPS);
|
||||
appgc.setMaximumLogicUpdateInterval(1000 / Game.TARGET_INTERNAL_FPS);
|
||||
appgc.start();
|
||||
}
|
||||
catch (SlickException ex)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.Torvald.Terrarum.TileStat;
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.GameMap.MapLayer;
|
||||
import com.Torvald.Terrarum.MapDrawer.MapCamera;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -23,8 +24,8 @@ public class TileStat {
|
||||
|
||||
for (int y = for_y_start; y < for_y_end; y++) {
|
||||
for (int x = for_x_start; x < for_x_end; x++) {
|
||||
int tileWall = Game.map.getTileFromWall(x, y);
|
||||
int tileTerrain = Game.map.getTileFromTerrain(x, y);
|
||||
int tileWall = Terrarum.game.map.getTileFromWall(x, y);
|
||||
int tileTerrain = Terrarum.game.map.getTileFromTerrain(x, y);
|
||||
tilestat[tileWall] += 1;
|
||||
tilestat[tileTerrain] += 1;
|
||||
}
|
||||
|
||||
@@ -31,18 +31,21 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
public BasicDebugInfoWindow() {
|
||||
width = Terrarum.WIDTH;
|
||||
height = Terrarum.HEIGHT;
|
||||
|
||||
playerDbg = new PlayerDebugger(Game.getPlayer());
|
||||
}
|
||||
|
||||
@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() / Game.screenZoom)
|
||||
int mouseTileX = (int) ((MapCamera.getCameraX() + gc.getInput().getMouseX() / Terrarum.game.screenZoom)
|
||||
/ MapDrawer.TILE_SIZE);
|
||||
int mouseTileY = (int) ((MapCamera.getCameraY() + gc.getInput().getMouseY() / Game.screenZoom)
|
||||
int mouseTileY = (int) ((MapCamera.getCameraY() + gc.getInput().getMouseY() / Terrarum.game.screenZoom)
|
||||
/ MapDrawer.TILE_SIZE);
|
||||
|
||||
g.setColor(Color.white);
|
||||
@@ -89,7 +92,7 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
|
||||
String tileNo;
|
||||
try {
|
||||
tileNo = String.valueOf(Game.map.getTileFromTerrain(mouseTileX, mouseTileY));
|
||||
tileNo = String.valueOf(Terrarum.game.map.getTileFromTerrain(mouseTileX, mouseTileY));
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
tileNo = "out of bounds";
|
||||
@@ -97,8 +100,8 @@ public class BasicDebugInfoWindow implements UICanvas {
|
||||
printLine(g, 10, "tile : " + tileNo);
|
||||
|
||||
// Memory allocation
|
||||
long memInUse = Terrarum.memInUse;
|
||||
long totalVMMem = Terrarum.totalVMMem;
|
||||
long memInUse = Terrarum.game.memInUse;
|
||||
long totalVMMem = Terrarum.game.totalVMMem;
|
||||
|
||||
g.setColor(new Color(0xFF7F00));
|
||||
g.drawString(
|
||||
|
||||
@@ -65,8 +65,8 @@ public class UIHandler {
|
||||
gameGraphicInstance.drawImage(UIDrawnCanvas
|
||||
// compensate for screenZoom AND camera translation
|
||||
// (see Game.render -> g.translate())
|
||||
, posX + MapCamera.getCameraX() * Game.screenZoom
|
||||
, posY + MapCamera.getCameraY() * Game.screenZoom
|
||||
, posX + MapCamera.getCameraX() * Terrarum.game.screenZoom
|
||||
, posY + MapCamera.getCameraY() * Terrarum.game.screenZoom
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package com.Torvald.spriteAnimation;
|
||||
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Image;
|
||||
import org.newdawn.slick.SlickException;
|
||||
@@ -130,7 +131,7 @@ public class SpriteAnimation {
|
||||
* @param scale
|
||||
*/
|
||||
public void render(Graphics g, float posX, float posY, float scale){
|
||||
scale *= Game.screenZoom;
|
||||
scale *= Terrarum.game.screenZoom;
|
||||
|
||||
// Null checking
|
||||
if (currentImage == null) {
|
||||
@@ -148,8 +149,8 @@ public class SpriteAnimation {
|
||||
|
||||
flippedImage.startUse();
|
||||
flippedImage.drawEmbedded(
|
||||
Math.round(posX * Game.screenZoom)
|
||||
, Math.round(posY * Game.screenZoom)
|
||||
Math.round(posX * Terrarum.game.screenZoom)
|
||||
, Math.round(posY * Terrarum.game.screenZoom)
|
||||
, width * scale
|
||||
, height * scale
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user