Implement three camera views

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent f35a5a6c88
commit 7a7f9359fd
  1. BIN
      maps/world1.map
  2. 2
      src/sig/objects/LevelRenderer.java
  3. 16
      src/sig/objects/Player.java

Binary file not shown.

@ -46,7 +46,7 @@ public class LevelRenderer extends Object{
* @param object
*/
protected void Draw_Object(Object object) {
super.Draw_Sprite(Math.round(object.getX()-this.getX()-object.getSprite().getWidth()/2), Math.round(object.getY()-this.getY()-object.getSprite().getHeight()/2), object.getSprite());
super.Draw_Sprite(object.getX()-this.getX()-object.getSprite().getWidth()/2, Math.round(object.getY()-this.getY()-object.getSprite().getHeight()/2), object.getSprite());
}
private void DrawTile(double x, double y, Tile tile) {

@ -5,6 +5,7 @@ import sig.engine.Object;
import sig.engine.Panel;
import sig.engine.Sprite;
import sig.map.CollisionType;
import sig.map.Map;
import sig.map.Tile;
import sig.map.View;
@ -33,6 +34,9 @@ public class Player extends Object{
int maxJumpCount=1;
int jumpCount=maxJumpCount;
final double viewBoundaryX=RabiClone.BASE_WIDTH/3;
final double viewBoundaryY=RabiClone.BASE_HEIGHT/3;
public Player(Panel panel) {
super(panel);
this.setSprite(Sprite.NANA_SMALL);
@ -55,8 +59,20 @@ public class Player extends Object{
RabiClone.level_renderer.setY(getY()-RabiClone.BASE_HEIGHT/2);
break;
case FIXED:
RabiClone.level_renderer.setX((tileX/Tile.TILE_SCREEN_COUNT_X)*Map.MAP_WIDTH);
RabiClone.level_renderer.setY((tileY/Tile.TILE_SCREEN_COUNT_Y)*Map.MAP_HEIGHT);
break;
case LIGHT_FOLLOW:
if (getX()-RabiClone.level_renderer.getX()<viewBoundaryX) {
RabiClone.level_renderer.setX(getX()-viewBoundaryX);
} else if (getX()-RabiClone.level_renderer.getX()>RabiClone.BASE_WIDTH-viewBoundaryX) {
RabiClone.level_renderer.setX(getX()-(RabiClone.BASE_WIDTH-viewBoundaryX));
}
if (getY()-RabiClone.level_renderer.getY()<viewBoundaryY) {
RabiClone.level_renderer.setY(getY()-viewBoundaryY);
} else if (getY()-RabiClone.level_renderer.getY()>RabiClone.BASE_HEIGHT-viewBoundaryY) {
RabiClone.level_renderer.setY(getY()-(RabiClone.BASE_HEIGHT-viewBoundaryY));
}
break;
case LIGHT_HORIZONTAL_FOLLOW:
break;

Loading…
Cancel
Save