diff --git a/app/app.iml b/app/app.iml index 19c3c46..816798b 100644 --- a/app/app.iml +++ b/app/app.iml @@ -90,7 +90,6 @@ - diff --git a/app/build/intermediates/assets/debug/levelpack_01.xml b/app/build/intermediates/assets/debug/levelpack_01.xml deleted file mode 100644 index 5d000c8..0000000 --- a/app/build/intermediates/assets/debug/levelpack_01.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/build/intermediates/assets/debug/levelpacks/Grasslands.xml b/app/build/intermediates/assets/debug/levelpacks/Grasslands.xml index d5a9e0e..300a394 100644 --- a/app/build/intermediates/assets/debug/levelpacks/Grasslands.xml +++ b/app/build/intermediates/assets/debug/levelpacks/Grasslands.xml @@ -1,284 +1,272 @@ - - GRASSLANDS + + GRASSLANDS - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - - - - - - + + + - - - + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/app/build/intermediates/assets/debug/levelpacks/Testcave.xml b/app/build/intermediates/assets/debug/levelpacks/Testcave.xml deleted file mode 100644 index 7048a0f..0000000 --- a/app/build/intermediates/assets/debug/levelpacks/Testcave.xml +++ /dev/null @@ -1,115 +0,0 @@ - - TESTCAVE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/build/intermediates/assets/debug/shader/entityVertexShader.glsl b/app/build/intermediates/assets/debug/shader/entityVertexShader.glsl index 19da5d9..b96c4d4 100644 --- a/app/build/intermediates/assets/debug/shader/entityVertexShader.glsl +++ b/app/build/intermediates/assets/debug/shader/entityVertexShader.glsl @@ -1,5 +1,6 @@ uniform mat4 mvpMatrix; uniform mat4 transformationMatrix; +uniform vec2 texCoordScaling; attribute vec4 position; attribute vec2 texCoords; @@ -11,5 +12,9 @@ void main() { vec4 transformatedPosition = transformationMatrix * position; gl_Position = mvpMatrix * transformatedPosition; pass_TexCoords = texCoords; + if(texCoordScaling.x != 0.0) + pass_TexCoords.x *= texCoordScaling.x; + if(texCoordScaling.y != 0.0) + pass_TexCoords.y *= texCoordScaling.y; } \ No newline at end of file diff --git a/app/build/intermediates/assets/debug/testlevelpack.xml b/app/build/intermediates/assets/debug/testlevelpack.xml deleted file mode 100644 index 844f2fb..0000000 --- a/app/build/intermediates/assets/debug/testlevelpack.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/build/intermediates/blame/res/debug/single/drawable.json b/app/build/intermediates/blame/res/debug/single/drawable.json index 59a67e0..8d8ef7a 100644 --- a/app/build/intermediates/blame/res/debug/single/drawable.json +++ b/app/build/intermediates/blame/res/debug/single/drawable.json @@ -43,14 +43,14 @@ "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\abc_seekbar_thumb_material.xml", "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\drawable\\abc_seekbar_thumb_material.xml" }, - { - "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\xml_background_tutorialtextview.xml", - "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\drawable\\xml_background_tutorialtextview.xml" - }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\abc_btn_check_material.xml", "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\drawable\\abc_btn_check_material.xml" }, + { + "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\xml_background_tutorialtextview.xml", + "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\drawable\\xml_background_tutorialtextview.xml" + }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\abc_spinner_textfield_background_material.xml", "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\drawable\\abc_spinner_textfield_background_material.xml" @@ -167,14 +167,14 @@ "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\backgrounds_game_mountains.png", "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\drawable\\backgrounds_game_mountains.png" }, - { - "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\tools_unlockedbutton.png", - "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\drawable\\tools_unlockedbutton.png" - }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\guis_playerarrow.png", "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\drawable\\guis_playerarrow.png" }, + { + "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\tools_unlockedbutton.png", + "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\drawable\\tools_unlockedbutton.png" + }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\abc_ratingbar_full_material.xml", "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\drawable\\abc_ratingbar_full_material.xml" @@ -195,14 +195,14 @@ "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\tip_icon.png", "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\drawable\\tip_icon.png" }, - { - "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\abc_cab_background_top_material.xml", - "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\drawable\\abc_cab_background_top_material.xml" - }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\tools_emptybutton.png", "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\drawable\\tools_emptybutton.png" }, + { + "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\abc_cab_background_top_material.xml", + "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\drawable\\abc_cab_background_top_material.xml" + }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\abc_text_cursor_material.xml", "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\drawable\\abc_text_cursor_material.xml" @@ -219,14 +219,14 @@ "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\obstacles_grass.png", "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\drawable\\obstacles_grass.png" }, - { - "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\abc_list_selector_holo_light.xml", - "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\drawable\\abc_list_selector_holo_light.xml" - }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\abc_switch_thumb_material.xml", "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\drawable\\abc_switch_thumb_material.xml" }, + { + "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\abc_list_selector_holo_light.xml", + "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\drawable\\abc_list_selector_holo_light.xml" + }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\drawable\\tools_bombbutton.png", "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\drawable\\tools_bombbutton.png" diff --git a/app/build/intermediates/blame/res/debug/single/layout.json b/app/build/intermediates/blame/res/debug/single/layout.json index eb011f2..9b7dc63 100644 --- a/app/build/intermediates/blame/res/debug/single/layout.json +++ b/app/build/intermediates/blame/res/debug/single/layout.json @@ -3,22 +3,22 @@ "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\layout\\levels.xml", "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\layout\\levels.xml" }, - { - "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\layout\\toolshop.xml", - "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\layout\\toolshop.xml" - }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\layout\\tutorial.xml", "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\layout\\tutorial.xml" }, { - "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\layout\\abc_screen_simple_overlay_action_mode.xml", - "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\layout\\abc_screen_simple_overlay_action_mode.xml" + "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\layout\\toolshop.xml", + "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\layout\\toolshop.xml" }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\layout\\worlds.xml", "source": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\src\\main\\res\\layout\\worlds.xml" }, + { + "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\layout\\abc_screen_simple_overlay_action_mode.xml", + "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\layout\\abc_screen_simple_overlay_action_mode.xml" + }, { "merged": "C:\\Users\\Julian\\AndroidStudioProjects\\EndlessRoll\\app\\build\\intermediates\\res\\merged\\debug\\layout\\abc_screen_simple.xml", "source": "C:\\Users\\Julian\\.android\\build-cache\\2232000db64551c7682d41127fbc27c912efcc3d\\output\\res\\layout\\abc_screen_simple.xml" diff --git a/app/build/intermediates/incremental/mergeDebugAssets/merger.xml b/app/build/intermediates/incremental/mergeDebugAssets/merger.xml index 0d5833a..25d4117 100644 --- a/app/build/intermediates/incremental/mergeDebugAssets/merger.xml +++ b/app/build/intermediates/incremental/mergeDebugAssets/merger.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/build/intermediates/res/merged/debug/drawable/goal.png b/app/build/intermediates/res/merged/debug/drawable/goal.png index d530dc2..5e67350 100644 Binary files a/app/build/intermediates/res/merged/debug/drawable/goal.png and b/app/build/intermediates/res/merged/debug/drawable/goal.png differ diff --git a/app/build/intermediates/res/merged/debug/layout/start_screen.xml b/app/build/intermediates/res/merged/debug/layout/start_screen.xml index 8368a3a..87142f8 100644 --- a/app/build/intermediates/res/merged/debug/layout/start_screen.xml +++ b/app/build/intermediates/res/merged/debug/layout/start_screen.xml @@ -51,6 +51,6 @@ android:layout_marginLeft="48dp" android:layout_marginStart="48dp" android:text="Lv to 100" - android:visibility="gone"/> + android:visibility="visible"/> \ No newline at end of file diff --git a/app/build/intermediates/res/resources-debug.ap_ b/app/build/intermediates/res/resources-debug.ap_ index 164fb87..af456c7 100644 Binary files a/app/build/intermediates/res/resources-debug.ap_ and b/app/build/intermediates/res/resources-debug.ap_ differ diff --git a/app/src/main/assets/Grasslands.xml b/app/src/main/assets/Grasslands.xml deleted file mode 100644 index 562e5a2..0000000 --- a/app/src/main/assets/Grasslands.xml +++ /dev/null @@ -1,285 +0,0 @@ - - GRASSLANDS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/assets/Icy Mountains.xml b/app/src/main/assets/Icy Mountains.xml deleted file mode 100644 index e93c0c8..0000000 --- a/app/src/main/assets/Icy Mountains.xml +++ /dev/null @@ -1,57 +0,0 @@ - - ICY_MOUNTAINS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/assets/levelpack_01.xml b/app/src/main/assets/levelpack_01.xml deleted file mode 100644 index 5d000c8..0000000 --- a/app/src/main/assets/levelpack_01.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/assets/levelpacks/Grasslands.xml b/app/src/main/assets/levelpacks/Grasslands.xml index d5a9e0e..300a394 100644 --- a/app/src/main/assets/levelpacks/Grasslands.xml +++ b/app/src/main/assets/levelpacks/Grasslands.xml @@ -1,284 +1,272 @@ - - GRASSLANDS + + GRASSLANDS - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - - - - - - + + + - - - + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/app/src/main/assets/levelpacks/Testcave.xml b/app/src/main/assets/levelpacks/Testcave.xml deleted file mode 100644 index 7048a0f..0000000 --- a/app/src/main/assets/levelpacks/Testcave.xml +++ /dev/null @@ -1,115 +0,0 @@ - - TESTCAVE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/assets/shader/entityVertexShader.glsl b/app/src/main/assets/shader/entityVertexShader.glsl index 19da5d9..b96c4d4 100644 --- a/app/src/main/assets/shader/entityVertexShader.glsl +++ b/app/src/main/assets/shader/entityVertexShader.glsl @@ -1,5 +1,6 @@ uniform mat4 mvpMatrix; uniform mat4 transformationMatrix; +uniform vec2 texCoordScaling; attribute vec4 position; attribute vec2 texCoords; @@ -11,5 +12,9 @@ void main() { vec4 transformatedPosition = transformationMatrix * position; gl_Position = mvpMatrix * transformatedPosition; pass_TexCoords = texCoords; + if(texCoordScaling.x != 0.0) + pass_TexCoords.x *= texCoordScaling.x; + if(texCoordScaling.y != 0.0) + pass_TexCoords.y *= texCoordScaling.y; } \ No newline at end of file diff --git a/app/src/main/assets/testlevelpack.xml b/app/src/main/assets/testlevelpack.xml deleted file mode 100644 index 844f2fb..0000000 --- a/app/src/main/assets/testlevelpack.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/example/julian/endlessroll/entities/Background.java b/app/src/main/java/com/example/julian/endlessroll/entities/Background.java index fc94d2d..4b4889a 100644 --- a/app/src/main/java/com/example/julian/endlessroll/entities/Background.java +++ b/app/src/main/java/com/example/julian/endlessroll/entities/Background.java @@ -11,6 +11,7 @@ public class Background extends SynchronizedArrayList { private final float PART_WIDTH = 5; private final float HALF_PART_WIDTH = PART_WIDTH / 2; + private final float HEIGHT = 2.5f; private Texture texture; public Background(Texture texture) { @@ -27,7 +28,7 @@ public class Background extends SynchronizedArrayList { } private Entity createPart(float xLeftEdge) { - return new Entity(texture, new Vector(xLeftEdge + HALF_PART_WIDTH, 0), PART_WIDTH, 2); + return new Entity(texture, new Vector(xLeftEdge + HALF_PART_WIDTH, (HEIGHT - 2) / 2), PART_WIDTH, HEIGHT); } public void move(float x, float cameraX) { diff --git a/app/src/main/java/com/example/julian/endlessroll/entities/Entity.java b/app/src/main/java/com/example/julian/endlessroll/entities/Entity.java index fd9eff7..06ed3be 100644 --- a/app/src/main/java/com/example/julian/endlessroll/entities/Entity.java +++ b/app/src/main/java/com/example/julian/endlessroll/entities/Entity.java @@ -16,11 +16,13 @@ public class Entity extends Quad { private float alpha = 1.0f; private boolean destroyed; private DestroyEffect destroyEffect; + private Vector maxTexSize; public Entity(Texture texture, Vector position, float width, float height) { super(position, width, height); this.texture = texture; this.movement = new Vector(); + this.maxTexSize = new Vector(); } public void move(Vector movement) { @@ -91,4 +93,12 @@ public class Entity extends Quad { public int getTextureAtlasIndex() { return textureAtlasIndex; } + + public void setMaxTexSize(Vector maxTexSize) { + this.maxTexSize = maxTexSize; + } + + public Vector getMaxTexSize() { + return maxTexSize; + } } diff --git a/app/src/main/java/com/example/julian/endlessroll/entities/Goal.java b/app/src/main/java/com/example/julian/endlessroll/entities/Goal.java index 4d64a63..d1dc4a0 100644 --- a/app/src/main/java/com/example/julian/endlessroll/entities/Goal.java +++ b/app/src/main/java/com/example/julian/endlessroll/entities/Goal.java @@ -6,7 +6,8 @@ import com.example.julian.endlessroll.entities.textures.Texture; public class Goal extends Entity { public Goal(Texture texture) { - super(texture, new Vector(), 0.1f, 2); + super(texture, new Vector(), 0.1f, 3); + super.getMaxTexSize().setY(0.2f); } public void setGoalX(float goalX) { diff --git a/app/src/main/java/com/example/julian/endlessroll/entities/Obstacle.java b/app/src/main/java/com/example/julian/endlessroll/entities/Obstacle.java index 342a8c5..a35566d 100644 --- a/app/src/main/java/com/example/julian/endlessroll/entities/Obstacle.java +++ b/app/src/main/java/com/example/julian/endlessroll/entities/Obstacle.java @@ -3,7 +3,7 @@ package com.example.julian.endlessroll.entities; import com.example.julian.endlessroll.data.Vector; import com.example.julian.endlessroll.levels.MoveComponent; import com.example.julian.endlessroll.levels.ObstacleData; -import com.example.julian.endlessroll.levels.worlds.Theme; +import com.example.julian.endlessroll.levels.worlds.World; import java.util.Random; @@ -23,8 +23,8 @@ public class Obstacle extends Entity { private float moveProgress; - public Obstacle(Theme theme, ObstacleData data, float terrainEdge) { - super(theme.getObstacleTexture(), new Vector(data.getX(), data.getY()), data.getWidth(), data.getHeight()); + public Obstacle(World world, ObstacleData data, float terrainEdge) { + super(world.getObstacleTexture(), new Vector(data.getX(), data.getY()), data.getWidth(), data.getHeight()); this.deadly = data.isDeadly(); this.floating = data.isFloating(); this.moving = data.isMoving(); diff --git a/app/src/main/java/com/example/julian/endlessroll/entities/particles/Particle.java b/app/src/main/java/com/example/julian/endlessroll/entities/particles/Particle.java index a0af089..d45733d 100644 --- a/app/src/main/java/com/example/julian/endlessroll/entities/particles/Particle.java +++ b/app/src/main/java/com/example/julian/endlessroll/entities/particles/Particle.java @@ -56,7 +56,7 @@ public class Particle extends Entity { public void update(Timer timer, float windStrength, float gravityStrength) { if (active) { - passedLifetime += timer.getFrameTime(); + passedLifetime += timer.getFrameTimeSeconds(); if (passedLifetime >= maxLife) active = false; float lifetimePercent = passedLifetime / maxLife; diff --git a/app/src/main/java/com/example/julian/endlessroll/entities/particles/ParticleSource.java b/app/src/main/java/com/example/julian/endlessroll/entities/particles/ParticleSource.java index 1b9f980..25cd568 100644 --- a/app/src/main/java/com/example/julian/endlessroll/entities/particles/ParticleSource.java +++ b/app/src/main/java/com/example/julian/endlessroll/entities/particles/ParticleSource.java @@ -56,18 +56,18 @@ public class ParticleSource { public void update(Timer timer) { if (alife) { - passedTime += timer.getFrameTime(); + passedTime += timer.getFrameTimeSeconds(); lifePercent = passedTime / maxTime; if (passedTime >= currentDelay) { - passedEmittPause += timer.getFrameTime(); + passedEmittPause += timer.getFrameTimeSeconds(); calcWindAndGravity(); while (passedEmittPause >= emittPause) { passedEmittPause -= emittPause; emitt(); } - passedSecond += timer.getFrameTime(); + passedSecond += timer.getFrameTimeSeconds(); if (passedSecond >= 1000) { passedSecond -= 1000; calcEmittPause(); @@ -89,7 +89,7 @@ public class ParticleSource { inactiveParticles.add(particle); iter.remove(); } else { - particle.move(new Vector(particle.getMovement()).mul(timer.getFrameTime() / 1000)); + particle.move(new Vector(particle.getMovement()).mul(timer.getFrameTimeSeconds() / 1000)); } } activeParticleLock.unlock(); diff --git a/app/src/main/java/com/example/julian/endlessroll/entities/textures/TexturePack.java b/app/src/main/java/com/example/julian/endlessroll/entities/textures/TexturePack.java index ab4fc39..cfa600e 100644 --- a/app/src/main/java/com/example/julian/endlessroll/entities/textures/TexturePack.java +++ b/app/src/main/java/com/example/julian/endlessroll/entities/textures/TexturePack.java @@ -5,7 +5,7 @@ import android.support.annotation.DrawableRes; import com.example.julian.endlessroll.R; import com.example.julian.endlessroll.entities.tools.ToolType; -import com.example.julian.endlessroll.levels.worlds.Theme; +import com.example.julian.endlessroll.levels.worlds.World; /** * Created by Julian on 05.12.2015. @@ -30,7 +30,7 @@ public class TexturePack { energy = loadAtlas(R.drawable.currency_energy_atlas, 2, 2); ToolType.loadAllToolTextures(this); - Theme.loadAllSpecificTextures(this); + World.loadAllSpecificTextures(this); } public Texture loadTexture(@DrawableRes int id) { diff --git a/app/src/main/java/com/example/julian/endlessroll/entities/tileLists/TileList.java b/app/src/main/java/com/example/julian/endlessroll/entities/tileLists/TileList.java index 2f8f743..81a781a 100644 --- a/app/src/main/java/com/example/julian/endlessroll/entities/tileLists/TileList.java +++ b/app/src/main/java/com/example/julian/endlessroll/entities/tileLists/TileList.java @@ -3,7 +3,7 @@ package com.example.julian.endlessroll.entities.tileLists; import com.example.julian.endlessroll.data.SynchronizedArrayList; import com.example.julian.endlessroll.entities.textures.Texture; import com.example.julian.endlessroll.levels.TileData; -import com.example.julian.endlessroll.levels.worlds.Theme; +import com.example.julian.endlessroll.levels.worlds.World; import java.util.ArrayList; import java.util.List; @@ -36,10 +36,10 @@ public class TileList extends SynchronizedArrayList { this.texture = texture; } - public void loadData(Theme theme, float edge, List tileData) { - this.texture = theme.getTerrainTexture(); + public void loadData(World world, float edge, List tileData) { + this.texture = world.getTerrainTexture(); if (type == Type.CEILING) - this.texture = theme.getCeilingTexture(); + this.texture = world.getCeilingTexture(); this.endless = false; super.clear(); for (TileData data : tileData) @@ -49,8 +49,8 @@ public class TileList extends SynchronizedArrayList { super.clear(); } - public void createEndless(Theme theme, float edge) { - loadData(theme, edge, new ArrayList()); + public void createEndless(World world, float edge) { + loadData(world, edge, new ArrayList()); super.add(createEndlessTile(0)); this.endless = true; } diff --git a/app/src/main/java/com/example/julian/endlessroll/entities/tools/Bomb.java b/app/src/main/java/com/example/julian/endlessroll/entities/tools/Bomb.java index 2c53f32..39996c5 100644 --- a/app/src/main/java/com/example/julian/endlessroll/entities/tools/Bomb.java +++ b/app/src/main/java/com/example/julian/endlessroll/entities/tools/Bomb.java @@ -30,7 +30,7 @@ public class Bomb extends Tool { @Override public void update(Timer timer) { super.update(timer); - delta += timer.getFrameTime(); + delta += timer.getFrameTimeSeconds(); if (delta >= 1000) exploding = true; } diff --git a/app/src/main/java/com/example/julian/endlessroll/entities/tools/ToolSlot.java b/app/src/main/java/com/example/julian/endlessroll/entities/tools/ToolSlot.java index 182df69..7c5ca4d 100644 --- a/app/src/main/java/com/example/julian/endlessroll/entities/tools/ToolSlot.java +++ b/app/src/main/java/com/example/julian/endlessroll/entities/tools/ToolSlot.java @@ -15,11 +15,6 @@ public class ToolSlot { this.locked = locked; } - public ToolSlot(String type) { - this.toolType = ToolType.valueOf(type); - this.locked = toolType == ToolType.NONE; - } - public ToolType getToolType() { return toolType; } diff --git a/app/src/main/java/com/example/julian/endlessroll/levels/LevelPack.java b/app/src/main/java/com/example/julian/endlessroll/levels/LevelPack.java index ea0789b..eff4e8a 100644 --- a/app/src/main/java/com/example/julian/endlessroll/levels/LevelPack.java +++ b/app/src/main/java/com/example/julian/endlessroll/levels/LevelPack.java @@ -1,6 +1,6 @@ package com.example.julian.endlessroll.levels; -import com.example.julian.endlessroll.levels.worlds.Theme; +import com.example.julian.endlessroll.levels.worlds.World; import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Element; @@ -18,7 +18,7 @@ public class LevelPack { @Attribute private int id; @Element - private Theme theme; + private World world; @ElementList private List levels; @@ -33,8 +33,8 @@ public class LevelPack { return levels; } - public Theme getTheme() { - return theme; + public World getWorld() { + return world; } public void setName(String name) { diff --git a/app/src/main/java/com/example/julian/endlessroll/levels/worlds/Theme.java b/app/src/main/java/com/example/julian/endlessroll/levels/worlds/World.java similarity index 93% rename from app/src/main/java/com/example/julian/endlessroll/levels/worlds/Theme.java rename to app/src/main/java/com/example/julian/endlessroll/levels/worlds/World.java index e37c0ff..f533190 100644 --- a/app/src/main/java/com/example/julian/endlessroll/levels/worlds/Theme.java +++ b/app/src/main/java/com/example/julian/endlessroll/levels/worlds/World.java @@ -10,7 +10,7 @@ import com.example.julian.endlessroll.entities.textures.TexturePack; * Created by Julian on 14.11.2016. */ -public enum Theme { +public enum World { GRASSLANDS("Grasslands", R.drawable.previews_grass, R.drawable.backgrounds_game_grass, R.drawable.terrain_t_grass, R.drawable.terrain_c_grass, R.drawable.obstacles_grass), TESTCAVE("Testcave", R.drawable.previews_grass, R.drawable.backgrounds_game_cave, R.drawable.terrain_t_grass, R.drawable.terrain_c_grass, R.drawable.obstacles_cave), @@ -33,7 +33,7 @@ public enum Theme { private Texture ceiling; private Texture obstacle; - Theme(String name, @DrawableRes int previewId, @DrawableRes int backgroundId, @DrawableRes int terrainId, @DrawableRes int ceilingId, @DrawableRes int obstacleId) { + World(String name, @DrawableRes int previewId, @DrawableRes int backgroundId, @DrawableRes int terrainId, @DrawableRes int ceilingId, @DrawableRes int obstacleId) { this.name = name; this.previewId = previewId; this.backgroundId = backgroundId; @@ -43,8 +43,8 @@ public enum Theme { } public static void loadAllSpecificTextures(TexturePack texturePack) { - for (Theme theme : values()) - theme.loadSpecificTextures(texturePack); + for (World world : values()) + world.loadSpecificTextures(texturePack); } private void loadSpecificTextures(TexturePack texturePack) { diff --git a/app/src/main/java/com/example/julian/endlessroll/main/game/Camera.java b/app/src/main/java/com/example/julian/endlessroll/main/game/Camera.java new file mode 100644 index 0000000..9d6e118 --- /dev/null +++ b/app/src/main/java/com/example/julian/endlessroll/main/game/Camera.java @@ -0,0 +1,47 @@ +package com.example.julian.endlessroll.main.game; + +import com.example.julian.endlessroll.main.GameLog; + +/** + * Created by Julian on 22.05.2017. + */ + +public class Camera { + + private final float MOVE_SPEED_UP = 0.7f; + private final float MOVE_SPEED_DOWN = 0.7f; + private final float MAX_Y = 0.5f; + private final float MIN_Y = 0; + private float x, y; + + public void update(float playerY, Timer timer){ + float frameTime = timer.getFrameTimeSeconds() / 1000f; + float maxY = Math.min(playerY - 1 + 0.6f, MAX_Y); + if(playerY >= 0.5f){ + y += MOVE_SPEED_UP * frameTime; + if(y > maxY) + y = maxY; + } else if(y > MIN_Y){ + y -= MOVE_SPEED_DOWN * frameTime; + if(y < MIN_Y) + y = MIN_Y; + } + } + + public void moveX(float move){ + x += move; + } + + public void reset(){ + x = 0; + y = 0; + } + + public float getX() { + return x; + } + + public float getY() { + return y; + } +} diff --git a/app/src/main/java/com/example/julian/endlessroll/main/game/Game.java b/app/src/main/java/com/example/julian/endlessroll/main/game/Game.java index 6d5b4f4..5634822 100644 --- a/app/src/main/java/com/example/julian/endlessroll/main/game/Game.java +++ b/app/src/main/java/com/example/julian/endlessroll/main/game/Game.java @@ -111,10 +111,9 @@ public class Game extends Rendering { collectedStars.clear(); energyCollected = false; particleSystem.deleteAllSources(); - scene.loadLevel(level, levelPack.getTheme()); + scene.loadLevel(level, levelPack.getWorld()); player = scene.getPlayer(); - if (viewManager.isScreenSizeSet()) - viewManager.resetViews(); + viewManager.resetViews(user); currentTool = viewManager.toolButtonBar.getActiveButton().getToolType(); viewManager.startCountdown(); } @@ -131,7 +130,6 @@ public class Game extends Rendering { public void setScreenSize(int width, int height) { Vector screenSize = new Vector(width, height); scene.setScreenSize(screenSize); - viewManager.setScreenSize(screenSize); } @Override @@ -139,14 +137,11 @@ public class Game extends Rendering { particleSystem.update(timer); float playerProgress = 0; float playerSpeed = 0; - float playerY = 0; if (player != null) { playerProgress = player.getProgress(); playerSpeed = player.getSpeed(); - playerY = player.getPosition().y; } - viewManager.update(gameState == GameState.RUNNING, timer, playerProgress, playerSpeed, - playerY); + viewManager.update(gameState == GameState.RUNNING, timer, playerProgress, playerSpeed); switch (gameState) { case RUNNING: if (player.getPosition().y < -2f) { @@ -157,6 +152,7 @@ public class Game extends Rendering { onGoalReached(); return; } + scene.getCamera().update(player.getPosition().y, timer); if (currentTutorial != null) { currentTutorial.update(playerProgress); @@ -190,7 +186,7 @@ public class Game extends Rendering { } public void resetViews() { - viewManager.resetViews(); + viewManager.resetViews(user); } public void continueGame() { @@ -217,6 +213,8 @@ public class Game extends Rendering { } public void tryToPause() { + if(gameState == GameState.GAME_OVER || gameState == GameState.PAUSED) + return; viewManager.showShortMenu(); if (gameState == GameState.COUNTDOWN) viewManager.stopCountdown(); diff --git a/app/src/main/java/com/example/julian/endlessroll/main/game/GameScene.java b/app/src/main/java/com/example/julian/endlessroll/main/game/GameScene.java index 412ecfb..511a0e5 100644 --- a/app/src/main/java/com/example/julian/endlessroll/main/game/GameScene.java +++ b/app/src/main/java/com/example/julian/endlessroll/main/game/GameScene.java @@ -16,7 +16,7 @@ import com.example.julian.endlessroll.entities.tools.ToolType; import com.example.julian.endlessroll.levels.Level; import com.example.julian.endlessroll.levels.ObstacleData; import com.example.julian.endlessroll.levels.PositionData; -import com.example.julian.endlessroll.levels.worlds.Theme; +import com.example.julian.endlessroll.levels.worlds.World; import com.example.julian.endlessroll.main.GameLog; import java.util.ArrayList; @@ -29,7 +29,7 @@ import java.util.List; */ public class GameScene extends Scene { - private Theme currentTheme; + private World currentWorld; private CollisionDetector collisionDetector; private Goal goal; @@ -46,12 +46,12 @@ public class GameScene extends Scene { goal = new Goal(textures.goal); } - public void loadLevel(Level level, Theme theme) throws Exception { - this.currentTheme = theme; + public void loadLevel(Level level, World world) throws Exception { + this.currentWorld = world; reset(); - background.changeTexture(theme.getBackgroundTexture()); - terrain.loadData(theme, level.getTerrainEdge(), level.getTerrainTiles()); - ceiling.loadData(theme, level.getCeilingEdge(), level.getCeilingTiles()); + background.changeTexture(world.getBackgroundTexture()); + terrain.loadData(world, level.getTerrainEdge(), level.getTerrainTiles()); + ceiling.loadData(world, level.getCeilingEdge(), level.getCeilingTiles()); super.add(goal); player.init(terrain.getEdge(), level.getStartSpeed(), level.getEndSpeed()); super.add(player); @@ -81,7 +81,7 @@ public class GameScene extends Scene { obstacles.clear(); tools.clear(); energy = null; - cameraX = 0; + camera.reset(); background.resetPosition(); } @@ -103,7 +103,7 @@ public class GameScene extends Scene { } public void addObstacle(ObstacleData data) { - Obstacle obstacle = new Obstacle(currentTheme, data, terrain.getEdge()); + Obstacle obstacle = new Obstacle(currentWorld, data, terrain.getEdge()); super.add(obstacle); obstacles.add(obstacle); } diff --git a/app/src/main/java/com/example/julian/endlessroll/main/game/Physics.java b/app/src/main/java/com/example/julian/endlessroll/main/game/Physics.java index 8c5fe85..62f8786 100644 --- a/app/src/main/java/com/example/julian/endlessroll/main/game/Physics.java +++ b/app/src/main/java/com/example/julian/endlessroll/main/game/Physics.java @@ -16,7 +16,6 @@ import com.example.julian.endlessroll.entities.tileLists.Terrain; import com.example.julian.endlessroll.entities.tileLists.Tile; import com.example.julian.endlessroll.entities.tools.Bomb; import com.example.julian.endlessroll.entities.tools.Tool; -import com.example.julian.endlessroll.main.GameLog; import java.util.ArrayList; import java.util.HashMap; @@ -36,7 +35,7 @@ public class Physics { } public void applyGravity(GameScene scene, Timer timer) { - float gravity = GRAVITY_FORCE * timer.getFrameTime(); + float gravity = GRAVITY_FORCE * timer.getFrameTimeSeconds(); scene.getPlayer().getMovement().y -= gravity; synchronized (scene.getTools()) { diff --git a/app/src/main/java/com/example/julian/endlessroll/main/game/Scene.java b/app/src/main/java/com/example/julian/endlessroll/main/game/Scene.java index 1985ace..eb81f8f 100644 --- a/app/src/main/java/com/example/julian/endlessroll/main/game/Scene.java +++ b/app/src/main/java/com/example/julian/endlessroll/main/game/Scene.java @@ -11,7 +11,7 @@ import com.example.julian.endlessroll.entities.particles.ParticleSystem; import com.example.julian.endlessroll.entities.textures.TexturePack; import com.example.julian.endlessroll.entities.tileLists.Ceiling; import com.example.julian.endlessroll.entities.tileLists.Terrain; -import com.example.julian.endlessroll.levels.worlds.Theme; +import com.example.julian.endlessroll.levels.worlds.World; import java.util.Iterator; @@ -20,8 +20,7 @@ import java.util.Iterator; */ public abstract class Scene extends SynchronizedArrayList { - public float cameraX; - + protected Camera camera; private Vector screenSize; private Entity playerArrow; @@ -35,10 +34,11 @@ public abstract class Scene extends SynchronizedArrayList { public Scene(TexturePack texturePack, ParticleSystem particleSystem) { this.particleSystem = particleSystem; setTexturePack(texturePack); + camera = new Camera(); playerArrow = new Entity(textures.playerArrow, new Vector(0, 0.9f), .2f, .2f); - background = new Background(Theme.GRASSLANDS.getBackgroundTexture()); - terrain = new Terrain(Theme.GRASSLANDS.getTerrainTexture()); - ceiling = new Ceiling(Theme.GRASSLANDS.getTerrainTexture()); + background = new Background(World.GRASSLANDS.getBackgroundTexture()); + terrain = new Terrain(World.GRASSLANDS.getTerrainTexture()); + ceiling = new Ceiling(World.GRASSLANDS.getTerrainTexture()); player = new Player(textures.player); } @@ -54,26 +54,27 @@ public abstract class Scene extends SynchronizedArrayList { if(entity instanceof AnimatedEntity) ((AnimatedEntity) entity).update(timer); Vector movement = entity.getMovement(); - Vector finalMovement = new Vector(movement).mul(timer.getFrameTime()); + Vector finalMovement = new Vector(movement).mul(timer.getFrameTimeSeconds()); entity.move(finalMovement); if (entity instanceof Obstacle) { Obstacle obstacle = (Obstacle) entity; if (obstacle.isMoving()) - obstacle.moveWithMoveComponent(timer.getFrameTime()); + obstacle.moveWithMoveComponent(timer.getFrameTimeSeconds()); } if (entity.isDestroyed() && entity.getDestroyEffect() != null) entity.getDestroyEffect().createEffect(particleSystem, new Vector(entity.getPosition()), new Vector(entity.getWidth(), entity.getHeight())).start(); if (entity.equals(player)) moveEnviroment(finalMovement.x); - else if (entity.getRightEdge() - cameraX < -3f || entity.isDestroyed()) { + else if (entity.getRightEdge() - camera.getX() < -3f || entity.isDestroyed()) { iterator.remove(); removeEntityFromAllLists(entity); } } } - if (player.getPosition().y >= player.RADIUS + 1) { + if (player.getPosition().y >= player.RADIUS + 1 + camera.getY()) { playerArrow.getPosition().x = player.getPosition().x; + playerArrow.getPosition().y = camera.getY() + 0.9f; if (!super.contains(playerArrow)) { super.add(playerArrow); } @@ -89,10 +90,10 @@ public abstract class Scene extends SynchronizedArrayList { protected abstract void removeEntityFromAllLists(Entity entity); private void moveEnviroment(float x) { - cameraX += x; - background.move(x * 0.95f, cameraX); - terrain.update(cameraX); - ceiling.update(cameraX); + camera.moveX(x); + background.move(x * 0.95f, camera.getX()); + terrain.update(camera.getX()); + ceiling.update(camera.getX()); } protected Vector calcWorldFromScreenCoords(float screenX, float screenY) throws Exception { @@ -100,7 +101,7 @@ public abstract class Scene extends SynchronizedArrayList { throw new Exception("ScreenSize not set"); float glCoordWidth = (2f * screenSize.x / screenSize.y); float x = ((screenX / screenSize.x) * 2f - 1f) * glCoordWidth / 2; - x += cameraX; + x += camera.getX(); float y = -((screenY / screenSize.y) * 2f - 1f); return new Vector(x, y); } @@ -132,4 +133,8 @@ public abstract class Scene extends SynchronizedArrayList { public ParticleSystem getParticleSystem() { return particleSystem; } + + public Camera getCamera() { + return camera; + } } diff --git a/app/src/main/java/com/example/julian/endlessroll/main/game/StartScene.java b/app/src/main/java/com/example/julian/endlessroll/main/game/StartScene.java index 0ef678f..00342e3 100644 --- a/app/src/main/java/com/example/julian/endlessroll/main/game/StartScene.java +++ b/app/src/main/java/com/example/julian/endlessroll/main/game/StartScene.java @@ -3,13 +3,13 @@ package com.example.julian.endlessroll.main.game; import com.example.julian.endlessroll.entities.Entity; import com.example.julian.endlessroll.entities.particles.ParticleSystem; import com.example.julian.endlessroll.entities.textures.TexturePack; -import com.example.julian.endlessroll.levels.worlds.Theme; +import com.example.julian.endlessroll.levels.worlds.World; public class StartScene extends Scene { public StartScene(TexturePack texturePack, ParticleSystem particleSystem) { super(texturePack, particleSystem); - terrain.createEndless(Theme.ICY_MOUNTAINS, -.8f); + terrain.createEndless(World.ICY_MOUNTAINS, -.8f); player.init(terrain.getEdge(), 0.5f, 0.5f); super.add(player); } diff --git a/app/src/main/java/com/example/julian/endlessroll/main/game/Timer.java b/app/src/main/java/com/example/julian/endlessroll/main/game/Timer.java index 3973c00..aa0a32d 100644 --- a/app/src/main/java/com/example/julian/endlessroll/main/game/Timer.java +++ b/app/src/main/java/com/example/julian/endlessroll/main/game/Timer.java @@ -31,7 +31,7 @@ public class Timer { } } - public float getFrameTime() { + public float getFrameTimeSeconds() { return delta; } diff --git a/app/src/main/java/com/example/julian/endlessroll/main/screens/StartScreen.java b/app/src/main/java/com/example/julian/endlessroll/main/screens/StartScreen.java index e185b7b..fc10f7c 100644 --- a/app/src/main/java/com/example/julian/endlessroll/main/screens/StartScreen.java +++ b/app/src/main/java/com/example/julian/endlessroll/main/screens/StartScreen.java @@ -83,7 +83,7 @@ public class StartScreen extends GLScreen implements View.OnClic // user.setStarCount(100); levelManager.unlockAllLevels(); levelManager.unlockAllPacks(); - user.gainEp(75); + user.gainEp(90); } else if (v.equals(lvUp)) { user.gainEp(100); } diff --git a/app/src/main/java/com/example/julian/endlessroll/rendering/MatrixCreator.java b/app/src/main/java/com/example/julian/endlessroll/rendering/MatrixCreator.java index 797bfc5..02af2ba 100644 --- a/app/src/main/java/com/example/julian/endlessroll/rendering/MatrixCreator.java +++ b/app/src/main/java/com/example/julian/endlessroll/rendering/MatrixCreator.java @@ -4,6 +4,7 @@ import android.opengl.Matrix; import com.example.julian.endlessroll.data.Vector; import com.example.julian.endlessroll.entities.Entity; +import com.example.julian.endlessroll.main.game.Camera; /** * Created by Julian on 23.11.2015. @@ -17,13 +18,13 @@ public class MatrixCreator { this.height = height; } - public float[] createModelViewProjectionMatrix(float cameraX) { + public float[] createModelViewProjectionMatrix(Camera camera) { float[] mvpMatrix = new float[16]; float[] projectionMatrix = new float[16]; float[] viewMatrix = new float[16]; float ratio = width / height; - Matrix.frustumM(projectionMatrix, 0, -ratio + cameraX, ratio + cameraX, -1, 1, 1, 2); + Matrix.frustumM(projectionMatrix, 0, -ratio + camera.getX(), ratio + camera.getX(), -1 + camera.getY(), 1 + camera.getY(), 1, 2); Matrix.setLookAtM(viewMatrix, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0); Matrix.multiplyMM(mvpMatrix, 0, projectionMatrix, 0, viewMatrix, 0); return mvpMatrix; diff --git a/app/src/main/java/com/example/julian/endlessroll/rendering/renderer/GameRenderer.java b/app/src/main/java/com/example/julian/endlessroll/rendering/renderer/GameRenderer.java index de47c3d..46c722e 100644 --- a/app/src/main/java/com/example/julian/endlessroll/rendering/renderer/GameRenderer.java +++ b/app/src/main/java/com/example/julian/endlessroll/rendering/renderer/GameRenderer.java @@ -113,7 +113,7 @@ public class GameRenderer implements GLSurfaceView.Renderer { private void renderEntities(GL10 gl, Scene scene) { entityShader.start(); - entityShader.loadMVPMatrix(matrixCreator, scene.cameraX); + entityShader.loadMVPMatrix(matrixCreator, scene.getCamera()); synchronized (scene.getBackground()) { for (Entity backgroundPart : scene.getBackground()) renderEntity(gl, backgroundPart); @@ -131,12 +131,15 @@ public class GameRenderer implements GLSurfaceView.Renderer { entityShader.loadTransformationMatrix(matrixCreator, entity); entityShader.loadAlpha(entity.getAlpha()); entityShader.loadTextureAtlasInfos(entity.getTexture(), entity.getTextureAtlasIndex()); + float texScaleX = entity.getMaxTexSize().x == 0 ? 1 : entity.getWidth() / entity.getMaxTexSize().x; + float texScaleY = entity.getMaxTexSize().y == 0 ? 1 : entity.getHeight() / entity.getMaxTexSize().y; + entityShader.loadTexCoordScaling(texScaleX, texScaleY); quad.draw(); } private void renderTileList(GL10 gl, TileList tileList, Scene scene) { terrainShader.start(); - terrainShader.loadMVPMatrix(matrixCreator, scene.cameraX); + terrainShader.loadMVPMatrix(matrixCreator, scene.getCamera()); synchronized (tileList) { for (Tile tile : tileList) { gl.glActiveTexture(GL10.GL_TEXTURE0); diff --git a/app/src/main/java/com/example/julian/endlessroll/rendering/renderer/ParticleRenderer.java b/app/src/main/java/com/example/julian/endlessroll/rendering/renderer/ParticleRenderer.java index c93c41e..fa0949f 100644 --- a/app/src/main/java/com/example/julian/endlessroll/rendering/renderer/ParticleRenderer.java +++ b/app/src/main/java/com/example/julian/endlessroll/rendering/renderer/ParticleRenderer.java @@ -47,7 +47,7 @@ public class ParticleRenderer { GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); particleShader.start(); - particleShader.loadMVPMatrix(matrixCreator, scene.cameraX); + particleShader.loadMVPMatrix(matrixCreator, scene.getCamera()); synchronized (scene.getParticleSystem().getEffects()) { for (ParticleEffect effect : scene.getParticleSystem().getEffects()) { gl.glActiveTexture(GL10.GL_TEXTURE0); diff --git a/app/src/main/java/com/example/julian/endlessroll/rendering/shader/EntityShader.java b/app/src/main/java/com/example/julian/endlessroll/rendering/shader/EntityShader.java index 489226b..6a87e38 100644 --- a/app/src/main/java/com/example/julian/endlessroll/rendering/shader/EntityShader.java +++ b/app/src/main/java/com/example/julian/endlessroll/rendering/shader/EntityShader.java @@ -3,8 +3,10 @@ package com.example.julian.endlessroll.rendering.shader; import android.content.Context; import android.opengl.GLES20; +import com.example.julian.endlessroll.data.Vector; import com.example.julian.endlessroll.entities.Entity; import com.example.julian.endlessroll.entities.textures.Texture; +import com.example.julian.endlessroll.main.game.Camera; import com.example.julian.endlessroll.rendering.MatrixCreator; /** @@ -17,6 +19,7 @@ public class EntityShader extends ShaderProgram { private int location_alpha; private int location_texAtlasSize; private int location_texAtlasIndex; + private int location_texCoordScaling; public EntityShader(Context context) throws Exception { super(context, "shader/entityVertexShader.glsl", "shader/entityFragmentShader.glsl"); @@ -29,10 +32,11 @@ public class EntityShader extends ShaderProgram { location_alpha = super.getUniformLocation("alpha"); location_texAtlasSize = super.getUniformLocation("texAtlasSize"); location_texAtlasIndex = super.getUniformLocation("texAtlasIndex"); + location_texCoordScaling = super.getUniformLocation("texCoordScaling"); } - public void loadMVPMatrix(MatrixCreator matrixCreator, float cameraX) { - float[] mvpMatrix = matrixCreator.createModelViewProjectionMatrix(cameraX); + public void loadMVPMatrix(MatrixCreator matrixCreator, Camera camera) { + float[] mvpMatrix = matrixCreator.createModelViewProjectionMatrix(camera); GLES20.glUniformMatrix4fv(location_mvpMatrix, 1, false, mvpMatrix, 0); } @@ -49,4 +53,9 @@ public class EntityShader extends ShaderProgram { GLES20.glUniform2f(location_texAtlasSize, texture.getAtlasWidth(), texture.getAtlasHeight()); GLES20.glUniform1f(location_texAtlasIndex, atlasIndex); } + + public void loadTexCoordScaling(float scalingX, float scalingY){ + GLES20.glUniform2f(location_texCoordScaling, scalingX, scalingY); + } + } diff --git a/app/src/main/java/com/example/julian/endlessroll/rendering/shader/ParticleShader.java b/app/src/main/java/com/example/julian/endlessroll/rendering/shader/ParticleShader.java index 9d3d2fc..fe0ece3 100644 --- a/app/src/main/java/com/example/julian/endlessroll/rendering/shader/ParticleShader.java +++ b/app/src/main/java/com/example/julian/endlessroll/rendering/shader/ParticleShader.java @@ -5,6 +5,7 @@ import android.opengl.GLES20; import com.example.julian.endlessroll.data.Color; import com.example.julian.endlessroll.entities.Entity; +import com.example.julian.endlessroll.main.game.Camera; import com.example.julian.endlessroll.rendering.MatrixCreator; /** @@ -27,8 +28,8 @@ public class ParticleShader extends ShaderProgram { location_color = super.getUniformLocation("color"); } - public void loadMVPMatrix(MatrixCreator matrixCreator, float cameraX) { - float[] mvpMatrix = matrixCreator.createModelViewProjectionMatrix(cameraX); + public void loadMVPMatrix(MatrixCreator matrixCreator, Camera camera) { + float[] mvpMatrix = matrixCreator.createModelViewProjectionMatrix(camera); GLES20.glUniformMatrix4fv(location_mvpMatrix, 1, false, mvpMatrix, 0); } diff --git a/app/src/main/java/com/example/julian/endlessroll/rendering/shader/TerrainShader.java b/app/src/main/java/com/example/julian/endlessroll/rendering/shader/TerrainShader.java index 95ba31e..a04c6b3 100644 --- a/app/src/main/java/com/example/julian/endlessroll/rendering/shader/TerrainShader.java +++ b/app/src/main/java/com/example/julian/endlessroll/rendering/shader/TerrainShader.java @@ -4,6 +4,7 @@ import android.content.Context; import android.opengl.GLES20; import com.example.julian.endlessroll.entities.Entity; +import com.example.julian.endlessroll.main.game.Camera; import com.example.julian.endlessroll.rendering.MatrixCreator; /** @@ -24,8 +25,8 @@ public class TerrainShader extends ShaderProgram { location_transformationMatrix = super.getUniformLocation("transformationMatrix"); } - public void loadMVPMatrix(MatrixCreator matrixCreator, float cameraX) { - float[] mvpMatrix = matrixCreator.createModelViewProjectionMatrix(cameraX); + public void loadMVPMatrix(MatrixCreator matrixCreator, Camera camera) { + float[] mvpMatrix = matrixCreator.createModelViewProjectionMatrix(camera); GLES20.glUniformMatrix4fv(location_mvpMatrix, 1, false, mvpMatrix, 0); } diff --git a/app/src/main/java/com/example/julian/endlessroll/user/ToolSlotSettings.java b/app/src/main/java/com/example/julian/endlessroll/user/ToolSlotSettings.java index ca9e019..a80c7e4 100644 --- a/app/src/main/java/com/example/julian/endlessroll/user/ToolSlotSettings.java +++ b/app/src/main/java/com/example/julian/endlessroll/user/ToolSlotSettings.java @@ -40,11 +40,11 @@ public class ToolSlotSettings extends ArrayList { } public int getLockedSlotCount() { - for (int i = super.size() - 1; i > 0; i--) { - if (!super.get(i).isLocked()) - return i + 1; - } - return 0; + int count = 0; + for (ToolSlot slot : this) + if(slot.isLocked()) + count ++; + return count; } } diff --git a/app/src/main/java/com/example/julian/endlessroll/user/User.java b/app/src/main/java/com/example/julian/endlessroll/user/User.java index 0423044..7042926 100644 --- a/app/src/main/java/com/example/julian/endlessroll/user/User.java +++ b/app/src/main/java/com/example/julian/endlessroll/user/User.java @@ -1,5 +1,7 @@ package com.example.julian.endlessroll.user; +import com.example.julian.endlessroll.main.GameLog; + /** * Created by Julian on 10.07.2016. */ diff --git a/app/src/main/java/com/example/julian/endlessroll/views/ToolButtonBar.java b/app/src/main/java/com/example/julian/endlessroll/views/ToolButtonBar.java index ec78f3e..c248560 100644 --- a/app/src/main/java/com/example/julian/endlessroll/views/ToolButtonBar.java +++ b/app/src/main/java/com/example/julian/endlessroll/views/ToolButtonBar.java @@ -8,6 +8,7 @@ import android.widget.LinearLayout; import android.widget.RelativeLayout; import com.example.julian.endlessroll.R; +import com.example.julian.endlessroll.main.GameLog; import com.example.julian.endlessroll.user.ToolSlotSettings; import com.example.julian.endlessroll.entities.tools.ToolType; import com.example.julian.endlessroll.main.game.Game; @@ -36,7 +37,6 @@ public class ToolButtonBar implements View.OnClickListener, Animation.AnimationL private Animation fadeIn, fadeOut; private Game game; - private ToolSlotSettings toolSlotSettings; private List buttons = new ArrayList<>(4); private RelativeLayout button1; private RelativeLayout button2; @@ -46,7 +46,6 @@ public class ToolButtonBar implements View.OnClickListener, Animation.AnimationL public ToolButtonBar(Game game, ToolSlotSettings toolSlotSettings, LinearLayout layout1) { this.game = game; - this.toolSlotSettings = toolSlotSettings; Context context = game.getContext(); fadeIn = AnimationUtils.loadAnimation(game.getContext(), R.anim.fade_in); fadeIn.setAnimationListener(this); @@ -80,14 +79,15 @@ public class ToolButtonBar implements View.OnClickListener, Animation.AnimationL button4.startAnimation(fadeOut); } - public void changeToolButtonTypes() { + public void changeToolButtonTypes(ToolSlotSettings toolSlotSettings) { for (int i = 0; i < 4; i++) { buttons.get(i).changeToolSlot(toolSlotSettings.get(i)); } } - public void reset() { - changeToolButtonTypes(); + public void reset(ToolSlotSettings toolSlotSettings) { + GameLog.i("Reset toolbuttonBar"); + changeToolButtonTypes(toolSlotSettings); for (int i = 0; i < 4; i++) { if (toolSlotSettings.get(i).getToolType() != ToolType.NONE) { setActive(i); diff --git a/app/src/main/java/com/example/julian/endlessroll/views/ViewManager.java b/app/src/main/java/com/example/julian/endlessroll/views/ViewManager.java index 7f68093..9de80b5 100644 --- a/app/src/main/java/com/example/julian/endlessroll/views/ViewManager.java +++ b/app/src/main/java/com/example/julian/endlessroll/views/ViewManager.java @@ -10,15 +10,16 @@ import android.widget.TextView; import com.example.julian.endlessroll.R; import com.example.julian.endlessroll.data.Vector; import com.example.julian.endlessroll.main.GameHandler; +import com.example.julian.endlessroll.main.game.Camera; import com.example.julian.endlessroll.main.game.Game; import com.example.julian.endlessroll.main.game.Timer; +import com.example.julian.endlessroll.user.User; /** * Created by Julian on 11.12.2015. */ public class ViewManager implements View.OnClickListener { - private Vector screenSize; private GameHandler gameViewHandler; private Game game; @@ -52,24 +53,16 @@ public class ViewManager implements View.OnClickListener { fpsView = (TextView) layout.findViewById(R.id.game_fps); } - public void setScreenSize(Vector screenSize) { - this.screenSize = screenSize; - } - - public boolean isScreenSizeSet() { - return screenSize != null; - } - @Override public void onClick(View v) { game.tryToPause(); } - public void resetViews() { + public void resetViews(final User user) { gameViewHandler.startInUiThread(new Runnable() { @Override public void run() { - toolButtonBar.reset(); + toolButtonBar.reset(user.getToolSlotSettings()); toolButtonBar.update(0); playerProgress.setText("0.0m"); playerSpeed.setText("0.0m/s"); @@ -104,7 +97,7 @@ public class ViewManager implements View.OnClickListener { countdown.stop(); } - public void update(final boolean gameRunning, final Timer timer, final float playerX, final float playerXMov, final float playerY) { + public void update(final boolean gameRunning, final Timer timer, final float playerX, final float playerXMov) { gameViewHandler.startInUiThread(new Runnable() { @Override public void run() { @@ -112,7 +105,7 @@ public class ViewManager implements View.OnClickListener { if (gameRunning) { playerProgress.setText(toMeters(playerX) + "m"); playerSpeed.setText(toMeters(playerXMov * 1000) + "m/s"); - toolButtonBar.update(timer.getFrameTime()); + toolButtonBar.update(timer.getFrameTimeSeconds()); } } }); diff --git a/app/src/main/java/com/example/julian/endlessroll/views/WorldButton.java b/app/src/main/java/com/example/julian/endlessroll/views/WorldButton.java index dff69d1..6ef9d71 100644 --- a/app/src/main/java/com/example/julian/endlessroll/views/WorldButton.java +++ b/app/src/main/java/com/example/julian/endlessroll/views/WorldButton.java @@ -10,7 +10,7 @@ import android.widget.TextView; import com.example.julian.endlessroll.R; import com.example.julian.endlessroll.levels.LevelPack; -import com.example.julian.endlessroll.levels.worlds.Theme; +import com.example.julian.endlessroll.levels.worlds.World; /** * Created by Julian on 01.08.2016. @@ -18,7 +18,7 @@ import com.example.julian.endlessroll.levels.worlds.Theme; public class WorldButton extends RelativeLayout { private LevelPack levelPack; - private Theme theme; + private World world; private TextView title; private ImageView previewImage; @@ -30,7 +30,7 @@ public class WorldButton extends RelativeLayout { public WorldButton(Context context, Typeface typeface, View.OnClickListener clickListener, LevelPack levelPack) { super(context); this.levelPack = levelPack; - this.theme = levelPack.getTheme(); + this.world = levelPack.getWorld(); LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.world_button, this); @@ -52,7 +52,7 @@ public class WorldButton extends RelativeLayout { public void updateInformation() { title.setText(levelPack.getName()); - previewImage.setImageDrawable(getContext().getResources().getDrawable(theme.getPreviewId())); + previewImage.setImageDrawable(getContext().getResources().getDrawable(world.getPreviewId())); levelCount.setText(levelPack.getFinishedLevelCount() + "/" + levelPack.getLevels().size()); starCount.setText(levelPack.getCollectedStarCount() + "/" + levelPack.getAvailableStars()); energyCount.setText(levelPack.getCollectedEnergyCount() + "/" + levelPack.getAvailableEnergy()); diff --git a/app/src/main/res/drawable/goal.png b/app/src/main/res/drawable/goal.png index 9d4848e..f1ad4b1 100644 Binary files a/app/src/main/res/drawable/goal.png and b/app/src/main/res/drawable/goal.png differ diff --git a/app/src/main/res/layout/start_screen.xml b/app/src/main/res/layout/start_screen.xml index 8368a3a..87142f8 100644 --- a/app/src/main/res/layout/start_screen.xml +++ b/app/src/main/res/layout/start_screen.xml @@ -51,6 +51,6 @@ android:layout_marginLeft="48dp" android:layout_marginStart="48dp" android:text="Lv to 100" - android:visibility="gone"/> + android:visibility="visible"/> \ No newline at end of file diff --git a/build.gradle b/build.gradle index b78a0b8..d0aa704 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.1' + classpath 'com.android.tools.build:gradle:2.3.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files