Android performance improvements

This commit is contained in:
Anuken
2017-07-05 11:58:45 -04:00
parent 9c0b31e19a
commit 154247a461
7 changed files with 28 additions and 46 deletions

View File

@@ -77,7 +77,8 @@ project(":core") {
apply plugin: "java"
dependencies {
compile 'com.github.Anuken:ucore:07fe3a5394'
//compile fileTree(dir: '../core/lib', include: '*.jar')
compile 'com.github.Anuken:ucore:b58e4bd'
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
}

View File

@@ -146,7 +146,7 @@ public class Control extends RendererModule{
smoothCamera(core.worldx(), core.worldy(), 0.4f);
}
updateShake();
updateShake(0.5f);
float prevx = camera.position.x, prevy = camera.position.y;
clampCamera(-tilesize / 2f, -tilesize / 2f, pixsize - tilesize / 2f, pixsize - tilesize / 2f);

View File

@@ -40,27 +40,19 @@ public class UI extends SceneModule{
Dialog about, menu, restart, tutorial, levels, upgrades;
Tooltip tooltip;
VisibilityProvider play = () -> {
return playing;
};
VisibilityProvider play = () -> playing;
VisibilityProvider nplay = () -> {
return !playing;
};
VisibilityProvider nplay = () -> !playing;
public UI() {
Dialog.setShowAction(()->{
return sequence(Actions.moveToAligned(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight(), Align.center),
Dialog.setShowAction(()-> sequence(Actions.moveToAligned(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight(), Align.center),
parallel(Actions.moveToAligned(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, Align.center, 0.09f, Interpolation.fade),
Actions.fadeIn(0.09f, Interpolation.fade)));
});
Actions.fadeIn(0.09f, Interpolation.fade))));
Dialog.setHideAction(()->{
return sequence(
Dialog.setHideAction(()-> sequence(
parallel(Actions.moveBy(0, -Gdx.graphics.getHeight()/2, 0.08f, Interpolation.fade),
Actions.fadeOut(0.08f, Interpolation.fade)));
});
Actions.fadeOut(0.08f, Interpolation.fade))));
skin.font().setUseIntegerPositions(false);
skin.font().getData().setScale(Vars.fontscale);
@@ -301,9 +293,7 @@ public class UI extends SceneModule{
table.add().size(size);
}
table.setVisible(()->{
return button.isChecked();
});
table.setVisible(()-> button.isChecked());
stack.add(table);
}
@@ -355,21 +345,13 @@ public class UI extends SceneModule{
new table(){{
get().background("button");
new label("Wave 1"){{
get().setFontScale(fontscale*2f);
get().update(() -> {
get().setText("[YELLOW]Wave " + wave);
});
}}.left();
new label(()->"[YELLOW]Wave " + wave).scale(fontscale*2f).left();
row();
new label("Time"){{
get().update(() -> {
get().setText(enemies > 0 ?
enemies + " Enemies remaining" : "New wave in " + (int) (wavetime / 60f));
});
}}.minWidth(150);
new label(()->enemies > 0 ?
enemies + " Enemies remaining" : "New wave in " + (int) (wavetime / 60f))
.minWidth(150);
get().pad(Unit.dp.inPixels(12));
}};
@@ -379,7 +361,8 @@ public class UI extends SceneModule{
//if(Gdx.app.getType() != ApplicationType.Android){
//+- table
//+- table
//TODO refactor to make this less messy
new table(){{
aleft();
abottom();

View File

@@ -28,6 +28,7 @@ public class Vars{
public static final int baseCameraScale = Math.round(Unit.dp.inPixels(4));
public static final int zoomScale = Math.round(Unit.dp.inPixels(1));
public static int multiplier = android ? 2 : 1;
public static final Vector2 vector = new Vector2();
public static final int tilesize = 8;

View File

@@ -10,7 +10,6 @@ import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.entities.Enemy;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
public class Pathfind{
static MHueristic heuristic = new MHueristic();
static PassTileGraph passgraph = new PassTileGraph();
@@ -77,10 +76,10 @@ public class Pathfind{
}
if(debug)
for(Tile tile : path){
Effects.effect("ind", tile.worldx(), tile.worldy());
}
//if(debug)
//for(Tile tile : path){
// Effects.effect("ind", tile.worldx(), tile.worldy());
//}
}
}

View File

@@ -54,7 +54,7 @@ public class Enemy extends DestructibleEntity{
}
if(target != null){
if(Timers.get(hashCode()+"reload", reload)){
if(Timers.get(this, "reload", reload*Vars.multiplier)){
shoot();
Effects.sound(shootsound, this);
}
@@ -62,9 +62,9 @@ public class Enemy extends DestructibleEntity{
}
public void shoot(){
vector.set(length, 0).rotate(direction.angle());
new Bullet(bullet, this, x+vector.x, y+vector.y, direction.angle()).add();
Bullet out = new Bullet(bullet, this, x+vector.x, y+vector.y, direction.angle()).add();
out.damage = bullet.damage*Vars.multiplier;
}
@Override

View File

@@ -90,7 +90,7 @@ public class Turret extends Block{
if(enemy != null){
entity.rotation = MathUtils.lerpAngleDeg(entity.rotation, Angles.predictAngle(tile.worldx(), tile.worldy(), enemy.x, enemy.y, enemy.xvelocity, enemy.yvelocity, bullet.speed - 0.1f), 0.2f);
float reload = Vars.android ? this.reload*2 : this.reload;
float reload = Vars.multiplier*this.reload;
if(Timers.get(tile, reload)){
Effects.sound(shootsound, entity);
shoot(tile);
@@ -109,15 +109,13 @@ public class Turret extends Block{
TurretEntity entity = tile.entity();
vector.set(0, 4).setAngle(entity.rotation);
new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, entity.rotation).add();
Bullet out = new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, entity.rotation).add();
out.damage = bullet.damage*Vars.multiplier;
}
protected void bullet(Tile tile, float angle){
Bullet out = new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, angle).add();
if(Vars.android){
out.damage *= 2;
}
out.damage = bullet.damage*Vars.multiplier;
}
static class TurretEntity extends TileEntity{