Added juris graphics

Changed layout of shape-shop and tool-shop
This commit is contained in:
=
2018-05-06 18:19:00 +02:00
parent 7363b7d5cc
commit 2e24ef619d
25 changed files with 335 additions and 231 deletions

View File

@ -1,56 +1,49 @@
package de.frajul.endlessroll.entities;
import de.frajul.endlessroll.data.SynchronizedArrayList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.textures.Texture;
/**
* Created by Julian on 20.07.2016.
*/
public class Background extends SynchronizedArrayList<Entity> {
public class Background {
private final float PART_WIDTH = 5;
private final float HALF_PART_WIDTH = PART_WIDTH / 2;
private final float HEIGHT = 2.5f;
private Texture texture;
private List<BackgroundLayer> layers = Collections
.synchronizedList(new ArrayList<BackgroundLayer>());
public Background(Texture texture) {
this.texture = texture;
super.add(createPart(-HALF_PART_WIDTH));
public Background(List<Texture> textures) {
changeTextures(textures);
}
public void changeTexture(Texture texture) {
this.texture = texture;
synchronized (this) {
for (Entity entity : this)
entity.setTexture(texture);
public void changeTextures(List<Texture> textures) {
layers.clear();
for (int i = 0; i < textures.size(); i++) {
Texture texture = textures.get(i);
float speed = (float) Math.pow(0.95f, Math.pow(i + 1, Math.sqrt(i + 1)));
layers.add(new BackgroundLayer(texture, speed));
}
}
private Entity createPart(float xLeftEdge) {
return new Entity(texture, new Vector(xLeftEdge + HALF_PART_WIDTH, (HEIGHT - 2) / 2), PART_WIDTH, HEIGHT);
}
public void move(float x, float cameraX) {
Vector movement = new Vector(x, 0);
synchronized (this) {
for (Entity part : this)
part.move(movement);
}
if (!super.isEmpty()) {
Entity last = super.get(super.size() - 1);
if (last.getRightEdge() - cameraX < 3) {
super.add(createPart(last.getRightEdge() - 0.001f));
}
if (super.get(0).getRightEdge() - cameraX < -3) {
super.remove(0);
public void move(float playerMoveX, float cameraX) {
synchronized (layers){
for(BackgroundLayer layer : layers){
layer.move(playerMoveX, cameraX);
}
}
}
public void resetPosition() {
super.clear();
super.add(createPart(-HALF_PART_WIDTH));
synchronized (layers){
for(BackgroundLayer layer : layers)
layer.resetPosition();
}
}
public List<BackgroundLayer> getLayers() {
return layers;
}
}

View File

@ -0,0 +1,49 @@
package de.frajul.endlessroll.entities;
import java.util.List;
import de.frajul.endlessroll.data.SynchronizedArrayList;
import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.textures.Texture;
public class BackgroundLayer extends SynchronizedArrayList<Entity> {
private final float PART_WIDTH = 5;
private final float HALF_PART_WIDTH = PART_WIDTH / 2f;
private final float HEIGHT = 2.5f;
private Texture texture;
private float speed;
public BackgroundLayer(Texture texture, float speed) {
this.texture = texture;
this.speed = speed;
super.add(createPart(-HALF_PART_WIDTH));
}
private Entity createPart(float xLeftEdge) {
return new Entity(texture, new Vector(xLeftEdge + HALF_PART_WIDTH, (HEIGHT - 2) / 2), PART_WIDTH, HEIGHT);
}
public void move(float playerMovX, float cameraX) {
Vector movement = new Vector(playerMovX * speed, 0);
synchronized (this) {
for (Entity part : this)
part.move(movement);
}
if (!super.isEmpty()) {
Entity last = super.get(super.size() - 1);
if (last.getRightEdge() - cameraX < 3) {
super.add(createPart(last.getRightEdge() - 0.001f));
}
if (super.get(0).getRightEdge() - cameraX < -3) {
super.remove(0);
}
}
}
public void resetPosition() {
super.clear();
super.add(createPart(-HALF_PART_WIDTH));
}
}

View File

@ -26,7 +26,9 @@ public enum PlayerShape {
WHEEL(R.string.playershape_name_wheel, R.string.playershape_description_wheel,
R.drawable.playershapes_wheel, new CollectStarTask(45)),
SUN(R.string.playershape_name_sun, R.string.playershape_description_sun,
R.drawable.playershapes_sun, new CollectEnergyTask(10));
R.drawable.playershapes_sun, new CollectEnergyTask(10)),
BLUE(R.string.playershape_name_blue, R.string.playershape_description_blue,
R.drawable.jury_playershapes_ball_omg_im_blue, new CompleteWorldTask(2));
@StringRes
private int nameId;

View File

@ -2,6 +2,10 @@ package de.frajul.endlessroll.levels.worlds;
import android.support.annotation.DrawableRes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.textures.Texture;
import de.frajul.endlessroll.entities.textures.TexturePack;
@ -12,32 +16,38 @@ import de.frajul.endlessroll.entities.textures.TexturePack;
public enum World {
GRASSLANDS(R.drawable.world_previews_grasslands, R.drawable.backgrounds_game_grass, R.drawable.terrain_t_grass, R.drawable.terrain_c_grass, R.drawable.obstacles_grass),
ICY_MOUNTAINS(R.drawable.world_previews_icymountains, R.drawable.backgrounds_game_snow, R.drawable.terrain_t_ice, R.drawable.terrain_c_ice, R.drawable.obstacles_snow);
GRASSLANDS(R.drawable.world_previews_grasslands, R.drawable.terrain_t_grass,
R.drawable.terrain_c_grass, R.drawable.juri_obstacles_grass,
R.drawable.backgrounds_game_grass),
ICY_MOUNTAINS(R.drawable.world_previews_icymountains, R.drawable.terrain_t_ice,
R.drawable.terrain_c_ice, R.drawable.obstacles_snow, R.drawable.backgrounds_game_snow),
TEST_WORLD_GRASS(R.drawable.world_previews_grasslands, R.drawable.terrain_t_grass,
R.drawable.terrain_c_grass, R.drawable.juri_obstacles_grass,
R.drawable.backgrounds_game_grass, R.drawable.juri_background_game_grass_2, R.drawable.juri_background_game_grass_3),
TEST_WORLD_SNOW(R.drawable.world_previews_icymountains, R.drawable.terrain_t_ice,
R.drawable.terrain_c_ice, R.drawable.obstacles_snow, R.drawable.backgrounds_game_snow, R.drawable.juri_background_game_snow_2, R.drawable.juri_background_game_snow_3);
private String name;
@DrawableRes
private int previewId;
@DrawableRes
private int backgroundId;
@DrawableRes
private int terrainId;
@DrawableRes
private int ceilingId;
@DrawableRes
private int obstacleId;
private List<Integer> backgroundIds;
private Texture background;
private List<Texture> backgroundTextures = new ArrayList<>();
private Texture terrain;
private Texture ceiling;
private Texture obstacle;
World(@DrawableRes int previewId, @DrawableRes int backgroundId, @DrawableRes int terrainId, @DrawableRes int ceilingId, @DrawableRes int obstacleId) {
World(@DrawableRes int previewId, @DrawableRes int terrainId, @DrawableRes int ceilingId, @DrawableRes int obstacleId, @DrawableRes Integer... backgroundIds) {
this.previewId = previewId;
this.backgroundId = backgroundId;
this.terrainId = terrainId;
this.ceilingId = ceilingId;
this.obstacleId = obstacleId;
this.backgroundIds = Arrays.asList(backgroundIds);
}
public static void loadAllSpecificTextures(TexturePack texturePack) {
@ -46,7 +56,8 @@ public enum World {
}
private void loadSpecificTextures(TexturePack texturePack) {
background = texturePack.loadTexture(backgroundId);
for (int backgroundId : backgroundIds)
backgroundTextures.add(texturePack.loadTexture(backgroundId));
terrain = texturePack.loadTexture(terrainId);
ceiling = texturePack.loadTexture(ceilingId);
obstacle = texturePack.loadAtlas(obstacleId, 8, 8);
@ -56,8 +67,8 @@ public enum World {
return previewId;
}
public Texture getBackgroundTexture() {
return background;
public List<Texture> getBackgroundTextures() {
return backgroundTextures;
}
public Texture getTerrainTexture() {

View File

@ -45,7 +45,7 @@ public class GameScene extends Scene {
public void loadLevel(Level level, World world, PlayerShape playerShape) throws Exception {
this.currentWorld = world;
super.reset();
background.changeTexture(world.getBackgroundTexture());
background.changeTextures(world.getBackgroundTextures());
terrain.loadData(world, level.getTerrainEdge(), level.getTerrainTiles());
ceiling.loadData(world, level.getCeilingEdge(), level.getCeilingTiles());
uncategorizedEntities.add(goal);

View File

@ -58,7 +58,7 @@ public abstract class Scene {
setTexturePack(texturePack);
camera = new Camera();
playerArrow = new Entity(textures.playerArrow, new Vector(0, 0.9f), .2f, .2f);
background = new Background(World.GRASSLANDS.getBackgroundTexture());
background = new Background(World.GRASSLANDS.getBackgroundTextures());
terrain = new Terrain(World.GRASSLANDS.getTerrainTexture());
ceiling = new Ceiling(World.GRASSLANDS.getTerrainTexture());
player = new Player();
@ -144,7 +144,7 @@ public abstract class Scene {
private void moveEnviroment(float x) {
camera.moveX(x);
background.move(x * 0.95f, camera.getX());
background.move(x, camera.getX());
terrain.update(camera.getX());
ceiling.update(camera.getX());
}

View File

@ -42,7 +42,7 @@ public class StartScene extends Scene {
public void loadTexturesForCurrentWorld() {
terrain.clear();
terrain.createEndless(currentWorld, TERRAIN_EDGE);
background.changeTexture(currentWorld.getBackgroundTexture());
background.changeTextures(currentWorld.getBackgroundTextures());
}
}

View File

@ -13,10 +13,10 @@ public class TestScreenScene extends Scene {
public TestScreenScene(GameActivity gameActivity, TexturePack texturePack, ParticleSystem particleSystem) {
super(gameActivity, texturePack, particleSystem);
// terrain.createEndless(World.GRASSLANDS, 0.6f);
// background.changeTexture(World.ICY_MOUNTAINS.getBackgroundTexture());
// background.changeTextures(World.ICY_MOUNTAINS.getBackgroundTexture());
//
// player.init(PlayerShape.BALL, 0.6f, 0.5f, 0.5f, particleSystem);
// uncategorizedEntities.add(player);
uncategorizedEntities.add(new Entity(World.GRASSLANDS.getBackgroundTexture(), new Vector(), 1, 1));
uncategorizedEntities.add(new Entity(World.GRASSLANDS.getBackgroundTextures().get(0), new Vector(), 1, 1));
}
}

View File

@ -36,19 +36,22 @@ public class PlayerShapeShopScreen extends Screen<RelativeLayout> implements Pla
private void createViews() {
topRow.removeAllViews();
bottomRow.removeAllViews();
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(30, 0, 30, 0);
int i = 0;
int totalShapes = PlayerShape.values().length;
for (PlayerShape playerShape : PlayerShape.values()) {
playerShape.getUnlockTask().update(gameActivity.getLevelManager());
boolean lastInRow = i == totalShapes / 2 || i == totalShapes - 1;
boolean locked = !playerShape.getUnlockTask()
.isConditionFulfilled();
PlayerShapeButton button = new PlayerShapeButton(gameActivity, playerShape, this,
locked, !lastInRow);
if (i < totalShapes / 2 + 1)
topRow.addView(button.getView());
locked);
if (i % 2 == 0)
topRow.addView(button.getView(), params);
else
bottomRow.addView(button.getView());
bottomRow.addView(button.getView(), params);
if (playerShape.equals(gameActivity.getUser().getCurrentPlayerShape())) {
this.activeButton = button;

View File

@ -62,7 +62,7 @@ public class ToolShopScreen extends Screen<RelativeLayout> implements View.OnCli
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(10, 0, 10, 0);
params.setMargins(30, 0, 30, 0);
int i = 0;
for (ToolType type : ToolType.values()) {
@ -70,7 +70,7 @@ public class ToolShopScreen extends Screen<RelativeLayout> implements View.OnCli
ToolOfferSlot slot = new ToolOfferSlot(this, gameActivity, gameActivity.getTypeface(),
type);
toolOfferSlots.add(slot);
if (i > 5)
if (i % 2 == 0)
toolOfferBottomRow.addView(slot.getLayout(), params);
else
toolOfferTopRow.addView(slot.getLayout(), params);

View File

@ -9,6 +9,7 @@ import java.util.List;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import de.frajul.endlessroll.entities.BackgroundLayer;
import de.frajul.endlessroll.entities.Entity;
import de.frajul.endlessroll.entities.Obstacle;
import de.frajul.endlessroll.entities.textures.TexturePack;
@ -127,9 +128,14 @@ public class GameRenderer implements GLSurfaceView.Renderer {
private void renderBackground(GL10 gl, Scene scene) {
entityShader.start();
entityShader.loadMVPMatrix(matrixCreator, scene.getCamera());
synchronized (scene.getBackground()) {
for (Entity backgroundPart : scene.getBackground())
renderEntity(gl, backgroundPart);
List<BackgroundLayer> layers = scene.getBackground().getLayers();
synchronized (layers) {
for(BackgroundLayer layer : layers){
synchronized (layer){
for(Entity backgroundPart : layer)
renderEntity(gl, backgroundPart);
}
}
}
entityShader.stop();
}

View File

@ -29,12 +29,11 @@ public class PlayerShapeButton implements View.OnClickListener {
private boolean locked;
public PlayerShapeButton(GameActivity gameActivity, PlayerShape playerShape, PlayerShapeButtonOnClickListener clickListener, boolean locked, boolean marginToRight) {
public PlayerShapeButton(GameActivity gameActivity, PlayerShape playerShape, PlayerShapeButtonOnClickListener clickListener, boolean locked) {
this.clickListener = clickListener;
this.playerShape = playerShape;
this.locked = locked;
view = LayoutInflater.from(gameActivity).inflate(R.layout.shape_button, null);
view.setLayoutParams(createLayoutParams(marginToRight));
textView = (TextView) view.findViewById(R.id.shape_button_textview);
textView.setTypeface(gameActivity.getTypeface());
textView.setText(locked ? R.string.playershape_name_locked : playerShape.getNameId());
@ -45,14 +44,6 @@ public class PlayerShapeButton implements View.OnClickListener {
rotation = AnimationUtils.loadAnimation(gameActivity, R.anim.shape_button_rotation);
}
private LinearLayout.LayoutParams createLayoutParams(boolean marginToRight) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
if (marginToRight)
params.setMargins(0, 0, 60, 0);
return params;
}
public void startRotating() {
button.startAnimation(rotation);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -15,10 +15,21 @@
android:layout_height="match_parent"
android:layout_below="@id/shape_shop_topbar">
<LinearLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@id/shape_shop_shape_inspector"
android:layout_toLeftOf="@id/shape_shop_shape_inspector">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:overScrollMode="never"
android:scrollbars="none">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
@ -51,6 +62,10 @@
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
<include
android:id="@+id/shape_shop_shape_inspector"
layout="@layout/shape_inspector"

View File

@ -12,24 +12,25 @@
<RelativeLayout
android:layout_width="match_parent"
android:background="@drawable/backgrounds_menu_grasslands"
android:layout_height="match_parent"
android:layout_below="@+id/toolshop_topbar">
android:layout_below="@+id/toolshop_topbar"
android:background="@drawable/backgrounds_menu_grasslands">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:layout_toLeftOf="@+id/toolshop_toolinspector"
android:layout_toStartOf="@+id/toolshop_toolinspector">
android:layout_toStartOf="@+id/toolshop_toolinspector"
android:clipChildren="false">
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipChildren="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:clipChildren="false"
android:orientation="horizontal">
<include
@ -67,32 +68,53 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:layout_below="@+id/linearLayout4">
android:layout_below="@+id/linearLayout4"
android:clipChildren="false">
<LinearLayout
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:clipChildren="false"
android:orientation="vertical">
android:overScrollMode="never"
android:scrollbars="none">
<LinearLayout
android:id="@+id/toolshop_tool_offer_top_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipChildren="false"
android:layout_marginBottom="10dp"
android:orientation="horizontal"/>
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/toolshop_tool_offer_bottom_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipChildren="false"
android:orientation="horizontal"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:id="@+id/toolshop_tool_offer_top_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:clipChildren="false"
android:orientation="horizontal"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:layout_weight="1">
<LinearLayout
android:id="@+id/toolshop_tool_offer_bottom_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:clipChildren="false"
android:orientation="horizontal"/>
</RelativeLayout>
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>

View File

@ -77,4 +77,6 @@
<string name="settings_music">Musik</string>
<string name="settings_show_fps">Fps anzeigen</string>
<string name="settings_boost_performance">Leistung erhöhen</string>
<string name="playershape_name_blue">Ich bin blau</string>
<string name="playershape_description_blue">Warum bin ich blau?</string>
</resources>

View File

@ -54,6 +54,7 @@
<string name="playershape_name_smiley">Smiley</string>
<string name="playershape_name_wheel">Wheel</string>
<string name="playershape_name_sun">Sun</string>
<string name="playershape_name_blue">I\'m blue</string>
<string name="playershape_name_locked" translatable="false">\?\?\?</string>
<string name="playershape_description_ball" translatable="false">Keep calm and roll on</string>
<string name="playershape_description_clock" translatable="false">Tick tack!</string>
@ -62,6 +63,7 @@
<string name="playershape_description_smiley" translatable="false">Don\'t worry, roll happy!</string>
<string name="playershape_description_wheel">A nice car without the... car</string>
<string name="playershape_description_sun">Shine bright like the sun</string>
<string name="playershape_description_blue">Why am I blue?</string>
<string name="playershape_description_locked">A new shape for more fun</string>
<string name="task_empty">Empty task</string>