diff --git a/core/assets/levels/level1.tmx b/core/assets/levels/level1.tmx index b28e2df..d673cf4 100644 --- a/core/assets/levels/level1.tmx +++ b/core/assets/levels/level1.tmx @@ -1,18 +1,33 @@ - - - + + + - - + + + + + + + + + + + + + + + + + - eJxjYBgFxAImJDyUABMDfrczY8HEAHL1kQIoDXNCbqK2mxmRMK3SC7XDnREHHowAl1tp4V58dlGK6e0uWgEAX2sAgg== + eJxjYBgFwx2wIGEmAniwAWS3kwKYkfBAA1LdTg4gNx5ZcGBscsQARjyYkDpK3YtNLSmAVLcQq45SgMvPgwEDALPDAS4= - + @@ -29,9 +44,11 @@ - - - eJxjYBgFo2AUjIJRMApIBwAGQAAB - - + + + + + + + diff --git a/core/assets/levels/level10.tmx b/core/assets/levels/level10.tmx index 630da21..10c6bf7 100644 --- a/core/assets/levels/level10.tmx +++ b/core/assets/levels/level10.tmx @@ -1,18 +1,32 @@ - - - + + + - - + + + + + + + + + + + + + + + + - eJxjYBgFo2AUDARgIoAHC2AmgKkB0P2Oyy5GApge4YnL7pEIALMwAF8= + eJxjYBgFo2AU4AKMBDATHkwI4NNLjH56AWYCmBoA3e+47GJBw9SMD2IBrrQwEgEAB58AgQ== - + @@ -29,4 +43,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/assets/levels/level2.tmx b/core/assets/levels/level2.tmx index d07c016..2c6ade0 100644 --- a/core/assets/levels/level2.tmx +++ b/core/assets/levels/level2.tmx @@ -1,18 +1,32 @@ - - - + + + - - + + + + + + + + + + + + + + + + - eJxjYBgFo2AUDBbAhIZBgBENEwPQ9WDDIMCMBWNzB8wtxNhFCSDWTkoBNj9TyyxKzRtKAACkFABW + eJxjYBgFo2AUDBbAhIZBgBENEwPQ9bBgwSDAjAUz4FBPLKYEYPP/YAe4wnAkAAAVcwCH - + @@ -29,9 +43,16 @@ - - - eJxjYBgFo2AUjIJRMApIBwAGQAAB - - + + + + + + + + + + + + diff --git a/core/assets/levels/level3.tmx b/core/assets/levels/level3.tmx index abdf43d..26f782d 100644 --- a/core/assets/levels/level3.tmx +++ b/core/assets/levels/level3.tmx @@ -1,18 +1,32 @@ - - - + + + - - + + + + + + + + + + + + + + + + - eJxjYBgFQwEwo2EQYELDuNQxomFcerGpI9ZedIBuFiMOdaNg4AB6POKKy4EG5KYhbGkQV/rHlX9w5SFyzRluAACcKwCU + eJxjYBgFgx0wY8EgwISGsakFAUY0jEsvNnXE2osOWLDgUTC4AHo84orLgQboaZIcfYTSP648gA/jMwdXnh1uAADZqwCd - + @@ -29,9 +43,41 @@ - - - eJxjYBgFo2AUjIJRMApIBwAGQAAB - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/assets/levels/level4.tmx b/core/assets/levels/level4.tmx index 36ce74c..f9fdd61 100644 --- a/core/assets/levels/level4.tmx +++ b/core/assets/levels/level4.tmx @@ -1,21 +1,32 @@ - - - + + + - - + + - - + + + + + + + + + + + + + - eJxjYBgFo2AU0AIwIWEQYMSCQYAZCyZkHhMONbgANnvRAbHuIBUQYzcleskNE1oAWoXhYAUAsHwAUw== + eJxjYBgFo2AU0AIwIWEQYMSCQYAZCyZkHhMONbgACxrGBoh1B6kAm5+pqZfcMKEFoFUYDlYAAMxUAF8= - + @@ -32,9 +43,26 @@ - - - eJxjYBgFo2BoAFYSxUfB0AOjcTm0AAAyAAAQ - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/assets/levels/level5.tmx b/core/assets/levels/level5.tmx index a7fd15f..9222463 100644 --- a/core/assets/levels/level5.tmx +++ b/core/assets/levels/level5.tmx @@ -1,18 +1,32 @@ - - - + + + - - + + + + + + + + + + + + + + + + - eJxjYBgFQxkwQTE6YEbDIMCIhpH1I5tDrF5KALr5QwngCvPBBNDjkBrxh08/rrjEpR5XGKKnRXoAQm5BB6T6dTgDAE5DAG8= + eJxjYBgFQxkwQTE6YEbDIMCIhpH1I5tDrF5KALr5QwngCvPBBNDjkAUNkwPwxT+uuMSlHlcYoqdFegBCbkEHpPp1OAMAahsAew== - + @@ -29,9 +43,31 @@ - - - eJxjYBgFo2AUjIJRMApIBwAGQAAB - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/assets/levels/level6.tmx b/core/assets/levels/level6.tmx index c198aa1..5553103 100644 --- a/core/assets/levels/level6.tmx +++ b/core/assets/levels/level6.tmx @@ -1,21 +1,32 @@ - - - + + + - - + + - - + + + + + + + + + + + + + - eJxjYBgFQx0wIeGhBBiRMCF5fOpIBdQKK2YkTAlgYsAeh8jmEgoHZHcw4jETl72kAmYG6vmfFECL9DAKyAcA3mgAUA== + eJxjYBgFgwkwomEmIvQwIeGhBJD9SUgenzpSAbXCihkJUwKYGLDHIbK5hMIB2R2wdEMoXVCSbpgZqOd/UgALGh4FAwsADNcAYg== - + @@ -32,9 +43,51 @@ - - - eJxjYBgFwxmwQvFIB8SGwWhYjYJRQDwAAFKUABU= - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/assets/levels/level7.tmx b/core/assets/levels/level7.tmx index 52e6025..10bf53c 100644 --- a/core/assets/levels/level7.tmx +++ b/core/assets/levels/level7.tmx @@ -1,21 +1,32 @@ - - - + + + - - + + - - + + + + + + + + + + + + + - eJxjYBgFlAJmKKYGYETC2OxAt4cJCRNSj24uLr3DHSCHAylhOtBgsLqLWEBttzNiwcj2wOzClg/Q3UNqvhsFEAAAL3cAZA== + eJxjYBh+gBGK6QWYoZgagAUJY7MD3R4mJExIPXq44NI73AFyOJASpgMNBqu7iAXUdjsjFoxsD8wubPkA3T3oZsAArnw3CiAAAGRXAG8= - + @@ -32,9 +43,31 @@ - - - eJxjYBj+gJUG6kk1cxQMLBiNr1EwCqgPAGTIABU= - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/assets/levels/level8.tmx b/core/assets/levels/level8.tmx index 804bd88..dd8fb0c 100644 --- a/core/assets/levels/level8.tmx +++ b/core/assets/levels/level8.tmx @@ -1,21 +1,32 @@ - - - + + + - - + + - - + + + + + + + + + + + + + - eJxjYBgFgwEwAzHjQDuCQsCExGZEwuiAGYoHIyAUB0wMqP4kxjxkM4n1NyVhRIr78JlBql9BAFeckwIGMn1QGnbU8P9AAHLiGgQAlYAAOA== + eJxjYBgFgwEwAzHjQDuCQsCExGZBwuiAGYoHIyAUB0wMqP4kxjxkM4n1NyVhRIr78JlBql9BAN2/5ICBTB+Uhh01/D8QgJy4BgEAuIQAQQ== - + @@ -32,9 +43,16 @@ - - - eJxjYBgFo2AUUBOw0lnfKBhYMJLjDQAnTAAQ - - + + + + + + + + + + + + diff --git a/core/assets/levels/level9.tmx b/core/assets/levels/level9.tmx index 8702aab..8b2f918 100644 --- a/core/assets/levels/level9.tmx +++ b/core/assets/levels/level9.tmx @@ -1,18 +1,32 @@ - - - + + + - - + + + + + + + + + + + + + + + + - eJxjYBgFQw0wIuFRgBswDbQDiASMDJTFKaVpgVA4DUQ4MpFoL7p6ZihGlqcU0Cu/IfsFVzgwYxEDgcFQNlBqN3p+QPYPMwNm3OIzY6ABEwP2OCTGD/gAJXpHAf0AADOTAFA= + eJztlEsKACAIRE27/5kjaCGVZQhZ4IPZ9FPHCiD4jcQUyKB3Akpyp1Osd2Hnk4ePeBi3X09NfN7KrffGa5F8oMlY5YW/wRo7CaoQjL1dneENwryHmhpWWPYG9yh5mwBc - + @@ -29,9 +43,21 @@ - - - eJztwTEBAAAAwqD1T20JT6AAAHgaCWAAAQ== - - + + + + + + + + + + + + + + + + + diff --git a/core/assets/spritesheets/characters.png b/core/assets/spritesheets/characters.png deleted file mode 100644 index d9eac75..0000000 Binary files a/core/assets/spritesheets/characters.png and /dev/null differ diff --git a/core/assets/spritesheets/characters.svg b/core/assets/spritesheets/characters.svg index 236b581..85af6d6 100644 --- a/core/assets/spritesheets/characters.svg +++ b/core/assets/spritesheets/characters.svg @@ -14,8 +14,8 @@ height="1052.3622047" id="svg2" version="1.1" - inkscape:version="0.48.1 " - sodipodi:docname="idea.svg"> + inkscape:version="0.91 r13725" + sodipodi:docname="characters.svg"> - - - + + + + inkscape:window-maximized="1" /> @@ -324,7 +328,7 @@ sodipodi:cy="232.00504" sodipodi:rx="21.383928" sodipodi:ry="9.9107141" - d="m 214.46428,232.00504 c 0,5.47353 -9.57391,9.91071 -21.38393,9.91071 -11.81001,0 -21.38393,-4.43718 -21.38393,-9.91071 0,-5.47354 9.57392,-9.91072 21.38393,-9.91072 11.81002,0 21.38393,4.43718 21.38393,9.91072 z" + d="m 214.46428,232.00504 a 21.383928,9.9107141 0 0 1 -21.38393,9.91071 21.383928,9.9107141 0 0 1 -21.38393,-9.91071 21.383928,9.9107141 0 0 1 21.38393,-9.91072 21.383928,9.9107141 0 0 1 21.38393,9.91072 z" transform="matrix(1,0,0,0.78340873,-14.625,37.087193)" /> - - + - + - + - + + transform="matrix(0.17814697,0,0,0.17814697,121.40185,178.82351)" + cx="120.95982" + cy="130.77736" + r="1.8080357" /> - - + - + - + - + + transform="matrix(-0.27334874,0,0,0.27334874,171.27641,164.8047)" + cx="120.95982" + cy="130.77736" + r="1.8080357" /> - - + + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> - - + - + - + - + + transform="matrix(0.17814697,0,0,0.17814697,121.40185,178.82351)" + cx="120.95982" + cy="130.77736" + r="1.8080357" /> - + - + - + - + - + + transform="matrix(-0.27334874,0,0,0.27334874,171.27641,164.8047)" + cx="120.95982" + cy="130.77736" + r="1.8080357" /> - + cx="133.90625" + cy="209.35437" + rx="3.84375" + ry="2.5390625" /> + style="fill:#00222b;stroke:#000000;stroke-width:0.08333858;stroke-miterlimit:4;stroke-dasharray:none;fill-opacity:1" /> + style="fill:#00222b;stroke:#000000;stroke-width:0.08347526;stroke-miterlimit:4;stroke-dasharray:none;fill-opacity:1" /> - + style="fill:#ff0000;stroke:#2b0000;stroke-width:0.98461539" + cx="96.017334" + cy="307.32953" + r="31.507692" /> - - + - + - + - + + transform="matrix(0.17814697,0,0,0.17814697,121.40185,178.82351)" + cx="120.95982" + cy="130.77736" + r="1.8080357" /> - + - + - + - + - + + transform="matrix(-0.27334874,0,0,0.27334874,171.27641,164.8047)" + cx="120.95982" + cy="130.77736" + r="1.8080357" /> - + diff --git a/core/assets/spritesheets/drawing.svg b/core/assets/spritesheets/drawing.svg index ee95e20..d474cca 100644 --- a/core/assets/spritesheets/drawing.svg +++ b/core/assets/spritesheets/drawing.svg @@ -9,13 +9,16 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="256" + width="320" height="64" - viewBox="0 0 256 63.999999" + viewBox="0 0 320 63.999999" id="svg3336" version="1.1" inkscape:version="0.91 r13725" - sodipodi:docname="drawing.svg"> + sodipodi:docname="drawing.svg" + inkscape:export-filename="C:\Users\Ash\Documents\GitHub\libGDXGroupProject\core\assets\spritesheets\drawing.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + units="px" + showguides="false" /> @@ -158,5 +162,27 @@ inkscape:connector-curvature="0" sodipodi:nodetypes="cccc" /> + + + diff --git a/core/assets/spritesheets/platformSet.png b/core/assets/spritesheets/platformSet.png index 86159af..0f0b558 100644 Binary files a/core/assets/spritesheets/platformSet.png and b/core/assets/spritesheets/platformSet.png differ diff --git a/core/assets/spritesheets/platformSetOld.png b/core/assets/spritesheets/platformSetOld.png deleted file mode 100644 index c09d717..0000000 Binary files a/core/assets/spritesheets/platformSetOld.png and /dev/null differ diff --git a/core/assets/textures/failureBackground.png b/core/assets/textures/backgrounds/failureBackground.png similarity index 100% rename from core/assets/textures/failureBackground.png rename to core/assets/textures/backgrounds/failureBackground.png diff --git a/core/assets/textures/leaderboardBackground.jpg b/core/assets/textures/backgrounds/leaderboardBackground.jpg similarity index 100% rename from core/assets/textures/leaderboardBackground.jpg rename to core/assets/textures/backgrounds/leaderboardBackground.jpg diff --git a/core/assets/textures/levelSelectBackground.jpg b/core/assets/textures/backgrounds/levelSelectBackground.jpg similarity index 100% rename from core/assets/textures/levelSelectBackground.jpg rename to core/assets/textures/backgrounds/levelSelectBackground.jpg diff --git a/core/assets/textures/menuBackground.jpg b/core/assets/textures/backgrounds/menuBackground.jpg similarity index 100% rename from core/assets/textures/menuBackground.jpg rename to core/assets/textures/backgrounds/menuBackground.jpg diff --git a/core/assets/textures/pauseBackground.png b/core/assets/textures/backgrounds/pauseBackground.png similarity index 100% rename from core/assets/textures/pauseBackground.png rename to core/assets/textures/backgrounds/pauseBackground.png diff --git a/core/assets/textures/position0.png b/core/assets/textures/backgrounds/position0.png similarity index 100% rename from core/assets/textures/position0.png rename to core/assets/textures/backgrounds/position0.png diff --git a/core/assets/textures/position1.png b/core/assets/textures/backgrounds/position1.png similarity index 100% rename from core/assets/textures/position1.png rename to core/assets/textures/backgrounds/position1.png diff --git a/core/assets/textures/position2.png b/core/assets/textures/backgrounds/position2.png similarity index 100% rename from core/assets/textures/position2.png rename to core/assets/textures/backgrounds/position2.png diff --git a/core/assets/textures/successBackground.png b/core/assets/textures/backgrounds/successBackground.png similarity index 100% rename from core/assets/textures/successBackground.png rename to core/assets/textures/backgrounds/successBackground.png diff --git a/core/assets/textures/badlogic.jpg b/core/assets/textures/badlogic.jpg deleted file mode 100644 index 4390da6..0000000 Binary files a/core/assets/textures/badlogic.jpg and /dev/null differ diff --git a/core/assets/textures/enemies/blueAlive.png b/core/assets/textures/enemies/blueAlive.png new file mode 100644 index 0000000..fe415c7 Binary files /dev/null and b/core/assets/textures/enemies/blueAlive.png differ diff --git a/core/assets/textures/enemies/blueDead.png b/core/assets/textures/enemies/blueDead.png new file mode 100644 index 0000000..c08771d Binary files /dev/null and b/core/assets/textures/enemies/blueDead.png differ diff --git a/core/assets/textures/enemies/greenAlive.png b/core/assets/textures/enemies/greenAlive.png new file mode 100644 index 0000000..b67c14a Binary files /dev/null and b/core/assets/textures/enemies/greenAlive.png differ diff --git a/core/assets/textures/enemies/greenDead.png b/core/assets/textures/enemies/greenDead.png new file mode 100644 index 0000000..f52542d Binary files /dev/null and b/core/assets/textures/enemies/greenDead.png differ diff --git a/core/assets/textures/enemies/redAlive.png b/core/assets/textures/enemies/redAlive.png new file mode 100644 index 0000000..a31257f Binary files /dev/null and b/core/assets/textures/enemies/redAlive.png differ diff --git a/core/assets/textures/enemies/redDead.png b/core/assets/textures/enemies/redDead.png new file mode 100644 index 0000000..9ea001d Binary files /dev/null and b/core/assets/textures/enemies/redDead.png differ diff --git a/core/assets/textures/level10Intro.png b/core/assets/textures/intros/level10Intro.png similarity index 100% rename from core/assets/textures/level10Intro.png rename to core/assets/textures/intros/level10Intro.png diff --git a/core/assets/textures/level1Intro.png b/core/assets/textures/intros/level1Intro.png similarity index 100% rename from core/assets/textures/level1Intro.png rename to core/assets/textures/intros/level1Intro.png diff --git a/core/assets/textures/level2Intro.png b/core/assets/textures/intros/level2Intro.png similarity index 100% rename from core/assets/textures/level2Intro.png rename to core/assets/textures/intros/level2Intro.png diff --git a/core/assets/textures/level3Intro.png b/core/assets/textures/intros/level3Intro.png similarity index 100% rename from core/assets/textures/level3Intro.png rename to core/assets/textures/intros/level3Intro.png diff --git a/core/assets/textures/level4Intro.png b/core/assets/textures/intros/level4Intro.png similarity index 100% rename from core/assets/textures/level4Intro.png rename to core/assets/textures/intros/level4Intro.png diff --git a/core/assets/textures/level5Intro.png b/core/assets/textures/intros/level5Intro.png similarity index 100% rename from core/assets/textures/level5Intro.png rename to core/assets/textures/intros/level5Intro.png diff --git a/core/assets/textures/level6Intro.png b/core/assets/textures/intros/level6Intro.png similarity index 100% rename from core/assets/textures/level6Intro.png rename to core/assets/textures/intros/level6Intro.png diff --git a/core/assets/textures/level7Intro.png b/core/assets/textures/intros/level7Intro.png similarity index 100% rename from core/assets/textures/level7Intro.png rename to core/assets/textures/intros/level7Intro.png diff --git a/core/assets/textures/level8Intro.png b/core/assets/textures/intros/level8Intro.png similarity index 100% rename from core/assets/textures/level8Intro.png rename to core/assets/textures/intros/level8Intro.png diff --git a/core/assets/textures/level9Intro.png b/core/assets/textures/intros/level9Intro.png similarity index 100% rename from core/assets/textures/level9Intro.png rename to core/assets/textures/intros/level9Intro.png diff --git a/core/assets/textures/pauseGlow.png b/core/assets/textures/pauseGlow.png deleted file mode 100644 index 915ac19..0000000 Binary files a/core/assets/textures/pauseGlow.png and /dev/null differ diff --git a/core/assets/textures/player/player_blue.png b/core/assets/textures/player/player_blue.png new file mode 100644 index 0000000..79a39b7 Binary files /dev/null and b/core/assets/textures/player/player_blue.png differ diff --git a/core/assets/textures/player/player_green.png b/core/assets/textures/player/player_green.png new file mode 100644 index 0000000..6cbff0f Binary files /dev/null and b/core/assets/textures/player/player_green.png differ diff --git a/core/assets/textures/player/player_red.png b/core/assets/textures/player/player_red.png new file mode 100644 index 0000000..ba0b348 Binary files /dev/null and b/core/assets/textures/player/player_red.png differ diff --git a/core/assets/textures/player/player_yellow.png b/core/assets/textures/player/player_yellow.png new file mode 100644 index 0000000..1772770 Binary files /dev/null and b/core/assets/textures/player/player_yellow.png differ diff --git a/core/assets/textures/player_blue.png b/core/assets/textures/player_blue.png deleted file mode 100644 index 28eebf4..0000000 Binary files a/core/assets/textures/player_blue.png and /dev/null differ diff --git a/core/assets/textures/player_green.png b/core/assets/textures/player_green.png deleted file mode 100644 index b6dd8c7..0000000 Binary files a/core/assets/textures/player_green.png and /dev/null differ diff --git a/core/assets/textures/player_red.png b/core/assets/textures/player_red.png deleted file mode 100644 index fcb2f34..0000000 Binary files a/core/assets/textures/player_red.png and /dev/null differ diff --git a/core/assets/textures/player_yellow.png b/core/assets/textures/player_yellow.png deleted file mode 100644 index 69e6a98..0000000 Binary files a/core/assets/textures/player_yellow.png and /dev/null differ diff --git a/core/assets/textures/spikes.png b/core/assets/textures/spikes.png deleted file mode 100644 index 2c5fcd6..0000000 Binary files a/core/assets/textures/spikes.png and /dev/null differ diff --git a/core/src/com/game/Actor/Base.java b/core/src/com/game/Actor/Base.java index 301cf45..13e6550 100644 --- a/core/src/com/game/Actor/Base.java +++ b/core/src/com/game/Actor/Base.java @@ -12,7 +12,6 @@ public abstract class Base { // Physics definitions protected Body body; - protected String bodyType; // Position and Size protected Vector2 pos; @@ -24,16 +23,14 @@ public abstract class Base { RED, GREEN, BLUE, - YELLOW, - NONE, + WHITE } - public Base(World world, Vector2 pos, Vector2 size, String bodyType, Colours curColour) + public Base(World world, Vector2 pos, Vector2 size, Colours curColour) { this.world = world; this.pos = pos; this.size = size; - this.bodyType = bodyType; this.curColour = curColour; } diff --git a/core/src/com/game/Actor/Box2DSprite.java b/core/src/com/game/Actor/Box2DSprite.java deleted file mode 100644 index f699d74..0000000 --- a/core/src/com/game/Actor/Box2DSprite.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.game.actor; - -import com.badlogic.gdx.graphics.g2d.Animation; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.math.Vector2; -import com.badlogic.gdx.physics.box2d.Body; - -import static com.game.misc.Vars.PPM; - -/** - * Created by Ash on 09/02/2016. - */ -public class Box2DSprite { - - protected Body body; - protected Animation animation; - - protected float width, height; - protected Vector2 pos; - - protected TextureRegion currentFrame; - - public Box2DSprite(Body body) - { - this.body = body; - //setAnimation(); - } - - public void update(float dt) - { - pos = body.getPosition(); - currentFrame = animation.getKeyFrame(dt, true); - } - - public void render(SpriteBatch sb) - { - sb.begin(); - sb.draw(currentFrame, - (pos.x * PPM) - width / 2, - (pos.y * PPM) - height / 2 - ); - sb.end(); - - } - - /*public void setAnimation(TextureRegion[] reg, float delay) - { - setAnimation(reg, delay); - }*/ - - -} diff --git a/core/src/com/game/Actor/Enemy.java b/core/src/com/game/Actor/Enemy.java new file mode 100644 index 0000000..5ecfb9f --- /dev/null +++ b/core/src/com/game/Actor/Enemy.java @@ -0,0 +1,93 @@ +package com.game.actor; + +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.physics.box2d.*; +import com.badlogic.gdx.utils.Array; +import com.game.App; +import com.game.misc.utils.Box2dUtils; +import com.game.misc.Vars; + +import static com.game.misc.Vars.PPM; + +/** + * Created by Ash on 22/02/2016. + */ +public class Enemy extends Base { + + private Sprite sprite; + private boolean isAlive; + + public Enemy(World world, Vector2 pos, Vector2 size, Colours curColour, short categoryBits, short maskBits) { + super(world, pos, size, curColour); + + body = Box2dUtils.makeBody(world, + BodyDef.BodyType.StaticBody, + pos + ); + Box2dUtils.makePolygon(body, size, "ENEMY", true, 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) + }, + "ENEMY", + true, + Vars.BIT_ALL, + Vars.BIT_PLAYER + );*/ + + isAlive = true; + + sprite = new Sprite(App.assets.get("textures/enemies/redAlive.png", Texture.class)); + sprite.setPosition(pos.x - size.x / 2, pos.y - size.y / 2); + setCurColour(curColour); + } + + public void render(SpriteBatch sb) + { + sprite.draw(sb); + } + + @Override + public void setCurColour(Colours curColour) + { + super.setCurColour(curColour); + Filter filter = body.getFixtureList().first().getFilterData(); + short bits = filter.maskBits; + + switch (curColour) + { + case RED: + bits &= ~Vars.BIT_GREEN; + bits &= ~Vars.BIT_BLUE; + bits |= Vars.BIT_RED; + if(isAlive) { sprite.setTexture(App.assets.get("textures/enemies/redAlive.png", Texture.class)); } + else { sprite.setTexture(App.assets.get("textures/enemies/redDead.png", Texture.class)); } + break; + case GREEN: + bits &= ~Vars.BIT_RED; + bits &= ~Vars.BIT_BLUE; + bits |= Vars.BIT_GREEN; + if(isAlive) { sprite.setTexture(App.assets.get("textures/enemies/greenAlive.png", Texture.class)); } + else { sprite.setTexture(App.assets.get("textures/enemies/greenDead.png", Texture.class)); } + break; + case BLUE: + bits &= ~Vars.BIT_RED; + bits &= ~Vars.BIT_GREEN; + bits |= Vars.BIT_BLUE; + if(isAlive) { sprite.setTexture(App.assets.get("textures/enemies/blueAlive.png", Texture.class)); } + else { sprite.setTexture(App.assets.get("textures/enemies/blueDead.png", Texture.class)); } + break; + } + + filter.maskBits = bits; + body.getFixtureList().first().setFilterData(filter); + } + + public void setAlive(boolean isAlive) { this.isAlive = isAlive; } + + public Array getFixtures() { return body.getFixtureList(); } +} diff --git a/core/src/com/game/Actor/Object/Background.java b/core/src/com/game/Actor/Object/Background.java deleted file mode 100644 index 21116e4..0000000 --- a/core/src/com/game/Actor/Object/Background.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.game.actor.object; - -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.math.Vector2; -import com.game.misc.Vars; - -/** - * Created by Ash on 09/02/2016. - */ -public class Background { - - private Vector2 pos; - - private Texture texture; - - public Background(String path) - { - loadTexture(path); - } - - public void update(float dt, Vector2 pos) - { - this.pos = pos; - } - - public void render(SpriteBatch sb) - { - sb.draw(texture, pos.x, pos.y, Vars.SCREEN_WIDTH, Vars.SCREEN_HEIGHT); - } - - private void loadTexture(String path) - { - this.texture = new Texture(path); - } -} diff --git a/core/src/com/game/Actor/Player.java b/core/src/com/game/Actor/Player.java index 2968fe9..7ce5024 100644 --- a/core/src/com/game/Actor/Player.java +++ b/core/src/com/game/Actor/Player.java @@ -1,6 +1,5 @@ package com.game.actor; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Sprite; @@ -9,7 +8,7 @@ import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.*; import com.game.App; -import com.game.misc.Box2dUtils; +import com.game.misc.utils.Box2dUtils; import com.game.misc.Vars; import static com.game.misc.Vars.PPM; @@ -36,19 +35,20 @@ public class Player extends Base { private Sound colourchangeSound; public Player(World world, Vector2 pos, Vector2 size, Colours curColour) { - super(world, pos, size, "", curColour); + super(world, pos, size, curColour); curAction = Action.IDLE; body = Box2dUtils.makeBody(world, BodyDef.BodyType.DynamicBody, pos ); - Box2dUtils.makeCircle(body, size.x, "PLAYER", false, Vars.BIT_PLAYER, (short)(Vars.BIT_RED | Vars.BIT_PRISMATIC)); + Box2dUtils.makeCircle(body, size.x, "PLAYER", false, Vars.BIT_PLAYER, (short)(Vars.BIT_RED | Vars.BIT_ALL)); jumpSound = App.assets.get("sounds/jumping.mp3", Sound.class); colourchangeSound = App.assets.get("sounds/colourchange.mp3", Sound.class); - sprite = new Sprite(App.assets.get("textures/player_red.png", Texture.class)); + sprite = new Sprite(App.assets.get("textures/player/player_red.png", Texture.class)); + sprite.setPosition((pos.x * PPM) - size.x / 2, (pos.y * PPM) - size.y / 2); } public void update(float dt) @@ -100,30 +100,20 @@ public class Player extends Base { case RED: bits &= ~Vars.BIT_GREEN; bits &= ~Vars.BIT_BLUE; - bits &= ~Vars.BIT_YELLOW; bits |= Vars.BIT_RED; - sprite.setTexture(App.assets.get("textures/player_red.png", Texture.class)); + sprite.setTexture(App.assets.get("textures/player/player_red.png", Texture.class)); break; case GREEN: bits &= ~Vars.BIT_RED; bits &= ~Vars.BIT_BLUE; - bits &= ~Vars.BIT_YELLOW; bits |= Vars.BIT_GREEN; - sprite.setTexture(App.assets.get("textures/player_green.png", Texture.class)); + sprite.setTexture(App.assets.get("textures/player/player_green.png", Texture.class)); break; case BLUE: bits &= ~Vars.BIT_RED; bits &= ~Vars.BIT_GREEN; - bits &= ~Vars.BIT_YELLOW; bits |= Vars.BIT_BLUE; - sprite.setTexture(App.assets.get("textures/player_blue.png", Texture.class)); - break; - case YELLOW: - bits &= ~Vars.BIT_RED; - bits &= ~Vars.BIT_GREEN; - bits &= ~Vars.BIT_BLUE; - bits |= Vars.BIT_YELLOW; - sprite.setTexture(App.assets.get("textures/player_yellow.png", Texture.class)); + sprite.setTexture(App.assets.get("textures/player/player_blue.png", Texture.class)); break; } diff --git a/core/src/com/game/Actor/Spike.java b/core/src/com/game/Actor/Spike.java deleted file mode 100644 index 47882a0..0000000 --- a/core/src/com/game/Actor/Spike.java +++ /dev/null @@ -1,42 +0,0 @@ -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) { - super(world, pos, size, "STATIC", curColour); - - body = Box2dUtils.makeBody(world, - BodyDef.BodyType.StaticBody, - pos - ); - - short maskBits = 0; - 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) - }, - "SPIKES", - true, -<<<<<<< HEAD - Vars.BIT_PRISMATIC, - Vars.BIT_PLAYER -======= - Vars.BIT_MISC, maskBits ->>>>>>> origin/master - ); - } -} diff --git a/core/src/com/game/Actor/Platform.java b/core/src/com/game/Actor/object/Platform.java similarity index 83% rename from core/src/com/game/Actor/Platform.java rename to core/src/com/game/Actor/object/Platform.java index f2e02e8..c3616f5 100644 --- a/core/src/com/game/Actor/Platform.java +++ b/core/src/com/game/Actor/object/Platform.java @@ -1,8 +1,9 @@ -package com.game.actor; +package com.game.actor.object; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.*; -import com.game.misc.Box2dUtils; +import com.game.actor.Base; +import com.game.misc.utils.Box2dUtils; import com.game.misc.Vars; import static com.game.misc.Vars.PPM; @@ -13,7 +14,7 @@ import static com.game.misc.Vars.PPM; public class Platform extends Base { public Platform(World world, Vector2 pos, Vector2 size, Colours curColour, short categoryBits, short maskBits) { - super(world, pos, size, "STATIC", curColour); + super(world, pos, size, curColour); body = Box2dUtils.makeBody(world, BodyDef.BodyType.StaticBody, @@ -27,7 +28,7 @@ public class Platform extends Base { }, "PLATFORM", true, - Vars.BIT_PRISMATIC, + Vars.BIT_ALL, Vars.BIT_PLAYER ); } diff --git a/core/src/com/game/Misc/ParralaxBackground.java b/core/src/com/game/Misc/ParralaxBackground.java deleted file mode 100644 index 835f443..0000000 --- a/core/src/com/game/Misc/ParralaxBackground.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.game.misc; - -import com.badlogic.gdx.math.Vector2; -import com.game.actor.object.Background; - -/** - * Created by Ash on 09/02/2016. - */ -public class ParralaxBackground { - private Background back; - private Background middle; - private Background front; - - public ParralaxBackground(String back, String middle, String front) - { - this.back = new Background(back); - createBackground(middle); - createBackground(front); - } - - public void update(float dt) - { - Vector2 movementAmount = new Vector2(.1f, 0); - - back.update(dt, movementAmount); - - middle.update(dt, movementAmount); - - front.update(dt, movementAmount); - } - - private void createBackground(String path) - { - - } -} diff --git a/core/src/com/game/Misc/Vars.java b/core/src/com/game/Misc/Vars.java index 06d436b..1e2197c 100644 --- a/core/src/com/game/Misc/Vars.java +++ b/core/src/com/game/Misc/Vars.java @@ -23,9 +23,8 @@ public class Vars { // Filter bits public static final short BIT_PLAYER = 1; - public static final short BIT_PRISMATIC = 1; + public static final short BIT_ALL = 1; public static final short BIT_RED = 2; public static final short BIT_GREEN = 4; public static final short BIT_BLUE = 8; - public static final short BIT_YELLOW = 16; } diff --git a/core/src/com/game/Misc/Box2dUtils.java b/core/src/com/game/Misc/utils/Box2dUtils.java similarity index 98% rename from core/src/com/game/Misc/Box2dUtils.java rename to core/src/com/game/Misc/utils/Box2dUtils.java index 4686d1d..cbebfb0 100644 --- a/core/src/com/game/Misc/Box2dUtils.java +++ b/core/src/com/game/Misc/utils/Box2dUtils.java @@ -1,4 +1,4 @@ -package com.game.misc; +package com.game.misc.utils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.*; diff --git a/core/src/com/game/Misc/CameraUtils.java b/core/src/com/game/Misc/utils/CameraUtils.java similarity index 58% rename from core/src/com/game/Misc/CameraUtils.java rename to core/src/com/game/Misc/utils/CameraUtils.java index 83acf2e..795c273 100644 --- a/core/src/com/game/Misc/CameraUtils.java +++ b/core/src/com/game/Misc/utils/CameraUtils.java @@ -1,4 +1,4 @@ -package com.game.misc; +package com.game.misc.utils; import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.math.Vector2; @@ -13,7 +13,8 @@ public class CameraUtils { { Vector3 pos = cam.position; pos.x = cam.position.x + (tarX - cam.position.x) * .2f; - pos.y = cam.position.y + (tarY - cam.position.y) * .2f;; + pos.y = cam.position.y + (tarY - cam.position.y) * .2f; + cam.position.set(pos); cam.update(); } @@ -21,24 +22,12 @@ public class CameraUtils { public static void setBoundary(Camera cam, Vector2 start, Vector2 size) { Vector3 pos = cam.position; - if(pos.x < start.x) - { - pos.x = start.x; - } - if(pos.y < start.y) - { - pos.y = start.y; - } + if(pos.x < start.x) { pos.x = start.x; } + if(pos.x > start.x + size.x) { pos.x = start.x + size.x; } - if(pos.x > start.x + size.x) - { - pos.x = start.x + size.x; - } + if(pos.y < start.y) { pos.y = start.y; } + if(pos.y > start.y + size.y) { pos.y = start.y + size.y; } - if(pos.y > start.y + size.y) - { - pos.y = start.y + size.y; - } cam.position.set(pos); cam.update(); } diff --git a/core/src/com/game/Misc/myButton.java b/core/src/com/game/Misc/utils/myButton.java similarity index 94% rename from core/src/com/game/Misc/myButton.java rename to core/src/com/game/Misc/utils/myButton.java index fe273de..15b4001 100644 --- a/core/src/com/game/Misc/myButton.java +++ b/core/src/com/game/Misc/utils/myButton.java @@ -1,4 +1,4 @@ -package com.game.misc; +package com.game.misc.utils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.ui.Skin; diff --git a/core/src/com/game/Misc/myWindow.java b/core/src/com/game/Misc/utils/myWindow.java similarity index 96% rename from core/src/com/game/Misc/myWindow.java rename to core/src/com/game/Misc/utils/myWindow.java index 67babc4..0dba914 100644 --- a/core/src/com/game/Misc/myWindow.java +++ b/core/src/com/game/Misc/utils/myWindow.java @@ -1,4 +1,4 @@ -package com.game.misc; +package com.game.misc.utils; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.math.Vector2; diff --git a/core/src/com/game/Screens/EndlessMode.java b/core/src/com/game/Screens/EndlessMode.java deleted file mode 100644 index 819f043..0000000 --- a/core/src/com/game/Screens/EndlessMode.java +++ /dev/null @@ -1,467 +0,0 @@ -package com.game.screens; -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.Input; -import com.badlogic.gdx.audio.Sound; -import com.badlogic.gdx.graphics.OrthographicCamera; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.maps.MapLayer; -import com.badlogic.gdx.maps.MapProperties; -import com.badlogic.gdx.maps.objects.PolylineMapObject; -import com.badlogic.gdx.maps.objects.TextureMapObject; -import com.badlogic.gdx.maps.tiled.TiledMap; -import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; -import com.badlogic.gdx.maps.tiled.TmxMapLoader; -import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; -import com.badlogic.gdx.math.Polyline; -import com.badlogic.gdx.math.Vector2; -import com.badlogic.gdx.physics.box2d.*; -import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.badlogic.gdx.scenes.scene2d.ui.TextButton; -import com.badlogic.gdx.scenes.scene2d.ui.Window; -import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import com.game.App; -import com.game.managers.ScreenManager; -import com.game.misc.Box2dUtils; -import com.game.misc.Vars; -import com.game.screens.AbstractScreen; - -import java.util.ArrayList; - -import static com.game.misc.Vars.PPM; - -/** - * Created by Elliot on 16/02/2016. - */ -public class EndlessMode extends AbstractScreen { - - private Skin skin; - - // TODO, remove - public boolean isDebug = false; - - // Physics related - private World world; - private Box2DDebugRenderer b2dr; // TODO, remove - 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; - private Vector2 tileSize; - - // All Actors in level - private com.game.actor.Player player; - private ArrayList platforms = new ArrayList(); - - // Intro window - private boolean hasPlayedOnce = false; - private boolean isIntro; - private Window introWindow; - private Image introBackground; - private TextButton butProceed; - - // Pause window - private boolean isPaused; - private Window pauseWindow; - private Image pauseBackground; - private Image pauseGlow; - private TextButton butContinue, butReset, butExit; - private Vector2 buttonSize; - - // Endgame window - private boolean isEnd; - private boolean isSuccess; - private Window endgameWindow; - private TextButton butNext; - private Image failureBackground, successBackground; - - private int levelNumber; - - private Sound jumpSound = Gdx.audio.newSound(Gdx.files.internal("sounds/jumping.mp3")); - private Sound colourchangeSound = Gdx.audio.newSound(Gdx.files.internal("sounds/colourchange.mp3")); - - public EndlessMode(App app) { - super(app); - - skin = new Skin(); - world = new World(new Vector2(0, com.game.misc.Vars.GRAVITY.y), true); - world.setContactListener(cl); - - b2dr = new Box2DDebugRenderer(); // TODO, remove - - b2dCam = new OrthographicCamera(); - b2dCam.setToOrtho(false, com.game.misc.Vars.SCREEN_WIDTH / PPM, com.game.misc.Vars.SCREEN_HEIGHT / PPM); - - isIntro = true; - isPaused = false; - - buttonSize = new Vector2(50, 50); - - isEnd = false; - isSuccess = false; - } - - @Override - public void show() { - super.show(); - - skin.add("default-font", app.assets.get("badaboom60.ttf", BitmapFont.class)); - skin.load(Gdx.files.internal("spritesheets/uiskin.json")); - - initLevel(); - initIntroWindow(); - initPauseWindow(); - initEndgameWindow(false); - } - - @Override - public void update(float dt) { - if (!isPaused && !isEnd && !isIntro) { - world.step(dt, 6, 2); - - com.game.misc.CameraUtils.lerpToTarget(cam, player.getPos().scl(PPM).x, 0); - com.game.misc.CameraUtils.lerpToTarget(b2dCam, player.getPos().x, player.getPos().y); - b2dCam.zoom = 5f; - - Vector2 start = new Vector2(cam.viewportWidth / 2, cam.viewportHeight / 2); - com.game.misc.CameraUtils.setBoundary(cam, start, new Vector2(mapWidth * tileSize.x - start.x * 2, mapHeight * tileSize.y - start.y * 2)); - - player.update(dt); - } - - if (pauseWindow.isVisible() != isPaused) { - pauseWindow.setVisible(isPaused); - pauseGlow.setVisible(isPaused); - } - - if (endgameWindow.isVisible() != isEnd) { - initEndgameWindow(isSuccess); - - endgameWindow.setVisible(isEnd); - endgameWindow.setVisible(isEnd); - } - - stage.act(dt); - } - - @Override - public void render(float dt) { - super.render(dt); - - app.sb.setProjectionMatrix(cam.combined); - - if (!isDebug) { - app.sb.begin(); - app.sb.draw(app.assets.get("textures/position0.png", Texture.class), cam.position.x - cam.viewportWidth / 2, cam.position.y - cam.viewportHeight / 2); - app.sb.draw(app.assets.get("textures/position1.png", Texture.class), cam.position.x - cam.viewportWidth / 2, cam.position.y - (cam.viewportHeight / 2) + 75); - app.sb.draw(app.assets.get("textures/position2.png", Texture.class), cam.position.x - cam.viewportWidth / 2, cam.position.y - (cam.viewportHeight / 2) - 150); - player.render(app.sb); - app.sb.end(); - - tmr.setView(cam); - tmr.render(); - } else { - b2dr.render(world, b2dCam.combined); - } - - stage.draw(); - } - - @Override - public void handleInput() { - if (Gdx.input.isKeyPressed(Input.Keys.SPACE)) { - jumpSound.play(); - player.jump(); - } - - if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) { - isPaused = !isPaused; - System.out.println("isPaused: " + isPaused); - } - - if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_1)) { - if (!isPaused) { - colourchangeSound.play(); - player.setCurColour(com.game.actor.Base.Colours.RED); - } - } - - if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_2)) { - if (!isPaused) { - colourchangeSound.play(); - player.setCurColour(com.game.actor.Base.Colours.GREEN); - } - } - - if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_3)) { - if (!isPaused) { - colourchangeSound.play(); - player.setCurColour(com.game.actor.Base.Colours.BLUE); - } - } - if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_4)) { - if (!isPaused) { - player.setCurColour(com.game.actor.Base.Colours.YELLOW); - } - } - - if (Gdx.input.isKeyJustPressed(Input.Keys.V)) { - isDebug = !isDebug; - } - } - - @Override - public void dispose() { - super.dispose(); - world.dispose(); - b2dr.dispose(); - tileMap.dispose(); - tmr.dispose(); - } - - private void initLevel() { - tileMap = new TmxMapLoader().load("endlessblocks/endless1.tmx"); - MapProperties mapProp = tileMap.getProperties(); - mapWidth = mapProp.get("width", Integer.class); - mapHeight = mapProp.get("height", Integer.class); - tileSize = new Vector2(mapProp.get("tilewidth", Integer.class), mapProp.get("tileheight", Integer.class)); - - - TiledMapTileLayer platformLayer = (TiledMapTileLayer) tileMap.getLayers().get("PLATFORM"); - - MapLayer boundaryLayer = tileMap.getLayers().get("BOUNDARY"); - PolylineMapObject polylineObj = (PolylineMapObject) boundaryLayer.getObjects().get(0); - initBoundary(polylineObj, "BOUNDARY", false); - - tmr = new OrthogonalTiledMapRenderer(tileMap); - - boundaryLayer = tileMap.getLayers().get("FAILBOUNDARY"); - polylineObj = (PolylineMapObject) boundaryLayer.getObjects().get(0); - initBoundary(polylineObj, "FAILBOUNDARY", true); - - MapLayer playerLayer = tileMap.getLayers().get("PLAYER"); - TextureMapObject playerObj = (TextureMapObject) playerLayer.getObjects().get(0); - player = new com.game.actor.Player(world, new Vector2(playerObj.getX(), playerObj.getY()), new Vector2(60, 60), com.game.actor.Base.Colours.NONE); - - for (int row = 0; row < platformLayer.getHeight(); row++) { - for (int col = 0; col < platformLayer.getWidth(); col++) { - TiledMapTileLayer.Cell cell = platformLayer.getCell(col, row); - - if (cell == null) { - continue; - } - if (cell.getTile() == null) { - continue; - } - - if (cell.getTile().getId() == 1) { - platforms.add(new com.game.actor.Platform(world, new Vector2((col + 0.5f) * tileSize.x, (row + 0.5f) * tileSize.y), new Vector2(tileSize.x, tileSize.y), com.game.actor.Base.Colours.RED, com.game.misc.Vars.BIT_RED, com.game.misc.Vars.BIT_PLAYER)); - } else if (cell.getTile().getId() == 2) { - platforms.add(new com.game.actor.Platform(world, new Vector2((col + 0.5f) * tileSize.x, (row + 0.5f) * tileSize.y), new Vector2(tileSize.x, tileSize.y), com.game.actor.Base.Colours.GREEN, com.game.misc.Vars.BIT_GREEN, com.game.misc.Vars.BIT_PLAYER)); - } else if (cell.getTile().getId() == 3) { - platforms.add(new com.game.actor.Platform(world, new Vector2((col + 0.5f) * tileSize.x, (row + 0.5f) * tileSize.y), new Vector2(tileSize.x, tileSize.y), com.game.actor.Base.Colours.BLUE, com.game.misc.Vars.BIT_BLUE, com.game.misc.Vars.BIT_PLAYER)); - } - } - } - } - - private void initBoundary(PolylineMapObject polylineObj, String userData, boolean isSensor) - { - Polyline r = polylineObj.getPolyline(); - BodyDef bd = new BodyDef(); - bd.type = BodyDef.BodyType.StaticBody; - - Body body = world.createBody(bd); - - float[] v = r.getTransformedVertices(); - Vector2[] finalV = new Vector2[v.length / 2]; - - for(int i = 0; i < v.length / 2; ++i) - { - finalV[i] = new Vector2(); - finalV[i].x = v[i * 2] / PPM; - finalV[i].y = v[i * 2 + 1] / PPM; - } - - Box2dUtils.makeChain(body, finalV, userData, isSensor, Vars.BIT_PRISMATIC, Vars.BIT_PLAYER); - } - - private void initIntroWindow() { - isPaused = true; - introWindow = new Window("Level " + levelNumber, skin); - introWindow.getTitleLabel().setPosition(350, 500); - introBackground = new Image(app.assets.get("textures/level1Intro.png", Texture.class)); - introWindow.setBackground(introBackground.getDrawable()); - introWindow.setSize(700, 500); - introWindow.setPosition(280, 50); - introWindow.setVisible(true); - - butProceed = new TextButton("PROCEED", skin, "default"); - butProceed.setPosition((introWindow.getWidth() / 4) * 3, buttonSize.y + 360); - butProceed.setSize(buttonSize.x, buttonSize.y); - butProceed.addListener(new ClickListener() { - @Override - public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { - introWindow.setVisible(false); - isIntro = false; - isPaused = false; - } - }); - - introWindow.addActor(butProceed); - - - if (!hasPlayedOnce) { - stage.addActor(introWindow); - hasPlayedOnce = true; - } - } - - private void initPauseWindow() { - pauseWindow = new Window("Paused", skin); - pauseWindow.getTitleLabel().setPosition(350, 500); - pauseBackground = new Image(app.assets.get("textures/pauseBackground.png", Texture.class)); - pauseWindow.setBackground(pauseBackground.getDrawable()); - pauseWindow.setSize(700, 500); - pauseWindow.setPosition(280, 50); - pauseWindow.setVisible(false); - - butContinue = new TextButton("Continue", skin, "default"); - butContinue.setPosition((pauseWindow.getWidth() / 2) - buttonSize.x / 2, buttonSize.y + 240); - butContinue.setSize(buttonSize.x, buttonSize.y); - butContinue.addListener(new ClickListener() { - @Override - public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { - isPaused = false; - } - }); - - butReset = new TextButton("Reset", skin, "default"); - butReset.setPosition((pauseWindow.getWidth() / 2) - buttonSize.x / 2, buttonSize.y + 140); - butReset.setSize(buttonSize.x, buttonSize.y); - butReset.addListener(new ClickListener() { - @Override - public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { - app.sm.setPlayScreen(levelNumber); - } - }); - - butExit = new TextButton("Exit", skin, "default"); - butExit.setPosition((pauseWindow.getWidth() / 2) - buttonSize.x / 2, buttonSize.y + 40); - butExit.setSize(buttonSize.x, buttonSize.y); - butExit.addListener(new ClickListener() { - @Override - public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { - app.sm.setScreen(ScreenManager.Screen.MENU); - } - }); - - pauseGlow = new Image(app.assets.get("textures/pauseGlow.png", Texture.class)); - pauseGlow.setVisible(false); - - pauseWindow.addActor(butContinue); - pauseWindow.addActor(butReset); - pauseWindow.addActor(butExit); - - stage.addActor(pauseGlow); - stage.addActor(pauseWindow); - } - - private void initEndgameWindow(boolean success) { - isPaused = true; - if (success) { - endgameWindow = new Window("Success", skin); - successBackground = new Image(app.assets.get("textures/successBackground.png", Texture.class)); - endgameWindow.setBackground(successBackground.getDrawable()); - - butNext = new TextButton("Next", skin, "default"); - butNext.setPosition((pauseWindow.getWidth() / 2) - buttonSize.x / 2, buttonSize.y + 240); - butNext.setSize(buttonSize.x, buttonSize.y); - butNext.addListener(new ClickListener() { - @Override - public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { - app.sm.setPlayScreen(levelNumber + 1); - } - }); - endgameWindow.addActor(butNext); - } else { - endgameWindow = new Window("Failure", skin); - failureBackground = new Image(app.assets.get("textures/failureBackground.png", Texture.class)); - endgameWindow.setBackground(failureBackground.getDrawable()); - } - endgameWindow.getTitleLabel().setPosition(350, 500); - endgameWindow.setSize(700, 500); - endgameWindow.setPosition(280, 50); - endgameWindow.setVisible(false); - - endgameWindow.addActor(butReset); - endgameWindow.addActor(butExit); - - stage.addActor(pauseGlow); - stage.addActor(endgameWindow); - } - - // Accessors - - // Mutators - - // Contact Listener - ContactListener cl = new ContactListener() { - @Override - public void beginContact(Contact contact) { - Fixture fa = contact.getFixtureA(); - Fixture fb = contact.getFixtureB(); - - if (fa == null || fb == null) { - return; - } - if (fa.getUserData() == null || fb.getUserData() == null) { - return; - } - - if (fa.getUserData().equals("PLAYER") && fb.getUserData().equals("PLATFORM") || - fb.getUserData().equals("PLAYER") && fa.getUserData().equals("PLATFORM")) { - if (player.getCurAction() != com.game.actor.Player.Action.IDLE) { - player.setAction(com.game.actor.Player.Action.IDLE); - return; - } - } - - if (fa.getUserData().equals("PLAYER") && fb.getUserData().equals("PASSBOUNDARY") || - fb.getUserData().equals("PLAYER") && fa.getUserData().equals("PASSBOUNDARY")) { - isEnd = true; - isSuccess = true; - - return; - } - - if (fa.getUserData().equals("PLAYER") && fb.getUserData().equals("FAILBOUNDARY") || - fb.getUserData().equals("PLAYER") && fa.getUserData().equals("FAILBOUNDARY")) { - isEnd = true; - isSuccess = false; - return; - } - - } - - @Override - public void endContact(Contact contact) { - - } - - @Override - public void preSolve(Contact contact, Manifold oldManifold) { - - } - - @Override - public void postSolve(Contact contact, ContactImpulse impulse) { - - } - }; -} diff --git a/core/src/com/game/Screens/Leaderboard.java b/core/src/com/game/Screens/Leaderboard.java index 83fe2d5..31a55d0 100644 --- a/core/src/com/game/Screens/Leaderboard.java +++ b/core/src/com/game/Screens/Leaderboard.java @@ -50,7 +50,7 @@ public class Leaderboard extends AbstractScreen { super.render(dt); app.sb.begin(); - app.sb.draw(app.assets.get("textures/leaderboardBackground.jpg", Texture.class), 0, 0); + app.sb.draw(app.assets.get("textures/backgrounds/leaderboardBackground.jpg", Texture.class), 0, 0); app.sb.end(); stage.draw(); diff --git a/core/src/com/game/Screens/LevelSelect.java b/core/src/com/game/Screens/LevelSelect.java index 348fbbe..d3768a4 100644 --- a/core/src/com/game/Screens/LevelSelect.java +++ b/core/src/com/game/Screens/LevelSelect.java @@ -54,7 +54,7 @@ public class LevelSelect extends AbstractScreen { super.render(dt); app.sb.begin(); - app.sb.draw(app.assets.get("textures/levelSelectBackground.jpg", Texture.class), 0, 0); + app.sb.draw(app.assets.get("textures/backgrounds/levelSelectBackground.jpg", Texture.class), 0, 0); app.sb.end(); stage.draw(); @@ -106,7 +106,7 @@ public class LevelSelect extends AbstractScreen { butEndless.addListener(new ClickListener() { @Override public void clicked (com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { - app.sm.setScreen(ScreenManager.Screen.ENDLESSMODE); + //app.sm.setScreen(ScreenManager.Screen.ENDLESSMODE); TODO, finish this ;) } }); diff --git a/core/src/com/game/Screens/Loading.java b/core/src/com/game/Screens/Loading.java index cc107a8..f374b10 100644 --- a/core/src/com/game/Screens/Loading.java +++ b/core/src/com/game/Screens/Loading.java @@ -39,10 +39,10 @@ public class Loading extends AbstractScreen { loadFont("fonts/badaboom.TTF", 60, Color.BLACK); - app.assets.load("textures/player_red.png", Texture.class); + app.assets.load("textures/player/player_red.png", Texture.class); app.assets.finishLoading(); // make sure player texture and font is loaded - logo = app.assets.get("textures/player_red.png", Texture.class); + logo = app.assets.get("textures/player/player_red.png", Texture.class); loadingRect = new Rectangle(stage.getWidth() / 6f, (stage.getHeight() / 2f - 25), 0, 25); assetsToLoad(); @@ -97,25 +97,30 @@ public class Loading extends AbstractScreen { loadFont("fonts/badaboom.TTF", 45, Color.BLACK); // Textures - app.assets.load("textures/badlogic.jpg", Texture.class); - app.assets.load("textures/menuBackground.jpg", Texture.class); - app.assets.load("textures/leaderboardBackground.jpg", Texture.class); - app.assets.load("textures/levelSelectBackground.jpg", Texture.class); - app.assets.load("textures/pauseBackground.png", Texture.class); - app.assets.load("textures/failureBackground.png", Texture.class); - app.assets.load("textures/successBackground.png", Texture.class); - app.assets.load("textures/pauseGlow.png", Texture.class); - 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); + app.assets.load("textures/backgrounds/menuBackground.jpg", Texture.class); + app.assets.load("textures/backgrounds/leaderboardBackground.jpg", Texture.class); + app.assets.load("textures/backgrounds/levelSelectBackground.jpg", Texture.class); + app.assets.load("textures/backgrounds/pauseBackground.png", Texture.class); + app.assets.load("textures/backgrounds/failureBackground.png", Texture.class); + app.assets.load("textures/backgrounds/successBackground.png", Texture.class); + app.assets.load("textures/backgrounds/position0.png", Texture.class); + app.assets.load("textures/backgrounds/position1.png", Texture.class); + app.assets.load("textures/backgrounds/position2.png", Texture.class); + for(int i = 1; i <= 10; i++) { - app.assets.load("textures/level" + i + "Intro.png", Texture.class); + app.assets.load("textures/intros/level" + i + "Intro.png", Texture.class); } - app.assets.load("textures/player_green.png", Texture.class); - app.assets.load("textures/player_blue.png", Texture.class); - app.assets.load("textures/player_yellow.png", Texture.class); + app.assets.load("textures/player/player_green.png", Texture.class); + app.assets.load("textures/player/player_blue.png", Texture.class); + app.assets.load("textures/player/player_yellow.png", Texture.class); + + app.assets.load("textures/enemies/redAlive.png", Texture.class); + app.assets.load("textures/enemies/redDead.png", Texture.class); + app.assets.load("textures/enemies/greenAlive.png", Texture.class); + app.assets.load("textures/enemies/greenDead.png", Texture.class); + app.assets.load("textures/enemies/blueAlive.png", Texture.class); + app.assets.load("textures/enemies/blueDead.png", Texture.class); // Spritesheets app.assets.load("spritesheets/platformSet.png", Texture.class); diff --git a/core/src/com/game/Screens/Menu.java b/core/src/com/game/Screens/Menu.java index dbc368c..2c64612 100644 --- a/core/src/com/game/Screens/Menu.java +++ b/core/src/com/game/Screens/Menu.java @@ -61,7 +61,7 @@ public class Menu extends AbstractScreen { super.render(dt); app.sb.begin(); - app.sb.draw(app.assets.get("textures/menuBackground.jpg", Texture.class), 0, 0); + app.sb.draw(app.assets.get("textures/backgrounds/menuBackground.jpg", Texture.class), 0, 0); app.sb.end(); stage.draw(); diff --git a/core/src/com/game/Screens/Play.java b/core/src/com/game/Screens/Play.java index 8a27a16..5132938 100644 --- a/core/src/com/game/Screens/Play.java +++ b/core/src/com/game/Screens/Play.java @@ -2,12 +2,12 @@ package com.game.screens; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; -import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.maps.MapLayer; +import com.badlogic.gdx.maps.MapObjects; import com.badlogic.gdx.maps.MapProperties; import com.badlogic.gdx.maps.objects.PolylineMapObject; import com.badlogic.gdx.maps.objects.TextureMapObject; @@ -20,20 +20,26 @@ import com.badlogic.gdx.math.Polyline; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.*; +import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.game.actor.Base; -import com.game.actor.Platform; +import com.game.actor.Enemy; +import com.game.actor.object.Platform; import com.game.actor.Player; import com.game.App; -import com.game.actor.Spike; import com.game.managers.ScreenManager; import com.game.misc.*; -import com.game.misc.myWindow; +import com.game.misc.utils.myButton; +import com.game.misc.utils.myWindow; +import com.game.misc.utils.Box2dUtils; +import com.game.misc.utils.CameraUtils; import java.util.ArrayList; import java.util.HashMap; +import static com.game.misc.Vars.BIT_ALL; +import static com.game.misc.Vars.BIT_PLAYER; import static com.game.misc.Vars.PPM; /** @@ -41,30 +47,6 @@ import static com.game.misc.Vars.PPM; */ public class Play extends AbstractScreen { - private Skin skin; - - // TODO, remove - public boolean isDebug = false; - - // Physics related - private World world; - private Box2DDebugRenderer b2dr; // TODO, remove - private OrthographicCamera b2dCam; // TODO, remove - - // TileMap and Map Renderer - private TiledMap tileMap; - private OrthogonalTiledMapRenderer tmr; - private float mapWidth, mapHeight; - private Vector2 tileSize; - - // All Actors in level - private Player player; - private ArrayList platforms = new ArrayList(); - private ArrayList spikes = new ArrayList(); - - // Windows - private HashMap windows = new HashMap(); - private GameState curGameState; public enum GameState { @@ -75,26 +57,44 @@ public class Play extends AbstractScreen { FAILURE, } - // Progress bar + + // Physics related + private World world; + public boolean isDebug = false; + private Box2DDebugRenderer b2dr; // TODO, remove + private OrthographicCamera b2dCam; // TODO, remove + + // TileMap and Map Renderer + private TiledMap tileMap; + private OrthogonalTiledMapRenderer tmr; + private float mapWidth, mapHeight; + private Vector2 tileSize; + private int levelNumber; + + // All Actors in level + private Player player; + private ArrayList platforms = new ArrayList(); + private ArrayList enemies = new ArrayList(); + + // Windows + private Skin skin; + private HashMap windows = new HashMap(); + + // HUD private Rectangle progressRect; private Texture progressTexture; private float percent; private float progressX; - - private int levelNumber; + private Image uiRedImage, uiGreenImage, uiBlueImage; public Play(App app, int levelNumber) { super(app); - - skin = new Skin(); - this.levelNumber = levelNumber; - + skin = new Skin(); world = new World(new Vector2(0, Vars.GRAVITY.y), true); world.setContactListener(cl); b2dr = new Box2DDebugRenderer(); // TODO, remove - b2dCam = new OrthographicCamera(); b2dCam.setToOrtho(false, Vars.SCREEN_WIDTH / PPM, Vars.SCREEN_HEIGHT / PPM); } @@ -108,12 +108,21 @@ public class Play extends AbstractScreen { skin.load(Gdx.files.internal("spritesheets/uiskin.json")); progressRect = new Rectangle(stage.getWidth() - 550, (stage.getHeight() - 50), 0, 25); - progressTexture = app.assets.get("textures/player_red.png", Texture.class); + progressTexture = app.assets.get("textures/player/player_red.png", Texture.class); + progressX = progressRect.x; + + uiRedImage = new Image(app.assets.get("textures/player/player_red.png", Texture.class)); + uiRedImage.setPosition(84, (stage.getHeight() - 70)); + uiGreenImage = new Image(app.assets.get("textures/player/player_green.png", Texture.class)); + uiGreenImage.setPosition(148, (stage.getHeight() - 70)); + uiBlueImage = new Image(app.assets.get("textures/player/player_blue.png", Texture.class)); + uiBlueImage.setPosition(212, (stage.getHeight() - 70)); + uiRedImage.setSize(64, 64); + uiGreenImage.setSize(32, 32); + uiBlueImage.setSize(32, 32); initLevel(); - System.out.println("Finished initLevel"); initWindows(); - System.out.println("Finished initWindows"); setCurGameState(GameState.INTRO); } @@ -122,11 +131,10 @@ public class Play extends AbstractScreen { if(curGameState == GameState.PLAYING) { - world.step(dt, 6, 2); + world.step(Vars.STEP, 6, 2); CameraUtils.lerpToTarget(cam, player.getPos().scl(PPM).x, 0); CameraUtils.lerpToTarget(b2dCam, player.getPos().x, player.getPos().y); - b2dCam.zoom = 5f; Vector2 start = new Vector2(cam.viewportWidth / 2, cam.viewportHeight / 2); CameraUtils.setBoundary(cam, start, new Vector2(mapWidth * tileSize.x - start.x * 2, mapHeight * tileSize.y - start.y * 2)); @@ -149,10 +157,15 @@ public class Play extends AbstractScreen { if(!isDebug) { app.sb.begin(); - app.sb.draw(app.assets.get("textures/position0.png", Texture.class), (cam.position.x - cam.viewportWidth / 2), cam.position.y - cam.viewportHeight / 2); - app.sb.draw(app.assets.get("textures/position1.png", Texture.class), (cam.position.x - cam.viewportWidth / 2) * .1f, cam.position.y - (cam.viewportHeight / 2) + 75); - app.sb.draw(app.assets.get("textures/position2.png", Texture.class), (cam.position.x - cam.viewportWidth / 2) * .01f, cam.position.y - (cam.viewportHeight / 2) - 150); + app.sb.draw(app.assets.get("textures/backgrounds/position0.png", Texture.class), (cam.position.x - cam.viewportWidth / 2), cam.position.y - cam.viewportHeight / 2); + app.sb.draw(app.assets.get("textures/backgrounds/position1.png", Texture.class), (cam.position.x - cam.viewportWidth / 2), cam.position.y - (cam.viewportHeight / 2) + 75); + app.sb.draw(app.assets.get("textures/backgrounds/position2.png", Texture.class), (cam.position.x - cam.viewportWidth / 2), cam.position.y - (cam.viewportHeight / 2) - 150); player.render(app.sb); + + for(Enemy e : enemies) + { + e.render(app.sb); + } app.sb.end(); tmr.setView(cam); @@ -169,7 +182,9 @@ public class Play extends AbstractScreen { app.sr.end(); app.sb.begin(); - app.sb.draw(app.assets.get("spritesheets/platformSet.png", Texture.class), 100, (stage.getHeight() - 50)); + uiRedImage.draw(app.sb, 1f); + uiGreenImage.draw(app.sb, 1f); + uiBlueImage.draw(app.sb, 1f); app.sb.draw(progressTexture, progressX, progressRect.y, 30, 30); app.sb.end(); } @@ -191,28 +206,9 @@ public class Play extends AbstractScreen { player.jump(); } - if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_1)) - { - player.setCurColour(Base.Colours.RED); - progressTexture = app.assets.get("textures/player_red.png", Texture.class); - } - - if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_2)) - { - player.setCurColour(Base.Colours.GREEN); - progressTexture = app.assets.get("textures/player_green.png", Texture.class); - } - - if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_3)) { - player.setCurColour(Base.Colours.BLUE); - progressTexture = app.assets.get("textures/player_blue.png", Texture.class); - } - - if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_4)) - { - player.setCurColour(Base.Colours.YELLOW); - progressTexture = app.assets.get("textures/player_yellow.png", Texture.class); - } + if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_1)) { changeColour(Base.Colours.RED); } + if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_2)) { changeColour(Base.Colours.GREEN); } + if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_3)) { changeColour(Base.Colours.BLUE); } } if(Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) @@ -238,6 +234,32 @@ public class Play extends AbstractScreen { tmr.dispose(); } + private void changeColour(Base.Colours curColour) + { + player.setCurColour(curColour); + switch(curColour) + { + case RED: + progressTexture = app.assets.get("textures/player/player_red.png", Texture.class); + uiRedImage.setSize(64, 64); + uiGreenImage.setSize(32, 32); + uiBlueImage.setSize(32, 32); + break; + case GREEN: + progressTexture = app.assets.get("textures/player/player_green.png", Texture.class); + uiGreenImage.setSize(64, 64); + uiRedImage.setSize(32, 32); + uiBlueImage.setSize(32, 32); + break; + case BLUE: + progressTexture = app.assets.get("textures/player/player_blue.png", Texture.class); + uiBlueImage.setSize(64, 64); + uiGreenImage.setSize(32, 32); + uiRedImage.setSize(32, 32); + break; + } + } + private void initLevel() { tileMap = new TmxMapLoader().load("levels/level" + levelNumber + ".tmx"); @@ -250,7 +272,6 @@ 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); @@ -266,7 +287,20 @@ public class Play extends AbstractScreen { MapLayer playerLayer = tileMap.getLayers().get("PLAYER"); TextureMapObject playerObj = (TextureMapObject)playerLayer.getObjects().get(0); - player = new Player(world, new Vector2(playerObj.getX(), playerObj.getY()), new Vector2(60, 60), Base.Colours.NONE); + player = new Player(world, new Vector2(playerObj.getX(), playerObj.getY()), new Vector2(60, 60), Base.Colours.WHITE); + + MapLayer enemyLayer = tileMap.getLayers().get("ENEMIES"); + MapObjects enemyObjs = enemyLayer.getObjects(); + + for(int i = 0; i < enemyObjs.getCount(); i++) + { + TextureMapObject tmo = (TextureMapObject)enemyObjs.get(i); + MapProperties mp = tmo.getProperties(); + + if(mp.get("Colour").equals("RED")) { enemies.add(new Enemy(world, new Vector2(tmo.getX(), tmo.getY()), new Vector2(64, 64), Base.Colours.RED, BIT_ALL, BIT_PLAYER)); } + else if(mp.get("Colour").equals("GREEN")) { enemies.add(new Enemy(world, new Vector2(tmo.getX(), tmo.getY()), new Vector2(64, 64), Base.Colours.GREEN, BIT_ALL, BIT_PLAYER)); } + else if(mp.get("Colour").equals("BLUE")) { enemies.add(new Enemy(world, new Vector2(tmo.getX() + 32, tmo.getY() + 32), new Vector2(64, 64), Base.Colours.GREEN, BIT_ALL, BIT_PLAYER)); } + } for(int row = 0; row < platformLayer.getHeight(); row++) { @@ -280,21 +314,9 @@ public class Play extends AbstractScreen { if(cell.getTile().getId() == 1) { 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.RED, Vars.BIT_RED, Vars.BIT_PLAYER)); } else if(cell.getTile().getId() == 2) { 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.GREEN, Vars.BIT_GREEN, 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)); } + else if(cell.getTile().getId() == 4) { 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.WHITE, Vars.BIT_ALL, 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)); } - } - }*/ } private void initBoundary(PolylineMapObject polylineObj, String userData, boolean isSensor) @@ -315,7 +337,7 @@ public class Play extends AbstractScreen { finalV[i].y = v[i * 2 + 1] / PPM; } - Box2dUtils.makeChain(body, finalV, userData, isSensor, Vars.BIT_PRISMATIC, Vars.BIT_PLAYER); + Box2dUtils.makeChain(body, finalV, userData, isSensor, Vars.BIT_ALL, Vars.BIT_PLAYER); } /** @@ -323,33 +345,18 @@ public class Play extends AbstractScreen { */ private void initWindows() { -<<<<<<< HEAD Vector2 winPos = new Vector2(280, 50); Vector2 winSize = new Vector2(700, 500); - windows.put(GameState.PLAYING, new myWindow("", new Vector2(0, 0), new Vector2(0, 0), skin, app.assets.get("textures/player_red.png", Texture.class))); - windows.put(GameState.INTRO, new myWindow("Level " + levelNumber, winPos, winSize, skin, app.assets.get("textures/level" + levelNumber + "Intro.png", Texture.class))); - windows.put(GameState.PAUSED, new myWindow("", winPos, winSize, skin, app.assets.get("textures/pauseBackground.png", Texture.class))); - windows.put(GameState.SUCCESS, new myWindow("", winPos, winSize, skin, app.assets.get("textures/successBackground.png", Texture.class))); - windows.put(GameState.FAILURE, new myWindow("", winPos, winSize, skin, app.assets.get("textures/failureBackground.png", Texture.class))); + windows.put(GameState.PLAYING, new myWindow("", new Vector2(0, 0), new Vector2(0, 0), skin, app.assets.get("textures/player/player_red.png", Texture.class))); + windows.put(GameState.INTRO, new myWindow("Level " + levelNumber, winPos, winSize, skin, app.assets.get("textures/intros/level" + levelNumber + "Intro.png", Texture.class))); + windows.put(GameState.PAUSED, new myWindow("", winPos, winSize, skin, app.assets.get("textures/backgrounds/pauseBackground.png", Texture.class))); + windows.put(GameState.SUCCESS, new myWindow("", winPos, winSize, skin, app.assets.get("textures/backgrounds/successBackground.png", Texture.class))); + windows.put(GameState.FAILURE, new myWindow("", winPos, winSize, skin, app.assets.get("textures/backgrounds/failureBackground.png", Texture.class))); // Init INTRO buttons myWindow tempWindow = windows.get(GameState.INTRO); tempWindow.addButton(new myButton("Continue", new Vector2((tempWindow.getX() * 2) - 5, tempWindow.getHeight() - 50), skin, "default", new ClickListener() { -======= - introWindow = new Window("Level "+levelNumber, skin); - introWindow.getTitleLabel().setPosition(350, 500); - introBackground = new Image(app.assets.get("textures/level" + levelNumber + "Intro.png", Texture.class)); - introWindow.setBackground(introBackground.getDrawable()); - introWindow.setSize(700, 500); - introWindow.setPosition(280, 50); - introWindow.setVisible(true); - - TextButton butProceed = new TextButton("PROCEED", skin, "default"); - butProceed.setPosition((introWindow.getWidth() / 4) * 3, buttonSize.y + 360); - butProceed.setSize(buttonSize.x, buttonSize.y); - butProceed.addListener(new ClickListener() { ->>>>>>> origin/master @Override public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { setCurGameState(GameState.PLAYING); @@ -452,12 +459,17 @@ public class Play extends AbstractScreen { } } - if(fa.getUserData().equals("PLAYER") && fb.getUserData().equals("SPIKES") || - fb.getUserData().equals("PLAYER") && fa.getUserData().equals("SPIKES")) + if(fa.getUserData().equals("PLAYER") && fb.getUserData().equals("ENEMY") || + fb.getUserData().equals("PLAYER") && fa.getUserData().equals("ENEMY")) { - setCurGameState(GameState.FAILURE); - System.out.println("FAILURE - TOUCHED SPIKE"); - return; + for(Enemy e : enemies) + { + if(e.getFixtures().contains(fa, false) || e.getFixtures().contains(fb, false)) + { + e.setAlive(false); + e.setCurColour(e.getCurColour()); + } + } } if(fa.getUserData().equals("PLAYER") && fb.getUserData().equals("PASSBOUNDARY") || diff --git a/core/src/com/game/managers/ScreenManager.java b/core/src/com/game/managers/ScreenManager.java index ee4b734..e36cc99 100644 --- a/core/src/com/game/managers/ScreenManager.java +++ b/core/src/com/game/managers/ScreenManager.java @@ -35,12 +35,11 @@ public class ScreenManager { screens.put(Screen.MENU, new Menu(app)); screens.put(Screen.LEADERBOARD, new Leaderboard(app)); screens.put(Screen.LEVELSELECT, new LevelSelect(app)); - screens.put(Screen.ENDLESSMODE, new EndlessMode(app)); + //screens.put(Screen.ENDLESSMODE, new EndlessMode(app)); } public void setPlayScreen(int levelNumber) { - // remove loaded level if(screens.get(Screen.PLAY) != null) {