Remade item and tile basic system.

Still not funcitonal but the shape is final. Sort of.
v5stable
Ondřej Hruška 11 years ago
parent ccbc95c74a
commit 65ad97994b
  1. 3
      src/mightypork/gamecore/audio/DeferredAudio.java
  2. 5
      src/mightypork/gamecore/audio/JointVolume.java
  3. 3
      src/mightypork/gamecore/audio/NullAudio.java
  4. 3
      src/mightypork/gamecore/audio/SoundBank.java
  5. 3
      src/mightypork/gamecore/audio/SoundSystem.java
  6. 5
      src/mightypork/gamecore/audio/Volume.java
  7. 3
      src/mightypork/gamecore/audio/players/BaseAudioPlayer.java
  8. 3
      src/mightypork/gamecore/audio/players/EffectPlayer.java
  9. 3
      src/mightypork/gamecore/audio/players/LoopPlayer.java
  10. 3
      src/mightypork/gamecore/control/AppAdapter.java
  11. 3
      src/mightypork/gamecore/control/AppModule.java
  12. 3
      src/mightypork/gamecore/control/AppSubModule.java
  13. 3
      src/mightypork/gamecore/control/GameLoop.java
  14. 3
      src/mightypork/gamecore/control/SlickLogRedirector.java
  15. 3
      src/mightypork/gamecore/control/events/KeyEvent.java
  16. 3
      src/mightypork/gamecore/control/events/LayoutChangeEvent.java
  17. 3
      src/mightypork/gamecore/control/events/MainLoopTaskRequest.java
  18. 3
      src/mightypork/gamecore/control/events/MouseButtonEvent.java
  19. 3
      src/mightypork/gamecore/control/events/MouseMotionEvent.java
  20. 3
      src/mightypork/gamecore/control/events/ResourceLoadRequest.java
  21. 3
      src/mightypork/gamecore/control/events/ScreenRequestEvent.java
  22. 3
      src/mightypork/gamecore/control/events/UpdateEvent.java
  23. 3
      src/mightypork/gamecore/control/events/ViewportChangeEvent.java
  24. 6
      src/mightypork/gamecore/gui/components/LayoutComponent.java
  25. 3
      src/mightypork/gamecore/gui/components/VisualComponent.java
  26. 6
      src/mightypork/gamecore/gui/components/layout/ColumnHolder.java
  27. 6
      src/mightypork/gamecore/gui/components/layout/ConstraintLayout.java
  28. 6
      src/mightypork/gamecore/gui/components/layout/GridLayout.java
  29. 6
      src/mightypork/gamecore/gui/components/layout/HorizontalFixedFlowLayout.java
  30. 6
      src/mightypork/gamecore/gui/components/layout/RowHolder.java
  31. 6
      src/mightypork/gamecore/gui/components/layout/VerticalFixedFlowLayout.java
  32. 3
      src/mightypork/gamecore/gui/components/painters/ImagePainter.java
  33. 6
      src/mightypork/gamecore/gui/components/painters/QuadPainter.java
  34. 12
      src/mightypork/gamecore/gui/components/painters/TextPainter.java
  35. 3
      src/mightypork/gamecore/gui/screens/BaseScreen.java
  36. 3
      src/mightypork/gamecore/gui/screens/LayeredScreen.java
  37. 3
      src/mightypork/gamecore/gui/screens/Overlay.java
  38. 3
      src/mightypork/gamecore/gui/screens/ScreenLayer.java
  39. 3
      src/mightypork/gamecore/gui/screens/ScreenRegistry.java
  40. 3
      src/mightypork/gamecore/input/InputSystem.java
  41. 3
      src/mightypork/gamecore/input/KeyBinding.java
  42. 6
      src/mightypork/gamecore/input/KeyStroke.java
  43. 3
      src/mightypork/gamecore/loading/AsyncResourceLoader.java
  44. 3
      src/mightypork/gamecore/loading/DeferredResource.java
  45. 3
      src/mightypork/gamecore/render/DisplaySystem.java
  46. 3
      src/mightypork/gamecore/render/Screenshot.java
  47. 3
      src/mightypork/gamecore/render/fonts/FontBank.java
  48. 6
      src/mightypork/gamecore/render/fonts/FontRenderer.java
  49. 9
      src/mightypork/gamecore/render/fonts/impl/CachedFont.java
  50. 9
      src/mightypork/gamecore/render/fonts/impl/DeferredFont.java
  51. 3
      src/mightypork/gamecore/render/fonts/impl/DeferredFontNative.java
  52. 4
      src/mightypork/gamecore/render/textures/DeferredTexture.java
  53. 3
      src/mightypork/gamecore/render/textures/FilterMode.java
  54. 4
      src/mightypork/gamecore/render/textures/GLTexture.java
  55. 12
      src/mightypork/gamecore/render/textures/QuadGrid.java
  56. 4
      src/mightypork/gamecore/render/textures/TextureBank.java
  57. 9
      src/mightypork/gamecore/render/textures/TxQuad.java
  58. 5
      src/mightypork/gamecore/render/textures/TxSheet.java
  59. 3
      src/mightypork/gamecore/render/textures/WrapMode.java
  60. 12
      src/mightypork/rogue/App.java
  61. 6
      src/mightypork/rogue/MainLoop.java
  62. 4
      src/mightypork/rogue/Res.java
  63. 3
      src/mightypork/rogue/events/ActionRequest.java
  64. 3
      src/mightypork/rogue/screens/CrossfadeOverlay.java
  65. 3
      src/mightypork/rogue/screens/CrossfadeRequest.java
  66. 3
      src/mightypork/rogue/screens/FpsOverlay.java
  67. 3
      src/mightypork/rogue/screens/ingame/GameGui.java
  68. 3
      src/mightypork/rogue/screens/ingame/HeartBar.java
  69. 3
      src/mightypork/rogue/screens/ingame/NavItemSlot.java
  70. 3
      src/mightypork/rogue/screens/ingame/ScreenGame.java
  71. 3
      src/mightypork/rogue/screens/main_menu/MenuButton.java
  72. 3
      src/mightypork/rogue/screens/main_menu/MenuLayer.java
  73. 3
      src/mightypork/rogue/screens/main_menu/ScreenMainMenu.java
  74. 3
      src/mightypork/rogue/screens/test_bouncyboxes/BouncyBox.java
  75. 3
      src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java
  76. 3
      src/mightypork/rogue/screens/test_bouncyboxes/ScreenTestBouncy.java
  77. 3
      src/mightypork/rogue/screens/test_cat_sound/LayerColor.java
  78. 3
      src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java
  79. 3
      src/mightypork/rogue/screens/test_cat_sound/ScreenTestCat.java
  80. 3
      src/mightypork/rogue/screens/test_render/LayerTestGradient.java
  81. 3
      src/mightypork/rogue/screens/test_render/ScreenTestRender.java
  82. 130
      src/mightypork/rogue/world/Entity.java
  83. 75
      src/mightypork/rogue/world/EntityModel.java
  84. 42
      src/mightypork/rogue/world/WorldMap.java
  85. 89
      src/mightypork/rogue/world/item/Item.java
  86. 13
      src/mightypork/rogue/world/item/ItemData.java
  87. 49
      src/mightypork/rogue/world/item/ItemModel.java
  88. 18
      src/mightypork/rogue/world/item/Items.java
  89. 122
      src/mightypork/rogue/world/tile/Tile.java
  90. 54
      src/mightypork/rogue/world/tile/TileData.java
  91. 39
      src/mightypork/rogue/world/tile/TileItems.java
  92. 59
      src/mightypork/rogue/world/tile/TileModel.java
  93. 11
      src/mightypork/rogue/world/tile/TileRenderContext.java
  94. 30
      src/mightypork/rogue/world/tile/Tiles.java
  95. 15
      src/mightypork/rogue/world/tile/impl/SimpleFloor.java
  96. 71
      src/mightypork/rogue/world/tile/impl/SimpleTile.java
  97. 16
      src/mightypork/rogue/world/tile/impl/SimpleWall.java
  98. 18
      src/mightypork/rogue/world/tile/models/Floor.java
  99. 57
      src/mightypork/rogue/world/tile/models/NullTile.java
  100. 43
      src/mightypork/rogue/world/tile/models/SimpleTile.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -42,7 +42,8 @@ public class DeferredAudio extends DeferredResource {
* *
* @param resourceName resource to load when needed * @param resourceName resource to load when needed
*/ */
public DeferredAudio(String resourceName) { public DeferredAudio(String resourceName)
{
super(resourceName); super(resourceName);
} }

@ -20,7 +20,8 @@ public class JointVolume extends Volume {
* @param volumes individual volumes to join * @param volumes individual volumes to join
*/ */
@SafeVarargs @SafeVarargs
public JointVolume(Volume... volumes) { public JointVolume(Volume... volumes)
{
super(1D); super(1D);
this.volumes = volumes; this.volumes = volumes;
} }
@ -36,7 +37,7 @@ public class JointVolume extends Volume {
for (final Volume v : volumes) for (final Volume v : volumes)
d *= v.get(); d *= v.get();
return Calc.clampd(d, 0, 1); return Calc.clamp(d, 0, 1);
} }

@ -17,7 +17,8 @@ public class NullAudio extends DeferredAudio implements NullResource {
/** /**
* new null audio * new null audio
*/ */
public NullAudio() { public NullAudio()
{
super(null); super(null);
} }
} }

@ -29,7 +29,8 @@ public class SoundBank extends AppAdapter {
/** /**
* @param app app access * @param app app access
*/ */
public SoundBank(AppAccess app) { public SoundBank(AppAccess app)
{
super(app); super(app);
if (getSoundSystem() == null) throw new NullPointerException("SoundSystem cannot be null."); if (getSoundSystem() == null) throw new NullPointerException("SoundSystem cannot be null.");
} }

@ -77,7 +77,8 @@ public class SoundSystem extends RootBusNode implements Updateable {
/** /**
* @param app app access * @param app app access
*/ */
public SoundSystem(AppAccess app) { public SoundSystem(AppAccess app)
{
super(app); super(app);
if (!soundSystemInited) { if (!soundSystemInited) {

@ -15,7 +15,8 @@ public class Volume extends Mutable<Double> {
/** /**
* @param d initial value * @param d initial value
*/ */
public Volume(Double d) { public Volume(Double d)
{
super(d); super(d);
} }
@ -23,7 +24,7 @@ public class Volume extends Mutable<Double> {
@Override @Override
public void set(Double d) public void set(Double d)
{ {
super.set(Calc.clampd(d, 0, 1)); super.set(Calc.clamp(d, 0, 1));
} }
} }

@ -32,7 +32,8 @@ public abstract class BaseAudioPlayer implements Destroyable {
* @param baseGain base gain (volume multiplier) * @param baseGain base gain (volume multiplier)
* @param volume colume control * @param volume colume control
*/ */
public BaseAudioPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) { public BaseAudioPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume)
{
this.audio = track; this.audio = track;
this.baseGain = baseGain; this.baseGain = baseGain;

@ -19,7 +19,8 @@ public class EffectPlayer extends BaseAudioPlayer {
* @param baseGain base gain (volume multiplier) * @param baseGain base gain (volume multiplier)
* @param volume volume control * @param volume volume control
*/ */
public EffectPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) { public EffectPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume)
{
super(track, (float) basePitch, (float) baseGain, volume); super(track, (float) basePitch, (float) baseGain, volume);
} }

@ -40,7 +40,8 @@ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable
* @param baseGain base gain (volume multiplier) * @param baseGain base gain (volume multiplier)
* @param volume volume control * @param volume volume control
*/ */
public LoopPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) { public LoopPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume)
{
super(track, (float) basePitch, (float) baseGain, volume); super(track, (float) basePitch, (float) baseGain, volume);
paused = true; paused = true;

@ -20,7 +20,8 @@ public class AppAdapter implements AppAccess {
/** /**
* @param app app access * @param app app access
*/ */
public AppAdapter(AppAccess app) { public AppAdapter(AppAccess app)
{
if (app == null) throw new NullPointerException("AppAccess instance cannot be null."); if (app == null) throw new NullPointerException("AppAccess instance cannot be null.");
this.app = app; this.app = app;

@ -23,7 +23,8 @@ public abstract class AppModule extends RootBusNode implements AppAccess {
* *
* @param app access to app systems * @param app access to app systems
*/ */
public AppModule(AppAccess app) { public AppModule(AppAccess app)
{
super(app); super(app);
this.app = app; this.app = app;

@ -25,7 +25,8 @@ public class AppSubModule extends BusNode implements AppAccess {
* *
* @param app access to app systems * @param app access to app systems
*/ */
public AppSubModule(AppAccess app) { public AppSubModule(AppAccess app)
{
super(app); super(app);
this.app = app; this.app = app;

@ -28,7 +28,8 @@ public abstract class GameLoop extends AppModule implements MainLoopTaskRequest.
/** /**
* @param app {@link AppAccess} instance * @param app {@link AppAccess} instance
*/ */
public GameLoop(AppAccess app) { public GameLoop(AppAccess app)
{
super(app); super(app);
} }

@ -21,7 +21,8 @@ public class SlickLogRedirector implements LogSystem {
/** /**
* @param log log to redirect into * @param log log to redirect into
*/ */
public SlickLogRedirector(LogWriter log) { public SlickLogRedirector(LogWriter log)
{
this.l = log; this.l = log;
} }

@ -23,7 +23,8 @@ public class KeyEvent implements Event<KeyEvent.Listener> {
* @param c typed char (can be zero char) * @param c typed char (can be zero char)
* @param down true = pressed, false = released. * @param down true = pressed, false = released.
*/ */
public KeyEvent(int key, char c, boolean down) { public KeyEvent(int key, char c, boolean down)
{
this.key = key; this.key = key;
this.c = c; this.c = c;
this.down = down; this.down = down;

@ -14,7 +14,8 @@ import mightypork.util.control.eventbus.events.flags.ImmediateEvent;
@ImmediateEvent @ImmediateEvent
public class LayoutChangeEvent implements Event<LayoutChangeEvent.Listener> { public class LayoutChangeEvent implements Event<LayoutChangeEvent.Listener> {
public LayoutChangeEvent() { public LayoutChangeEvent()
{
} }

@ -19,7 +19,8 @@ public class MainLoopTaskRequest implements Event<MainLoopTaskRequest.Listener>
/** /**
* @param task task to run on main thread in rendering context * @param task task to run on main thread in rendering context
*/ */
public MainLoopTaskRequest(Runnable task) { public MainLoopTaskRequest(Runnable task)
{
this.task = task; this.task = task;
} }

@ -31,7 +31,8 @@ public class MouseButtonEvent implements Event<MouseButtonEvent.Listener> {
* @param down button pressed * @param down button pressed
* @param wheeld wheel change * @param wheeld wheel change
*/ */
public MouseButtonEvent(Vect pos, int button, boolean down, int wheeld) { public MouseButtonEvent(Vect pos, int button, boolean down, int wheeld)
{
this.button = button; this.button = button;
this.down = down; this.down = down;
this.pos = pos; this.pos = pos;

@ -23,7 +23,8 @@ public class MouseMotionEvent implements Event<MouseMotionEvent.Listener> {
* @param pos end pos * @param pos end pos
* @param move move vector * @param move move vector
*/ */
public MouseMotionEvent(Vect pos, Vect move) { public MouseMotionEvent(Vect pos, Vect move)
{
this.move = move.freeze(); this.move = move.freeze();
this.pos = pos.freeze(); this.pos = pos.freeze();
} }

@ -20,7 +20,8 @@ public class ResourceLoadRequest implements Event<ResourceLoadRequest.Listener>
/** /**
* @param resource resource to load * @param resource resource to load
*/ */
public ResourceLoadRequest(Deferred resource) { public ResourceLoadRequest(Deferred resource)
{
this.resource = resource; this.resource = resource;
} }

@ -19,7 +19,8 @@ public class ScreenRequestEvent implements Event<ScreenRequestEvent.Listener> {
/** /**
* @param screenKey screen name * @param screenKey screen name
*/ */
public ScreenRequestEvent(String screenKey) { public ScreenRequestEvent(String screenKey)
{
scrName = screenKey; scrName = screenKey;
} }

@ -22,7 +22,8 @@ public class UpdateEvent implements Event<Updateable> {
/** /**
* @param deltaTime time since last update (sec) * @param deltaTime time since last update (sec)
*/ */
public UpdateEvent(double deltaTime) { public UpdateEvent(double deltaTime)
{
this.deltaTime = deltaTime; this.deltaTime = deltaTime;
} }

@ -22,7 +22,8 @@ public class ViewportChangeEvent implements Event<ViewportChangeEvent.Listener>
* @param fullscreen is now fullscreen * @param fullscreen is now fullscreen
* @param size new screen size * @param size new screen size
*/ */
public ViewportChangeEvent(boolean fsChanged, boolean fullscreen, Vect size) { public ViewportChangeEvent(boolean fsChanged, boolean fullscreen, Vect size)
{
this.fullscreen = fullscreen; this.fullscreen = fullscreen;
this.screenSize = size; this.screenSize = size;
this.fsChanged = fsChanged; this.fsChanged = fsChanged;

@ -23,14 +23,16 @@ public abstract class LayoutComponent extends VisualComponent implements Enablea
final LinkedList<Component> components = new LinkedList<>(); final LinkedList<Component> components = new LinkedList<>();
public LayoutComponent(AppAccess app, RectBound context) { public LayoutComponent(AppAccess app, RectBound context)
{
this.subModule = new AppSubModule(app); this.subModule = new AppSubModule(app);
setRect(context); setRect(context);
enableCaching(true); // layout is typically updated only when screen resizes. enableCaching(true); // layout is typically updated only when screen resizes.
} }
public LayoutComponent(AppAccess app) { public LayoutComponent(AppAccess app)
{
this(app, null); this(app, null);
} }

@ -23,7 +23,8 @@ public abstract class VisualComponent extends AbstractRectCache implements Compo
private boolean visible = true; private boolean visible = true;
public VisualComponent() { public VisualComponent()
{
super(); super();
enableCaching(false); enableCaching(false);
} }

@ -24,7 +24,8 @@ public class ColumnHolder extends LayoutComponent {
* @param context context * @param context context
* @param cols number of columns * @param cols number of columns
*/ */
public ColumnHolder(AppAccess app, RectBound context, int cols) { public ColumnHolder(AppAccess app, RectBound context, int cols)
{
super(app, context); super(app, context);
this.tiler = columns(cols); this.tiler = columns(cols);
} }
@ -37,7 +38,8 @@ public class ColumnHolder extends LayoutComponent {
* @param app app access * @param app app access
* @param cols number of columns * @param cols number of columns
*/ */
public ColumnHolder(AppAccess app, int cols) { public ColumnHolder(AppAccess app, int cols)
{
this(app, null, cols); this(app, null, cols);
} }

@ -14,12 +14,14 @@ import mightypork.util.constraints.rect.proxy.RectBound;
*/ */
public class ConstraintLayout extends LayoutComponent { public class ConstraintLayout extends LayoutComponent {
public ConstraintLayout(AppAccess app) { public ConstraintLayout(AppAccess app)
{
super(app); super(app);
} }
public ConstraintLayout(AppAccess app, RectBound context) { public ConstraintLayout(AppAccess app, RectBound context)
{
super(app, context); super(app, context);
} }

@ -24,7 +24,8 @@ public class GridLayout extends LayoutComponent {
* @param rows number of rows * @param rows number of rows
* @param cols number of columns * @param cols number of columns
*/ */
public GridLayout(AppAccess app, RectBound context, int rows, int cols) { public GridLayout(AppAccess app, RectBound context, int rows, int cols)
{
super(app, context); super(app, context);
this.tiler = tiles(cols, rows); this.tiler = tiles(cols, rows);
} }
@ -38,7 +39,8 @@ public class GridLayout extends LayoutComponent {
* @param rows number of rows * @param rows number of rows
* @param cols number of columns * @param cols number of columns
*/ */
public GridLayout(AppAccess app, int rows, int cols) { public GridLayout(AppAccess app, int rows, int cols)
{
this(app, null, rows, cols); this(app, null, rows, cols);
} }

@ -28,7 +28,8 @@ public class HorizontalFixedFlowLayout extends LayoutComponent {
* @param elementWidth width of all elements * @param elementWidth width of all elements
* @param align component align. Legal values are LEFT and RIGHT. * @param align component align. Legal values are LEFT and RIGHT.
*/ */
public HorizontalFixedFlowLayout(AppAccess app, RectBound context, Num elementWidth, AlignX align) { public HorizontalFixedFlowLayout(AppAccess app, RectBound context, Num elementWidth, AlignX align)
{
super(app, context); super(app, context);
this.colWidth = elementWidth; this.colWidth = elementWidth;
this.align = align; this.align = align;
@ -47,7 +48,8 @@ public class HorizontalFixedFlowLayout extends LayoutComponent {
* @param elementWidth width of all elements * @param elementWidth width of all elements
* @param align component align. Legal values are LEFT and RIGHT. * @param align component align. Legal values are LEFT and RIGHT.
*/ */
public HorizontalFixedFlowLayout(AppAccess app, Num elementWidth, AlignX align) { public HorizontalFixedFlowLayout(AppAccess app, Num elementWidth, AlignX align)
{
this(app, null, elementWidth, align); this(app, null, elementWidth, align);
} }

@ -26,7 +26,8 @@ public class RowHolder extends LayoutComponent {
* @param app app access * @param app app access
* @param rows number of rows * @param rows number of rows
*/ */
public RowHolder(AppAccess app, int rows) { public RowHolder(AppAccess app, int rows)
{
this(app, null, rows); this(app, null, rows);
} }
@ -36,7 +37,8 @@ public class RowHolder extends LayoutComponent {
* @param context bounding context * @param context bounding context
* @param rows number of rows * @param rows number of rows
*/ */
public RowHolder(AppAccess app, RectBound context, int rows) { public RowHolder(AppAccess app, RectBound context, int rows)
{
super(app, context); super(app, context);
this.tiler = rows(rows); this.tiler = rows(rows);
} }

@ -28,7 +28,8 @@ public class VerticalFixedFlowLayout extends LayoutComponent {
* @param elementHeight height of all elements * @param elementHeight height of all elements
* @param align component align. Legal values are TOP and BOTTOM. * @param align component align. Legal values are TOP and BOTTOM.
*/ */
public VerticalFixedFlowLayout(AppAccess app, RectBound context, Num elementHeight, AlignY align) { public VerticalFixedFlowLayout(AppAccess app, RectBound context, Num elementHeight, AlignY align)
{
super(app, context); super(app, context);
this.rowHeight = elementHeight; this.rowHeight = elementHeight;
this.align = align; this.align = align;
@ -47,7 +48,8 @@ public class VerticalFixedFlowLayout extends LayoutComponent {
* @param elementHeight height of all elements * @param elementHeight height of all elements
* @param align component align. Legal values are TOP and BOTTOM. * @param align component align. Legal values are TOP and BOTTOM.
*/ */
public VerticalFixedFlowLayout(AppAccess app, Num elementHeight, AlignY align) { public VerticalFixedFlowLayout(AppAccess app, Num elementHeight, AlignY align)
{
this(app, null, elementHeight, align); this(app, null, elementHeight, align);
} }

@ -19,7 +19,8 @@ public class ImagePainter extends VisualComponent {
/** /**
* @param texture drawn image * @param texture drawn image
*/ */
public ImagePainter(TxQuad texture) { public ImagePainter(TxQuad texture)
{
this.texture = texture; this.texture = texture;
} }

@ -38,7 +38,8 @@ public class QuadPainter extends VisualComponent {
* *
* @param color * @param color
*/ */
public QuadPainter(Color color) { public QuadPainter(Color color)
{
this.colorHMinVMin = color; this.colorHMinVMin = color;
this.colorHMaxVMin = color; this.colorHMaxVMin = color;
this.colorHMaxVMax = color; this.colorHMaxVMax = color;
@ -54,7 +55,8 @@ public class QuadPainter extends VisualComponent {
* @param colorHMaxVMax * @param colorHMaxVMax
* @param colorHMinVMax * @param colorHMinVMax
*/ */
public QuadPainter(Color colorHMinVMin, Color colorHMaxVMin, Color colorHMaxVMax, Color colorHMinVMax) { public QuadPainter(Color colorHMinVMin, Color colorHMaxVMin, Color colorHMaxVMax, Color colorHMinVMax)
{
this.colorHMinVMin = colorHMinVMin; this.colorHMinVMin = colorHMinVMin;
this.colorHMaxVMin = colorHMaxVMin; this.colorHMaxVMin = colorHMaxVMin;
this.colorHMaxVMax = colorHMaxVMax; this.colorHMaxVMax = colorHMaxVMax;

@ -34,7 +34,8 @@ public class TextPainter extends VisualComponent {
/** /**
* @param font font to use * @param font font to use
*/ */
public TextPainter(GLFont font) { public TextPainter(GLFont font)
{
this(font, AlignX.LEFT, Color.WHITE); this(font, AlignX.LEFT, Color.WHITE);
} }
@ -47,7 +48,8 @@ public class TextPainter extends VisualComponent {
* @param color default color * @param color default color
* @param text drawn text * @param text drawn text
*/ */
public TextPainter(GLFont font, AlignX align, Color color, String text) { public TextPainter(GLFont font, AlignX align, Color color, String text)
{
this(font, align, color, new StringWrapper(text)); this(font, align, color, new StringWrapper(text));
} }
@ -60,7 +62,8 @@ public class TextPainter extends VisualComponent {
* @param color default color * @param color default color
* @param text text provider * @param text text provider
*/ */
public TextPainter(GLFont font, AlignX align, Color color, StringProvider text) { public TextPainter(GLFont font, AlignX align, Color color, StringProvider text)
{
this.font = new FontRenderer(font); this.font = new FontRenderer(font);
this.color = color; this.color = color;
this.align = align; this.align = align;
@ -73,7 +76,8 @@ public class TextPainter extends VisualComponent {
* @param align text align * @param align text align
* @param color default color * @param color default color
*/ */
public TextPainter(GLFont font, AlignX align, Color color) { public TextPainter(GLFont font, AlignX align, Color color)
{
this(font, align, color, (StringProvider) null); this(font, align, color, (StringProvider) null);
} }

@ -28,7 +28,8 @@ public abstract class BaseScreen extends AppSubModule implements Screen, KeyBind
/** /**
* @param app app access * @param app app access
*/ */
public BaseScreen(AppAccess app) { public BaseScreen(AppAccess app)
{
super(app); super(app);
// disable events initially // disable events initially

@ -20,7 +20,8 @@ public abstract class LayeredScreen extends BaseScreen {
/** /**
* @param app app access * @param app app access
*/ */
public LayeredScreen(AppAccess app) { public LayeredScreen(AppAccess app)
{
super(app); super(app);
} }

@ -42,7 +42,8 @@ public abstract class Overlay extends AppSubModule implements Updateable, Compar
protected final Collection<Updateable> updated = new LinkedHashSet<>(); protected final Collection<Updateable> updated = new LinkedHashSet<>();
public Overlay(AppAccess app) { public Overlay(AppAccess app)
{
super(app); super(app);
this.mouse = getInput().getMousePos(); this.mouse = getInput().getMousePos();

@ -17,7 +17,8 @@ public abstract class ScreenLayer extends Overlay {
/** /**
* @param screen parent screen * @param screen parent screen
*/ */
public ScreenLayer(Screen screen) { public ScreenLayer(Screen screen)
{
super(screen); // screen as AppAccess super(screen); // screen as AppAccess
this.screen = screen; this.screen = screen;

@ -31,7 +31,8 @@ public class ScreenRegistry extends AppModule implements ScreenRequestEvent.List
/** /**
* @param app app access * @param app app access
*/ */
public ScreenRegistry(AppAccess app) { public ScreenRegistry(AppAccess app)
{
super(app); super(app);
} }

@ -55,7 +55,8 @@ public class InputSystem extends RootBusNode implements Updateable, KeyBinder {
/** /**
* @param app app access * @param app app access
*/ */
public InputSystem(AppAccess app) { public InputSystem(AppAccess app)
{
super(app); super(app);
initDevices(); initDevices();

@ -20,7 +20,8 @@ public class KeyBinding implements KeyEvent.Listener {
* @param stroke trigger keystroke * @param stroke trigger keystroke
* @param handler action * @param handler action
*/ */
public KeyBinding(KeyStroke stroke, Runnable handler) { public KeyBinding(KeyStroke stroke, Runnable handler)
{
this.keystroke = stroke; this.keystroke = stroke;
this.handler = handler; this.handler = handler;

@ -25,7 +25,8 @@ public class KeyStroke {
* @param fallingEdge true for falling edge, up for rising edge * @param fallingEdge true for falling edge, up for rising edge
* @param keys keys that must be pressed * @param keys keys that must be pressed
*/ */
public KeyStroke(boolean fallingEdge, int... keys) { public KeyStroke(boolean fallingEdge, int... keys)
{
this.fallingEdge = fallingEdge; this.fallingEdge = fallingEdge;
for (final int k : keys) { for (final int k : keys) {
this.keys.add(k); this.keys.add(k);
@ -38,7 +39,8 @@ public class KeyStroke {
* *
* @param keys * @param keys
*/ */
public KeyStroke(int... keys) { public KeyStroke(int... keys)
{
fallingEdge = false; fallingEdge = false;
for (final int k : keys) { for (final int k : keys) {
this.keys.add(k); this.keys.add(k);

@ -52,7 +52,8 @@ public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.L
/** /**
* @param app app acceess * @param app app acceess
*/ */
public AsyncResourceLoader(BusAccess app) { public AsyncResourceLoader(BusAccess app)
{
super("Deferred loader"); super("Deferred loader");
this.app = app; this.app = app;
app.getEventBus().subscribe(this); app.getEventBus().subscribe(this);

@ -25,7 +25,8 @@ public abstract class DeferredResource implements Deferred, Destroyable {
* @param resource resource path / name; this string is later used in * @param resource resource path / name; this string is later used in
* loadResource() * loadResource()
*/ */
public DeferredResource(String resource) { public DeferredResource(String resource)
{
this.resource = resource; this.resource = resource;
} }

@ -54,7 +54,8 @@ public class DisplaySystem extends AppModule implements RectBound {
/** /**
* @param app app access * @param app app access
*/ */
public DisplaySystem(AppAccess app) { public DisplaySystem(AppAccess app)
{
super(app); super(app);
} }

@ -30,7 +30,8 @@ public class Screenshot {
* @param bpp bits per pixel (typically 4) * @param bpp bits per pixel (typically 4)
* @param buffer * @param buffer
*/ */
public Screenshot(int width, int height, int bpp, ByteBuffer buffer) { public Screenshot(int width, int height, int bpp, ByteBuffer buffer)
{
this.width = width; this.width = width;
this.height = height; this.height = height;
this.bpp = bpp; this.bpp = bpp;

@ -21,7 +21,8 @@ public class FontBank extends AppAdapter {
/** /**
* @param app app access * @param app app access
*/ */
public FontBank(AppAccess app) { public FontBank(AppAccess app)
{
super(app); super(app);
} }

@ -23,7 +23,8 @@ public class FontRenderer {
/** /**
* @param font used font * @param font used font
*/ */
public FontRenderer(GLFont font) { public FontRenderer(GLFont font)
{
this(font, Color.WHITE); this(font, Color.WHITE);
} }
@ -32,7 +33,8 @@ public class FontRenderer {
* @param font used font * @param font used font
* @param color drawing color * @param color drawing color
*/ */
public FontRenderer(GLFont font, Color color) { public FontRenderer(GLFont font, Color color)
{
this.font = font; this.font = font;
this.color = color; this.color = color;
} }

@ -85,7 +85,8 @@ public class CachedFont implements GLFont {
* @param filter used Gl filter * @param filter used Gl filter
* @param chars chars to load * @param chars chars to load
*/ */
public CachedFont(java.awt.Font font, boolean antialias, FilterMode filter, String chars) { public CachedFont(java.awt.Font font, boolean antialias, FilterMode filter, String chars)
{
this(font, antialias, filter, chars.toCharArray()); this(font, antialias, filter, chars.toCharArray());
} }
@ -98,7 +99,8 @@ public class CachedFont implements GLFont {
* @param filter used Gl filter * @param filter used Gl filter
* @param chars chars to load * @param chars chars to load
*/ */
public CachedFont(java.awt.Font font, boolean antialias, FilterMode filter, char[] chars) { public CachedFont(java.awt.Font font, boolean antialias, FilterMode filter, char[] chars)
{
GLUtils.checkGLContext(); GLUtils.checkGLContext();
this.font = font; this.font = font;
@ -158,7 +160,8 @@ public class CachedFont implements GLFont {
public int height; public int height;
public LoadedGlyph(char c, BufferedImage image) { public LoadedGlyph(char c, BufferedImage image)
{
this.image = image; this.image = image;
this.c = c; this.c = c;
this.width = image.getWidth(); this.width = image.getWidth();

@ -32,7 +32,8 @@ public class DeferredFont extends DeferredResource implements GLFont {
int numval; int numval;
private FontStyle(int style) { private FontStyle(int style)
{
this.numval = style; this.numval = style;
} }
} }
@ -53,7 +54,8 @@ public class DeferredFont extends DeferredResource implements GLFont {
* @param chars chars to load; null to load basic chars only * @param chars chars to load; null to load basic chars only
* @param size size (px) * @param size size (px)
*/ */
public DeferredFont(String resourcePath, String chars, double size) { public DeferredFont(String resourcePath, String chars, double size)
{
this(resourcePath, chars, size, FontStyle.PLAIN, false, FilterMode.NEAREST); this(resourcePath, chars, size, FontStyle.PLAIN, false, FilterMode.NEAREST);
} }
@ -68,7 +70,8 @@ public class DeferredFont extends DeferredResource implements GLFont {
* @param antialias use antialiasing for caching texture * @param antialias use antialiasing for caching texture
* @param filter gl filtering mode * @param filter gl filtering mode
*/ */
public DeferredFont(String resourcePath, String chars, double size, FontStyle style, boolean antialias, FilterMode filter) { public DeferredFont(String resourcePath, String chars, double size, FontStyle style, boolean antialias, FilterMode filter)
{
super(resourcePath); super(resourcePath);
this.size = size; this.size = size;
this.style = style; this.style = style;

@ -27,7 +27,8 @@ public class DeferredFontNative extends DeferredFont {
* @param antialias use antialiasing when drawn on the cache texture * @param antialias use antialiasing when drawn on the cache texture
* @param filter GL filtering mode * @param filter GL filtering mode
*/ */
public DeferredFontNative(String fontName, String extraChars, double size, FontStyle style, boolean antialias, FilterMode filter) { public DeferredFontNative(String fontName, String extraChars, double size, FontStyle style, boolean antialias, FilterMode filter)
{
super(fontName, extraChars, size, style, antialias, filter); super(fontName, extraChars, size, style, antialias, filter);
} }

@ -27,7 +27,8 @@ public class DeferredTexture extends DeferredResource implements GLTexture {
/** /**
* @param resourcePath resource path * @param resourcePath resource path
*/ */
public DeferredTexture(String resourcePath) { public DeferredTexture(String resourcePath)
{
super(resourcePath); super(resourcePath);
} }
@ -212,6 +213,7 @@ public class DeferredTexture extends DeferredResource implements GLTexture {
this.wrap = wrapping; this.wrap = wrapping;
} }
@Override @Override
public QuadGrid grid(int x, int y) public QuadGrid grid(int x, int y)
{ {

@ -16,7 +16,8 @@ public enum FilterMode
public final int num; public final int num;
private FilterMode(int gl) { private FilterMode(int gl)
{
this.num = gl; this.num = gl;
} }
} }

@ -1,10 +1,10 @@
package mightypork.gamecore.render.textures; package mightypork.gamecore.render.textures;
import org.newdawn.slick.opengl.Texture;
import mightypork.util.constraints.rect.Rect; import mightypork.util.constraints.rect.Rect;
import org.newdawn.slick.opengl.Texture;
/** /**
* Texture with filter and wrap mode * Texture with filter and wrap mode

@ -12,12 +12,14 @@ import mightypork.util.constraints.rect.Rect;
public class QuadGrid { public class QuadGrid {
private final GLTexture tx; private final GLTexture tx;
private int txHeight; private final int txHeight;
private int txWidth; private final int txWidth;
private double tileW; private final double tileW;
private double tileH; private final double tileH;
public QuadGrid(GLTexture tx, int tilesX, int tilesY) {
public QuadGrid(GLTexture tx, int tilesX, int tilesY)
{
this.tx = tx; this.tx = tx;
this.txWidth = tilesX; this.txWidth = tilesX;
this.txHeight = tilesY; this.txHeight = tilesY;

@ -22,10 +22,12 @@ public class TextureBank extends AppAdapter {
private final Map<String, TxQuad> quads = new HashMap<>(); private final Map<String, TxQuad> quads = new HashMap<>();
private final Map<String, TxSheet> sheets = new HashMap<>(); private final Map<String, TxSheet> sheets = new HashMap<>();
/** /**
* @param app app access * @param app app access
*/ */
public TextureBank(AppAccess app) { public TextureBank(AppAccess app)
{
super(app); super(app);
} }

@ -62,7 +62,8 @@ public class TxQuad {
* @param x2 right bottom X (0-1) * @param x2 right bottom X (0-1)
* @param y2 right bottom Y (0-1) * @param y2 right bottom Y (0-1)
*/ */
public TxQuad(GLTexture tx, double x1, double y1, double x2, double y2) { public TxQuad(GLTexture tx, double x1, double y1, double x2, double y2)
{
this(tx, Rect.make(x1, y1, x2, y2)); this(tx, Rect.make(x1, y1, x2, y2));
} }
@ -71,7 +72,8 @@ public class TxQuad {
* @param tx Texture * @param tx Texture
* @param uvs Rect of texture UVs (0-1); will be frozen. * @param uvs Rect of texture UVs (0-1); will be frozen.
*/ */
public TxQuad(GLTexture tx, Rect uvs) { public TxQuad(GLTexture tx, Rect uvs)
{
this.tx = tx; this.tx = tx;
this.uvs = uvs.freeze(); this.uvs = uvs.freeze();
} }
@ -82,7 +84,8 @@ public class TxQuad {
* *
* @param txQuad a copied quad * @param txQuad a copied quad
*/ */
public TxQuad(TxQuad txQuad) { public TxQuad(TxQuad txQuad)
{
this.tx = txQuad.tx; this.tx = txQuad.tx;
this.uvs = txQuad.uvs; this.uvs = txQuad.uvs;
} }

@ -17,10 +17,11 @@ public class TxSheet {
private final Random rand = new Random(); private final Random rand = new Random();
private final Random randForSeed = new Random(); private final Random randForSeed = new Random();
private int count; private final int count;
public TxSheet(TxQuad tx, int width, int height) { public TxSheet(TxQuad tx, int width, int height)
{
this.original = tx; this.original = tx;
this.width = width; this.width = width;
this.count = width * height; this.count = width * height;

@ -16,7 +16,8 @@ public enum WrapMode
public final int num; public final int num;
private WrapMode(int gl) { private WrapMode(int gl)
{
this.num = gl; this.num = gl;
} }
} }

@ -24,9 +24,8 @@ import mightypork.rogue.screens.test_cat_sound.ScreenTestCat;
import mightypork.rogue.screens.test_render.ScreenTestRender; import mightypork.rogue.screens.test_render.ScreenTestRender;
import mightypork.rogue.world.WorldMap; import mightypork.rogue.world.WorldMap;
import mightypork.rogue.world.item.Item; import mightypork.rogue.world.item.Item;
import mightypork.rogue.world.item.ItemData;
import mightypork.rogue.world.tile.Tile; import mightypork.rogue.world.tile.Tile;
import mightypork.rogue.world.tile.TileData; import mightypork.rogue.world.tile.TileItems;
import mightypork.util.control.eventbus.EventBus; import mightypork.util.control.eventbus.EventBus;
import mightypork.util.control.eventbus.events.Event; import mightypork.util.control.eventbus.events.Event;
import mightypork.util.files.ion.Ion; import mightypork.util.files.ion.Ion;
@ -108,11 +107,10 @@ public final class App extends BaseApp {
@Override @Override
protected void preInit() protected void preInit()
{ {
Ion.registerIonizable(Tile.ION_MARK, Tile.class); // 700 Ion.registerIonizable(Tile.ION_MARK, Tile.class);
Ion.registerIonizable(Item.ION_MARK, Item.class); // 701 Ion.registerIonizable(Item.ION_MARK, Item.class);
Ion.registerIonizable(WorldMap.ION_MARK, WorldMap.class); // 702 Ion.registerIonizable(WorldMap.ION_MARK, WorldMap.class);
Ion.registerIonizable(TileData.ION_MARK, TileData.class); // 703 Ion.registerIonizable(TileItems.ION_MARK, TileItems.class); // used by tile to store contained items
Ion.registerIonizable(ItemData.ION_MARK, ItemData.class); // 704
} }

@ -19,7 +19,8 @@ import mightypork.util.logging.Log;
public final class MainLoop extends GameLoop implements ActionRequest.Listener { public final class MainLoop extends GameLoop implements ActionRequest.Listener {
public MainLoop(BaseApp app) { public MainLoop(BaseApp app)
{
super(app); super(app);
} }
@ -83,7 +84,8 @@ public final class MainLoop extends GameLoop implements ActionRequest.Listener {
private final Screenshot scr; private final Screenshot scr;
public TaskTakeScreenshot() { public TaskTakeScreenshot()
{
scr = getDisplay().takeScreenshot(); scr = getDisplay().takeScreenshot();
} }

@ -67,7 +67,7 @@ public final class Res {
texture = textures.loadTexture("test.kitten", "/res/img/kitten.png", FilterMode.LINEAR, WrapMode.CLAMP); texture = textures.loadTexture("test.kitten", "/res/img/kitten.png", FilterMode.LINEAR, WrapMode.CLAMP);
texture = textures.loadTexture("gui1", "/res/img/gui1.png", FilterMode.NEAREST, WrapMode.CLAMP); texture = textures.loadTexture("gui1", "/res/img/gui1.png", FilterMode.NEAREST, WrapMode.CLAMP);
QuadGrid gui = texture.grid(4, 4); final QuadGrid gui = texture.grid(4, 4);
textures.addQuad("item_frame", gui.makeQuad(0, 0)); textures.addQuad("item_frame", gui.makeQuad(0, 0));
textures.addQuad("sword", gui.makeQuad(1, 0)); textures.addQuad("sword", gui.makeQuad(1, 0));
textures.addQuad("meat", gui.makeQuad(2, 0)); textures.addQuad("meat", gui.makeQuad(2, 0));
@ -78,7 +78,7 @@ public final class Res {
textures.addQuad("panel", gui.makeQuad(0, 3.75, 4, .25)); textures.addQuad("panel", gui.makeQuad(0, 3.75, 4, .25));
texture = textures.loadTexture("tiles", "/res/img/map_tiles.png", FilterMode.NEAREST, WrapMode.CLAMP); texture = textures.loadTexture("tiles", "/res/img/map_tiles.png", FilterMode.NEAREST, WrapMode.CLAMP);
QuadGrid tiles = texture.grid(32, 32); final QuadGrid tiles = texture.grid(32, 32);
textures.addSheet("tile.mossy_bricks.wall", tiles.makeSheet(4, 0, 7, 1)); textures.addSheet("tile.mossy_bricks.wall", tiles.makeSheet(4, 0, 7, 1));
textures.addSheet("tile.mossy_bricks.floor", tiles.makeSheet(16, 5, 7, 1)); textures.addSheet("tile.mossy_bricks.floor", tiles.makeSheet(16, 5, 7, 1));

@ -16,7 +16,8 @@ public class ActionRequest implements Event<ActionRequest.Listener> {
private final RequestType type; private final RequestType type;
public ActionRequest(RequestType request) { public ActionRequest(RequestType request)
{
type = request; type = request;
} }

@ -47,7 +47,8 @@ public class CrossfadeOverlay extends Overlay implements CrossfadeRequest.Listen
}; };
public CrossfadeOverlay(AppAccess app) { public CrossfadeOverlay(AppAccess app)
{
super(app); super(app);
final QuadPainter qp = new QuadPainter(color); final QuadPainter qp = new QuadPainter(color);

@ -15,7 +15,8 @@ public class CrossfadeRequest implements Event<CrossfadeRequest.Listener> {
/** /**
* @param screen screen key to show. Null = exit the app. * @param screen screen key to show. Null = exit the app.
*/ */
public CrossfadeRequest(String screen) { public CrossfadeRequest(String screen)
{
super(); super();
this.screen = screen; this.screen = screen;
} }

@ -22,7 +22,8 @@ public class FpsOverlay extends Overlay {
TextPainter tp; TextPainter tp;
public FpsOverlay(AppAccess screen) { public FpsOverlay(AppAccess screen)
{
super(screen); super(screen);
/* /*

@ -16,7 +16,8 @@ import mightypork.util.math.color.PAL16;
public class GameGui extends ScreenLayer { public class GameGui extends ScreenLayer {
public GameGui(Screen screen) { public GameGui(Screen screen)
{
super(screen); super(screen);
final Num h = root.height(); final Num h = root.height();

@ -28,7 +28,8 @@ public class HeartBar extends VisualComponent {
* @param img_off * @param img_off
* @param align * @param align
*/ */
public HeartBar(int total, int active, TxQuad img_on, TxQuad img_off, AlignX align) { public HeartBar(int total, int active, TxQuad img_on, TxQuad img_off, AlignX align)
{
super(); super();
this.total = total; this.total = total;
this.active = active; this.active = active;

@ -24,7 +24,8 @@ public class NavItemSlot extends ClickableComponent implements MouseMotionEvent.
private boolean wasInside = false; private boolean wasInside = false;
public NavItemSlot(TxQuad image) { public NavItemSlot(TxQuad image)
{
this.image = image; this.image = image;
this.frame = Res.getTxQuad("item_frame"); this.frame = Res.getTxQuad("item_frame");

@ -7,7 +7,8 @@ import mightypork.gamecore.gui.screens.LayeredScreen;
public class ScreenGame extends LayeredScreen { public class ScreenGame extends LayeredScreen {
public ScreenGame(AppAccess app) { public ScreenGame(AppAccess app)
{
super(app); super(app);
addLayer(new GameGui(this)); addLayer(new GameGui(this));

@ -31,7 +31,8 @@ class MenuButton extends ClickableComponent {
private final NumVar alphaMulSh = Num.makeVar(SH_ALPHA_OFF); private final NumVar alphaMulSh = Num.makeVar(SH_ALPHA_OFF);
public MenuButton(String text, Color color) { public MenuButton(String text, Color color)
{
this.color = color.withAlpha(alphaMul); this.color = color.withAlpha(alphaMul);
this.painter = new TextPainter(font, AlignX.CENTER, this.color, text); this.painter = new TextPainter(font, AlignX.CENTER, this.color, text);

@ -17,7 +17,8 @@ import mightypork.util.math.color.PAL16;
class MenuLayer extends ScreenLayer { class MenuLayer extends ScreenLayer {
public MenuLayer(BaseScreen screen) { public MenuLayer(BaseScreen screen)
{
super(screen); super(screen);
init(); init();

@ -7,7 +7,8 @@ import mightypork.gamecore.gui.screens.LayeredScreen;
public class ScreenMainMenu extends LayeredScreen { public class ScreenMainMenu extends LayeredScreen {
public ScreenMainMenu(AppAccess app) { public ScreenMainMenu(AppAccess app)
{
super(app); super(app);
addLayer(new MenuLayer(this)); addLayer(new MenuLayer(this));

@ -23,7 +23,8 @@ public class BouncyBox extends VisualComponent implements Updateable {
private final NumAnimated pos = new NumAnimated(0, Easing.BOUNCE_OUT); private final NumAnimated pos = new NumAnimated(0, Easing.BOUNCE_OUT);
public BouncyBox() { public BouncyBox()
{
super(); super();
enableCaching(true); enableCaching(true);

@ -23,7 +23,8 @@ public class LayerBouncyBoxes extends ScreenLayer {
private RowHolder layout; private RowHolder layout;
public LayerBouncyBoxes(BaseScreen screen) { public LayerBouncyBoxes(BaseScreen screen)
{
super(screen); super(screen);
bindKey(new KeyStroke(true, Keys.RIGHT), new Runnable() { bindKey(new KeyStroke(true, Keys.RIGHT), new Runnable() {

@ -10,7 +10,8 @@ public class ScreenTestBouncy extends LayeredScreen {
private final LayerBouncyBoxes layer; private final LayerBouncyBoxes layer;
public ScreenTestBouncy(AppAccess app) { public ScreenTestBouncy(AppAccess app)
{
super(app); super(app);
layer = new LayerBouncyBoxes(this); layer = new LayerBouncyBoxes(this);

@ -9,7 +9,8 @@ import mightypork.util.math.color.Color;
public class LayerColor extends ScreenLayer { public class LayerColor extends ScreenLayer {
public LayerColor(BaseScreen screen, Color color) { public LayerColor(BaseScreen screen, Color color)
{
super(screen); super(screen);
root.add(new QuadPainter(color)); root.add(new QuadPainter(color));

@ -29,7 +29,8 @@ public class LayerFlyingCat extends ScreenLayer implements MouseButtonEvent.List
private final Random rand = new Random(); private final Random rand = new Random();
public LayerFlyingCat(BaseScreen screen) { public LayerFlyingCat(BaseScreen screen)
{
super(screen); super(screen);
// timing // timing

@ -12,7 +12,8 @@ import mightypork.rogue.events.ActionRequest.RequestType;
public class ScreenTestCat extends LayeredScreen { public class ScreenTestCat extends LayeredScreen {
public ScreenTestCat(AppAccess app) { public ScreenTestCat(AppAccess app)
{
super(app); super(app);
addLayer(new LayerFlyingCat(this)); addLayer(new LayerFlyingCat(this));

@ -14,7 +14,8 @@ public class LayerTestGradient extends ScreenLayer {
private final RectBound pos2; private final RectBound pos2;
public LayerTestGradient(BaseScreen screen) { public LayerTestGradient(BaseScreen screen)
{
super(screen); super(screen);
pos1 = root.topEdge().growDown(64); pos1 = root.topEdge().growDown(64);

@ -7,7 +7,8 @@ import mightypork.gamecore.gui.screens.LayeredScreen;
public class ScreenTestRender extends LayeredScreen { public class ScreenTestRender extends LayeredScreen {
public ScreenTestRender(AppAccess app) { public ScreenTestRender(AppAccess app)
{
super(app); super(app);
addLayer(new LayerTestGradient(this)); addLayer(new LayerTestGradient(this));

@ -1,130 +0,0 @@
package mightypork.rogue.world;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import mightypork.util.constraints.rect.proxy.RectBound;
import mightypork.util.control.timing.Updateable;
import mightypork.util.files.ion.Ion;
import mightypork.util.files.ion.Ionizable;
/**
* Abstract entity
*
* @author MightyPork
* @param <D> Data object class
* @param <M> Model class
* @param <R> Render context class
*/
public abstract class Entity<D, M extends EntityModel<D, R>, R extends RectBound> implements Ionizable, Updateable {
protected M model;
protected D data;
/**
* Used by Ion for loading.
*/
public Entity() {
}
/**
* Create from model
*
* @param model model
*/
public Entity(M model) {
setModel(model);
}
@Override
public final void loadFrom(InputStream in) throws IOException
{
final int id = Ion.readInt(in);
setModel(id);
model.load(data, in); // load saved data
}
private void initData()
{
data = model.createData();
}
/**
* @return data
*/
public final D getData()
{
return data;
}
/**
* @return entity model
*/
public final M getModel()
{
return model;
}
/**
* Assign a model.
*
* @param id model id
*/
public final void setModel(int id)
{
setModel(getModelForId(id));
}
/**
* Assign a model.
*
* @param model model
*/
public final void setModel(M model)
{
this.model = model;
initData();
}
@Override
public final void saveTo(OutputStream out) throws IOException
{
Ion.writeInt(out, model.getId());
model.save(data, out);
}
public void render(R context)
{
model.render(data, context);
}
@Override
public void update(double delta)
{
model.update(data, delta);
}
/**
* Get model for ID
*
* @param id id
* @return model for the ID
*/
protected abstract M getModelForId(int id);
}

@ -1,75 +0,0 @@
package mightypork.rogue.world;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import mightypork.util.annotations.DefaultImpl;
import mightypork.util.constraints.rect.proxy.RectBound;
/**
* Entity model. Provides concrete implementation to an entity, working with
* it's data object.
*
* @author MightyPork
* @param <D> Data object class
* @param <R> Render context class
*/
public abstract class EntityModel<D, R extends RectBound> {
/** Model id */
private final int id;
/**
* Create a model. The caller must then register this instance in a Model
* registry for the particular entity type.
*
* @param id model id
*/
public EntityModel(int id) {
this.id = id;
}
/**
* Get the model id.
*
* @return id
*/
public final int getId()
{
return id;
}
/**
* Create a data object and populate it with default values.<br>
* It's allowed to return null for no data.
*
* @return data object
*/
public abstract D createData();
/**
* Render the item according to given context.
*
* @param data rendered item
* @param context rendering context
*/
public abstract void render(D data, R context);
/**
* Update the item (animation, decay etc)
*
* @param item item to update
* @param delta delta time
*/
@DefaultImpl
public abstract void update(D item, double delta);
}

@ -7,7 +7,9 @@ import java.io.OutputStream;
import mightypork.rogue.world.tile.Tile; import mightypork.rogue.world.tile.Tile;
import mightypork.rogue.world.tile.TileGrid; import mightypork.rogue.world.tile.TileGrid;
import mightypork.rogue.world.tile.Tiles;
import mightypork.util.files.ion.Ion; import mightypork.util.files.ion.Ion;
import mightypork.util.files.ion.IonConstructor;
import mightypork.util.files.ion.Ionizable; import mightypork.util.files.ion.Ionizable;
@ -21,12 +23,14 @@ public class WorldMap implements TileGrid, Ionizable {
private Tile[][] tiles; private Tile[][] tiles;
public WorldMap() { @IonConstructor
// constructor for ION public WorldMap()
{
} }
public WorldMap(int width, int height) { public WorldMap(int width, int height)
{
this.width = width; this.width = width;
this.height = height; this.height = height;
buildArray(); buildArray();
@ -36,6 +40,12 @@ public class WorldMap implements TileGrid, Ionizable {
private void buildArray() private void buildArray()
{ {
this.tiles = new Tile[height][width]; this.tiles = new Tile[height][width];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
tiles[y][x] = Tiles.NONE.create();
}
}
} }
@ -73,35 +83,27 @@ public class WorldMap implements TileGrid, Ionizable {
@Override @Override
public void loadFrom(InputStream in) throws IOException public void load(InputStream in) throws IOException
{ {
width = Ion.readInt(in); width = Ion.readInt(in);
height = Ion.readInt(in); height = Ion.readInt(in);
buildArray(); buildArray();
while (true) { while (Ion.hasNextEntry(in)) {
final short mark = Ion.readMark(in);
if (mark == Ion.END) {
break;
} else if (mark == Ion.ENTRY) {
final int x = Ion.readInt(in);
final int y = Ion.readInt(in);
final Tile tile = (Tile) Ion.readObject(in); final int x = Ion.readInt(in);
final int y = Ion.readInt(in);
setTile(tile, x, y); final Tile tile = (Tile) Ion.readObject(in);
} else { setTile(tile, x, y);
throw new IOException("Invalid mark encountered while reading tile map.");
}
} }
} }
@Override @Override
public void saveTo(OutputStream out) throws IOException public void save(OutputStream out) throws IOException
{ {
Ion.writeInt(out, width); Ion.writeInt(out, width);
Ion.writeInt(out, height); Ion.writeInt(out, height);
@ -109,7 +111,8 @@ public class WorldMap implements TileGrid, Ionizable {
for (int x = 0; x < width; x++) { for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) { for (int y = 0; y < height; y++) {
final Tile t = getTile(x, y); final Tile t = getTile(x, y);
if (t != null) { // skip null tiles
if (!t.getModel().isNullTile()) {
Ion.writeMark(out, Ion.ENTRY); Ion.writeMark(out, Ion.ENTRY);
Ion.writeInt(out, x); Ion.writeInt(out, x);
Ion.writeInt(out, y); Ion.writeInt(out, y);
@ -118,6 +121,7 @@ public class WorldMap implements TileGrid, Ionizable {
} }
} }
// end of sequence
Ion.writeMark(out, Ion.END); Ion.writeMark(out, Ion.END);
} }

@ -1,34 +1,87 @@
package mightypork.rogue.world.item; package mightypork.rogue.world.item;
import mightypork.rogue.world.Entity; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import mightypork.rogue.world.tile.TileRenderContext;
import mightypork.util.constraints.rect.proxy.RectBound; import mightypork.util.constraints.rect.proxy.RectBound;
import mightypork.util.control.timing.Animator;
import mightypork.util.control.timing.AnimatorBounce;
import mightypork.util.control.timing.Updateable;
import mightypork.util.files.ion.Ion;
import mightypork.util.files.ion.IonBundle;
import mightypork.util.files.ion.IonConstructor;
import mightypork.util.files.ion.Ionizable;
import mightypork.util.math.Easing;
public final class Item extends Entity<ItemData, ItemModel, RectBound> { public class Item implements Updateable, Ionizable {
public static final short ION_MARK = 701; public static final short ION_MARK = 701;
private transient ItemModel model;
public transient Object modelData;
public transient Animator anim;
public int id;
public boolean[] flags;
public int[] numbers;
public Item() { public Item(int id)
super(); {
this(Items.get(id));
} }
public Item(ItemModel model) { @IonConstructor
super(model); public Item()
{
} }
public Item(int id) { public Item(ItemModel model)
super(Items.get(id)); {
this.model = model;
this.id = model.id;
this.anim = new AnimatorBounce(2, Easing.SINE_BOTH);
}
public void render(RectBound context)
{
model.render(this, context);
}
@Override
public void save(OutputStream out) throws IOException
{
final IonBundle ib = new IonBundle();
ib.put("id", id);
ib.put("flags", flags);
ib.put("numbers", numbers);
Ion.writeObject(out, ib);
} }
@Override @Override
protected ItemModel getModelForId(int id) public void load(InputStream in) throws IOException
{ {
return Items.get(id); final IonBundle ib = (IonBundle) Ion.readObject(in);
id = ib.get("id", id);
flags = ib.get("flags", flags);
numbers = ib.get("numbers", numbers);
if (id != model.id) {
model = Items.get(id);
}
} }
@ -38,4 +91,20 @@ public final class Item extends Entity<ItemData, ItemModel, RectBound> {
return ION_MARK; return ION_MARK;
} }
@Override
public void update(double delta)
{
if (anim != null) {
anim.update(delta);
}
}
public void renderOnTile(TileRenderContext context)
{
model.renderOnTile(this, context);
}
} }

@ -1,13 +0,0 @@
package mightypork.rogue.world.item;
/**
* Item data object.
*
* @author MightyPork
*/
public final class ItemData {
public static final int ION_MARK = 704;
}

@ -1,19 +1,50 @@
package mightypork.rogue.world.item; package mightypork.rogue.world.item;
import mightypork.rogue.world.EntityModel; import mightypork.rogue.world.tile.TileRenderContext;
import mightypork.util.annotations.DefaultImpl;
import mightypork.util.constraints.num.proxy.NumBoundAdapter;
import mightypork.util.constraints.rect.Rect;
import mightypork.util.constraints.rect.proxy.RectBound; import mightypork.util.constraints.rect.proxy.RectBound;
import mightypork.util.constraints.rect.proxy.RectBoundAdapter;
/** public abstract class ItemModel {
* An item model
*
* @author MightyPork
*/
public abstract class ItemModel extends EntityModel<ItemData, RectBound> {
public ItemModel(int id) { public final int id;
super(id);
private final RectBoundAdapter tileRect = new RectBoundAdapter();
private final NumBoundAdapter yOffset = new NumBoundAdapter();
private final Rect itemRect = tileRect.shrink(tileRect.height().perc(10)).moveY(yOffset.neg());
public ItemModel(int id)
{
Items.register(id, this); Items.register(id, this);
this.id = id;
}
/**
* @return new tile with this model
*/
@DefaultImpl
public Item create()
{
return new Item(this);
} }
public abstract void render(Item item, RectBound context);
public void renderOnTile(Item item, TileRenderContext context)
{
tileRect.setRect(context.getRect());
yOffset.setNum(item.anim);
render(item, itemRect);
}
} }

@ -1,25 +1,27 @@
package mightypork.rogue.world.item; package mightypork.rogue.world.item;
import java.util.HashMap; /**
import java.util.Map; * Item registry
*
* @author MightyPork
*/
public final class Items { public final class Items {
private static final Map<Integer, ItemModel> registered = new HashMap<>(); private static final ItemModel[] items = new ItemModel[256];
static void register(int id, ItemModel model) static void register(int id, ItemModel model)
{ {
if (registered.containsKey(id)) throw new IllegalArgumentException("Item ID " + id + " already in use."); if (id < 0 || id >= items.length) if (items[id] != null) throw new IllegalArgumentException("Item ID " + id + " already in use.");
registered.put(id, model);
items[id] = model;
} }
public static ItemModel get(int id) public static ItemModel get(int id)
{ {
final ItemModel m = registered.get(id); final ItemModel m = items[id];
if (m == null) throw new IllegalArgumentException("No item with ID " + id + "."); if (m == null) throw new IllegalArgumentException("No item with ID " + id + ".");
return m; return m;
} }

@ -1,118 +1,116 @@
package mightypork.rogue.world.tile; package mightypork.rogue.world.tile;
import mightypork.rogue.world.Entity; import java.io.IOException;
import mightypork.rogue.world.item.Item; import java.io.InputStream;
import java.io.OutputStream;
import mightypork.util.control.timing.Animator;
import mightypork.util.control.timing.Updateable;
import mightypork.util.files.ion.Ion;
import mightypork.util.files.ion.IonBundle;
import mightypork.util.files.ion.IonConstructor;
import mightypork.util.files.ion.Ionizable;
/**
* Concrete tile in the world.
*
* @author MightyPork
*/
public final class Tile extends Entity<TileData, TileModel, TileRenderContext> {
public static final short ION_MARK = 700; public final class Tile implements Ionizable, Updateable {
/** Whether the tile is occupied by an entity */ public static final short ION_MARK = 700;
private transient boolean occupied;
private transient TileModel model;
public transient Object modelData;
public transient Animator anim;
public Tile() { public int id;
super();
}
public TileItems items;
public Tile(TileModel model) { public boolean[] flags;
super(model); public int[] numbers;
}
public Tile(int id) { public Tile(int id)
super(Tiles.get(id)); {
this(Tiles.get(id));
} }
@Override @IonConstructor
protected TileModel getModelForId(int id) public Tile()
{ {
return Tiles.get(id);
} }
@Override public Tile(TileModel model)
public short getIonMark()
{ {
return ION_MARK; this.model = model;
this.id = model.id;
this.items = new TileItems();
} }
@Override
public void render(TileRenderContext context) public void render(TileRenderContext context)
{ {
super.render(context); model.render(this, context);
// render laying-on-top item if (!items.isEmpty()) {
if (!data.items.isEmpty()) { items.peek().renderOnTile(context);
final Item item = data.items.peek();
item.render(context.getRect());
} }
} }
@Override @Override
public void update(double delta) public void save(OutputStream out) throws IOException
{ {
super.update(delta); if (model.isNullTile()) throw new RuntimeException("Cannot save null tile.");
// update laying-on-top item final IonBundle ib = new IonBundle();
if (!data.items.isEmpty()) {
final Item item = data.items.peek();
item.update(delta);
}
}
ib.put("id", id);
ib.put("flags", flags);
ib.put("numbers", numbers);
ib.put("items", items);
/** Ion.writeObject(out, ib);
* Try to reveal secrets of this tile
*/
public void search()
{
model.search(data);
} }
/** @Override
* @return true if a mob can walk through public void load(InputStream in) throws IOException
*/
public boolean isWalkable()
{ {
return model.isWalkable(data); final IonBundle ib = (IonBundle) Ion.readObject(in);
}
id = ib.get("id", id);
flags = ib.get("flags", flags);
numbers = ib.get("numbers", numbers);
items = ib.get("items", items);
public boolean hasItem() // renew model
{ if (model == null || id != model.id) {
return !data.items.isEmpty(); model = Tiles.get(id);
}
} }
public Item removeItem() @Override
public short getIonMark()
{ {
if(!hasItem()) return null; return ION_MARK;
return data.items.pop();
} }
public boolean isOccupied() @Override
public void update(double delta)
{ {
return occupied; if (!items.isEmpty()) {
items.peek().update(delta);
}
} }
public void setOccupied(boolean occupied) public TileModel getModel()
{ {
this.occupied = occupied; return model;
} }
} }

@ -1,54 +0,0 @@
package mightypork.rogue.world.tile;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Stack;
import mightypork.rogue.world.item.Item;
import mightypork.util.files.ion.IonList;
import mightypork.util.files.ion.Ionizable;
/**
* Tile data object.
*
* @author MightyPork
*/
public final class TileData implements Ionizable {
public static final short ION_MARK = 703;
/** Items dropped onto this tile */
public final Stack<Item> items = new Stack<>();
public int id;
public boolean[] flags;
public int[] numbers;
@Override
public void loadFrom(InputStream in) throws IOException
{
}
@Override
public void saveTo(OutputStream out) throws IOException
{
}
@Override
public short getIonMark()
{
return 0;
}
public Tile toTile() {
Tile t = new Tile(Tiles.get(id));
t.s
}
}

@ -0,0 +1,39 @@
package mightypork.rogue.world.tile;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Stack;
import mightypork.rogue.world.item.Item;
import mightypork.util.files.ion.Ion;
import mightypork.util.files.ion.Ionizable;
public class TileItems extends Stack<Item> implements Ionizable {
public static final short ION_MARK = 703;
@Override
public void load(InputStream in) throws IOException
{
Ion.readSequence(in, this);
}
@Override
public void save(OutputStream out) throws IOException
{
Ion.writeSequence(out, this);
}
@Override
public short getIonMark()
{
return ION_MARK;
}
}

@ -1,51 +1,62 @@
package mightypork.rogue.world.tile; package mightypork.rogue.world.tile;
import mightypork.rogue.world.EntityModel;
import mightypork.util.annotations.DefaultImpl; import mightypork.util.annotations.DefaultImpl;
public abstract class TileModel extends EntityModel<TileData, TileRenderContext> { /**
* Singleton-like tile implementation
*
* @author MightyPork
*/
public abstract class TileModel {
public TileModel(int id) { /** Model ID */
super(id); public final int id;
public TileModel(int id)
{
Tiles.register(id, this); Tiles.register(id, this);
this.id = id;
} }
@Override
public TileData createData() /**
* @return new tile with this model
*/
@DefaultImpl
public Tile create()
{ {
return null; return new Tile(this);
} }
/** /**
* Test if this tile type is potentially walkable. Used during world * Render the tile.
* generation.
* *
* @return can be walked through (if discovered / open) * @param tile
* @param context
*/ */
public abstract boolean isWalkable(); public abstract void render(Tile tile, TileRenderContext context);
/** /**
* Try to reveal a secret. * @param tile
* * @return is walkable at the current conditions
* @param data tile data
*/ */
@DefaultImpl public abstract boolean isWalkable(Tile tile);
public void search(TileData data)
{
// do nothing.
}
/** /**
* Check if a mob can walk through. * @return true if the tile can be walkable at some conditions
*
* @param data tile data
* @return is walkable
*/ */
public abstract boolean isWalkable(TileData data); public abstract boolean isPotentiallyWalkable();
public boolean isNullTile()
{
return false;
}
} }

@ -16,7 +16,8 @@ public final class TileRenderContext implements RectBound {
public int x, y; public int x, y;
public TileRenderContext(TileGrid map, Rect drawArea, long renderNoiseSeed) { public TileRenderContext(TileGrid map, Rect drawArea, long renderNoiseSeed)
{
this.map = map; this.map = map;
this.tiler = drawArea.tiles(map.getWidth(), map.getHeight()); this.tiler = drawArea.tiles(map.getWidth(), map.getHeight());
this.noise = new NoiseGen(0.2, 0, 0.5, 1, renderNoiseSeed); this.noise = new NoiseGen(0.2, 0, 0.5, 1, renderNoiseSeed);
@ -45,7 +46,7 @@ public final class TileRenderContext implements RectBound {
/** /**
* @return per-coord noise value 0..1 * @return per-coord noise value 0..1
*/ */
public double getNoise() public double getTileNoise()
{ {
return noise.valueAt(x, y); return noise.valueAt(x, y);
} }
@ -56,4 +57,10 @@ public final class TileRenderContext implements RectBound {
this.x = x; this.x = x;
this.y = y; this.y = y;
} }
public void renderTile(Tile t)
{
t.render(this);
}
} }

@ -1,26 +1,42 @@
package mightypork.rogue.world.tile; package mightypork.rogue.world.tile;
import java.util.HashMap; import mightypork.rogue.world.tile.models.Floor;
import java.util.Map; import mightypork.rogue.world.tile.models.NullTile;
/**
* Tile registry
*
* @author MightyPork
*/
public final class Tiles { public final class Tiles {
private static final Map<Integer, TileModel> registered = new HashMap<>(); private static final TileModel[] tiles = new TileModel[256];
public static final TileModel NONE = new NullTile(0);
public static final TileModel FLOOR_MOSSY = new Floor(1, "tile.mossy_bricks.floor");
public static final TileModel WALL_MOSSY = new Floor(2, "tile.mossy_bricks.wall");
static void register(int id, TileModel model) static void register(int id, TileModel model)
{ {
if (registered.containsKey(id)) throw new IllegalArgumentException("Tile ID " + id + " already in use."); if (id < 0 || id >= tiles.length) if (tiles[id] != null) {
registered.put(id, model); throw new IllegalArgumentException("Tile ID " + id + " already in use.");
}
tiles[id] = model;
} }
public static TileModel get(int id) public static TileModel get(int id)
{ {
final TileModel m = registered.get(id); final TileModel m = tiles[id];
if (m == null) throw new IllegalArgumentException("No tile with ID " + id + ".");
if (m == null) {
throw new IllegalArgumentException("No tile with ID " + id + ".");
}
return m; return m;
} }
} }

@ -1,15 +0,0 @@
package mightypork.rogue.world.tile.impl;
public class SimpleFloor extends SimpleTile {
public SimpleFloor(int id, String sheetKey) {
super(id, sheetKey);
}
@Override
public boolean isWalkable()
{
return true;
}
}

@ -1,71 +0,0 @@
package mightypork.rogue.world.tile.impl;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.render.Render;
import mightypork.gamecore.render.textures.TxSheet;
import mightypork.rogue.Res;
import mightypork.rogue.world.tile.TileData;
import mightypork.rogue.world.tile.TileModel;
import mightypork.rogue.world.tile.TileRenderContext;
import mightypork.util.annotations.DefaultImpl;
public abstract class SimpleTile extends TileModel {
private TxSheet sheet;
public SimpleTile(int id, String sheetKey) {
super(id);
this.sheet = Res.getTxSheet(sheetKey);
}
@Override
@DefaultImpl
public void load(TileData data, InputStream in) throws IOException
{
// do nothing
}
@Override
@DefaultImpl
public void save(TileData data, OutputStream out) throws IOException
{
// do nothing
}
@Override
public void render(TileData data, TileRenderContext context)
{
// TODO worldmap should take care of this and break the row drawing when it encounters end of screen etc
// not in screen -> no draw
if (!context.getRect().intersectsWith(DisplaySystem.getBounds())) return;
Render.quadTextured(context.getRect(), sheet.getRandomQuad(context.getNoise()));
}
@Override
@DefaultImpl
public void update(TileData item, double delta)
{
// do nothing
}
@Override
@DefaultImpl
public boolean isWalkable(TileData data)
{
return isWalkable();
}
}

@ -1,16 +0,0 @@
package mightypork.rogue.world.tile.impl;
public class SimpleWall extends SimpleTile {
public SimpleWall(int id, String sheetKey) {
super(id, sheetKey);
}
@Override
public boolean isWalkable()
{
return false;
}
}

@ -0,0 +1,18 @@
package mightypork.rogue.world.tile.models;
public class Floor extends SimpleTile {
public Floor(int id, String sheetKey)
{
super(id, sheetKey);
}
@Override
public boolean isPotentiallyWalkable()
{
return true;
}
}

@ -0,0 +1,57 @@
package mightypork.rogue.world.tile.models;
import mightypork.rogue.world.tile.Tile;
import mightypork.rogue.world.tile.TileModel;
import mightypork.rogue.world.tile.TileRenderContext;
public class NullTile extends TileModel {
private Tile inst;
public NullTile(int id)
{
super(id);
}
@Override
public void render(Tile tile, TileRenderContext context)
{
}
@Override
public boolean isWalkable(Tile tile)
{
return false;
}
@Override
public boolean isPotentiallyWalkable()
{
return true;
}
@Override
public boolean isNullTile()
{
return true;
}
@Override
public Tile create()
{
if (inst == null) {
inst = new Tile(this);
}
return inst;
}
}

@ -0,0 +1,43 @@
package mightypork.rogue.world.tile.models;
import mightypork.gamecore.render.Render;
import mightypork.gamecore.render.textures.TxSheet;
import mightypork.rogue.Res;
import mightypork.rogue.world.tile.Tile;
import mightypork.rogue.world.tile.TileModel;
import mightypork.rogue.world.tile.TileRenderContext;
import mightypork.util.annotations.DefaultImpl;
public abstract class SimpleTile extends TileModel {
protected final TxSheet sheet;
public SimpleTile(int id, String sheetKey)
{
super(id);
this.sheet = Res.getTxSheet(sheetKey);
}
@Override
public void render(Tile tile, TileRenderContext context)
{
Render.quadTextured(context.getRect(), sheet.getRandomQuad(context.getTileNoise()));
}
@Override
@DefaultImpl
public boolean isWalkable(Tile tile)
{
return isPotentiallyWalkable();
}
@Override
public abstract boolean isPotentiallyWalkable();
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save