Move and refactor engine objects

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 2 years ago
parent 82b25fbc17
commit 2cc1292946
  1. 2
      src/sig/RabiClone.java
  2. 1
      src/sig/engine/Panel.java
  3. 2
      src/sig/engine/String.java
  4. 5
      src/sig/engine/objects/AnimatedObject.java
  5. 24
      src/sig/engine/objects/Object.java
  6. 4
      src/sig/objects/ConfigureControls.java
  7. 4
      src/sig/objects/EditorRenderer.java
  8. 2
      src/sig/objects/Erinoah.java
  9. 9
      src/sig/objects/LevelRenderer.java
  10. 8
      src/sig/objects/Player.java

@ -11,6 +11,7 @@ import java.util.List;
import sig.engine.Panel;
import sig.engine.Point;
import sig.engine.objects.Object;
import sig.map.Maps;
import sig.objects.ConfigureControls;
import sig.objects.EditorRenderer;
@ -18,7 +19,6 @@ import sig.objects.LevelRenderer;
import sig.objects.Player;
import sig.engine.Key;
import sig.engine.KeyBind;
import sig.engine.Object;
import sig.engine.PaletteColor;
import java.awt.Toolkit;

@ -22,6 +22,7 @@ import java.awt.event.KeyListener;
import sig.DrawLoop;
import sig.RabiClone;
import sig.engine.objects.Object;
public class Panel extends JPanel implements Runnable,KeyListener {
JFrame window;

@ -2,6 +2,8 @@ package sig.engine;
import java.util.regex.Pattern;
import sig.engine.objects.Object;
public class String{
private StringBuilder sb;
private Point bounds = new Point(0,1);

@ -1,4 +1,7 @@
package sig.engine;
package sig.engine.objects;
import sig.engine.AnimatedSprite;
import sig.engine.Panel;
public abstract class AnimatedObject extends Object{

@ -1,7 +1,19 @@
package sig.engine;
package sig.engine.objects;
import java.awt.event.MouseEvent;
import sig.DrawLoop;
import sig.engine.Action;
import sig.engine.Alpha;
import sig.engine.AnimatedSprite;
import sig.engine.Font;
import sig.engine.GameEntity;
import sig.engine.KeyBind;
import sig.engine.MouseScrollValue;
import sig.engine.PaletteColor;
import sig.engine.Panel;
import sig.engine.Sprite;
import sig.engine.String;
import sig.engine.Transform;
public abstract class Object implements GameEntity{
double x,y;
@ -102,16 +114,16 @@ public abstract class Object implements GameEntity{
return KeyBind.isKeyHeld(a);
}
protected void KeyPressed(Action a) {
public void KeyPressed(Action a) {
}
protected void KeyReleased(Action a) {
public void KeyReleased(Action a) {
}
protected void MousePressed(MouseEvent e) {
public void MousePressed(MouseEvent e) {
}
protected void MouseReleased(MouseEvent e) {
public void MouseReleased(MouseEvent e) {
}
protected boolean MouseHeld(int mb) {
@ -122,6 +134,6 @@ public abstract class Object implements GameEntity{
* @param scrolled -1 is UP, 1 is DOWN
* @return
*/
protected void MouseScrolled(MouseScrollValue scrolled) {
public void MouseScrolled(MouseScrollValue scrolled) {
}
}

@ -13,10 +13,10 @@ import sig.engine.Action;
import sig.engine.Alpha;
import sig.engine.Font;
import sig.engine.KeyBind;
import sig.engine.Object;
import sig.engine.PaletteColor;
import sig.engine.Panel;
import sig.engine.String;
import sig.engine.objects.Object;
public class ConfigureControls extends Object{
@ -120,7 +120,7 @@ public class ConfigureControls extends Object{
}
@Override
protected void MousePressed(MouseEvent e) {
public void MousePressed(MouseEvent e) {
if ((e.getButton()==MouseEvent.BUTTON3||e.getButton()==MouseEvent.BUTTON1)&&selectedKeybind!=null) {
//Remove that keybind.
List<KeyBind> keybinds = KeyBind.KEYBINDS.get(selectedAction);

@ -87,7 +87,7 @@ public class EditorRenderer extends LevelRenderer{
}
@Override
protected void MouseScrolled(MouseScrollValue scrolled) {
public void MouseScrolled(MouseScrollValue scrolled) {
int up = scrolled==MouseScrollValue.UP?1:0;
int down = scrolled==MouseScrollValue.DOWN?1:0;
int tempIndex = selectedTile.ordinal()+down-up;
@ -174,7 +174,7 @@ public class EditorRenderer extends LevelRenderer{
@Override
@SuppressWarnings("incomplete-switch")
protected void KeyPressed(Action a) {
public void KeyPressed(Action a) {
int tileX = (int)(RabiClone.MOUSE_POS.getX()+getX())/Tile.TILE_WIDTH;
int tileY = (int)(RabiClone.MOUSE_POS.getY()+getY())/Tile.TILE_HEIGHT;
switch (a) {

@ -1,8 +1,8 @@
package sig.objects;
import sig.engine.AnimatedObject;
import sig.engine.Panel;
import sig.engine.Sprite;
import sig.engine.objects.AnimatedObject;
public class Erinoah extends AnimatedObject{

@ -4,13 +4,13 @@ import java.util.Arrays;
import sig.RabiClone;
import sig.engine.Alpha;
import sig.engine.AnimatedObject;
import sig.engine.Font;
import sig.engine.Object;
import sig.engine.PaletteColor;
import sig.engine.Panel;
import sig.engine.Sprite;
import sig.engine.Transform;
import sig.engine.objects.AnimatedObject;
import sig.engine.objects.Object;
import sig.engine.String;
import sig.map.Background;
import sig.map.CollisionType;
@ -79,6 +79,11 @@ public class LevelRenderer extends Object{
Draw_Text(4,4,new String(RabiClone.player.x_velocity),Font.PROFONT_12);
Draw_Text(4,4+Font.PROFONT_12.getGlyphHeight(),new String(RabiClone.player.slide_time3),Font.PROFONT_12);
}
//RenderCollisionGrid(p);
}
@SuppressWarnings("unused")
private void RenderCollisionGrid(byte[] p) {
for (int y=0;y<RabiClone.BASE_HEIGHT;y++) {
for (int x=0;x<RabiClone.BASE_WIDTH;x++) {
if (RabiClone.COLLISION[y*RabiClone.BASE_WIDTH+x]) {

@ -2,9 +2,9 @@ package sig.objects;
import sig.RabiClone;
import sig.engine.Action;
import sig.engine.AnimatedObject;
import sig.engine.Panel;
import sig.engine.Sprite;
import sig.engine.objects.AnimatedObject;
import sig.map.CollisionType;
import sig.map.Map;
import sig.map.Tile;
@ -171,7 +171,7 @@ public class Player extends AnimatedObject {
}
@Override
protected void KeyReleased(Action a) {
public void KeyReleased(Action a) {
if (a == Action.JUMP) {
spacebarPressed = 0;
spacebarReleased = true;
@ -187,7 +187,7 @@ public class Player extends AnimatedObject {
@Override
@SuppressWarnings("incomplete-switch")
protected void KeyPressed(Action a) {
public void KeyPressed(Action a) {
switch (state) {
case ATTACK:
break;
@ -472,6 +472,8 @@ public class Player extends AnimatedObject {
return (getX() % Tile.TILE_WIDTH)
+ (int) (getY() + getAnimatedSpr().getHeight() / 2) / Tile.TILE_HEIGHT * Tile.TILE_HEIGHT
+ (getAnimatedSpr().getHeight() / 2 - 4) - Tile.TILE_WIDTH;
default:
break;
}
return 0;
}

Loading…
Cancel
Save