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:
parent
61322d04d4
commit
299d1a2d94
6 changed files with 72 additions and 13 deletions
|
@ -1,14 +1,17 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="8" tilewidth="64" tileheight="64" nextobjectid="30">
|
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="8" tilewidth="64" tileheight="64" nextobjectid="46">
|
||||||
<tileset firstgid="1" name="platformSet" tilewidth="64" tileheight="64" tilecount="3" columns="3">
|
<tileset firstgid="1" name="platformSet" tilewidth="64" tileheight="64" tilecount="3" columns="3">
|
||||||
<image source="../spritesheets/platformSet.png" width="192" height="64"/>
|
<image source="../spritesheets/platformSet.png" width="192" height="64"/>
|
||||||
</tileset>
|
</tileset>
|
||||||
<tileset firstgid="4" name="player" tilewidth="64" tileheight="64" tilecount="1" columns="1">
|
<tileset firstgid="4" name="player" tilewidth="64" tileheight="64" tilecount="1" columns="1">
|
||||||
<image source="../textures/player_red.png" width="64" height="64"/>
|
<image source="../textures/player_red.png" width="64" height="64"/>
|
||||||
</tileset>
|
</tileset>
|
||||||
|
<tileset firstgid="5" name="Spikes" tilewidth="64" tileheight="64" tilecount="1" columns="1">
|
||||||
|
<image source="../textures/spikes.png" width="64" height="64"/>
|
||||||
|
</tileset>
|
||||||
<layer name="PLATFORM" width="50" height="8">
|
<layer name="PLATFORM" width="50" height="8">
|
||||||
<data encoding="base64" compression="zlib">
|
<data encoding="base64" compression="zlib">
|
||||||
eJxjYBgFIwkwDbQDqARo4Q9qm8mEhEGAEQsGyTFjwYTMw+dWbHLo9mIDxLqDWDtJsRuXmcToJSZMSLGTEoAtDIdzngMA3GQAZw==
|
eJxjYBgFo2AU0AIwIWEQYMSCQYAZCyZkHhMONbgANnvRAbHuIBUQYzcleskNE1oAWoXhYAUAsHwAUw==
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
<objectgroup name="PLAYER">
|
<objectgroup name="PLAYER">
|
||||||
|
@ -29,4 +32,9 @@
|
||||||
<polyline points="0,0 128,0 128,512 0,512 0,0"/>
|
<polyline points="0,0 128,0 128,512 0,512 0,0"/>
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
|
<objectgroup name="SPIKES">
|
||||||
|
<object id="41" gid="5" x="1344" y="256" width="64" height="64"/>
|
||||||
|
<object id="44" gid="5" x="1728" y="256" width="64" height="64"/>
|
||||||
|
<object id="45" gid="5" x="2688" y="384" width="64" height="64"/>
|
||||||
|
</objectgroup>
|
||||||
</map>
|
</map>
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
</tileset>
|
</tileset>
|
||||||
<layer name="PLATFORM" width="50" height="8">
|
<layer name="PLATFORM" width="50" height="8">
|
||||||
<data encoding="base64" compression="zlib">
|
<data encoding="base64" compression="zlib">
|
||||||
eJxjYBgFo2AUDARgIoAHC2AmgKkB0P2Oyy5GApge4YnL7pEIALMwAF8=
|
eJxjYBgFgwEwAzHjQDuCQsCExGZEwuiAGYoHIyAUB0wMqP4kxjxkM4n1NyVhRIr78JlBql9BAFeckwIGMn1QGnbU8P9AAHLiGgQAlYAAOA==
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
<objectgroup name="PLAYER">
|
<objectgroup name="PLAYER">
|
||||||
<object id="24" gid="4" x="0" y="320" width="64" height="64"/>
|
<object id="24" gid="4" x="0" y="128" width="64" height="64"/>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
<objectgroup name="BOUNDARY">
|
<objectgroup name="BOUNDARY">
|
||||||
<object id="23" x="0" y="-192">
|
<object id="23" x="0" y="-192">
|
||||||
|
@ -29,4 +29,5 @@
|
||||||
<polyline points="0,0 0,640 128,640 128,0 0,0"/>
|
<polyline points="0,0 0,640 128,640 128,0 0,0"/>
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
|
<objectgroup name="SPIKES"/>
|
||||||
</map>
|
</map>
|
||||||
|
|
BIN
core/assets/textures/spikes.png
Normal file
BIN
core/assets/textures/spikes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
35
core/src/com/game/Actor/Spike.java
Normal file
35
core/src/com/game/Actor/Spike.java
Normal 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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -108,6 +108,7 @@ public class Loading extends AbstractScreen {
|
||||||
app.assets.load("textures/position0.png", Texture.class);
|
app.assets.load("textures/position0.png", Texture.class);
|
||||||
app.assets.load("textures/position1.png", Texture.class);
|
app.assets.load("textures/position1.png", Texture.class);
|
||||||
app.assets.load("textures/position2.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++)
|
for(int i = 1; i <= 10; i++)
|
||||||
{
|
{
|
||||||
app.assets.load("textures/level" + i + "Intro.png", Texture.class);
|
app.assets.load("textures/level" + i + "Intro.png", Texture.class);
|
||||||
|
|
|
@ -29,6 +29,7 @@ import com.game.actor.Base;
|
||||||
import com.game.actor.Platform;
|
import com.game.actor.Platform;
|
||||||
import com.game.actor.Player;
|
import com.game.actor.Player;
|
||||||
import com.game.App;
|
import com.game.App;
|
||||||
|
import com.game.actor.Spike;
|
||||||
import com.game.managers.ScreenManager;
|
import com.game.managers.ScreenManager;
|
||||||
import com.game.misc.Box2dUtils;
|
import com.game.misc.Box2dUtils;
|
||||||
import com.game.misc.CameraUtils;
|
import com.game.misc.CameraUtils;
|
||||||
|
@ -55,8 +56,6 @@ public class Play extends AbstractScreen {
|
||||||
private OrthographicCamera b2dCam; // TODO, remove
|
private OrthographicCamera b2dCam; // TODO, remove
|
||||||
|
|
||||||
// TileMap and Map Renderer
|
// TileMap and Map Renderer
|
||||||
private TiledMap tile1;
|
|
||||||
private TiledMap tile2;
|
|
||||||
private TiledMap tileMap;
|
private TiledMap tileMap;
|
||||||
private OrthogonalTiledMapRenderer tmr;
|
private OrthogonalTiledMapRenderer tmr;
|
||||||
private float mapWidth, mapHeight;
|
private float mapWidth, mapHeight;
|
||||||
|
@ -65,6 +64,7 @@ public class Play extends AbstractScreen {
|
||||||
// All Actors in level
|
// All Actors in level
|
||||||
private Player player;
|
private Player player;
|
||||||
private ArrayList<Platform> platforms = new ArrayList<Platform>();
|
private ArrayList<Platform> platforms = new ArrayList<Platform>();
|
||||||
|
private ArrayList<Spike> spikes = new ArrayList<Spike>();
|
||||||
|
|
||||||
// Intro window
|
// Intro window
|
||||||
private boolean isIntro;
|
private boolean isIntro;
|
||||||
|
@ -214,13 +214,7 @@ public class Play extends AbstractScreen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleInput() {
|
public void handleInput() {
|
||||||
if(Gdx.input.isKeyPressed(Input.Keys.SPACE))
|
if(Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE))
|
||||||
{
|
|
||||||
jumpSound.play();
|
|
||||||
player.jump();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE))
|
|
||||||
{
|
{
|
||||||
isPaused = !isPaused;
|
isPaused = !isPaused;
|
||||||
System.out.println("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);
|
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; }
|
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 platformLayer = (TiledMapTileLayer)tileMap.getLayers().get("PLATFORM");
|
||||||
|
TiledMapTileLayer spikeLayer = (TiledMapTileLayer)tileMap.getLayers().get("SPIKES");
|
||||||
|
|
||||||
MapLayer boundaryLayer = tileMap.getLayers().get("BOUNDARY");
|
MapLayer boundaryLayer = tileMap.getLayers().get("BOUNDARY");
|
||||||
PolylineMapObject polylineObj = (PolylineMapObject)boundaryLayer.getObjects().get(0);
|
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)); }
|
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)
|
private void initBoundary(PolylineMapObject polylineObj, String userData, boolean isSensor)
|
||||||
|
|
Reference in a new issue