diff --git a/src/shootergame/entity/Entity.java b/src/shootergame/entity/Entity.java index 313e058..6b8ac7c 100644 --- a/src/shootergame/entity/Entity.java +++ b/src/shootergame/entity/Entity.java @@ -19,7 +19,7 @@ import shootergame.world.layer.Layer; public class Entity implements ITransparentObject { public Vec2d pos; - public double angle; + public double angle = 0; public boolean opaqueTile = true; public double hitbox = 1; public boolean isSolid = false; @@ -34,20 +34,15 @@ public class Entity implements ITransparentObject public int stepOnTileCooldown = 0; - public Entity(Vec2d pos, double angle) + public Entity(Vec2d pos) { // Add this entity to the list of entities Entities.entities.add(this); // Store the specified values - this.angle = angle; this.pos = pos; } - public Entity() { - this(new Vec2d(0, 0), 0); - } - public void tick(Chunk chunk, Layer layer) { speed = 1; angle = MathHelpers.mod(angle, 360); diff --git a/src/shootergame/entity/EntityBoss.java b/src/shootergame/entity/EntityBoss.java index ea40b74..261e337 100644 --- a/src/shootergame/entity/EntityBoss.java +++ b/src/shootergame/entity/EntityBoss.java @@ -31,7 +31,7 @@ public class EntityBoss extends EntityVertical implements IBossBar private OpenSimplexNoise noise_spawn; public EntityBoss(Vec2d pos) { - super(null, new Vec2d(4, 4)); + super(pos, TextureReference.EMPTY, new Vec2d(4, 4)); this.isSolid = true; this.goThroughSolid = false; @@ -54,12 +54,10 @@ public class EntityBoss extends EntityVertical implements IBossBar if(this.noise_spawn.eval(GameTimer.getTime() / 5000.0, 0) > 0.2) { if(spawn_frequency == 0) { - EntityZombie zombie = new EntityZombie(); int r = 2; - zombie.pos = this.pos.add(new Vec2d( + layer.spawnEntity(new EntityZombie(this.pos.add(new Vec2d( RandomHelpers.randrange(rand, -r, r), - RandomHelpers.randrange(rand, -r, r))); - layer.spawnEntity(zombie); + RandomHelpers.randrange(rand, -r, r))))); spawn_frequency = 50; } spawn_frequency -= 1; diff --git a/src/shootergame/entity/EntityBullet.java b/src/shootergame/entity/EntityBullet.java index 8db47f3..85bae85 100644 --- a/src/shootergame/entity/EntityBullet.java +++ b/src/shootergame/entity/EntityBullet.java @@ -25,10 +25,9 @@ public class EntityBullet extends EntityParticle private double height_angle = 0; public EntityBullet(Vec2d pos, Entity parent, double angle, double damage, int breakchance, int despawn_time) { - super(0.2, 0.4); + super(pos, 0.2, 0.4); // Store some specified values - this.pos = pos; this.angle = angle; this.parent = parent; this.damage = damage; diff --git a/src/shootergame/entity/EntityDummy.java b/src/shootergame/entity/EntityDummy.java index 2d81c18..00c6fb3 100644 --- a/src/shootergame/entity/EntityDummy.java +++ b/src/shootergame/entity/EntityDummy.java @@ -7,11 +7,10 @@ public class EntityDummy extends EntityVertical implements EntityAlive { public EntityDummy(Vec2d pos) { - super(Textures.ENTITY_DUMMY, new Vec2d(1, 1)); + super(pos, Textures.ENTITY_DUMMY, new Vec2d(1, 1)); this.hitbox = 0.5; this.isSolid = true; - this.pos = pos; } @Override diff --git a/src/shootergame/entity/EntityExplosion.java b/src/shootergame/entity/EntityExplosion.java index 77ef762..8e93344 100644 --- a/src/shootergame/entity/EntityExplosion.java +++ b/src/shootergame/entity/EntityExplosion.java @@ -19,9 +19,8 @@ public class EntityExplosion extends Entity private double damage; private int radius; - public EntityExplosion(Vec2d pos, int radius, double damage) - { - this.pos = pos; + public EntityExplosion(Vec2d pos, int radius, double damage) { + super(pos); this.damage = damage; this.radius = radius; } diff --git a/src/shootergame/entity/EntityGrapplingHook.java b/src/shootergame/entity/EntityGrapplingHook.java index f65da13..49ac46a 100644 --- a/src/shootergame/entity/EntityGrapplingHook.java +++ b/src/shootergame/entity/EntityGrapplingHook.java @@ -18,12 +18,11 @@ public class EntityGrapplingHook extends EntityVertical private Entity entity; public EntityGrapplingHook(Vec2d pos, int layerId, Entity entity) { - super(Textures.ENTITY_GRAPPLING_HOOK, new Vec2d(1, 16)); + super(pos, Textures.ENTITY_GRAPPLING_HOOK, new Vec2d(1, 16)); this.layerId = layerId; this.height = -16; this.entity = entity; - this.pos = pos; if(entity instanceof EntityPlayer) { EntityPlayer ep = (EntityPlayer)entity; diff --git a/src/shootergame/entity/EntityItem.java b/src/shootergame/entity/EntityItem.java index fa874c2..b74cc3e 100644 --- a/src/shootergame/entity/EntityItem.java +++ b/src/shootergame/entity/EntityItem.java @@ -17,10 +17,9 @@ public class EntityItem extends EntityVertical private int pickup_time = 100; public EntityItem(Vec2d pos, ItemStack stack) { - super(stack.item.texture, new Vec2d(0.5, 0.5)); + super(pos, stack.item.texture, new Vec2d(0.5, 0.5)); this.opaqueTile = true; - this.pos = pos; this.stack = stack; this.angle = RandomHelpers.randrange(rand, 360); height_speed = RandomHelpers.randrange(rand, 10000) / 200000.0; diff --git a/src/shootergame/entity/EntityParticle.java b/src/shootergame/entity/EntityParticle.java index c9e9be8..70a6681 100644 --- a/src/shootergame/entity/EntityParticle.java +++ b/src/shootergame/entity/EntityParticle.java @@ -12,8 +12,9 @@ public class EntityParticle extends Entity private double height; private double size; - public EntityParticle(double size, double height) - { + public EntityParticle(Vec2d pos, double size, double height) { + super(pos); + // Set some settings this.opaqueTile = false; this.height = height; diff --git a/src/shootergame/entity/EntityTnt.java b/src/shootergame/entity/EntityTnt.java index 66b95d8..253b6c2 100644 --- a/src/shootergame/entity/EntityTnt.java +++ b/src/shootergame/entity/EntityTnt.java @@ -19,11 +19,10 @@ public class EntityTnt extends EntityVertical private double explode_damage; public EntityTnt(Vec2d pos, double angle, int explode_radius, double explode_damage) { - super(Textures.ENTITY_TNT, new Vec2d(0.5, 0.5)); + super(pos, Textures.ENTITY_TNT, new Vec2d(0.5, 0.5)); Vec2d v = MathHelpers.moveTowards2(0.05, Math.toRadians(angle)); velocity = new Vec3d(v.x, v.y, 0.01); - this.pos = pos; this.explode_radius = explode_radius; this.crossUnWalkable = true; this.goThroughSolid = false; diff --git a/src/shootergame/entity/EntityVertical.java b/src/shootergame/entity/EntityVertical.java index 3636c2d..1087969 100644 --- a/src/shootergame/entity/EntityVertical.java +++ b/src/shootergame/entity/EntityVertical.java @@ -13,7 +13,8 @@ public class EntityVertical extends Entity private TextureReference tex; private Vec2d size; - public EntityVertical(TextureReference tex, Vec2d size) { + public EntityVertical(Vec2d pos, TextureReference tex, Vec2d size) { + super(pos); this.size = size; this.tex = tex; } diff --git a/src/shootergame/entity/EntityZombie.java b/src/shootergame/entity/EntityZombie.java index 87c850b..a703c2f 100644 --- a/src/shootergame/entity/EntityZombie.java +++ b/src/shootergame/entity/EntityZombie.java @@ -18,8 +18,8 @@ public class EntityZombie extends EntityVertical implements EntityAlive protected int gun_interval = 0; protected int gun_level = 0; - public EntityZombie() { - super(Textures.ENTITY_ZOMBIE, new Vec2d(1, 1)); + public EntityZombie(Vec2d pos) { + super(pos, Textures.ENTITY_ZOMBIE, new Vec2d(1, 1)); noise_movement = new OpenSimplexNoise(rand.nextLong()); noise_gun_fire = new OpenSimplexNoise(rand.nextLong()); noise_gun_angle = new OpenSimplexNoise(rand.nextLong()); diff --git a/src/shootergame/entity/EntityZombieArmored.java b/src/shootergame/entity/EntityZombieArmored.java index e6fdbb3..889b077 100644 --- a/src/shootergame/entity/EntityZombieArmored.java +++ b/src/shootergame/entity/EntityZombieArmored.java @@ -9,7 +9,8 @@ public class EntityZombieArmored extends EntityZombie { - public EntityZombieArmored() { + public EntityZombieArmored(Vec2d pos) { + super(pos); this.health_max *= 5; this.health = this.health_max; this.gun_level = 3; diff --git a/src/shootergame/entity/particle/ParticleBlood.java b/src/shootergame/entity/particle/ParticleBlood.java index c22f57a..b381f01 100644 --- a/src/shootergame/entity/particle/ParticleBlood.java +++ b/src/shootergame/entity/particle/ParticleBlood.java @@ -21,9 +21,8 @@ public class ParticleBlood extends EntityParticle private double height_velocity = 0; public ParticleBlood(Random rand, Vec2d pos, double angle) { - super(rand.nextDouble() / 5, 0); + super(pos, rand.nextDouble() / 5, 0); - this.pos = pos; this.angle = angle + RandomHelpers.randrange(rand, -100, 100); this.speed = rand.nextDouble() / 10; this.height = rand.nextDouble(); diff --git a/src/shootergame/entity/particle/ParticleBreak.java b/src/shootergame/entity/particle/ParticleBreak.java index 02a02db..99a49eb 100644 --- a/src/shootergame/entity/particle/ParticleBreak.java +++ b/src/shootergame/entity/particle/ParticleBreak.java @@ -36,9 +36,8 @@ public class ParticleBreak extends EntityVertical } public ParticleBreak(Vec2d pos, TileState ts) { - super(getTexture(ts), new Vec2d(1/4.0, 1/4.0)); + super(pos, getTexture(ts), new Vec2d(1/4.0, 1/4.0)); this.opaqueTile = ts.tile.opaqueTile; - this.pos = pos; this.angle = RandomHelpers.randrange(rand, 360); height_speed = RandomHelpers.randrange(rand, 10000) / 200000.0; } diff --git a/src/shootergame/entity/particle/ParticleLava.java b/src/shootergame/entity/particle/ParticleLava.java index 4ca2751..c62627b 100644 --- a/src/shootergame/entity/particle/ParticleLava.java +++ b/src/shootergame/entity/particle/ParticleLava.java @@ -19,13 +19,11 @@ public class ParticleLava extends EntityParticle private double height = 0; public ParticleLava(Vec2d pos) { - super(rand.nextDouble()/5, 0); + super(pos, rand.nextDouble()/5, 0); // Set the velocity velocity = MathHelpers.moveTowards3(0.05, new Vec2d(Math.toRadians( RandomHelpers.randrange(rand, 360)), Math.toRadians(RandomHelpers.randrange(rand, 0, 45)))); - - this.pos = pos; } @Override diff --git a/src/shootergame/entity/particle/ParticleSmoke.java b/src/shootergame/entity/particle/ParticleSmoke.java index cfbc42b..ab60ad8 100644 --- a/src/shootergame/entity/particle/ParticleSmoke.java +++ b/src/shootergame/entity/particle/ParticleSmoke.java @@ -20,7 +20,7 @@ public class ParticleSmoke extends EntityVertical double disappear_speed; public ParticleSmoke(Vec2d pos) { - super(Textures.PARTICLE_SMOKE_RANDOM.getTexture(), new Vec2d(1, 1)); + super(new Vec2d(0, 0), Textures.PARTICLE_SMOKE_RANDOM.getTexture(), new Vec2d(1, 1)); this.pos = new Vec2d( RandomHelpers.randrange(rand, 1000)/1000.0 - 0.5 + pos.x, diff --git a/src/shootergame/entity/particle/ParticleSpark.java b/src/shootergame/entity/particle/ParticleSpark.java index f4f55c6..e8c1991 100644 --- a/src/shootergame/entity/particle/ParticleSpark.java +++ b/src/shootergame/entity/particle/ParticleSpark.java @@ -12,8 +12,7 @@ public class ParticleSpark extends EntityParticle private double size = 0.1; public ParticleSpark(Vec2d pos, double height) { - super(1, height+0.4); - this.pos = pos; + super(pos, 1, height+0.4); this.opaqueTile = false; } diff --git a/src/shootergame/entity/particle/ParticleWater.java b/src/shootergame/entity/particle/ParticleWater.java index 8889b24..c29943a 100644 --- a/src/shootergame/entity/particle/ParticleWater.java +++ b/src/shootergame/entity/particle/ParticleWater.java @@ -17,13 +17,11 @@ public class ParticleWater extends EntityParticle private double height = 0; public ParticleWater(Vec2d pos) { - super(rand.nextDouble()/5, 0); + super(pos, rand.nextDouble()/5, 0); // Set the velocity velocity = MathHelpers.moveTowards3(0.1, new Vec2d(Math.toRadians( RandomHelpers.randrange(rand, 360)), Math.toRadians(RandomHelpers.randrange(rand, 0, 45)))); - - this.pos = pos; } @Override diff --git a/src/shootergame/entity/player/EntityPlayer.java b/src/shootergame/entity/player/EntityPlayer.java index 2c91afa..f78669e 100644 --- a/src/shootergame/entity/player/EntityPlayer.java +++ b/src/shootergame/entity/player/EntityPlayer.java @@ -49,7 +49,7 @@ public class EntityPlayer extends EntityVertical implements EntityAlive, EntityI private static final Vec2d size = new Vec2d(1, 1); public EntityPlayer() { - super(TextureReference.EMPTY, size); + super(new Vec2d(0, 0), TextureReference.EMPTY, size); this.angle = 45; diff --git a/src/shootergame/world/layer/layergen/LayerGenCaves.java b/src/shootergame/world/layer/layergen/LayerGenCaves.java index 3619f01..472b02a 100644 --- a/src/shootergame/world/layer/layergen/LayerGenCaves.java +++ b/src/shootergame/world/layer/layergen/LayerGenCaves.java @@ -84,20 +84,7 @@ public class LayerGenCaves extends LayerGen { if(rand.nextDouble() > 0.95) { - Entity zombie = new EntityZombie(); - zombie.pos = new Vec2d( - RandomHelpers.randrange(rand, (int)Main.player.pos.x - 128, (int)Main.player.pos.x + 128), - RandomHelpers.randrange(rand, (int)Main.player.pos.y - 128, (int)Main.player.pos.y + 128)); - - if(layer.getBackTile(new Vec2i((int)zombie.pos.x, - (int)zombie.pos.y)).tile == getTileDestroyed().tile && - zombie.pos.squareDistance(Main.player.pos) > 32) - layer.spawnEntity(zombie); - } - - /*if(rand.nextDouble() > 0.98) - { - Entity zombie = new EntityZombieBomber(new Vec2d( + Entity zombie = new EntityZombie(new Vec2d( RandomHelpers.randrange(rand, (int)Main.player.pos.x - 128, (int)Main.player.pos.x + 128), RandomHelpers.randrange(rand, (int)Main.player.pos.y - 128, (int)Main.player.pos.y + 128))); @@ -105,7 +92,7 @@ public class LayerGenCaves extends LayerGen (int)zombie.pos.y)).tile == getTileDestroyed().tile && zombie.pos.squareDistance(Main.player.pos) > 32) layer.spawnEntity(zombie); - }*/ + } } @Override diff --git a/src/shootergame/world/layer/layergen/LayerGenEarth.java b/src/shootergame/world/layer/layergen/LayerGenEarth.java index 2aa0cc1..d20e0e3 100644 --- a/src/shootergame/world/layer/layergen/LayerGenEarth.java +++ b/src/shootergame/world/layer/layergen/LayerGenEarth.java @@ -73,10 +73,9 @@ public class LayerGenEarth extends LayerGen { if(rand.nextDouble() > 0.98) { - Entity zombie = new EntityZombie(); - zombie.pos = new Vec2d( + Entity zombie = new EntityZombie(new Vec2d( RandomHelpers.randrange(rand, (int)Main.player.pos.x - 128, (int)Main.player.pos.x + 128), - RandomHelpers.randrange(rand, (int)Main.player.pos.y - 128, (int)Main.player.pos.y + 128)); + RandomHelpers.randrange(rand, (int)Main.player.pos.y - 128, (int)Main.player.pos.y + 128))); if(zombie.pos.squareDistance(Main.player.pos) > 64) layer.spawnEntity(zombie); diff --git a/src/shootergame/world/layer/layergen/LayerGenLavaCaves.java b/src/shootergame/world/layer/layergen/LayerGenLavaCaves.java index ee1bb4a..f201554 100644 --- a/src/shootergame/world/layer/layergen/LayerGenLavaCaves.java +++ b/src/shootergame/world/layer/layergen/LayerGenLavaCaves.java @@ -119,10 +119,9 @@ public class LayerGenLavaCaves extends LayerGen { if(rand.nextDouble() > 0.98) { - Entity zombie = new EntityZombieArmored(); - zombie.pos = new Vec2d( + Entity zombie = new EntityZombieArmored(new Vec2d( RandomHelpers.randrange(rand, (int)Main.player.pos.x - 128, (int)Main.player.pos.x + 128), - RandomHelpers.randrange(rand, (int)Main.player.pos.y - 128, (int)Main.player.pos.y + 128)); + RandomHelpers.randrange(rand, (int)Main.player.pos.y - 128, (int)Main.player.pos.y + 128))); TileState tsb = layer.getBackTile(new Vec2i((int)zombie.pos.x, (int)zombie.pos.y));