diff --git a/resources/texmap.png b/resources/texmap.png index de1bf19..b727656 100644 Binary files a/resources/texmap.png and b/resources/texmap.png differ diff --git a/resources/texmap.xcf b/resources/texmap.xcf index d090507..d5e6740 100644 Binary files a/resources/texmap.xcf and b/resources/texmap.xcf differ diff --git a/src/shootergame/Main.java b/src/shootergame/Main.java index 475fbce..817c54f 100644 --- a/src/shootergame/Main.java +++ b/src/shootergame/Main.java @@ -10,6 +10,7 @@ import shootergame.display.DisplayStatsEventHandler; import shootergame.display.DisplayWindow; import shootergame.entity.EntityEventHandler; import shootergame.entity.player.EntityPlayer; +import shootergame.init.Layers; import shootergame.init.Resources; import shootergame.init.Sounds; import shootergame.init.Textures; @@ -17,6 +18,7 @@ import shootergame.input.JoystickCallback; import shootergame.mainloop.MainloopEventHandler; import shootergame.menu.Menu; import shootergame.menu.MenuNone; +import shootergame.tiles.LightLevelNoise; import shootergame.time.GameTimer; import shootergame.world.World; import shootergame.world.chunk.ChunkEventHandler; @@ -57,6 +59,7 @@ public class Main mainloop.register(ChunkEventHandler.CHUNK_EVENT_HANDLER); mainloop.register(DisplayStatsEventHandler.DISPLAY_STATS_EVENT_HANDLER); mainloop.register(JoystickCallback.JOYSTICK_CALLBACK); + mainloop.register(new LightLevelNoise()); mainloop.register(new GameTimer()); // Create the display @@ -70,7 +73,7 @@ public class Main JoystickCallback.JOYSTICK_CALLBACK.init(); // Create the world - world = new World(new Random(), new LayerGenEarth(), new LayerGenCaves(), new LayerGenLavaCaves()); + Layers.init(rand.nextLong()); // Initialise the entities mainloop.register(EntityEventHandler.ENTITY_EVENT_HANDLER); diff --git a/src/shootergame/display/lighting/LightingManager.java b/src/shootergame/display/lighting/LightingManager.java index 514edd5..d9e51f1 100644 --- a/src/shootergame/display/lighting/LightingManager.java +++ b/src/shootergame/display/lighting/LightingManager.java @@ -83,8 +83,8 @@ public class LightingManager // Calculate the light given off by the tile double light_tile = chunk.getLightLevel(tid); double light_tile_old = light_tile; - light_tile = MathHelpers.biggest(light_tile, fts.tile.getLightLevel(fts)); - light_tile = MathHelpers.biggest(light_tile, fts.tile.getLightLevel(bts)); + light_tile = MathHelpers.biggest(light_tile, fts.tile.getLightLevel(fts, tpos)); + light_tile = MathHelpers.biggest(light_tile, fts.tile.getLightLevel(bts, tpos)); // Has the light level changed; add light to this tile if(light_tile != light_tile_old) { diff --git a/src/shootergame/entity/Entity.java b/src/shootergame/entity/Entity.java index 23f6c62..8bdcd76 100644 --- a/src/shootergame/entity/Entity.java +++ b/src/shootergame/entity/Entity.java @@ -2,6 +2,7 @@ package shootergame.entity; import java.util.Random; +import mainloop.task.IMainloopTask; import shootergame.Main; import shootergame.display.Camera; import shootergame.display.transparent.ITransparentObject; @@ -31,6 +32,8 @@ public class Entity implements ITransparentObject protected static final Random rand = new Random(); public boolean emitsLight = false; + public int stepOnTileCooldown = 0; + public Entity(Vec2d pos, double angle) { // Add this entity to the list of entities @@ -47,13 +50,17 @@ public class Entity implements ITransparentObject public void tick(Chunk chunk, Layer layer) { speed = 1; - angle = MathHelpers.floor(angle); + angle = MathHelpers.mod(angle, 360); Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0); if(chunk == null) chunk = layer.getChunk(pos); this.chunk = chunk; tile_back = chunk.getBackTile(tpos); tile_front = chunk.getFrontTile(tpos); + if(stepOnTileCooldown > 0) { + stepOnTileCooldown -= 1; + } + if(this.isSolid) { this.addSlowness(tile_back.tile.slowness); @@ -140,14 +147,20 @@ public class Entity implements ITransparentObject public void activateSteppedOnTile() { - // Get the tile position and the layer - Layer layer = Main.world.getLayer(); - Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0); - - // Activate both tiles - tile_front.tile.onWalkedOn(chunk, layer, tpos, this, tile_front); - tile_back.tile.onWalkedOn(chunk, layer, tpos, this, tile_back); + // Has the cooldown expired + if(stepOnTileCooldown == 0) + { + // Get the tile position and the layer + Layer layer = Main.world.getLayer(); + Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0); + + // Activate both tiles + tile_front.tile.onWalkedOn(chunk, layer, tpos, this, tile_front); + tile_back.tile.onWalkedOn(chunk, layer, tpos, this, tile_back); + // Reset the cooldown + stepOnTileCooldown = 1; + } } public boolean moveIsLegal(Vec2d pos) @@ -219,4 +232,30 @@ public class Entity implements ITransparentObject public double getLightLevel() { return 0; } + + public void push(double amount, double angle) + { + double[] a = {amount}; + + Main.mainloop.register(new IMainloopTask() { + + @Override + public void MainLoopUpdate() { + if(!Main.game_paused) { + moveTowards(angle, a[0]/100.0); + a[0] -= a[0] / 100.0; + } + } + + @Override + public boolean MainLoopRepeat() { + return a[0] > 0.2; + } + + @Override + public boolean MainLoopDelay(long millis) { + return millis > 10; + } + }); + } } diff --git a/src/shootergame/entity/EntityAlive.java b/src/shootergame/entity/EntityAlive.java index e05fea3..f786445 100644 --- a/src/shootergame/entity/EntityAlive.java +++ b/src/shootergame/entity/EntityAlive.java @@ -9,4 +9,5 @@ public interface EntityAlive public void clearHealth(); public double maxHealth(); public void setHealth(double health); + public int bloodParticles(); } diff --git a/src/shootergame/entity/EntityBullet.java b/src/shootergame/entity/EntityBullet.java index 071a0e3..3779b10 100644 --- a/src/shootergame/entity/EntityBullet.java +++ b/src/shootergame/entity/EntityBullet.java @@ -87,8 +87,11 @@ public class EntityBullet extends EntityParticle // Get the alive entity EntityAlive ea = (EntityAlive)e; + // Knock the entity back abit + e.push(1, angle); + // Spawn some blood particles - for(int i=0;i<10;i++) { + for(int i=0;i 0) @@ -184,7 +183,10 @@ public class EntityPlayer extends EntityVertical implements EntityAlive, EntityI ammo -= 1; // Summon bullets at this angle relative to the player - Main.world.getLayer().spawnEntity(new EntityBullet(pos.copy(), this, angle + this.angle, 20, 5)); + int d = (int)(1 + gun_level / 4.0); + int b = (int)(1 + gun_level / 4.0); + Main.world.getLayer().spawnEntity(new EntityBullet(pos.copy(), this, angle + this.angle, + 20*d*d, 5/b)); } } @@ -206,7 +208,7 @@ public class EntityPlayer extends EntityVertical implements EntityAlive, EntityI @Override public void removeHealth(double amount) { - amount = amount * amount / (amount + defence_level*2); + amount = amount / (defence_level / 2.5 + 1); health -= amount; } @@ -252,4 +254,13 @@ public class EntityPlayer extends EntityVertical implements EntityAlive, EntityI i.count -= 1; } } + + @Override + public void push(double amount, double angle) { + } + + @Override + public int bloodParticles() { + return 5; + } } diff --git a/src/shootergame/init/Items.java b/src/shootergame/init/Items.java index 265c388..dd187fa 100644 --- a/src/shootergame/init/Items.java +++ b/src/shootergame/init/Items.java @@ -4,8 +4,10 @@ import shootergame.items.Item; import shootergame.items.ItemAmmo; import shootergame.items.ItemDefenceUpgrade; import shootergame.items.ItemEmpty; +import shootergame.items.ItemFlare; import shootergame.items.ItemGunUpgrade; import shootergame.items.ItemHealthPotion; +import shootergame.items.ItemLantern; import shootergame.items.ItemTnt; public class Items @@ -16,4 +18,6 @@ public class Items public static final Item HEALTH_POTION = new ItemHealthPotion("health_potion"); public static final Item EMPTY = new ItemEmpty("empty"); public static final Item TNT = new ItemTnt("tnt"); + public static final Item LANTERN = new ItemLantern("lantern"); + public static final Item FLARE = new ItemFlare("flare"); } diff --git a/src/shootergame/init/Layers.java b/src/shootergame/init/Layers.java new file mode 100644 index 0000000..ffedf92 --- /dev/null +++ b/src/shootergame/init/Layers.java @@ -0,0 +1,40 @@ +package shootergame.init; + +import java.util.ArrayList; +import java.util.Random; + +import shootergame.Main; +import shootergame.world.World; +import shootergame.world.layer.Layer; + +import shootergame.world.layer.layergen.*; + +public class Layers +{ + private static final ArrayList id_layers = new ArrayList(); + + public static void init(long seed) + { + // Create all the layers + EARTH = new Layer(new Random(seed), new LayerGenEarth(), 0); + CAVES = new Layer(new Random(seed), new LayerGenCaves(), 1); + LAVA_CAVES = new Layer(new Random(seed), new LayerGenLavaCaves(), 2); + + // Setup all the id-able layers + id_layers.add(EARTH); + id_layers.add(CAVES); + id_layers.add(LAVA_CAVES); + + // Create the world and set the earth as the default layer + Main.world = new World(); + Main.world.setLayer(EARTH); + } + + public static Layer getLayer(int id) { + return id_layers.get(id); + } + + public static Layer EARTH; + public static Layer CAVES; + public static Layer LAVA_CAVES; +} diff --git a/src/shootergame/init/Textures.java b/src/shootergame/init/Textures.java index 29bc092..6d2cdad 100644 --- a/src/shootergame/init/Textures.java +++ b/src/shootergame/init/Textures.java @@ -38,6 +38,16 @@ public class Textures public static final TextureReference TILE_WALL = texmap.getTextureReference(2, 3, 5, 6); public static final TextureReference TILE_LADDER_UP = texmap.getTextureReference(16, 17, 0, 16); public static final TextureReference TILE_CHEST = texmap.getTextureReference(2, 3, 4, 5); + public static final TextureReference ENTITY_FLARE = texmap.getTextureReference(6, 7, 15, 16); + public static final TextureReference ENTITY_DUMMY = texmap.getTextureReference(7, 8, 15, 16); + + public static final AnimationReference TILE_LANTERN = new AnimationReference(10, + texmap.getTextureReference(8, 9, 15, 16), + texmap.getTextureReference(9, 10, 15, 16), + texmap.getTextureReference(10, 11, 15, 16), + texmap.getTextureReference(11, 12, 15, 16), + texmap.getTextureReference(12, 13, 15, 16), + texmap.getTextureReference(13, 14, 15, 16)); public static final TextureReferenceRandom PARTICLE_SMOKE_RANDOM = new TextureReferenceRandom( texmap.getTextureReference(14, 15, 13, 14), texmap.getTextureReference(15, 16, 13, 14), diff --git a/src/shootergame/init/Tiles.java b/src/shootergame/init/Tiles.java index b142100..3d2e0d0 100644 --- a/src/shootergame/init/Tiles.java +++ b/src/shootergame/init/Tiles.java @@ -7,6 +7,7 @@ import shootergame.tiles.TileFire; import shootergame.tiles.TileGrass; import shootergame.tiles.TileLadder; import shootergame.tiles.TileLadderUp; +import shootergame.tiles.TileLantern; import shootergame.tiles.TileLava; import shootergame.tiles.TileLavaFlow; import shootergame.tiles.TilePortalDown; @@ -37,5 +38,6 @@ public class Tiles public static final Tile PORTAL_DOWN = new TilePortalDown("portal_down"); public static final Tile WALL = new TileWall("wall"); public static final Tile LADDER_UP = new TileLadderUp("ladder_up"); - public static final Tile TILE_CHEST = new TileChest("chest"); + public static final Tile CHEST = new TileChest("chest"); + public static final Tile LANTERN = new TileLantern("lantern"); } diff --git a/src/shootergame/items/Item.java b/src/shootergame/items/Item.java index 6fe24ed..5981e3e 100644 --- a/src/shootergame/items/Item.java +++ b/src/shootergame/items/Item.java @@ -62,8 +62,13 @@ public class Item stack.count = 0; return; } - + } + + // Loop over the inventory + for(int i=0;i