diff --git a/layer.bdf b/layer.bdf index ab26ebd..da678f0 100644 Binary files a/layer.bdf and b/layer.bdf differ diff --git a/settings.bdf b/settings.bdf new file mode 100644 index 0000000..f9fd6f0 Binary files /dev/null and b/settings.bdf differ diff --git a/src/projectzombie/display/DisplayWindow.java b/src/projectzombie/display/DisplayWindow.java index 6fecfd4..deae0e3 100755 --- a/src/projectzombie/display/DisplayWindow.java +++ b/src/projectzombie/display/DisplayWindow.java @@ -76,7 +76,7 @@ public class DisplayWindow implements IMainloopTask width = w.get()*4; height = h.get()*4; - //GLFW.glfwWindowHint(GLFW.GLFW_DOUBLEBUFFER, GLFW.GLFW_FALSE); + GLFW.glfwWindowHint(GLFW.GLFW_DOUBLEBUFFER, GLFW.GLFW_FALSE); // Create the window window = GraphicsHelpers.initWindow("Project Zombie", width, height, monitor); diff --git a/src/projectzombie/display/lighting/TileLighting.java b/src/projectzombie/display/lighting/TileLighting.java index 124b4ec..8c933c9 100755 --- a/src/projectzombie/display/lighting/TileLighting.java +++ b/src/projectzombie/display/lighting/TileLighting.java @@ -32,10 +32,10 @@ public class TileLighting implements IMainloopTask cx + MathHelpers.floor(player.pos.x / 16), cy + MathHelpers.floor(player.pos.y / 16)); Chunk chunk = layer.chunks.get(cpos); - /*if(chunk.light_dirty) { - chunk.light_dirty = false; + if(chunk.isLightDirty()) { + chunk.resetLightDirty(); dirty = true; - }*/ + } } } diff --git a/src/projectzombie/entity/Entity.java b/src/projectzombie/entity/Entity.java index 0b92d5b..d4ad407 100755 --- a/src/projectzombie/entity/Entity.java +++ b/src/projectzombie/entity/Entity.java @@ -34,9 +34,14 @@ public abstract class Entity implements IBdfClassManager protected static final Random rand = new Random(); public boolean emitsLight = false; public int stepOnTileCooldown = 0; + private boolean dead = false; public abstract Model getModel(); + public boolean isDead() { + return dead; + } + protected double getTilesLightDissipation() { if(chunk == null) return 0; TileState tsf = chunk.getFrontTile(pos.toInt()); @@ -219,6 +224,7 @@ public abstract class Entity implements IBdfClassManager public void kill() { chunk.killEntity(this); + dead = true; } public void activateTile() diff --git a/src/projectzombie/entity/EntityBullet.java b/src/projectzombie/entity/EntityBullet.java index 302f4f8..2710b05 100755 --- a/src/projectzombie/entity/EntityBullet.java +++ b/src/projectzombie/entity/EntityBullet.java @@ -155,9 +155,7 @@ public class EntityBullet extends EntityParticle // Spawn some blood particles if(!EntityParticle.DISABLED) { - for(int i=0;i entities.length) { + continue; + } + // Spawn some blood if entities were killed if(killed_entities) - l.spawnEntity(new ParticleBlood(rand, new Vec2d(px, py), py)); + entities[upto + 1] = new ParticleBlood(new Vec2d(px, py)); // Spawn some smoke - l.spawnEntity(new ParticleSmoke(new Vec2d(px, py))); + entities[upto] = new ParticleSmoke(new Vec2d(px, py)); + + upto += multiplier; } } } + layer.spawnEntity(new EntityContainer(pos, entities)); + // Play the explosion sound Sounds.EXPLOSION.play(new Vec3d(pos.x, pos.y, 0), 1); diff --git a/src/projectzombie/entity/EntityFlare.java b/src/projectzombie/entity/EntityFlare.java index 0eb6d57..3dd3249 100755 --- a/src/projectzombie/entity/EntityFlare.java +++ b/src/projectzombie/entity/EntityFlare.java @@ -2,6 +2,8 @@ package projectzombie.entity; import bdf.types.BdfObject; import gl_engine.vec.Vec2d; +import projectzombie.init.Models; +import projectzombie.model.Model; import projectzombie.world.layer.Layer; public class EntityFlare extends EntityTnt @@ -12,7 +14,6 @@ public class EntityFlare extends EntityTnt @Override protected void explode(Layer layer) { - kill(); } public EntityFlare(Vec2d pos, double angle) { @@ -25,5 +26,10 @@ public class EntityFlare extends EntityTnt public double getLightLevel() { return getLightWithHeight(1 - (this.pos.y * (1/12.0))) * ( rand.nextDouble() / 10.0 + 0.9 ); } + + @Override + public Model getModel() { + return active ? Models.ENTITY_FLARE : Models.EMPTY; + } } diff --git a/src/projectzombie/entity/EntityHoldsEntities.java b/src/projectzombie/entity/EntityHoldsEntities.java new file mode 100644 index 0000000..e9ab372 --- /dev/null +++ b/src/projectzombie/entity/EntityHoldsEntities.java @@ -0,0 +1,6 @@ +package projectzombie.entity; + +public interface EntityHoldsEntities +{ + public Entity[] getEntities(); +} diff --git a/src/projectzombie/entity/EntityTnt.java b/src/projectzombie/entity/EntityTnt.java index a7e9022..b0f7673 100755 --- a/src/projectzombie/entity/EntityTnt.java +++ b/src/projectzombie/entity/EntityTnt.java @@ -5,22 +5,42 @@ import bdf.types.BdfObject; import gl_engine.MathHelpers; import gl_engine.vec.Vec2d; import gl_engine.vec.Vec3d; +import projectzombie.entity.particle.ParticleSmoke; import projectzombie.entity.particle.ParticleSpark; import projectzombie.init.Models; import projectzombie.model.Model; import projectzombie.world.chunk.Chunk; import projectzombie.world.layer.Layer; -public class EntityTnt extends Entity +public class EntityTnt extends Entity implements EntityHeight, EntityHoldsEntities { + protected boolean active = true; protected double height = 0.4; protected Vec3d velocity; protected int explode_time; private int explode_radius; private double explode_damage; + private ParticleSpark[] smoke_particles; + + @Override + public Entity[] getEntities() { + return smoke_particles; + } + + @Override + public double getHeight() { + return height; + } + + @Override + public void setHeight(double height) { + this.height = height; + } public EntityTnt(BdfObject bdf) { super(bdf); + + this.smoke_particles = new ParticleSpark[50]; } @Override @@ -60,6 +80,7 @@ public class EntityTnt extends Entity this.crossUnWalkable = true; this.goThroughSolid = false; this.explode_damage = explode_damage; + this.smoke_particles = new ParticleSpark[100]; this.emitsLight = true; // Set to 2.5 seconds @@ -68,18 +89,38 @@ public class EntityTnt extends Entity protected void explode(Layer layer) { - // Create an explosion layer.spawnEntity(new EntityExplosion(pos, explode_radius, explode_damage)); - - // Delete the entity - kill(); - return; } @Override public void tick(Chunk chunk, Layer layer) { super.tick(chunk, layer); + int dead_particle = 0; + int dead_particle_count = 0; + + for(int i=0;i