Move keyboard controls into respective renderer objects

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago committed by GitHub
parent 3dc3129ac1
commit 6ec8dd01ba
  1. BIN
      bin/RabiClone.jar
  2. 24
      src/sig/RabiClone.java
  3. 7
      src/sig/objects/EditorRenderer.java
  4. 18
      src/sig/objects/LevelRenderer.java

Binary file not shown.

@ -74,7 +74,6 @@ public class RabiClone {
RENDERHINTS.put(RenderingHints.KEY_COLOR_RENDERING,RenderingHints.VALUE_COLOR_RENDER_SPEED);
RENDERHINTS.put(RenderingHints.KEY_DITHERING,RenderingHints.VALUE_DITHER_DISABLE);
RENDERHINTS.put(RenderingHints.KEY_FRACTIONALMETRICS,RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
RENDERHINTS.put(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
RENDERHINTS.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_SPEED);
Key.InitializeKeyConversionMap();
@ -120,25 +119,6 @@ public class RabiClone {
KeyBind.poll();
if (Key.isKeyHeld(KeyEvent.VK_F1)) {
if (level_renderer instanceof EditorRenderer) {
OBJ.remove(level_renderer);
OBJ.add(level_renderer = new LevelRenderer(p));
StartGame();
}
}
if (Key.isKeyHeld(KeyEvent.VK_F2)) {
if (!(level_renderer instanceof EditorRenderer)) {
OBJ.clear();
ResetGame();
OBJ.add(level_renderer = new EditorRenderer(p));
}
}
if (Key.isKeyHeld(KeyEvent.VK_F6)) {
OBJ.clear();
ResetGame();
OBJ.add(control_settings_menu = new ConfigureControls(p));
}
if (Key.isKeyHeld(KeyEvent.VK_F5) && System.currentTimeMillis() - lastControllerScan > 5000) {
CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().rescanControllers();
System.out.println(Arrays.toString(CONTROLLERS));
@ -193,14 +173,14 @@ public class RabiClone {
}
}
private static void ResetGame() {
public static void ResetGame() {
player = null;
level_renderer = null;
control_settings_menu = null;
// System.gc();
}
private static void StartGame() {
public static void StartGame() {
// System.gc();
OBJ.add(player = new Player(p));
//OBJ.add(new Erinoah(p));

@ -2,11 +2,13 @@ package sig.objects;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.awt.event.KeyEvent;
import sig.RabiClone;
import sig.engine.Action;
import sig.engine.Alpha;
import sig.engine.Font;
import sig.engine.Key;
import sig.engine.MouseScrollValue;
import sig.engine.PaletteColor;
import sig.engine.Panel;
@ -188,5 +190,10 @@ public class EditorRenderer extends LevelRenderer{
RabiClone.CURRENT_MAP.setBackground(tileX,tileY,Background.values()[(RabiClone.CURRENT_MAP.getBackground(tileX, tileY).ordinal()+1)%Background.values().length]);
}break;
}
if (Key.isKeyHeld(KeyEvent.VK_F1)) {
RabiClone.OBJ.remove(RabiClone.level_renderer);
RabiClone.OBJ.add(RabiClone.level_renderer = new LevelRenderer(RabiClone.p));
RabiClone.StartGame();
}
}
}

@ -1,8 +1,12 @@
package sig.objects;
import java.awt.event.KeyEvent;
import sig.RabiClone;
import sig.engine.Action;
import sig.engine.Alpha;
import sig.engine.Font;
import sig.engine.Key;
import sig.engine.PaletteColor;
import sig.engine.Panel;
import sig.engine.Sprite;
@ -103,5 +107,19 @@ public class LevelRenderer extends Object{
protected void DrawTransparentTile(double x, double y, Tile tile, Alpha alpha) {
Draw_Sprite_Partial_Ext(x,y, tile.getSpriteSheetX()*tile.getTileWidth(), tile.getSpriteSheetY()*tile.getTileHeight(), tile.getTileWidth(), tile.getTileHeight(), getSprite(), alpha, Transform.NONE);
}
@Override
public void KeyPressed(Action a) {
if (Key.isKeyHeld(KeyEvent.VK_F2)) {
RabiClone.OBJ.clear();
RabiClone.ResetGame();
RabiClone.OBJ.add(RabiClone.level_renderer = new EditorRenderer(RabiClone.p));
}
if (Key.isKeyHeld(KeyEvent.VK_F3)) {
RabiClone.OBJ.clear();
RabiClone.ResetGame();
RabiClone.OBJ.add(RabiClone.control_settings_menu = new ConfigureControls(RabiClone.p));
}
}
}

Loading…
Cancel
Save