Added soccer-player-shape
fixed bug with tools not being set on top of obstacles Tools are no longer moved to left if set hard on edge of obstacle
This commit is contained in:
@ -135,7 +135,9 @@ public class Player extends Entity {
|
||||
@Override
|
||||
public void move(Vector movement) {
|
||||
super.move(movement);
|
||||
rotate(movement.x * ROTATION_SPEED);
|
||||
float circumference = 2 * 3.14f * RADIUS;
|
||||
float rotation = -360 * (movement.x / circumference);
|
||||
rotate(rotation);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,22 +13,24 @@ import de.frajul.endlessroll.entities.textures.TexturePack;
|
||||
|
||||
public enum PlayerShape {
|
||||
BALL(R.string.playershape_name_ball, R.string.playershape_description_ball,
|
||||
R.drawable.playershapes_ball, new EmptyTask()),
|
||||
HYPNO_SPIRAL(R.string.playershape_name_hypno_spiral,
|
||||
R.string.playershape_description_hypno_spiral, R.drawable.playershapes_hypno_spiral,
|
||||
new CollectEnergyTask(5)),
|
||||
R.drawable.playershapes_ball, true, new EmptyTask()),
|
||||
CLOCK(R.string.playershape_name_clock, R.string.playershape_description_clock,
|
||||
R.drawable.playershapes_clock, new CollectStarTask(15)),
|
||||
SUN(R.string.playershape_name_sun, R.string.playershape_description_sun,
|
||||
R.drawable.playershapes_sun, new CollectEnergyTask(25)),
|
||||
R.drawable.playershapes_clock, true, new CollectStarTask(15)),
|
||||
SMILEY(R.string.playershape_name_smiley, R.string.playershape_description_smiley,
|
||||
R.drawable.playershapes_smiley, new CollectStarTask(50)),
|
||||
PACMAN(R.string.playershape_name_pacman, R.string.playershape_description_pacman,
|
||||
R.drawable.playershapes_pacman, new CompleteWorldTask(1)),
|
||||
R.drawable.playershapes_smiley, true, new CollectStarTask(50)),
|
||||
WHEEL(R.string.playershape_name_wheel, R.string.playershape_description_wheel,
|
||||
R.drawable.playershapes_wheel, new CollectStarTask(80)),
|
||||
R.drawable.playershapes_wheel, true, new CollectStarTask(80)),
|
||||
|
||||
PACMAN(R.string.playershape_name_pacman, R.string.playershape_description_pacman,
|
||||
R.drawable.playershapes_pacman, false, new CompleteWorldTask(1)),
|
||||
SOCCER(R.string.playershape_name_soccer, R.string.playershape_description_soccer, R.drawable.playershapes_soccer, false, new CompleteWorldTask(2)),
|
||||
HYPNO_SPIRAL(R.string.playershape_name_hypno_spiral,
|
||||
R.string.playershape_description_hypno_spiral, R.drawable.playershapes_hypno_spiral, false,
|
||||
new CollectEnergyTask(5)),
|
||||
BLUE(R.string.playershape_name_blue, R.string.playershape_description_blue,
|
||||
R.drawable.jury_playershapes_ball_omg_im_blue, new CompleteWorldTask(2));
|
||||
R.drawable.playershapes_blue, false, new CollectEnergyTask(20)),
|
||||
SUN(R.string.playershape_name_sun, R.string.playershape_description_sun,
|
||||
R.drawable.playershapes_sun, false, new CollectEnergyTask(30));
|
||||
|
||||
@StringRes
|
||||
private int nameId;
|
||||
@ -36,14 +38,16 @@ public enum PlayerShape {
|
||||
private int descriptionId;
|
||||
@DrawableRes
|
||||
private int drawableId;
|
||||
private boolean inTopRow;
|
||||
private Task unlockTask;
|
||||
|
||||
private Texture texture;
|
||||
|
||||
PlayerShape(@StringRes int nameId, @StringRes int descriptionId, @DrawableRes int drawableId, Task unlockTask) {
|
||||
PlayerShape(@StringRes int nameId, @StringRes int descriptionId, @DrawableRes int drawableId, boolean inTopRow, Task unlockTask) {
|
||||
this.nameId = nameId;
|
||||
this.descriptionId = descriptionId;
|
||||
this.drawableId = drawableId;
|
||||
this.inTopRow = inTopRow;
|
||||
this.unlockTask = unlockTask;
|
||||
}
|
||||
|
||||
@ -80,4 +84,8 @@ public enum PlayerShape {
|
||||
public Texture getTexture() {
|
||||
return texture;
|
||||
}
|
||||
|
||||
public boolean isInTopRow() {
|
||||
return inTopRow;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ public class Bomb extends Tool {
|
||||
animation.setLooping(false);
|
||||
animation.setRequiredDelta(
|
||||
(int) (ToolType.BOMB.getCurrentUpgradeValue(ToolUpgradeType.DURATION) / 3f));
|
||||
super.setFloating(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,7 +28,6 @@ public class MyGlSurfaceView extends GLSurfaceView {
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if(event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
GameLog.i("TouchEvent!!!");
|
||||
renderer.onTouch(event.getX(), event.getY());
|
||||
}
|
||||
return true;
|
||||
|
@ -19,7 +19,6 @@ import de.frajul.endlessroll.entities.collision.geometry.Circle;
|
||||
import de.frajul.endlessroll.entities.tileLists.Ceiling;
|
||||
import de.frajul.endlessroll.entities.tileLists.Terrain;
|
||||
import de.frajul.endlessroll.entities.tileLists.Tile;
|
||||
import de.frajul.endlessroll.entities.tools.Bomb;
|
||||
import de.frajul.endlessroll.entities.tools.Tool;
|
||||
import de.frajul.endlessroll.main.game.GameScene;
|
||||
import de.frajul.endlessroll.main.game.Scene;
|
||||
@ -31,7 +30,6 @@ import de.frajul.endlessroll.main.game.Timer;
|
||||
public class Physics {
|
||||
|
||||
public final float GRAVITY_FORCE = .0000025f;
|
||||
private final float TOOL_ON_OBSTACLE_LEFT_EDGE_TOLERANCE = 0.05f;
|
||||
private CollisionDetector detector;
|
||||
|
||||
public Physics() {
|
||||
@ -63,28 +61,17 @@ public class Physics {
|
||||
public synchronized void checkSingleToolCollision(Tool tool, Scene scene) {
|
||||
if (tool.isFloating())
|
||||
return;
|
||||
float terrainEdge = getTerrainEdge(tool, scene.getTerrain());
|
||||
Obstacle toolIsCollidingWith = getHighestObstacleToolIsCollidingWith(tool, scene);
|
||||
|
||||
if (toolIsCollidingWith != null) {
|
||||
float distObstTool = tool.getRightEdge() - toolIsCollidingWith.getLeftEdge();
|
||||
if (distObstTool < TOOL_ON_OBSTACLE_LEFT_EDGE_TOLERANCE) {
|
||||
tool.getPosition().x -= TOOL_ON_OBSTACLE_LEFT_EDGE_TOLERANCE;
|
||||
terrainEdge = getTerrainEdge(tool, scene.getTerrain());
|
||||
toolIsCollidingWith = getHighestObstacleToolIsCollidingWith(tool, scene);
|
||||
}
|
||||
boolean collidingWithTerrain = isToolCollidingWithTerrain(tool, scene.getTerrain());
|
||||
if (collidingWithTerrain) {
|
||||
tool.getMovement().y = 0;
|
||||
tool.setToTerrain(scene.getTerrain().getEdge());
|
||||
}
|
||||
|
||||
float orientingHeight = terrainEdge;
|
||||
if (toolIsCollidingWith != null)
|
||||
orientingHeight = Math.max(toolIsCollidingWith.getTopEdge(), terrainEdge);
|
||||
|
||||
if (tool.getBottomEdge() <= orientingHeight) {
|
||||
Obstacle collidingObstacle = getHighestObstacleToolIsCollidingWith(tool, scene);
|
||||
if (collidingObstacle != null && tool.getBottomEdge() <= collidingObstacle.getTopEdge()) {
|
||||
tool.getMovement().y = 0;
|
||||
if (tool instanceof Bomb)
|
||||
tool.setFloating(true);
|
||||
else
|
||||
tool.setToTerrain(orientingHeight);
|
||||
tool.setToTerrain(collidingObstacle.getTopEdge());
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,17 +92,12 @@ public class Physics {
|
||||
return highest;
|
||||
}
|
||||
|
||||
private float getTerrainEdge(Entity tool, Terrain terrain) {
|
||||
for (Tile instance : terrain) {
|
||||
if ((tool.getLeftEdge() >= instance.getLeftEdge() && tool.getLeftEdge() <= instance
|
||||
.getRightEdge()) || (tool.getRightEdge() <= instance.getRightEdge() && tool
|
||||
.getRightEdge() >= instance.getLeftEdge()) || (instance.getLeftEdge() >= tool
|
||||
.getLeftEdge() && instance.getLeftEdge() <= tool.getRightEdge()) || (instance
|
||||
.getRightEdge() <= tool.getRightEdge() && instance.getRightEdge() >= tool
|
||||
.getLeftEdge()))
|
||||
return terrain.getEdge();
|
||||
private boolean isToolCollidingWithTerrain(Entity tool, Terrain terrain) {
|
||||
for (Tile tile : terrain) {
|
||||
if (detector.isCollision(tool, tile))
|
||||
return true;
|
||||
}
|
||||
return -10;
|
||||
return false;
|
||||
}
|
||||
|
||||
public PlayerCollisionData getPlayerCollisionData(GameScene scene) {
|
||||
|
@ -41,14 +41,13 @@ public class PlayerShapeShopScreen extends Screen<RelativeLayout> implements Pla
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(30, 0, 30, 0);
|
||||
|
||||
int i = 0;
|
||||
for (PlayerShape playerShape : PlayerShape.values()) {
|
||||
playerShape.getUnlockTask().update(gameActivity.getLevelManager());
|
||||
boolean locked = !playerShape.getUnlockTask()
|
||||
.isConditionFulfilled();
|
||||
PlayerShapeButton button = new PlayerShapeButton(gameActivity, playerShape, this,
|
||||
locked);
|
||||
if (i % 2 == 0)
|
||||
if (playerShape.isInTopRow())
|
||||
topRow.addView(button.getView(), params);
|
||||
else
|
||||
bottomRow.addView(button.getView(), params);
|
||||
@ -57,8 +56,6 @@ public class PlayerShapeShopScreen extends Screen<RelativeLayout> implements Pla
|
||||
this.activeButton = button;
|
||||
button.startRotating();
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
shapeInspector.update(activeButton.getPlayerShape(), activeButton.isLocked());
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 39 KiB |
Binary file not shown.
Before Width: | Height: | Size: 21 KiB |
Binary file not shown.
Before Width: | Height: | Size: 21 KiB |
Binary file not shown.
Before Width: | Height: | Size: 27 KiB |
Binary file not shown.
Before Width: | Height: | Size: 44 KiB |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB |
@ -11,6 +11,7 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_margin="10dp"
|
||||
android:visibility="invisible"
|
||||
android:src="@drawable/guis_pausebutton"/>
|
||||
|
||||
<TextView
|
||||
@ -21,6 +22,7 @@
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="@string/game_playerprogress_placeholder"
|
||||
android:visibility="invisible"
|
||||
android:textColor="@color/secondary"
|
||||
android:textSize="22sp"/>
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="@string/start_screen_gain_90_ep"
|
||||
android:visibility="invisible"/>
|
||||
android:visibility="invisible"/>l
|
||||
|
||||
<Button
|
||||
android:id="@+id/startscreen_finish_world_1"
|
||||
|
@ -17,7 +17,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:scrollbars="none"
|
||||
|
@ -25,6 +25,7 @@
|
||||
<string name="playershape_name_clock">Uhr</string>
|
||||
<string name="playershape_name_hypno_spiral">Hypnose</string>
|
||||
<string name="playershape_name_pacman">Pacman</string>
|
||||
<string name="playershape_name_soccer">Fußball</string>
|
||||
<string name="playershape_name_smiley">Smiley</string>
|
||||
<string name="playershape_name_wheel">Reifen</string>
|
||||
<string name="playershape_name_sun">Sonne</string>
|
||||
@ -78,4 +79,5 @@
|
||||
<string name="settings_show_fps">Fps anzeigen</string>
|
||||
<string name="playershape_name_blue">Blau</string>
|
||||
<string name="playershape_description_blue">Warum bin ich blau?</string>
|
||||
<string name="playershape_description_soccer">Fuß. Ball. Fußball!</string>
|
||||
</resources>
|
@ -50,6 +50,7 @@
|
||||
<string name="playershape_name_clock">Clock</string>
|
||||
<string name="playershape_name_hypno_spiral">Hypno</string>
|
||||
<string name="playershape_name_pacman">Pacman</string>
|
||||
<string name="playershape_name_soccer">Soccer</string>
|
||||
<string name="playershape_name_smiley">Smiley</string>
|
||||
<string name="playershape_name_wheel">Wheel</string>
|
||||
<string name="playershape_name_sun">Sun</string>
|
||||
@ -58,6 +59,7 @@
|
||||
<string name="playershape_description_ball" translatable="false">Keep calm and roll on</string>
|
||||
<string name="playershape_description_clock" translatable="false">Tick tack!</string>
|
||||
<string name="playershape_description_hypno_spiral">Hypnotizes you for more fun</string>
|
||||
<string name="playershape_description_soccer">Let\'s roll to the goal!</string>
|
||||
<string name="playershape_description_pacman" translatable="false">PACMAN!</string>
|
||||
<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>
|
||||
|
@ -1,6 +1,10 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/primary</item>
|
||||
<item name="colorPrimaryDark">@color/primary_dark</item>
|
||||
<item name="colorAccent">@color/secondary</item>
|
||||
|
||||
<item name="android:buttonStyle">@style/GameButton</item>
|
||||
<item name="android:textColor">@color/black</item>
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user