Refactor input, fix color crash bugs, prototype multi-block placement
This commit is contained in:
@@ -36,7 +36,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||
},
|
||||
iron = new BulletType(1.7f, 2){
|
||||
public void draw(Bullet b){
|
||||
Draw.color("gray");
|
||||
Draw.color(Color.GRAY);
|
||||
Draw.rect("bullet", b.x, b.y, b.angle());
|
||||
Draw.reset();
|
||||
}
|
||||
@@ -241,7 +241,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||
},
|
||||
smallSlow = new BulletType(1.2f, 2){
|
||||
public void draw(Bullet b){
|
||||
Draw.color("orange");
|
||||
Draw.color(Color.ORANGE);
|
||||
Draw.rect("shot", b.x, b.y, b.angle() - 45);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@@ -3,30 +3,30 @@ package io.anuke.mindustry.entities;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import com.badlogic.gdx.Input.Buttons;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.effect.Fx;
|
||||
import io.anuke.mindustry.input.Input;
|
||||
import io.anuke.mindustry.input.PlaceMode;
|
||||
import io.anuke.mindustry.resource.Mech;
|
||||
import io.anuke.mindustry.resource.Recipe;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.DestructibleEntity;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class Player extends DestructibleEntity{
|
||||
private static final float speed = 1.1f;
|
||||
private static final float dashSpeed = 1.8f;
|
||||
|
||||
public Weapon weapon;
|
||||
public Mech mech = Mech.standard;
|
||||
public float breaktime = 0;
|
||||
public float angle;
|
||||
|
||||
public Recipe recipe;
|
||||
public int rotation;
|
||||
|
||||
private Vector2 direction = new Vector2();
|
||||
private float speed = 1.1f;
|
||||
private float dashSpeed = 1.8f;
|
||||
public transient float breaktime = 0;
|
||||
public transient Recipe recipe;
|
||||
public transient int rotation;
|
||||
public transient PlaceMode placeMode = PlaceMode.touch;
|
||||
|
||||
public Player(){
|
||||
hitbox.setSize(5);
|
||||
@@ -59,9 +59,9 @@ public class Player extends DestructibleEntity{
|
||||
if(Vars.debug && (!Vars.showPlayer || !Vars.showUI)) return;
|
||||
|
||||
if(Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate")){
|
||||
Draw.rect("mech-"+mech.name(), (int)x, (int)y, direction.angle()-90);
|
||||
Draw.rect("mech-"+mech.name(), (int)x, (int)y, angle-90);
|
||||
}else{
|
||||
Draw.rect("mech-"+mech.name(), x, y, direction.angle()-90);
|
||||
Draw.rect("mech-"+mech.name(), x, y, angle-90);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,15 +69,7 @@ public class Player extends DestructibleEntity{
|
||||
@Override
|
||||
public void update(){
|
||||
|
||||
float speed = this.speed;
|
||||
|
||||
if(Inputs.keyDown("dash")){
|
||||
speed = dashSpeed;
|
||||
|
||||
if(Vars.debug){
|
||||
// speed *= 3f;
|
||||
}
|
||||
}
|
||||
float speed = Inputs.keyDown("dash") ? Player.dashSpeed : Player.speed;
|
||||
|
||||
if(health < maxhealth && Timers.get(this, "regen", 50))
|
||||
health ++;
|
||||
@@ -93,7 +85,8 @@ public class Player extends DestructibleEntity{
|
||||
if(Inputs.keyDown("right"))
|
||||
vector.x += speed;
|
||||
|
||||
boolean shooting = !Inputs.keyDown("dash") && Inputs.buttonDown(Buttons.LEFT) && recipe == null && !ui.hasMouse() && !Input.onConfigurable();
|
||||
boolean shooting = !Inputs.keyDown("dash") && Inputs.buttonDown(Buttons.LEFT) && recipe == null
|
||||
&& !ui.hasMouse() && !control.getInput().onConfigurable();
|
||||
|
||||
if(shooting && Timers.get(this, "reload", weapon.reload)){
|
||||
weapon.shoot(this);
|
||||
@@ -101,7 +94,7 @@ public class Player extends DestructibleEntity{
|
||||
}
|
||||
|
||||
if(Inputs.keyDown("dash") && Timers.get(this, "dashfx", 3) && vector.len() > 0){
|
||||
Angles.translation(direction.angle() + 180, 3f);
|
||||
Angles.translation(angle + 180, 3f);
|
||||
Effects.effect(Fx.dashsmoke, x + Angles.x(), y + Angles.y());
|
||||
}
|
||||
|
||||
@@ -115,14 +108,10 @@ public class Player extends DestructibleEntity{
|
||||
}
|
||||
|
||||
if(!shooting){
|
||||
direction.add(vector);
|
||||
direction.limit(speed*6);
|
||||
angle = Mathf.lerpAngDelta(angle, vector.angle(), 0.13f);
|
||||
}else{
|
||||
float angle = Angles.mouseAngle(x, y);
|
||||
direction.lerp(vector.set(0, 1).setAngle(angle), 0.26f);
|
||||
if(MathUtils.isEqual(angle, direction.angle(), 0.05f)){
|
||||
direction.setAngle(angle);
|
||||
}
|
||||
this.angle = Mathf.lerpAngDelta(this.angle, angle, 0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ public class Fx{
|
||||
|
||||
ind = new Effect(100, e -> {
|
||||
Draw.thickness(3f);
|
||||
Draw.color("royal");
|
||||
Draw.color(Color.ROYAL);
|
||||
Draw.circle(e.x, e.y, 3);
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user