diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/ActorWithBody.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/ActorWithBody.class index b94cc5967..bcf11162a 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/ActorWithBody.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/ActorWithBody.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Player.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Player.class index 04914512e..ab70e49e3 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Player.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Actors/Player.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/CodexEdictis.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/CodexEdictis.class index 6ed48dfa8..9f081b38e 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/CodexEdictis.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/CodexEdictis.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/Echo.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/Echo.class index 26fbda6a3..7c8cb53b6 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/Echo.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/Echo.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/ExportMap.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/ExportMap.class index edd66b0b9..c51a4a7bf 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/ExportMap.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/ExportMap.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/GetAV.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/GetAV.class index b1e8089c2..ac5b9f356 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/GetAV.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/GetAV.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetAV.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetAV.class index e7a6b0d25..3ba991adb 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetAV.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetAV.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.class index b374bbaa8..3e4d1cf68 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.class index 7269cc9bb..a6df18f9f 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.class index 6eb0593d5..4c0489a9b 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/Zoom.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/Zoom.class index 504fba979..5acc8946e 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/Zoom.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/ConsoleCommand/Zoom.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Game.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Game.class index 3a3d32c09..ad1baeb0e 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Game.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Game.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/GameControl/GameController.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/GameControl/GameController.class index a20dfd5dc..71a3586ca 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/GameControl/GameController.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/GameControl/GameController.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapLantern.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapLantern.class index 22c868640..8a56c2844 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapLantern.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapLantern.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.class index d64fc48ae..e8d762e63 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapCamera.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapCamera.class index 06da9bfea..4f79b025b 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapCamera.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapCamera.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapDrawer.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapDrawer.class index 03a14ddec..82c3b6932 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapDrawer.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/MapDrawer/MapDrawer.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Terrarum.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Terrarum.class index edaa39f7c..89728a19c 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/Terrarum.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/Terrarum.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileStat/TileStat.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileStat/TileStat.class index 328f1bf1c..8cf40c920 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileStat/TileStat.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/TileStat/TileStat.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.class index 553aa7b1e..22d2674d2 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/Terrarum/UserInterface/UIHandler.class b/out/production/Terrarum_renewed/com/Torvald/Terrarum/UserInterface/UIHandler.class index c38e5f4bd..8384acd27 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/Terrarum/UserInterface/UIHandler.class and b/out/production/Terrarum_renewed/com/Torvald/Terrarum/UserInterface/UIHandler.class differ diff --git a/out/production/Terrarum_renewed/com/Torvald/spriteAnimation/SpriteAnimation.class b/out/production/Terrarum_renewed/com/Torvald/spriteAnimation/SpriteAnimation.class index 33095ef67..a6bc49f9c 100644 Binary files a/out/production/Terrarum_renewed/com/Torvald/spriteAnimation/SpriteAnimation.class and b/out/production/Terrarum_renewed/com/Torvald/spriteAnimation/SpriteAnimation.class differ diff --git a/res/graphics/terrain/grassplusplus.png b/res/graphics/terrain/grassplusplus.png index f8ec62495..14b8e1fde 100644 Binary files a/res/graphics/terrain/grassplusplus.png and b/res/graphics/terrain/grassplusplus.png differ diff --git a/res/graphics/terrain/terrainplusplus.png b/res/graphics/terrain/terrainplusplus.png index 1bc4ad56d..5023f0ccc 100644 Binary files a/res/graphics/terrain/terrainplusplus.png and b/res/graphics/terrain/terrainplusplus.png differ diff --git a/res/raw/CreatureHuman.json b/res/raw/CreatureHuman.json index ee06e0c89..447c2ac6e 100644 --- a/res/raw/CreatureHuman.json +++ b/res/raw/CreatureHuman.json @@ -1,6 +1,7 @@ { "racename" : "CONTEXT_RACE_HUMAN", "racenameplural" : "CONTEXT_RACE_HUMAN_PLURAL", + "ethnicgroup" : "human", "baseheight" : 40, "basemass" : 60.0, diff --git a/src/com/Torvald/Terrarum/Actors/ActorWithBody.java b/src/com/Torvald/Terrarum/Actors/ActorWithBody.java index e707d7242..72a2c95bd 100644 --- a/src/com/Torvald/Terrarum/Actors/ActorWithBody.java +++ b/src/com/Torvald/Terrarum/Actors/ActorWithBody.java @@ -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; diff --git a/src/com/Torvald/Terrarum/Actors/Player.java b/src/com/Torvald/Terrarum/Actors/Player.java index 3a5b104dc..5e0f7ce6e 100644 --- a/src/com/Torvald/Terrarum/Actors/Player.java +++ b/src/com/Torvald/Terrarum/Actors/Player.java @@ -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.).
* @@ -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); } diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Echo.java b/src/com/Torvald/Terrarum/ConsoleCommand/Echo.java index 9b323b9dc..e6b3341d8 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/Echo.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/Echo.java @@ -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); } diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/ExportMap.java b/src/com/Torvald/Terrarum/ConsoleCommand/ExportMap.java index 1e7f5e4eb..834639613 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/ExportMap.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/ExportMap.java @@ -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); diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java b/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java index 388ae85ba..01790014e 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/GetAV.java @@ -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) { diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java b/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java index 94aacbba2..f0f86141b 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/SetAV.java @@ -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) { diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.java b/src/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.java index 4e23f80a1..932044b9f 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/SetBulletin.java @@ -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); } } diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.java b/src/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.java index 54ed270ec..82b51e5ad 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/TeleportPlayer.java @@ -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); } } diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.java b/src/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.java index 49442f3a9..0fd72a919 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/ToggleNoClip.java @@ -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)); } diff --git a/src/com/Torvald/Terrarum/ConsoleCommand/Zoom.java b/src/com/Torvald/Terrarum/ConsoleCommand/Zoom.java index 5c12a89da..cec68b4c9 100644 --- a/src/com/Torvald/Terrarum/ConsoleCommand/Zoom.java +++ b/src/com/Torvald/Terrarum/ConsoleCommand/Zoom.java @@ -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(); diff --git a/src/com/Torvald/Terrarum/Game.java b/src/com/Torvald/Terrarum/Game.java index ccb9ba2a1..81dfe6053 100644 --- a/src/com/Torvald/Terrarum/Game.java +++ b/src/com/Torvald/Terrarum/Game.java @@ -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 actorContainer = new LinkedList<>(); - public static LinkedList uiContainer = new LinkedList<>(); + public LinkedList actorContainer = new LinkedList<>(); + public LinkedList 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); diff --git a/src/com/Torvald/Terrarum/GameControl/GameController.java b/src/com/Torvald/Terrarum/GameControl/GameController.java index e6df1e808..479121b41 100644 --- a/src/com/Torvald/Terrarum/GameControl/GameController.java +++ b/src/com/Torvald/Terrarum/GameControl/GameController.java @@ -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)); diff --git a/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.java b/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.java index 1ce34c933..e8a9eadc2 100644 --- a/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.java +++ b/src/com/Torvald/Terrarum/MapDrawer/LightmapRenderer.java @@ -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; diff --git a/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java b/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java index 909130a2f..b9e592e99 100644 --- a/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java +++ b/src/com/Torvald/Terrarum/MapDrawer/MapCamera.java @@ -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) ); } } diff --git a/src/com/Torvald/Terrarum/MapDrawer/MapDrawer.java b/src/com/Torvald/Terrarum/MapDrawer/MapDrawer.java index b15d683cd..0989e120f 100644 --- a/src/com/Torvald/Terrarum/MapDrawer/MapDrawer.java +++ b/src/com/Torvald/Terrarum/MapDrawer/MapDrawer.java @@ -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()); diff --git a/src/com/Torvald/Terrarum/Terrarum.java b/src/com/Torvald/Terrarum/Terrarum.java index fadaad3d3..769f6dfbc 100644 --- a/src/com/Torvald/Terrarum/Terrarum.java +++ b/src/com/Torvald/Terrarum/Terrarum.java @@ -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) diff --git a/src/com/Torvald/Terrarum/TileStat/TileStat.java b/src/com/Torvald/Terrarum/TileStat/TileStat.java index be15ac2ac..9d21f45d3 100644 --- a/src/com/Torvald/Terrarum/TileStat/TileStat.java +++ b/src/com/Torvald/Terrarum/TileStat/TileStat.java @@ -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; } diff --git a/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.java b/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.java index 2a2230b96..3a616a03f 100644 --- a/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.java +++ b/src/com/Torvald/Terrarum/UserInterface/BasicDebugInfoWindow.java @@ -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( diff --git a/src/com/Torvald/Terrarum/UserInterface/UIHandler.java b/src/com/Torvald/Terrarum/UserInterface/UIHandler.java index 0a203c56a..16cbc9de1 100644 --- a/src/com/Torvald/Terrarum/UserInterface/UIHandler.java +++ b/src/com/Torvald/Terrarum/UserInterface/UIHandler.java @@ -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 ); } } diff --git a/src/com/Torvald/spriteAnimation/SpriteAnimation.java b/src/com/Torvald/spriteAnimation/SpriteAnimation.java index 4965111ab..9a9557734 100644 --- a/src/com/Torvald/spriteAnimation/SpriteAnimation.java +++ b/src/com/Torvald/spriteAnimation/SpriteAnimation.java @@ -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 );