Fixed ridiculous screenshake, preparing for entity serialization
This commit is contained in:
@@ -294,6 +294,10 @@ public class Control extends RendererModule{
|
||||
log("Load time taken: " + Timers.elapsed());
|
||||
Renderer.clearTiles();
|
||||
}
|
||||
|
||||
if(Inputs.keyDown(Keys.SPACE)){
|
||||
Effects.shake(6, 4);
|
||||
}
|
||||
}
|
||||
|
||||
if(GameState.is(State.menu)){
|
||||
@@ -347,10 +351,14 @@ public class Control extends RendererModule{
|
||||
smoothCamera(World.core.worldx(), World.core.worldy(), 0.4f);
|
||||
}
|
||||
|
||||
updateShake(0.5f);
|
||||
float prex = camera.position.x, prey = camera.position.y;
|
||||
|
||||
updateShake(1f);
|
||||
float prevx = camera.position.x, prevy = camera.position.y;
|
||||
clampCamera(-tilesize / 2f, -tilesize / 2f, World.pixsize - tilesize / 2f, World.pixsize - tilesize / 2f);
|
||||
|
||||
float deltax = camera.position.x - prex, deltay = camera.position.y - prey;
|
||||
|
||||
if(android){
|
||||
player.x += camera.position.x-prevx;
|
||||
player.y += camera.position.y-prevy;
|
||||
@@ -373,7 +381,7 @@ public class Control extends RendererModule{
|
||||
Renderer.renderOverlay();
|
||||
batch.end();
|
||||
|
||||
camera.position.set(lastx, lasty, 0);
|
||||
camera.position.set(lastx - deltax, lasty - deltay, 0);
|
||||
|
||||
//recorder.update();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Vars{
|
||||
//how much the zoom changes every zoom button press
|
||||
public static final int zoomScale = Math.round(Unit.dp.inPixels(1));
|
||||
//if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available
|
||||
public static boolean debug = false;
|
||||
public static boolean debug = true;
|
||||
//number of save slots-- increasing may lead to layout issues
|
||||
public static final int saveSlots = 4;
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
@@ -29,6 +32,14 @@ public class TileEntity extends Entity{
|
||||
return this;
|
||||
}
|
||||
|
||||
public void write(DataOutputStream stream){
|
||||
|
||||
}
|
||||
|
||||
public void read(TileEntity entity, DataInputStream stream){
|
||||
|
||||
}
|
||||
|
||||
public void onDeath(){
|
||||
dead = true;
|
||||
|
||||
@@ -51,7 +62,6 @@ public class TileEntity extends Entity{
|
||||
public boolean collide(Bullet other){
|
||||
return other.owner instanceof Enemy;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
|
||||
@@ -14,12 +14,15 @@ import com.badlogic.gdx.utils.TimeUtils;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Weapon;
|
||||
import io.anuke.mindustry.entities.enemies.*;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.mindustry.world.blocks.Conveyor.ConveyorEntity;
|
||||
import io.anuke.mindustry.world.blocks.Turret.TurretEntity;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
|
||||
@@ -77,7 +80,7 @@ import io.anuke.ucore.entities.Entity;
|
||||
*/
|
||||
public class SaveIO{
|
||||
/**Save file version ID. Should be incremented every breaking release.*/
|
||||
private static final int fileVersionID = 2;
|
||||
private static final int fileVersionID = 3;
|
||||
|
||||
private static FormatProvider provider = null;
|
||||
|
||||
@@ -94,6 +97,17 @@ public class SaveIO{
|
||||
put(enemyIDs.get(value), value);
|
||||
}};
|
||||
|
||||
private static final ObjectMap<Class<? extends TileEntity>, Byte> tileIDs = new ObjectMap<Class<? extends TileEntity>, Byte>(){{
|
||||
put(TileEntity.class, (byte)0);
|
||||
put(TurretEntity.class, (byte)1);
|
||||
put(ConveyorEntity.class, (byte)2);
|
||||
}};
|
||||
|
||||
private static final ObjectMap<Byte, Class<? extends TileEntity>> idTiles = new ObjectMap<Byte, Class<? extends TileEntity>>(){{
|
||||
for(Class<? extends TileEntity> value : tileIDs.keys())
|
||||
put(tileIDs.get(value), value);
|
||||
}};
|
||||
|
||||
public static void saveToSlot(int slot){
|
||||
write(fileFor(slot));
|
||||
}
|
||||
@@ -222,6 +236,10 @@ public class SaveIO{
|
||||
stream.writeInt(tile.entity.health); //health
|
||||
stream.writeByte(tile.entity.items.size); //amount of items
|
||||
|
||||
//if(strea){
|
||||
// stream.writeInt(tile.entity.);
|
||||
//}
|
||||
|
||||
for(Item item : tile.entity.items.keys()){
|
||||
stream.writeByte(item.ordinal()); //item ID
|
||||
stream.writeInt(tile.entity.items.get(item)); //item amount
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Conveyor extends Block{
|
||||
entity.convey.add(new ItemPos(item, pos, y*0.9f));
|
||||
}
|
||||
|
||||
static class ConveyorEntity extends TileEntity{
|
||||
public static class ConveyorEntity extends TileEntity{
|
||||
DelayedRemovalArray<ItemPos> convey = new DelayedRemovalArray<>();
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class Turret extends Block{
|
||||
out.damage = bullet.damage*Vars.multiplier;
|
||||
}
|
||||
|
||||
static class TurretEntity extends TileEntity{
|
||||
public static class TurretEntity extends TileEntity{
|
||||
public TileEntity target;
|
||||
public int ammo;
|
||||
public float rotation;
|
||||
|
||||
Reference in New Issue
Block a user