diff options
author | Nao Pross <naopross@thearcway.org> | 2018-11-24 18:31:46 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-11-24 18:31:46 +0100 |
commit | d3e2168c3a449a96e5edc981c70e8d117abdfc15 (patch) | |
tree | f0dd383ec169ed9264e443680c092a80afe3fc53 | |
parent | Remove Swing dependency (diff) | |
download | Subconscious-java-d3e2168c3a449a96e5edc981c70e8d117abdfc15.tar.gz Subconscious-java-d3e2168c3a449a96e5edc981c70e8d117abdfc15.zip |
Add RenderingHints and minor performance improvements
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | src/subconscious/Actor.java | 2 | ||||
-rw-r--r-- | src/subconscious/Subconscious.java | 5 | ||||
-rw-r--r-- | src/subconscious/Tile.java | 1 | ||||
-rw-r--r-- | src/subconscious/graphics/Scene.java | 13 |
5 files changed, 21 insertions, 3 deletions
@@ -15,8 +15,7 @@ USE_JDB := 0 # java runtime configuration JAVA := java -JAVA_ARGS := -Dawt.useSystemAAFontSettings=on -cp ../lib/gson-2.6.2.jar:. \ - -Xmx2G +JAVA_ARGS := -cp ../lib/gson-2.6.2.jar:. -Xmx2G ifeq ($(USE_JDB),1) JAVA_ARGS += -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 endif diff --git a/src/subconscious/Actor.java b/src/subconscious/Actor.java index 6551dab..8280fe8 100644 --- a/src/subconscious/Actor.java +++ b/src/subconscious/Actor.java @@ -10,7 +10,7 @@ public class Actor { private int x; private int y; - public class SkillSet { + public static class SkillSet { public int agility = 0; // public int strenght; // public int defense; diff --git a/src/subconscious/Subconscious.java b/src/subconscious/Subconscious.java index bf57424..60b52e5 100644 --- a/src/subconscious/Subconscious.java +++ b/src/subconscious/Subconscious.java @@ -7,6 +7,11 @@ import java.lang.Thread; public class Subconscious { public static void main(String[] args) { + // antialias fonts + System.setProperty("awt.useSystemAAFontSettings","on"); + // use hw accelleration + System.setProperty("sun.java2d.opengl", "true"); + // for debugging Thread.currentThread().setName("Main"); diff --git a/src/subconscious/Tile.java b/src/subconscious/Tile.java index 79a8a83..703b196 100644 --- a/src/subconscious/Tile.java +++ b/src/subconscious/Tile.java @@ -3,6 +3,7 @@ package subconscious; import java.util.ArrayList; public class Tile { + // TODO: create an EnumSet for other modifiers public enum Type { CLEAR, GRASS, WATER, MOUNTAIN, NONE }; diff --git a/src/subconscious/graphics/Scene.java b/src/subconscious/graphics/Scene.java index 5188ab4..113a46f 100644 --- a/src/subconscious/graphics/Scene.java +++ b/src/subconscious/graphics/Scene.java @@ -6,12 +6,14 @@ import subconscious.graphics.widget.Widget; import subconscious.graphics.widget.Clickable; import java.util.ArrayList; +import java.util.Map; import java.awt.Canvas; import java.awt.Graphics2D; import java.awt.Dimension; import java.awt.BorderLayout; import java.awt.Panel; +import java.awt.RenderingHints; import java.awt.event.KeyListener; import java.awt.event.KeyEvent; @@ -45,6 +47,14 @@ public abstract class Scene extends Panel protected final long DESIRED_FPS = 60; protected final long DESIRED_DELTA_LOOP = (1000*1000*1000)/DESIRED_FPS; + protected final Map<RenderingHints.Key, ?> RENDERING_HINTS = Map.of( + RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON, + RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON, + RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED, + RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR, + // RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR, + RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED + ); protected ArrayList<Widget> widgets = new ArrayList<>(); @@ -95,6 +105,8 @@ public abstract class Scene extends Panel this(game, ""); } + /* */ + /* abstract methods */ // runs when the the scene thread starts protected abstract void build(); @@ -175,6 +187,7 @@ public abstract class Scene extends Panel do { do { Graphics2D g = (Graphics2D) this.buffer.getDrawGraphics(); + g.addRenderingHints(this.RENDERING_HINTS); this.render(g); this.renderWidgets(g); g.dispose(); |