Level Changes

Added in Level 8.
Also removed the walls that the player had to pass through in levels 4
onwards.
Edited Level 4 to introduce spikes and added a 'SPIKES' layer in Tiled.
Also added the texture to assets. Unfortunately my code is wrong and it
isn't working so level 4 is currently broken.
This commit is contained in:
ESloman 2016-02-22 12:34:54 +00:00
parent 61322d04d4
commit 299d1a2d94
6 changed files with 72 additions and 13 deletions

View file

@ -0,0 +1,35 @@
package com.game.actor;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.World;
import com.game.misc.Box2dUtils;
import com.game.misc.Vars;
import static com.game.misc.Vars.PPM;
/**
* Created by Elliot on 22/02/2016.
*/
public class Spike extends Base {
public Spike(World world, Vector2 pos, Vector2 size, Colours curColour, short categoryBits, short maskBits) {
super(world, pos, size, "STATIC", curColour);
body = Box2dUtils.makeBody(world,
BodyDef.BodyType.StaticBody,
pos
);
Box2dUtils.makePolygon(body, size, "", false, categoryBits, maskBits);
Box2dUtils.makeChain(body,
new Vector2[]{
new Vector2((-size.x / 2 + 5) / PPM, (size.y / 2 + 5) / PPM),
new Vector2((size.x / 2 - 5) / PPM, (size.y / 2 + 5) / PPM)
},
"SPIKE",
true,
Vars.BIT_MISC,
Vars.BIT_PLAYER
);
}
}

View file

@ -108,6 +108,7 @@ public class Loading extends AbstractScreen {
app.assets.load("textures/position0.png", Texture.class);
app.assets.load("textures/position1.png", Texture.class);
app.assets.load("textures/position2.png", Texture.class);
app.assets.load("textures/Spikes.png", Texture.class);
for(int i = 1; i <= 10; i++)
{
app.assets.load("textures/level" + i + "Intro.png", Texture.class);

View file

@ -29,6 +29,7 @@ import com.game.actor.Base;
import com.game.actor.Platform;
import com.game.actor.Player;
import com.game.App;
import com.game.actor.Spike;
import com.game.managers.ScreenManager;
import com.game.misc.Box2dUtils;
import com.game.misc.CameraUtils;
@ -55,8 +56,6 @@ public class Play extends AbstractScreen {
private OrthographicCamera b2dCam; // TODO, remove
// TileMap and Map Renderer
private TiledMap tile1;
private TiledMap tile2;
private TiledMap tileMap;
private OrthogonalTiledMapRenderer tmr;
private float mapWidth, mapHeight;
@ -65,6 +64,7 @@ public class Play extends AbstractScreen {
// All Actors in level
private Player player;
private ArrayList<Platform> platforms = new ArrayList<Platform>();
private ArrayList<Spike> spikes = new ArrayList<Spike>();
// Intro window
private boolean isIntro;
@ -214,13 +214,7 @@ public class Play extends AbstractScreen {
@Override
public void handleInput() {
if(Gdx.input.isKeyPressed(Input.Keys.SPACE))
{
jumpSound.play();
player.jump();
}
if(Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE))
if(Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE))
{
isPaused = !isPaused;
System.out.println("isPaused: " + isPaused);
@ -254,6 +248,12 @@ public class Play extends AbstractScreen {
progressTexture = app.assets.get("textures/player_yellow.png", Texture.class);
}
if(Gdx.input.isKeyPressed(Input.Keys.SPACE))
{
jumpSound.play();
player.jump();
}
}
if(Gdx.input.isKeyJustPressed(Input.Keys.V)) { isDebug = !isDebug; }
@ -280,6 +280,7 @@ public class Play extends AbstractScreen {
TiledMapTileLayer platformLayer = (TiledMapTileLayer)tileMap.getLayers().get("PLATFORM");
TiledMapTileLayer spikeLayer = (TiledMapTileLayer)tileMap.getLayers().get("SPIKES");
MapLayer boundaryLayer = tileMap.getLayers().get("BOUNDARY");
PolylineMapObject polylineObj = (PolylineMapObject)boundaryLayer.getObjects().get(0);
@ -311,6 +312,19 @@ public class Play extends AbstractScreen {
else if(cell.getTile().getId() == 3) { platforms.add(new Platform(world, new Vector2((col + 0.5f) * tileSize.x, (row + 0.5f) * tileSize.y), new Vector2(tileSize.x, tileSize.y), Base.Colours.BLUE, Vars.BIT_BLUE, Vars.BIT_PLAYER)); }
}
}
for(int row = 0; row < spikeLayer.getHeight(); row++)
{
for(int col = 0; col < spikeLayer.getWidth(); col++)
{
TiledMapTileLayer.Cell cell = spikeLayer.getCell(col, row);
if(cell == null) { continue; }
if(cell.getTile() == null) { continue; }
if(cell.getTile().getId() == 0) { spikes.add(new Spike(world, new Vector2((col + 0.5f) * tileSize.x, (row + 0.5f) * tileSize.y), new Vector2(tileSize.x, tileSize.y), Base.Colours.RED, Vars.BIT_RED, Vars.BIT_PLAYER)); }
}
}
}
private void initBoundary(PolylineMapObject polylineObj, String userData, boolean isSensor)