Editor background drawing should be based on the center of the view area instead of the upper-left corner

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 9bef6c0caf
commit 099a19c461
  1. 3
      src/sig/RabiClone.java
  2. 17
      src/sig/objects/EditorRenderer.java
  3. 1
      src/sig/objects/weapons/KnifeSwing.java
  4. 1
      src/sig/objects/weapons/KnifeSwing2.java

@ -2,11 +2,8 @@ package sig;
import javax.swing.JFrame;
import net.java.games.input.AbstractController;
import net.java.games.input.Controller;
import net.java.games.input.ControllerEnvironment;
import net.java.games.input.ControllerEvent;
import net.java.games.input.ControllerListener;
import java.util.ArrayList;
import java.util.Arrays;

@ -301,7 +301,20 @@ public class EditorRenderer extends LevelRenderer{
dataTileValue.clear();
}break;
}
}
}
@Override
public void drawBackground(byte[] p) {
int screenX = (int)(getX()+RabiClone.BASE_WIDTH/2)/Tile.TILE_WIDTH;
int screenY = (int)(getY()+RabiClone.BASE_HEIGHT/2)/Tile.TILE_HEIGHT;
Background targetBackground = RabiClone.CURRENT_MAP.getBackground(screenX, screenY);
for (int y=0;y<RabiClone.BASE_HEIGHT;y++) {
for (int x=0;x<RabiClone.BASE_WIDTH;x++) {
int index = y*RabiClone.BASE_WIDTH+x;
p[index] = targetBackground.getPixels()[
((y+(int)(getY()*targetBackground.getScrollSpeed()))%targetBackground.getHeight())*targetBackground.getWidth()+((x+(int)(getX()*targetBackground.getScrollSpeed()))%targetBackground.getWidth())
];
}
}
}
}

@ -5,7 +5,6 @@ import sig.engine.Panel;
import sig.engine.Transform;
import sig.objects.actor.AttachableObject;
import sig.objects.actor.PhysicsObject;
import sig.objects.actor.State;
import sig.engine.objects.AnimatedObject;
import sig.engine.objects.Object;

@ -5,7 +5,6 @@ import sig.engine.Panel;
import sig.engine.Transform;
import sig.objects.actor.AttachableObject;
import sig.objects.actor.PhysicsObject;
import sig.objects.actor.State;
import sig.engine.objects.AnimatedObject;
import sig.engine.objects.Object;

Loading…
Cancel
Save