From 299d1a2d94d67595bbfc07b28a507e514eacabf7 Mon Sep 17 00:00:00 2001 From: ESloman Date: Mon, 22 Feb 2016 12:34:54 +0000 Subject: [PATCH] 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. --- core/assets/levels/level4.tmx | 12 +++++++-- core/assets/levels/level8.tmx | 5 ++-- core/assets/textures/spikes.png | Bin 0 -> 6862 bytes core/src/com/game/Actor/Spike.java | 35 +++++++++++++++++++++++++ core/src/com/game/Screens/Loading.java | 1 + core/src/com/game/Screens/Play.java | 32 +++++++++++++++------- 6 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 core/assets/textures/spikes.png create mode 100644 core/src/com/game/Actor/Spike.java diff --git a/core/assets/levels/level4.tmx b/core/assets/levels/level4.tmx index fdfe0a3..d7707dc 100644 --- a/core/assets/levels/level4.tmx +++ b/core/assets/levels/level4.tmx @@ -1,14 +1,17 @@ - + + + + - eJxjYBgFIwkwDbQDqARo4Q9qm8mEhEGAEQsGyTFjwYTMw+dWbHLo9mIDxLqDWDtJsRuXmcToJSZMSLGTEoAtDIdzngMA3GQAZw== + eJxjYBgFo2AU0AIwIWEQYMSCQYAZCyZkHhMONbgANnvRAbHuIBUQYzcleskNE1oAWoXhYAUAsHwAUw== @@ -29,4 +32,9 @@ + + + + + diff --git a/core/assets/levels/level8.tmx b/core/assets/levels/level8.tmx index 630da21..e88c945 100644 --- a/core/assets/levels/level8.tmx +++ b/core/assets/levels/level8.tmx @@ -8,11 +8,11 @@ - eJxjYBgFo2AUDARgIoAHC2AmgKkB0P2Oyy5GApge4YnL7pEIALMwAF8= + eJxjYBgFgwEwAzHjQDuCQsCExGZEwuiAGYoHIyAUB0wMqP4kxjxkM4n1NyVhRIr78JlBql9BAFeckwIGMn1QGnbU8P9AAHLiGgQAlYAAOA== - + @@ -29,4 +29,5 @@ + diff --git a/core/assets/textures/spikes.png b/core/assets/textures/spikes.png new file mode 100644 index 0000000000000000000000000000000000000000..2c5fcd6f05c4fc34f18ffbbb969c515752609cc2 GIT binary patch literal 6862 zcmV;<8ZqUGP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_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rt`LY>kYJO`By|tx?6qae|@~0aqBprcH^9>Fk8L zbLp5dgAWP?t^)2O8FtRN+~z&)6G`7%eiKF9Pck4~{pcfZbB?!zfYVDQmX=DO$|u0T zh;TLVb>JCbds-5!``+|0#o;Y295;J5LALMK)?`pCijo3QM+Y2xY+?ev`G*_D&LYX| zPx@KPW!@Ya;mv%{E>~f0Q)R{kCg7ro#|i}=O0`6zi2rSB;vV2z#;~MP!IVn)=4MEN zZC$EmmjGV^K9?3@Z5@>FROJTmc^lXm1ZZkI*u8s$I0vn%i_h2%|dl71Wk#wQN*l92bzjS{v(QbRCWA@aEllOe6%CC&!Eo1miwaWH^0Tz1CGtJFhpvu|h zGV{G>ZEGuo*7C1;m*21?mQ8>jdF0rz9qsnVaV-a$R<_3 zYAt66K{BIc8YCDjSOCkH*FEyKPqvoa2&}HWHz!iBMnIxs`4VR9@sSz z&_&VMNwb+V$3XT#wQ&-42i@xhR1@MCEEwwnHdt-I!j#Y+RTcw1-g5*nw@zFhim)UI zSfa|GsPcgb8&r87_?ZarWmTj+07Jrv3|G8Q=6lREOd$N<0L_|9Lah6a%m4rY07*qo IM6N<$f}LpL0ssI2 literal 0 HcmV?d00001 diff --git a/core/src/com/game/Actor/Spike.java b/core/src/com/game/Actor/Spike.java new file mode 100644 index 0000000..a79fd41 --- /dev/null +++ b/core/src/com/game/Actor/Spike.java @@ -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 + ); + } +} diff --git a/core/src/com/game/Screens/Loading.java b/core/src/com/game/Screens/Loading.java index c9ad50d..cc107a8 100644 --- a/core/src/com/game/Screens/Loading.java +++ b/core/src/com/game/Screens/Loading.java @@ -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); diff --git a/core/src/com/game/Screens/Play.java b/core/src/com/game/Screens/Play.java index 22be5f2..ff50f22 100644 --- a/core/src/com/game/Screens/Play.java +++ b/core/src/com/game/Screens/Play.java @@ -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 platforms = new ArrayList(); + private ArrayList spikes = new ArrayList(); // 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)