Skip to content

Commit

Permalink
Prepare for release 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin.sciesinski committed Jan 10, 2021
1 parent fc1a539 commit 21f9a48
Show file tree
Hide file tree
Showing 27 changed files with 55 additions and 101 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ allprojects {
apply plugin: "maven-publish"

group = "com.gempukku.libgdx.lib"
version = '0.1.0'
version = '0.1.1'
ext {
appName = "Libgdx Graph"
gdxVersion = '1.9.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
import com.gempukku.libgdx.graph.time.DefaultTimeKeeper;
import com.gempukku.libgdx.graph.time.TimeKeeper;
import com.gempukku.libgdx.lib.camera2d.FocusCameraController;
import com.gempukku.libgdx.lib.camera2d.constraint.LockedToCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.SceneCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.CameraFocusConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.LockedToCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.focus.EntityFocus;
import com.gempukku.libgdx.lib.camera2d.focus.PositionProvider;
import com.gempukku.libgdx.lib.test.LibgdxLibTestScene;
Expand Down Expand Up @@ -125,9 +124,7 @@ public Vector2 getPosition(Vector2 position) {
FocusCameraController cameraController = new FocusCameraController(camera,
// Try to focus on the point provided by position provider
new EntityFocus(positionProvider),
new CameraFocusConstraint[]{
new LockedToCameraConstraint(new Vector2(0.5f, 0.5f))
},
new LockedToCameraConstraint(new Vector2(0.5f, 0.5f)),
// Move the camera to make sure that pixels outside of the scene bounds are not shown
new SceneCameraConstraint(new Rectangle(-2560, -414, 5120, 2000)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
import com.gempukku.libgdx.graph.time.DefaultTimeKeeper;
import com.gempukku.libgdx.graph.time.TimeKeeper;
import com.gempukku.libgdx.lib.camera2d.FocusCameraController;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.CameraFocusConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.LockedToCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.LockedToCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.focus.EntityFocus;
import com.gempukku.libgdx.lib.camera2d.focus.PositionProvider;
import com.gempukku.libgdx.lib.test.LibgdxLibTestScene;
Expand Down Expand Up @@ -119,10 +118,8 @@ public Vector2 getPosition(Vector2 position) {
FocusCameraController cameraController = new FocusCameraController(camera,
// Try to focus on the point provided by position provider
new EntityFocus(positionProvider),
new CameraFocusConstraint[]{
// Lock the camera to the focus (player)
new LockedToCameraConstraint(new Vector2(0.5f, 0.5f))
});
// Lock the camera to the focus (player)
new LockedToCameraConstraint(new Vector2(0.5f, 0.5f)));

engine.getSystem(CameraSystem.class).setConstraintCameraController(cameraController);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
import com.gempukku.libgdx.graph.time.DefaultTimeKeeper;
import com.gempukku.libgdx.graph.time.TimeKeeper;
import com.gempukku.libgdx.lib.camera2d.FocusCameraController;
import com.gempukku.libgdx.lib.camera2d.constraint.LockedToCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.SceneCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.CameraFocusConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.LockedToCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.focus.EntityFocus;
import com.gempukku.libgdx.lib.camera2d.focus.PositionProvider;
import com.gempukku.libgdx.lib.test.LibgdxLibTestScene;
Expand Down Expand Up @@ -121,9 +120,7 @@ public Vector2 getPosition(Vector2 position) {
FocusCameraController cameraController = new FocusCameraController(camera,
// Try to focus on the point provided by position provider
new EntityFocus(positionProvider),
new CameraFocusConstraint[]{
new LockedToCameraConstraint(new Vector2(0.5f, 0.5f))
},
new LockedToCameraConstraint(new Vector2(0.5f, 0.5f)),
// Move the camera to make sure that pixels outside of the scene bounds are not shown
new SceneCameraConstraint(new Rectangle(-2560, -414, 5120, 2000)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
import com.gempukku.libgdx.graph.time.TimeKeeper;
import com.gempukku.libgdx.lib.camera2d.FocusCameraController;
import com.gempukku.libgdx.lib.camera2d.constraint.FitAllCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.LockedToCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.MinimumViewportCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.SceneCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.CameraFocusConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.LockedToCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.focus.EntityFocus;
import com.gempukku.libgdx.lib.camera2d.focus.FitAllCameraFocus;
import com.gempukku.libgdx.lib.camera2d.focus.PositionProvider;
Expand Down Expand Up @@ -170,9 +169,7 @@ public Vector2 getPosition(Vector2 position) {
new EntityFocus(positionProvider1),
new EntityFocus(positionProvider2),
new EntityFocus(positionProvider3)),
new CameraFocusConstraint[]{
new LockedToCameraConstraint(new Vector2(0.5f, 0.5f))
},
new LockedToCameraConstraint(new Vector2(0.5f, 0.5f)),
new FitAllCameraConstraint(gameAreaRectangle,
new EntityFocus(positionProvider1),
new EntityFocus(positionProvider2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
import com.gempukku.libgdx.graph.time.TimeKeeper;
import com.gempukku.libgdx.lib.camera2d.FocusCameraController;
import com.gempukku.libgdx.lib.camera2d.constraint.SceneCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.CameraFocusConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.SnapToWindowCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.SnapToWindowCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.focus.EntityFocus;
import com.gempukku.libgdx.lib.camera2d.focus.PositionProvider;
import com.gempukku.libgdx.lib.test.LibgdxLibTestScene;
Expand Down Expand Up @@ -128,9 +127,7 @@ public Vector2 getPosition(Vector2 position) {
FocusCameraController cameraController = new FocusCameraController(camera,
// Try to focus on the point provided by position provider
new EntityFocus(positionProvider),
new CameraFocusConstraint[]{
new SnapToWindowCameraConstraint(snapRectangle, new Vector2(0.1f, 0.1f)),
},
new SnapToWindowCameraConstraint(snapRectangle, new Vector2(0.1f, 0.1f)),
// Move the camera to make sure that pixels outside of the scene bounds are not shown
new SceneCameraConstraint(new Rectangle(-2560, -414, 5120, 2000)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
import com.gempukku.libgdx.graph.time.DefaultTimeKeeper;
import com.gempukku.libgdx.graph.time.TimeKeeper;
import com.gempukku.libgdx.lib.camera2d.FocusCameraController;
import com.gempukku.libgdx.lib.camera2d.constraint.LockedToWindowCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.SceneCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.CameraFocusConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.LockedToWindowCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.SnapToWindowCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.SnapToWindowCameraConstraint;
import com.gempukku.libgdx.lib.camera2d.focus.EntityFocus;
import com.gempukku.libgdx.lib.camera2d.focus.PositionProvider;
import com.gempukku.libgdx.lib.test.LibgdxLibTestScene;
Expand Down Expand Up @@ -131,10 +130,8 @@ public Vector2 getPosition(Vector2 position) {
FocusCameraController cameraController = new FocusCameraController(camera,
// Try to focus on the point provided by position provider
new EntityFocus(positionProvider),
new CameraFocusConstraint[]{
new SnapToWindowCameraConstraint(snapRectangle, new Vector2(0.1f, 0.1f)),
new LockedToWindowCameraConstraint(lockRectangle)
},
new SnapToWindowCameraConstraint(snapRectangle, new Vector2(0.1f, 0.1f)),
new LockedToWindowCameraConstraint(lockRectangle),
// Move the camera to make sure that pixels outside of the scene bounds are not shown
new SceneCameraConstraint(new Rectangle(-2560, -414, 5120, 2000)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Vector2;
import com.gempukku.libgdx.lib.camera2d.constraint.CameraConstraint;
import com.gempukku.libgdx.lib.camera2d.constraint.focus.CameraFocusConstraint;
import com.gempukku.libgdx.lib.camera2d.focus.CameraFocus;

public class FocusCameraController {
private Camera camera;
private CameraFocus cameraFocus;
private CameraFocusConstraint[] focusConstraints;
private CameraConstraint[] constraints;

private Vector2 tmpVector = new Vector2();

public FocusCameraController(Camera camera, CameraFocus cameraFocus,
CameraFocusConstraint[] focusConstraints,
CameraConstraint... constraints) {
this.camera = camera;
this.cameraFocus = cameraFocus;
this.focusConstraints = focusConstraints;
this.constraints = constraints;
}

Expand All @@ -33,11 +29,8 @@ public void setCamera(Camera camera) {

public void update(float delta) {
Vector2 focus = cameraFocus.getFocus(tmpVector);
for (CameraFocusConstraint constraint : focusConstraints) {
constraint.applyConstraint(camera, focus, delta);
}
for (CameraConstraint constraint : constraints) {
constraint.applyConstraint(camera, delta);
constraint.applyConstraint(camera, focus, delta);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.gempukku.libgdx.lib.camera2d.constraint;

import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Vector2;

public interface CameraConstraint {
void applyConstraint(Camera camera, float delta);
void applyConstraint(Camera camera, Vector2 focus, float delta);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void removeCameraFocus(CameraFocus cameraFocus) {
}

@Override
public void applyConstraint(Camera camera, float delta) {
public void applyConstraint(Camera camera, Vector2 focus, float delta) {
boolean first = true;
for (CameraFocus cameraFocus : cameraFocusArray) {
tmpVector = cameraFocus.getFocus(tmpVector);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.gempukku.libgdx.lib.camera2d.constraint.focus;
package com.gempukku.libgdx.lib.camera2d.constraint;

import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

public class LerpToWindowCameraConstraint implements CameraFocusConstraint {
public class LerpToWindowCameraConstraint implements CameraConstraint {
private Rectangle snapRectangle;
private Vector2 partPerSecond;
private Vector2 maxSpeed;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.gempukku.libgdx.lib.camera2d.constraint.focus;
package com.gempukku.libgdx.lib.camera2d.constraint;

import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Vector2;

public class LockedToCameraConstraint implements CameraFocusConstraint {
public class LockedToCameraConstraint implements CameraConstraint {
private Vector2 anchor = new Vector2();

public LockedToCameraConstraint(Vector2 anchor) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.gempukku.libgdx.lib.camera2d.constraint.focus;
package com.gempukku.libgdx.lib.camera2d.constraint;

import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

public class LockedToWindowCameraConstraint implements CameraFocusConstraint {
public class LockedToWindowCameraConstraint implements CameraConstraint {
private Rectangle windowRectangle;

private Vector2 tmpVector = new Vector2();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gempukku.libgdx.lib.camera2d.constraint;

import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Vector2;

public class MinimumViewportCameraConstraint implements CameraConstraint {
private float width;
Expand All @@ -24,7 +25,7 @@ public void setSize(float width, float height) {
}

@Override
public void applyConstraint(Camera camera, float delta) {
public void applyConstraint(Camera camera, Vector2 focus, float delta) {
float cameraAspectRatio = camera.viewportWidth / camera.viewportHeight;

float resultWidth = Math.max(width, camera.viewportWidth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;

public class PixelPerfectCameraConstraint implements CameraConstraint {
@Override
public void applyConstraint(Camera camera, float delta) {
public void applyConstraint(Camera camera, Vector2 focus, float delta) {
camera.position.x = MathUtils.round(camera.position.x);
camera.position.y = MathUtils.round(camera.position.y);
camera.viewportWidth = MathUtils.round(camera.viewportWidth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public SceneCameraConstraint(Rectangle scene) {
}

@Override
public void applyConstraint(Camera camera, float delta) {
public void applyConstraint(Camera camera, Vector2 focus, float delta) {
Vector2 visibleMin = tmpVector1.set(camera.position.x, camera.position.y).add(-camera.viewportWidth / 2f, -camera.viewportHeight / 2f);
Vector2 visibleMax = tmpVector2.set(camera.position.x, camera.position.y).add(+camera.viewportWidth / 2f, +camera.viewportHeight / 2f);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.gempukku.libgdx.lib.camera2d.constraint.focus;
package com.gempukku.libgdx.lib.camera2d.constraint;

import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

public class SnapToWindowCameraConstraint implements CameraFocusConstraint {
public class SnapToWindowCameraConstraint implements CameraConstraint {
private Rectangle snapRectangle;
private Vector2 snapSpeed;

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void testWithOneFocus() {

OrthographicCamera camera = new OrthographicCamera(4, 3);

cameraConstraint.applyConstraint(camera, 0);
cameraConstraint.applyConstraint(camera, null, 0);

assertEquals(0, camera.viewportWidth, 0.0001f);
assertEquals(0, camera.viewportHeight, 0.0001f);
Expand All @@ -34,7 +34,7 @@ public void testWithTwoFociHorizontally() {

OrthographicCamera camera = new OrthographicCamera(4, 3);

cameraConstraint.applyConstraint(camera, 0);
cameraConstraint.applyConstraint(camera, null, 0);

assertEquals(2f, camera.viewportWidth, 0.0001f);
assertEquals(1.5f, camera.viewportHeight, 0.0001f);
Expand All @@ -50,7 +50,7 @@ public void testWithTwoFociVertically() {

OrthographicCamera camera = new OrthographicCamera(4, 3);

cameraConstraint.applyConstraint(camera, 0);
cameraConstraint.applyConstraint(camera, null, 0);

assertEquals(2.6666f, camera.viewportWidth, 0.0001f);
assertEquals(2f, camera.viewportHeight, 0.0001f);
Expand All @@ -66,7 +66,7 @@ public void testWithTwoFociBothSides() {

OrthographicCamera camera = new OrthographicCamera(4, 3);

cameraConstraint.applyConstraint(camera, 0);
cameraConstraint.applyConstraint(camera, null, 0);

assertEquals(8, camera.viewportWidth, 0.0001f);
assertEquals(6, camera.viewportHeight, 0.0001f);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gempukku.libgdx.lib.camera2d.constraint.focus;
package com.gempukku.libgdx.lib.camera2d.constraint;

import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Rectangle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gempukku.libgdx.lib.camera2d.constraint.focus;
package com.gempukku.libgdx.lib.camera2d.constraint;

import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Vector2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gempukku.libgdx.lib.camera2d.constraint.focus;
package com.gempukku.libgdx.lib.camera2d.constraint;

import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Rectangle;
Expand Down
Loading

0 comments on commit 21f9a48

Please sign in to comment.