Android performance improvements
This commit is contained in:
@@ -77,7 +77,8 @@ project(":core") {
|
|||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
dependencies {
|
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:$gdxVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class Control extends RendererModule{
|
|||||||
smoothCamera(core.worldx(), core.worldy(), 0.4f);
|
smoothCamera(core.worldx(), core.worldy(), 0.4f);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateShake();
|
updateShake(0.5f);
|
||||||
float prevx = camera.position.x, prevy = camera.position.y;
|
float prevx = camera.position.x, prevy = camera.position.y;
|
||||||
clampCamera(-tilesize / 2f, -tilesize / 2f, pixsize - tilesize / 2f, pixsize - tilesize / 2f);
|
clampCamera(-tilesize / 2f, -tilesize / 2f, pixsize - tilesize / 2f, pixsize - tilesize / 2f);
|
||||||
|
|
||||||
|
|||||||
@@ -40,27 +40,19 @@ public class UI extends SceneModule{
|
|||||||
Dialog about, menu, restart, tutorial, levels, upgrades;
|
Dialog about, menu, restart, tutorial, levels, upgrades;
|
||||||
Tooltip tooltip;
|
Tooltip tooltip;
|
||||||
|
|
||||||
VisibilityProvider play = () -> {
|
VisibilityProvider play = () -> playing;
|
||||||
return playing;
|
|
||||||
};
|
|
||||||
|
|
||||||
VisibilityProvider nplay = () -> {
|
VisibilityProvider nplay = () -> !playing;
|
||||||
return !playing;
|
|
||||||
};
|
|
||||||
|
|
||||||
public UI() {
|
public UI() {
|
||||||
Dialog.setShowAction(()->{
|
Dialog.setShowAction(()-> sequence(Actions.moveToAligned(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight(), Align.center),
|
||||||
return 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),
|
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(()->{
|
Dialog.setHideAction(()-> sequence(
|
||||||
return sequence(
|
|
||||||
parallel(Actions.moveBy(0, -Gdx.graphics.getHeight()/2, 0.08f, Interpolation.fade),
|
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().setUseIntegerPositions(false);
|
||||||
skin.font().getData().setScale(Vars.fontscale);
|
skin.font().getData().setScale(Vars.fontscale);
|
||||||
@@ -301,9 +293,7 @@ public class UI extends SceneModule{
|
|||||||
table.add().size(size);
|
table.add().size(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
table.setVisible(()->{
|
table.setVisible(()-> button.isChecked());
|
||||||
return button.isChecked();
|
|
||||||
});
|
|
||||||
|
|
||||||
stack.add(table);
|
stack.add(table);
|
||||||
}
|
}
|
||||||
@@ -355,21 +345,13 @@ public class UI extends SceneModule{
|
|||||||
new table(){{
|
new table(){{
|
||||||
get().background("button");
|
get().background("button");
|
||||||
|
|
||||||
new label("Wave 1"){{
|
new label(()->"[YELLOW]Wave " + wave).scale(fontscale*2f).left();
|
||||||
get().setFontScale(fontscale*2f);
|
|
||||||
get().update(() -> {
|
|
||||||
get().setText("[YELLOW]Wave " + wave);
|
|
||||||
});
|
|
||||||
}}.left();
|
|
||||||
|
|
||||||
row();
|
row();
|
||||||
|
|
||||||
new label("Time"){{
|
new label(()->enemies > 0 ?
|
||||||
get().update(() -> {
|
enemies + " Enemies remaining" : "New wave in " + (int) (wavetime / 60f))
|
||||||
get().setText(enemies > 0 ?
|
.minWidth(150);
|
||||||
enemies + " Enemies remaining" : "New wave in " + (int) (wavetime / 60f));
|
|
||||||
});
|
|
||||||
}}.minWidth(150);
|
|
||||||
|
|
||||||
get().pad(Unit.dp.inPixels(12));
|
get().pad(Unit.dp.inPixels(12));
|
||||||
}};
|
}};
|
||||||
@@ -379,7 +361,8 @@ public class UI extends SceneModule{
|
|||||||
|
|
||||||
|
|
||||||
//if(Gdx.app.getType() != ApplicationType.Android){
|
//if(Gdx.app.getType() != ApplicationType.Android){
|
||||||
//+- table
|
//+- table
|
||||||
|
//TODO refactor to make this less messy
|
||||||
new table(){{
|
new table(){{
|
||||||
aleft();
|
aleft();
|
||||||
abottom();
|
abottom();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class Vars{
|
|||||||
public static final int baseCameraScale = Math.round(Unit.dp.inPixels(4));
|
public static final int baseCameraScale = Math.round(Unit.dp.inPixels(4));
|
||||||
public static final int zoomScale = Math.round(Unit.dp.inPixels(1));
|
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 Vector2 vector = new Vector2();
|
||||||
|
|
||||||
public static final int tilesize = 8;
|
public static final int tilesize = 8;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
|
|
||||||
import io.anuke.mindustry.entities.Enemy;
|
import io.anuke.mindustry.entities.Enemy;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Effects;
|
|
||||||
public class Pathfind{
|
public class Pathfind{
|
||||||
static MHueristic heuristic = new MHueristic();
|
static MHueristic heuristic = new MHueristic();
|
||||||
static PassTileGraph passgraph = new PassTileGraph();
|
static PassTileGraph passgraph = new PassTileGraph();
|
||||||
@@ -77,10 +76,10 @@ public class Pathfind{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(debug)
|
//if(debug)
|
||||||
for(Tile tile : path){
|
//for(Tile tile : path){
|
||||||
Effects.effect("ind", tile.worldx(), tile.worldy());
|
// Effects.effect("ind", tile.worldx(), tile.worldy());
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class Enemy extends DestructibleEntity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(target != null){
|
if(target != null){
|
||||||
if(Timers.get(hashCode()+"reload", reload)){
|
if(Timers.get(this, "reload", reload*Vars.multiplier)){
|
||||||
shoot();
|
shoot();
|
||||||
Effects.sound(shootsound, this);
|
Effects.sound(shootsound, this);
|
||||||
}
|
}
|
||||||
@@ -62,9 +62,9 @@ public class Enemy extends DestructibleEntity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shoot(){
|
public void shoot(){
|
||||||
|
|
||||||
vector.set(length, 0).rotate(direction.angle());
|
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
|
@Override
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class Turret extends Block{
|
|||||||
|
|
||||||
if(enemy != null){
|
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);
|
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)){
|
if(Timers.get(tile, reload)){
|
||||||
Effects.sound(shootsound, entity);
|
Effects.sound(shootsound, entity);
|
||||||
shoot(tile);
|
shoot(tile);
|
||||||
@@ -109,15 +109,13 @@ public class Turret extends Block{
|
|||||||
TurretEntity entity = tile.entity();
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
vector.set(0, 4).setAngle(entity.rotation);
|
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){
|
protected void bullet(Tile tile, float angle){
|
||||||
Bullet out = new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, angle).add();
|
Bullet out = new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, angle).add();
|
||||||
|
out.damage = bullet.damage*Vars.multiplier;
|
||||||
if(Vars.android){
|
|
||||||
out.damage *= 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TurretEntity extends TileEntity{
|
static class TurretEntity extends TileEntity{
|
||||||
|
|||||||
Reference in New Issue
Block a user