Skip to content

Commit

Permalink
Merge pull request #25 from AlxTray/new-platforms-overlay-textures
Browse files Browse the repository at this point in the history
New platforms overlay textures
  • Loading branch information
AlxTray authored Oct 9, 2024
2 parents fc3cf6c + 452dae5 commit 8e77806
Show file tree
Hide file tree
Showing 32 changed files with 390 additions and 254 deletions.
1 change: 1 addition & 0 deletions assets/endless.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"platforms": [
{
"type": "normal",
"orientation": "NORTH",
"x": 0,
"y": 0,
"height": 54,
Expand Down
34 changes: 31 additions & 3 deletions assets/levels/level1.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,59 @@
"platforms": [
{
"type": "normal",
"orientation": "NORTH",
"x": 0,
"y": 0,
"height": 54,
"width": 216
},
{
"type": "cracked",
"orientation": "NORTH",
"x": 230,
"y": 0,
"height": 36,
"width": 252
},
{
"type": "normal",
"type": "bouncy",
"orientation": "NORTH",
"x": 550,
"y": 0,
"height": 18,
"width": 198
},
{
"type": "gravity",
"orientation": "NORTH",
"x": 870,
"y": 0,
"height": 18,
"width": 90
},
{
"type": "normal",
"orientation": "SOUTH",
"x": 800,
"y": 350,
"height": 54,
"width": 324
},
{
"type": "gravity",
"orientation": "SOUTH",
"x": 1200,
"y": 350,
"height": 54,
"width": 144
},
{
"type": "gravity",
"orientation": "NORTH",
"x": 1200,
"y": 0,
"height": 18,
"width": 900
"height": 36,
"width": 144
}
]
}
Expand Down
27 changes: 0 additions & 27 deletions assets/levels/level2.json

This file was deleted.

Binary file added assets/textures/level/bouncy_platform_overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/level/gravity_platform_overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package io.github.alxtray.groundclimber.bodies;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import io.github.alxtray.groundclimber.renderers.EnvironmentObjectVisitor;
import io.github.alxtray.groundclimber.enums.ObjectStatus;
import io.github.alxtray.groundclimber.visitors.EnvironmentObjectListenerVisitor;
import io.github.alxtray.groundclimber.visitors.EnvironmentObjectRenderVisitor;

public abstract class EnvironmentObject {
public abstract void acceptRender(EnvironmentObjectVisitor visitor, SpriteBatch batch);
public abstract void acceptRender(EnvironmentObjectRenderVisitor visitor, SpriteBatch batch);
public abstract ObjectStatus acceptContact(EnvironmentObjectListenerVisitor visitor, Player player);

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Player {
private static final float PLAYER_FRICTION = 0.3f;
private static final float PLAYER_RESTITUTION = 1f;
private final Body body;
private boolean upsideDown = false;

Check warning on line 11 in core/src/main/java/io/github/alxtray/groundclimber/bodies/Player.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Redundant field initialization

Field initialization to `false` is redundant

public Player(World world, int x, int y, int radius) {
BodyDef bodyDef = new BodyDef();
Expand Down Expand Up @@ -37,4 +38,12 @@ public Vector2 getPosition() {
return body.getPosition();
}

public boolean isUpsideDown() {
return upsideDown;
}

public void toggleUpsideDown() {
this.upsideDown = !upsideDown;

Check warning on line 46 in core/src/main/java/io/github/alxtray/groundclimber/bodies/Player.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unnecessary 'this' qualifier

`this` is unnecessary in this context
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.github.alxtray.groundclimber.bodies.platforms;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.physics.box2d.World;
import io.github.alxtray.groundclimber.bodies.Player;
import io.github.alxtray.groundclimber.enums.PlatformOrientation;
import io.github.alxtray.groundclimber.enums.ObjectStatus;
import io.github.alxtray.groundclimber.utilities.AssetLibrary;
import io.github.alxtray.groundclimber.visitors.EnvironmentObjectListenerVisitor;

public class BouncyPlatform extends Platform {
public BouncyPlatform(World world, PlatformOrientation orientation, float x, float y, float height, float width) {

Check warning on line 12 in core/src/main/java/io/github/alxtray/groundclimber/bodies/platforms/BouncyPlatform.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constructor with too many parameters

`BouncyPlatform()` has too many parameters (num parameters = 6)
super(world, orientation, x, y, height, width);
body.setUserData(this);
}

public Texture getOverlayTexture() {
return AssetLibrary.getInstance().getAsset("bouncy_platform_overlay", Texture.class);
}

@Override
public ObjectStatus acceptContact(EnvironmentObjectListenerVisitor visitor, Player player) {
visitor.visitBouncyPlatform(player);
return ObjectStatus.NoChange;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.github.alxtray.groundclimber.bodies.platforms;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.physics.box2d.World;
import io.github.alxtray.groundclimber.bodies.Player;
import io.github.alxtray.groundclimber.enums.LogLevel;
import io.github.alxtray.groundclimber.enums.PlatformOrientation;
import io.github.alxtray.groundclimber.enums.ObjectStatus;
import io.github.alxtray.groundclimber.utilities.AssetLibrary;
import io.github.alxtray.groundclimber.utilities.Logger;
import io.github.alxtray.groundclimber.visitors.EnvironmentObjectListenerVisitor;
import text.formic.Stringf;

public class CrackedPlatform extends Platform {
private int crackLevel;

public CrackedPlatform(World world, PlatformOrientation orientation, float x, float y, float height, float width) {

Check warning on line 17 in core/src/main/java/io/github/alxtray/groundclimber/bodies/platforms/CrackedPlatform.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constructor with too many parameters

`CrackedPlatform()` has too many parameters (num parameters = 6)
super(world, orientation, x, y, height, width);
crackLevel = 0;
body.setUserData(this);
}

public Texture getOverlayTexture() {
return AssetLibrary.getInstance().getAsset("cracked_platform_overlay", Texture.class);
}

@Override
public ObjectStatus acceptContact(EnvironmentObjectListenerVisitor visitor, Player player) {
visitor.visitCrackedPlatform(this);
return (crackLevel >= 3) ? ObjectStatus.Remove : ObjectStatus.NoChange;
}

public void incrementCrackLevel() {
crackLevel++;
Logger.log(
"CrackedPlatform",
Stringf.format(
"Cracked level for platform at (%s, %s) is now %s",
body.getPosition().x,
body.getPosition().y,
crackLevel),
LogLevel.DEBUG);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.github.alxtray.groundclimber.bodies.platforms;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.physics.box2d.World;
import io.github.alxtray.groundclimber.bodies.Player;
import io.github.alxtray.groundclimber.enums.PlatformOrientation;
import io.github.alxtray.groundclimber.enums.ObjectStatus;
import io.github.alxtray.groundclimber.utilities.AssetLibrary;
import io.github.alxtray.groundclimber.visitors.EnvironmentObjectListenerVisitor;

public class GravityPlatform extends Platform {
public GravityPlatform(World world, PlatformOrientation orientation, float x, float y, float height, float width) {

Check warning on line 12 in core/src/main/java/io/github/alxtray/groundclimber/bodies/platforms/GravityPlatform.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constructor with too many parameters

`GravityPlatform()` has too many parameters (num parameters = 6)
super(world, orientation, x, y, height, width);
body.setUserData(this);
}

public Texture getOverlayTexture() {
return AssetLibrary.getInstance().getAsset("gravity_platform_overlay", Texture.class);
}

@Override
public ObjectStatus acceptContact(EnvironmentObjectListenerVisitor visitor, Player player) {
visitor.visitGravityPlatform(player);
return ObjectStatus.NoChange;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.github.alxtray.groundclimber.bodies.platforms;

import com.badlogic.gdx.physics.box2d.World;
import io.github.alxtray.groundclimber.enums.PlatformOrientation;

public class NormalPlatform extends Platform {
public NormalPlatform(World world, PlatformOrientation orientation, float x, float y, float height, float width) {

Check warning on line 7 in core/src/main/java/io/github/alxtray/groundclimber/bodies/platforms/NormalPlatform.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constructor with too many parameters

`NormalPlatform()` has too many parameters (num parameters = 6)
super(world, orientation, x, y, height, width);
body.setUserData(this);
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
package io.github.alxtray.groundclimber.bodies;
package io.github.alxtray.groundclimber.bodies.platforms;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.*;
import io.github.alxtray.groundclimber.renderers.EnvironmentObjectVisitor;
import io.github.alxtray.groundclimber.bodies.EnvironmentObject;
import io.github.alxtray.groundclimber.bodies.Player;
import io.github.alxtray.groundclimber.enums.PlatformOrientation;
import io.github.alxtray.groundclimber.enums.ObjectStatus;
import io.github.alxtray.groundclimber.visitors.EnvironmentObjectListenerVisitor;
import io.github.alxtray.groundclimber.visitors.EnvironmentObjectRenderVisitor;

public class Platform extends EnvironmentObject {
protected final Body body;
private final PlatformOrientation orientation;
private final float height;
private final float width;

public Platform(World world, float x, float y, float height, float width) {
public Platform(World world, PlatformOrientation orientation, float x, float y, float height, float width) {

Check warning on line 20 in core/src/main/java/io/github/alxtray/groundclimber/bodies/platforms/Platform.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constructor with too many parameters

`Platform()` has too many parameters (num parameters = 6)
this.orientation = orientation;
this.height = height;
this.width = width;

Expand All @@ -30,15 +38,28 @@ public Platform(World world, float x, float y, float height, float width) {
shape.dispose();
}

public Texture getOverlayTexture() {
return null;

Check warning on line 42 in core/src/main/java/io/github/alxtray/groundclimber/bodies/platforms/Platform.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Return of 'null'

Return of `null`
}

@Override
public void acceptRender(EnvironmentObjectVisitor visitor, SpriteBatch batch) {
public void acceptRender(EnvironmentObjectRenderVisitor visitor, SpriteBatch batch) {
visitor.visitPlatform(this, batch);
}

@Override
public ObjectStatus acceptContact(EnvironmentObjectListenerVisitor visitor, Player player) {
return ObjectStatus.NoChange;
}

public Body getBody() {
return body;
}

public PlatformOrientation getOrientation() {
return orientation;
}

public Vector2 getPosition() {
return body.getPosition();
}
Expand Down
Loading

0 comments on commit 8e77806

Please sign in to comment.