Now with only 28 errors!

This commit is contained in:
Anuken
2018-02-05 23:38:23 -05:00
parent 55ae4c6ea5
commit 2fafb327c2
32 changed files with 206 additions and 211 deletions

View File

@@ -252,10 +252,11 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
Effects.effect(Fx.blastsmoke, b);
Effects.effect(Fx.blastexplosion, b);
Angles.circle(30, f->{
Angles.translation(f, 6f);
Bullet o = new Bullet(blastshot, b.owner, b.x + Angles.x(), b.y + Angles.y(), f).add();
//TODO remove translation() usage
Angles.circleVectors(30, 6f, (x, y) -> {
float ang = Mathf.atan2(x, y);
Bullet o = new Bullet(blastshot, b.owner, b.x + x, b.y + y, ang).add();
o.damage = b.damage/9;
});
}

View File

@@ -1,6 +1,7 @@
package io.anuke.mindustry.entities;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.TimeUtils;
import io.anuke.mindustry.graphics.Fx;
import io.anuke.mindustry.graphics.Shaders;
@@ -17,6 +18,7 @@ import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Tmp;
import io.anuke.ucore.util.Translator;
import java.nio.ByteBuffer;
@@ -41,6 +43,9 @@ public class Player extends SyncEntity{
public int clientid;
public boolean isLocal = false;
private Vector2 movement = new Vector2();
private Translator tr = new Translator();
public Player(){
hitbox.setSize(5);
@@ -121,12 +126,12 @@ public class Player extends SyncEntity{
if(!isAndroid) {
for (int i : Mathf.signs) {
Weapon weapon = i < 0 ? weaponLeft : weaponRight;
Angles.vector.set(3 * i, 2).rotate(angle - 90);
tr.trns(angle - 90, 3*i, 2);
float w = i > 0 ? -8 : 8;
if(snap){
Draw.rect(weapon.name + "-equip", (int)x + Angles.x(), (int)y + Angles.y(), w, 8, angle - 90);
Draw.rect(weapon.name + "-equip", (int)x + tr.x, (int)y + tr.y, w, 8, angle - 90);
}else{
Draw.rect(weapon.name + "-equip", x + Angles.x(), y + Angles.y(), w, 8, angle - 90);
Draw.rect(weapon.name + "-equip", x + tr.x, y + tr.y, w, 8, angle - 90);
}
}
}
@@ -172,15 +177,15 @@ public class Player extends SyncEntity{
health = Mathf.clamp(health, -1, maxhealth);
vector.set(0, 0);
movement.set(0, 0);
float xa = Inputs.getAxis("move_x");
float ya = Inputs.getAxis("move_y");
if(Math.abs(xa) < 0.3) xa = 0;
if(Math.abs(ya) < 0.3) ya = 0;
vector.y += ya*speed;
vector.x += xa*speed;
movement.y += ya*speed;
movement.x += xa*speed;
boolean shooting = !Inputs.keyDown("dash") && Inputs.keyDown("shoot") && control.input().recipe == null
&& !ui.hasMouse() && !control.input().onConfigurable();
@@ -190,23 +195,22 @@ public class Player extends SyncEntity{
weaponRight.update(player, false);
}
if(dashing && Timers.get(this, "dashfx", 3) && vector.len() > 0){
Angles.translation(angle + 180, 3f);
Effects.effect(Fx.dashsmoke, x + Angles.x(), y + Angles.y());
if(dashing && Timers.get(this, "dashfx", 3) && movement.len() > 0){
Effects.effect(Fx.dashsmoke, x + Angles.trnsx(angle + 180f, 3f), y + Angles.trnsy(angle + 180f, 3f));
}
vector.limit(speed);
movement.limit(speed);
if(!noclip){
move(vector.x*Timers.delta(), vector.y*Timers.delta());
move(movement.x*Timers.delta(), movement.y*Timers.delta());
}else{
x += vector.x*Timers.delta();
y += vector.y*Timers.delta();
x += movement.x*Timers.delta();
y += movement.y*Timers.delta();
}
if(!shooting){
if(!vector.isZero())
angle = Mathf.lerpAngDelta(angle, vector.angle(), 0.13f);
if(!movement.isZero())
angle = Mathf.lerpAngDelta(angle, movement.angle(), 0.13f);
}else{
float angle = Angles.mouseAngle(x, y);
this.angle = Mathf.lerpAngDelta(this.angle, angle, 0.1f);
@@ -299,14 +303,15 @@ public class Player extends SyncEntity{
angle = Mathf.lerpAngDelta(angle, i.targetrot, 0.6f);
float tx = x + Angles.trnsx(angle + 180f, 3f);
float ty = y + Angles.trnsy(angle + 180f, 3f);
if(isAndroid && i.target.dst(i.last) > 2f && Timers.get(this, "dashfx", 2)){
Angles.translation(angle + 180, 3f);
Effects.effect(Fx.dashsmoke, x + Angles.x(), y + Angles.y());
Effects.effect(Fx.dashsmoke, tx, ty);
}
if(dashing && !dead && Timers.get(this, "dashfx", 3) && i.target.dst(i.last) > 1f){
Angles.translation(angle + 180, 3f);
Effects.effect(Fx.dashsmoke, x + Angles.x(), y + Angles.y());
Effects.effect(Fx.dashsmoke, tx, ty);
}
}

View File

@@ -11,20 +11,21 @@ import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.entities.SolidEntity;
import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Physics;
import io.anuke.ucore.util.Translator;
import static io.anuke.mindustry.Vars.*;
public class DamageArea{
private static Rectangle rect = new Rectangle();
private static Translator tr = new Translator();
//only for entities, not tiles (yet!)
public static void damageLine(Entity owner, Effect effect, float x, float y, float angle, float length, int damage){
Angles.translation(angle, length);
rect.setPosition(x, y).setSize(Angles.x(), Angles.y());
float x2 = Angles.x() + x, y2 = Angles.y() + y;
tr.trns(angle, length);
rect.setPosition(x, y).setSize(tr.x, tr.y);
float x2 = tr.x + x, y2 = tr.y + y;
if(rect.width < 0){
rect.x += rect.width;

View File

@@ -3,21 +3,23 @@ package io.anuke.mindustry.entities.effect;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import static io.anuke.mindustry.Vars.*;
import io.anuke.mindustry.graphics.Fx;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.entities.TimedEntity;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Translator;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.world;
public class EMP extends TimedEntity{
static final int maxTargets = 8;
static Array<Tile> array = new Array<>();
static Translator tr = new Translator();
int radius = 4;
int damage = 6;
@@ -80,8 +82,8 @@ public class EMP extends TimedEntity{
}
for(int i = 0; i < 14 - targets.size; i ++){
Angles.translation(Mathf.randomSeed(i + id*77)*360f, radius * tilesize);
drawLine(x + Angles.x(), y + Angles.y());
tr.trns(Mathf.randomSeed(i + id*77)*360f, radius * tilesize);
drawLine(x + tr.x, y + tr.y);
}
Lines.stroke(fract()*2f);

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.entities.enemies;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.TimeUtils;
import io.anuke.mindustry.entities.Bullet;
@@ -10,10 +11,8 @@ import io.anuke.mindustry.net.NetEvents;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.entities.SolidEntity;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Timer;
import io.anuke.ucore.util.Tmp;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.*;
import java.nio.ByteBuffer;
@@ -37,6 +36,9 @@ public class Enemy extends SyncEntity {
public int tier = 1;
public Vector2 totalMove = new Vector2();
public TextureRegion region;
public Translator tr = new Translator();
public Enemy(EnemyType type){
this.type = type;
}
@@ -90,6 +92,7 @@ public class Enemy extends SyncEntity {
hitbox.setSize(type.hitsize);
hitboxTile.setSize(type.hitsizeTile);
maxhealth = type.health * tier;
region = Draw.region(type.name + "-t" + Mathf.clamp(tier, 1, 3));
heal();
}
@@ -166,13 +169,13 @@ public class Enemy extends SyncEntity {
public void shoot(BulletType bullet, float rotation){
if(!(Net.client())) {
Angles.translation(angle + rotation, type.length);
Bullet out = new Bullet(bullet, this, x + Angles.x(), y + Angles.y(), this.angle + rotation).add();
tr.trns(angle + rotation, type.length);
Bullet out = new Bullet(bullet, this, x + tr.x, y + tr.y, this.angle + rotation).add();
out.damage = (int) ((bullet.damage * (1 + (tier - 1) * 1f)));
type.onShoot(this, bullet, rotation);
if(Net.server()){
NetEvents.handleBullet(bullet, this, x + Angles.x(), y + Angles.y(), this.angle + rotation, (short)out.damage);
NetEvents.handleBullet(bullet, this, x + tr.x, y + tr.y, this.angle + rotation, (short)out.damage);
}
}
}

View File

@@ -67,15 +67,13 @@ public class EnemyType {
}
public void draw(Enemy enemy){
String region = name + "-t" + Mathf.clamp(enemy.tier, 1, 3);
Shaders.outline.color.set(tierColors[enemy.tier - 1]);
Shaders.outline.lighten = Mathf.clamp(enemy.hitTime/hitDuration);
Shaders.outline.region = Draw.region(region);
Shaders.outline.region = enemy.region;
Shaders.outline.apply();
Draw.rect(region, enemy.x, enemy.y, enemy.angle - 90);
Draw.rect(enemy.region, enemy.x, enemy.y, enemy.angle - 90);
Draw.color();
Graphics.flush();

View File

@@ -35,13 +35,13 @@ public class FortressType extends EnemyType {
world.getCore().worldy()) <= 90f){
if(Timers.get(this, "spawn", spawnTime) && enemy.spawned < maxSpawn){
Angles.translation(enemy.angle, 20f);
enemy.tr.trns(enemy.angle, 20f);
Enemy s = new Enemy(EnemyTypes.fast);
s.lane = enemy.lane;
s.tier = enemy.tier;
s.spawner = enemy;
s.set(enemy.x + Angles.x(), enemy.y + Angles.y());
s.set(enemy.x + enemy.tr.x, enemy.y + enemy.tr.y);
s.add();
Effects.effect(Fx.spawn, enemy);
@@ -53,7 +53,7 @@ public class FortressType extends EnemyType {
public void onShoot(Enemy enemy, BulletType type, float rotation){
Effects.effect(Fx.largeCannonShot, enemy.x + Angles.x(), enemy.y + Angles.y(), enemy.angle);
Effects.effect(Fx.largeCannonShot, enemy.x + enemy.tr.x, enemy.y + enemy.tr.y, enemy.angle);
Effects.shake(3f, 3f, enemy);
}

View File

@@ -74,7 +74,7 @@ public class HealerType extends EnemyType {
if(target == null) return;
Angles.translation(enemy.angleTo(target), 5f);
enemy.tr.trns(enemy.angleTo(target), 5f);
Shaders.outline.color.set(Color.CLEAR);
Shaders.outline.apply();
@@ -82,7 +82,7 @@ public class HealerType extends EnemyType {
if(target.health < target.maxhealth){
Draw.color(Hue.rgb(138, 244, 138, (MathUtils.sin(Timers.time()) + 1f) / 13f));
Draw.alpha(0.9f);
Shapes.laser("laser", "laserend", enemy.x + Angles.x(), enemy.y + Angles.y(), target.x - Angles.x()/1.5f, target.y - Angles.y()/1.5f);
Shapes.laser("laser", "laserend", enemy.x + enemy.tr.x, enemy.y + enemy.tr.y, target.x - enemy.tr.x/1.5f, target.y - enemy.tr.y/1.5f);
Draw.color();
}

View File

@@ -17,17 +17,14 @@ public class TankType extends EnemyType {
bullet = BulletType.small;
length = 3f;
mass = 1.4f;
length = 8f;
}
@Override
public void shoot(Enemy enemy){
super.shoot(enemy);
Angles.translation(enemy.angle, 8f);
Angles.shotgun(3, 8f, enemy.angle, f -> {
enemy.shoot(bullet, f);
});
Angles.shotgun(3, 8f, enemy.angle, f -> enemy.shoot(bullet, f));
}
}