Skip to content

Commit

Permalink
Added new SFX, dashing, made generation FPS-independent
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Dec 10, 2017
1 parent 347cae2 commit 5ea8f0b
Show file tree
Hide file tree
Showing 27 changed files with 111 additions and 45 deletions.
8 changes: 4 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ _Keep in mind that this is just a basic outline of planned features, and will be

### 3.0 Release
- New tutorial with the power blocks
- New SFX for specific blocks, especially turrets
- [DONE] New SFX for specific blocks, especially turrets
- [DONE] Block drawing layers. Refactor/remove `Block#drawOver()`, add `Layer` enum. Should fix 'glitchy' lasers and conveyor clipping
- [DONE] Balance nuclear reactor, improve effectiveness as they are currently underpowered
- Make generation frame independent
- Investigate issue #5 (enemies stuck in blocks)
- Faster mech movement, possibly with a "boost" key
- [DONE] Make generation frame independent
- [DONE/MOVED] Investigate issue #5 (enemies stuck in blocks) - looks like it's caused by map loading lag, needs to be fixed with a slightly different physics system
- [DONE] Faster mech movement, possibly with a "boost" key
- Balance enemy difficulty

### 3.x Planned
Expand Down
43 changes: 23 additions & 20 deletions android/src/io/anuke/mindustry/AndroidLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@
import io.anuke.mindustry.io.Formatter;
import io.anuke.ucore.scene.ui.layout.Unit;

public class AndroidLauncher extends AndroidApplication {

public class AndroidLauncher extends AndroidApplication{
boolean doubleScaleTablets = false;

@SuppressLint("SimpleDateFormat")
@Override
protected void onCreate (Bundle savedInstanceState) {
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.useImmersiveMode = true;

Mindustry.formatter = new Formatter(){
@SuppressLint("SimpleDateFormat")
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm");

@Override
public String format(Date date){
return format.format(date);
Expand All @@ -36,23 +37,25 @@ public String format(int number){
return NumberFormat.getIntegerInstance().format(number);
}
};

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

float yInches= metrics.heightPixels/metrics.ydpi;
float xInches= metrics.widthPixels/metrics.xdpi;
double diagonalInches = Math.sqrt(xInches*xInches + yInches*yInches);
if (diagonalInches>=6.5){
// 6.5inch device or bigger
Unit.dp.multiplier = 2f;
}else{
// smaller device
Unit.dp.multiplier = 1f;

if(doubleScaleTablets){
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

float yInches = metrics.heightPixels / metrics.ydpi;
float xInches = metrics.widthPixels / metrics.xdpi;
double diagonalInches = Math.sqrt(xInches * xInches + yInches * yInches);
if(diagonalInches >= 6.5){
// 6.5inch device or bigger
Unit.dp.multiplier = 2f;
}else{
// smaller device
Unit.dp.multiplier = 1f;
}
}

//Mindustry.args.add("-debug");

initialize(new Mindustry(), config);
}
}
Binary file added core/assets/sounds/bang.wav
Binary file not shown.
Binary file added core/assets/sounds/bang2.wav
Binary file not shown.
Binary file added core/assets/sounds/bigshot.wav
Binary file not shown.
Binary file added core/assets/sounds/blast.wav
Binary file not shown.
Binary file added core/assets/sounds/laser.wav
Binary file not shown.
Binary file added core/assets/sounds/lasershot.wav
Binary file not shown.
Binary file added core/assets/sounds/ping.wav
Binary file not shown.
Binary file added core/assets/sounds/railgun.wav
Binary file not shown.
Binary file added core/assets/sounds/tesla.wav
Binary file not shown.
Binary file added core/assets/sounds/waveend.wav
Binary file not shown.
8 changes: 5 additions & 3 deletions core/src/io/anuke/mindustry/Vars.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public class Vars{
public static final float respawnduration = 60*4;
//time between waves in frames (on normal mode)
public static final float wavespace = 50*60*(android ? 1 : 1);
//waves can last no longer than 6 minutes, otherwise the next one spawns
public static final float maxwavespace = 60*60*6;
//waves can last no longer than 5 minutes, otherwise the next one spawns
public static final float maxwavespace = 60*60*5;
//advance time the pathfinding starts at
public static final float aheadPathfinding = 60*20;
//how far away from spawn points the player can't place blocks
public static final float enemyspawnspace = 65;
//scale of the font
Expand All @@ -43,7 +45,7 @@ public class Vars{
//whether to draw chunk borders
public static boolean debugChunks = false;
//whether turrets have infinite ammo (only with debug)
public static boolean infiniteAmmo = false;
public static boolean infiniteAmmo = true;
//whether to show paths of enemies
public static boolean showPaths = false;
//if false, player is always hidden
Expand Down
9 changes: 9 additions & 0 deletions core/src/io/anuke/mindustry/ai/Pathfind.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ public void update(){
}
}

public boolean finishedUpdating(){
for(SpawnPoint point : Vars.control.getSpawnPoints()){
if(point.pathTiles == null){
return false;
}
}
return true;
}

public void updatePath(){
for(SpawnPoint point : Vars.control.getSpawnPoints()){
point.finder = new IndexedAStarPathFinder<Tile>(graph);
Expand Down
22 changes: 19 additions & 3 deletions core/src/io/anuke/mindustry/core/Control.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class Control extends Module{

Array<EnemySpawn> spawns = new Array<>();
int wave = 1;
int lastUpdated = -1;
float wavetime;
float extrawavetime;
int enemies = 0;
Expand Down Expand Up @@ -90,7 +91,8 @@ public Control(){

Sounds.load("shoot.wav", "place.wav", "explosion.wav", "enemyshoot.wav",
"corexplode.wav", "break.wav", "spawn.wav", "flame.wav", "die.wav",
"respawn.wav", "purchase.wav", "flame2.wav");
"respawn.wav", "purchase.wav", "flame2.wav", "bigshot.wav", "laser.wav", "lasershot.wav",
"ping.wav", "tesla.wav", "waveend.wav", "railgun.wav", "blast.wav", "bang2.wav");

Sounds.setFalloff(9000f);

Expand All @@ -103,7 +105,8 @@ public Control(){
"right", Keys.D,
"zoom_hold", Keys.CONTROL_LEFT,
"menu", Gdx.app.getType() == ApplicationType.Android ? Keys.BACK : Keys.ESCAPE,
"pause", Keys.SPACE
"pause", Keys.SPACE,
"dash", Keys.SHIFT_LEFT
);

for(int i = 0; i < Vars.saveSlots; i ++){
Expand All @@ -129,6 +132,7 @@ public void reset(){
weapons.add(Weapon.blaster);
player.weapon = weapons.first();

lastUpdated = -1;
wave = 1;
extrawavetime = maxwavespace;
wavetime = waveSpacing();
Expand Down Expand Up @@ -232,7 +236,10 @@ public void setWaveData(int enemies, int wave, float wavetime){
public void runWave(){
Sounds.play("spawn");

world.pathfinder().updatePath();
if(lastUpdated < wave + 1){
world.pathfinder().updatePath();
lastUpdated = wave + 1;
}

for(EnemySpawn spawn : spawns){
for(int lane = 0; lane < spawnpoints.size; lane ++){
Expand Down Expand Up @@ -471,6 +478,15 @@ public void update(){

if(enemies <= 0){
wavetime -= delta();

if(Vars.debug && Inputs.keyDown(Keys.I)){
wavetime -= delta() * 10f;
}

if(lastUpdated < wave + 1 && wavetime < Vars.aheadPathfinding){ //start updatingbeforehand
world.pathfinder().updatePath();
lastUpdated = wave + 1;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/io/anuke/mindustry/core/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ void drawFloor(){

Graphics.end();

int crangex = Math.round(camera.viewportWidth * camera.zoom / (chunksize * tilesize));
int crangey = Math.round(camera.viewportHeight * camera.zoom / (chunksize * tilesize));
int crangex = (int)(camera.viewportWidth * camera.zoom / (chunksize * tilesize))+1;
int crangey = (int)(camera.viewportHeight * camera.zoom / (chunksize * tilesize))+1;

drawCache(0, crangex, crangey);

Expand Down
20 changes: 15 additions & 5 deletions core/src/io/anuke/mindustry/entities/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static io.anuke.mindustry.Vars.*;

import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;

Expand All @@ -26,7 +25,8 @@ public class Player extends DestructibleEntity{
public int rotation;

private Vector2 direction = new Vector2();
private float speed = 1f;
private float speed = 1.1f;
private float dashSpeed = 1.8f;

public Player(){
hitbox.setSize(5);
Expand Down Expand Up @@ -71,8 +71,13 @@ public void update(){

float speed = this.speed;

if(Vars.debug && Inputs.keyDown(Keys.SHIFT_LEFT))
speed *= 3f;
if(Inputs.keyDown("dash")){
speed = dashSpeed;

if(Vars.debug){
// speed *= 3f;
}
}

if(health < maxhealth && Timers.get(this, "regen", 50))
health ++;
Expand All @@ -88,13 +93,18 @@ public void update(){
if(Inputs.keyDown("right"))
vector.x += speed;

boolean shooting = Inputs.buttonDown(Buttons.LEFT) && recipe == null && !ui.hasMouse() && !Input.onConfigurable();
boolean shooting = !Inputs.keyDown("dash") && Inputs.buttonDown(Buttons.LEFT) && recipe == null && !ui.hasMouse() && !Input.onConfigurable();

if(shooting && Timers.get(this, "reload", weapon.reload)){
weapon.shoot(this);
Sounds.play(weapon.shootsound);
}

if(Inputs.keyDown("dash") && Timers.get(this, "dashfx", 3) && vector.len() > 0){
Angles.translation(direction.angle() + 180, 3f);
Effects.effect(Fx.dashsmoke, x + Angles.x(), y + Angles.y());
}

vector.limit(speed);

if(!Vars.noclip){
Expand Down
8 changes: 8 additions & 0 deletions core/src/io/anuke/mindustry/entities/effect/Fx.java
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ public class Fx{
Draw.reset();
}),

dashsmoke = new Effect(30, e -> {
Draw.color(Color.CORAL, Color.GRAY, e.ifract());
//Draw.alpha(e.fract());
float size = e.fract()*4f;
Draw.rect("circle", e.x, e.y, size, size);
Draw.reset();
}),

spawn = new Effect(23, e -> {
Draw.thickness(2f);
Draw.color(Color.DARK_GRAY, Color.SCARLET, e.ifract());
Expand Down
2 changes: 1 addition & 1 deletion core/src/io/anuke/mindustry/entities/enemies/Enemy.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public boolean collides(SolidEntity other){
public void onDeath(){
Effects.effect(Fx.explosion, this);
Effects.shake(3f, 4f, this);
Effects.sound("explosion", this);
Effects.sound("bang2", this);
remove();
dead = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void drawOver(){

void explode(){
Bullet b = new Bullet(BulletType.blast, this, x, y, 0).add();
b.damage = BulletType.blast.damage + (tier-1) * 40;
b.damage = BulletType.blast.damage + (tier-1) * 30;
damage(999);
}

Expand Down
8 changes: 8 additions & 0 deletions core/src/io/anuke/mindustry/resource/Weapon.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public void shoot(Player p){
},
railgun(40, BulletType.sniper, "Shoots one long-range bullet.", stack(Item.steel, 60), stack(Item.iron, 60)){

{
shootsound = "railgun";
}

@Override
public void shoot(Player p){
float ang = mouseAngle(p);
Expand All @@ -79,6 +83,10 @@ public void shoot(Player p){
},
mortar(100, BulletType.shell, "Shoots a slow, but damaging shell.", stack(Item.titanium, 40), stack(Item.steel, 60)){

{
shootsound = "bigshot";
}

@Override
public void shoot(Player p){
float ang = mouseAngle(p);
Expand Down
7 changes: 7 additions & 0 deletions core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ protected void shoot(Tile tile){

sniperturret = new Turret("sniperturret"){
{
shootsound = "railgun";
formalName = "railgun turret";
range = 120;
reload = 50f;
Expand All @@ -113,6 +114,7 @@ protected void shoot(Tile tile){

mortarturret = new Turret("mortarturret"){
{
shootsound = "bigshot";
rotatespeed = 0.1f;
formalName = "flak turret";
range = 120;
Expand All @@ -131,6 +133,7 @@ protected void shoot(Tile tile){

laserturret = new LaserTurret("laserturret"){
{
shootsound = "laser";
beamColor = Color.SKY;
formalName = "laser turret";
range = 60;
Expand All @@ -145,6 +148,7 @@ protected void shoot(Tile tile){

teslaturret = new PowerTurret("waveturret"){
{
shootsound = "tesla";
formalName = "tesla turret";
range = 70;
reload = 15f;
Expand All @@ -166,6 +170,7 @@ public void shoot(Tile tile){

plasmaturret = new Turret("plasmaturret"){
{
shootsound = "flame2";
inaccuracy = 7f;
formalName = "plasma turret";
range = 60f;
Expand All @@ -181,6 +186,7 @@ public void shoot(Tile tile){

chainturret = new Turret("chainturret"){
{
shootsound = "bigshot";
inaccuracy = 8f;
formalName = "chain turret";
range = 80f;
Expand Down Expand Up @@ -219,6 +225,7 @@ protected void shoot(Tile tile){

titanturret = new Turret("titancannon"){
{
shootsound = "blast";
formalName = "titan cannon";
range = 120f;
reload = 23f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public LaserTurret(String name) {
super(name);
shootsound = null;
layer2 = Layer.laser;
soundReload = 20;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class Turret extends Block{

protected final int timerTarget = timers++;
protected final int timerReload = timers++;
protected final int timerSound = timers++;

protected float range = 50f;
protected float reload = 10f;
Expand All @@ -48,6 +49,7 @@ public class Turret extends Block{
protected float shootCone = 5f;
protected Effect shootEffect = null;
protected float shootShake = 0f;
protected int soundReload = 0;

public Turret(String name) {
super(name);
Expand Down Expand Up @@ -161,7 +163,7 @@ public void update(Tile tile){

float reload = Vars.multiplier*this.reload;
if(Angles.angleDist(entity.rotation, targetRot) < shootCone && entity.timer.get(timerReload, reload)){
if(shootsound != null) Effects.sound(shootsound, entity);
if(shootsound != null && entity.timer.get(timerSound, soundReload)) Effects.sound(shootsound, entity);
shoot(tile);
consumeAmmo(tile);
entity.ammo --;
Expand Down
Loading

0 comments on commit 5ea8f0b

Please sign in to comment.