Merge branch 'save' of jsrobson10/ShooterGame into master
This commit is contained in:
commit
d88b433b11
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
Binary file not shown.
|
|
@ -19,7 +19,7 @@ import shootergame.world.layer.Layer;
|
||||||
public class Entity implements ITransparentObject
|
public class Entity implements ITransparentObject
|
||||||
{
|
{
|
||||||
public Vec2d pos;
|
public Vec2d pos;
|
||||||
public double angle;
|
public double angle = 0;
|
||||||
public boolean opaqueTile = true;
|
public boolean opaqueTile = true;
|
||||||
public double hitbox = 1;
|
public double hitbox = 1;
|
||||||
public boolean isSolid = false;
|
public boolean isSolid = false;
|
||||||
|
|
@ -34,20 +34,15 @@ public class Entity implements ITransparentObject
|
||||||
|
|
||||||
public int stepOnTileCooldown = 0;
|
public int stepOnTileCooldown = 0;
|
||||||
|
|
||||||
public Entity(Vec2d pos, double angle)
|
public Entity(Vec2d pos)
|
||||||
{
|
{
|
||||||
// Add this entity to the list of entities
|
// Add this entity to the list of entities
|
||||||
Entities.entities.add(this);
|
Entities.entities.add(this);
|
||||||
|
|
||||||
// Store the specified values
|
// Store the specified values
|
||||||
this.angle = angle;
|
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity() {
|
|
||||||
this(new Vec2d(0, 0), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
public void tick(Chunk chunk, Layer layer) {
|
||||||
speed = 1;
|
speed = 1;
|
||||||
angle = MathHelpers.mod(angle, 360);
|
angle = MathHelpers.mod(angle, 360);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public class EntityBoss extends EntityVertical implements IBossBar
|
||||||
private OpenSimplexNoise noise_spawn;
|
private OpenSimplexNoise noise_spawn;
|
||||||
|
|
||||||
public EntityBoss(Vec2d pos) {
|
public EntityBoss(Vec2d pos) {
|
||||||
super(null, new Vec2d(4, 4));
|
super(pos, TextureReference.EMPTY, new Vec2d(4, 4));
|
||||||
|
|
||||||
this.isSolid = true;
|
this.isSolid = true;
|
||||||
this.goThroughSolid = false;
|
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(this.noise_spawn.eval(GameTimer.getTime() / 5000.0, 0) > 0.2) {
|
||||||
if(spawn_frequency == 0) {
|
if(spawn_frequency == 0) {
|
||||||
EntityZombie zombie = new EntityZombie();
|
|
||||||
int r = 2;
|
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),
|
||||||
RandomHelpers.randrange(rand, -r, r)));
|
RandomHelpers.randrange(rand, -r, r)))));
|
||||||
layer.spawnEntity(zombie);
|
|
||||||
spawn_frequency = 50;
|
spawn_frequency = 50;
|
||||||
}
|
}
|
||||||
spawn_frequency -= 1;
|
spawn_frequency -= 1;
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,9 @@ public class EntityBullet extends EntityParticle
|
||||||
private double height_angle = 0;
|
private double height_angle = 0;
|
||||||
|
|
||||||
public EntityBullet(Vec2d pos, Entity parent, double angle, double damage, int breakchance, int despawn_time) {
|
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
|
// Store some specified values
|
||||||
this.pos = pos;
|
|
||||||
this.angle = angle;
|
this.angle = angle;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,10 @@ public class EntityDummy extends EntityVertical implements EntityAlive
|
||||||
{
|
{
|
||||||
|
|
||||||
public EntityDummy(Vec2d pos) {
|
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.hitbox = 0.5;
|
||||||
this.isSolid = true;
|
this.isSolid = true;
|
||||||
this.pos = pos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,8 @@ public class EntityExplosion extends Entity
|
||||||
private double damage;
|
private double damage;
|
||||||
private int radius;
|
private int radius;
|
||||||
|
|
||||||
public EntityExplosion(Vec2d pos, int radius, double damage)
|
public EntityExplosion(Vec2d pos, int radius, double damage) {
|
||||||
{
|
super(pos);
|
||||||
this.pos = pos;
|
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,11 @@ public class EntityGrapplingHook extends EntityVertical
|
||||||
private Entity entity;
|
private Entity entity;
|
||||||
|
|
||||||
public EntityGrapplingHook(Vec2d pos, int layerId, 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.layerId = layerId;
|
||||||
this.height = -16;
|
this.height = -16;
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.pos = pos;
|
|
||||||
|
|
||||||
if(entity instanceof EntityPlayer) {
|
if(entity instanceof EntityPlayer) {
|
||||||
EntityPlayer ep = (EntityPlayer)entity;
|
EntityPlayer ep = (EntityPlayer)entity;
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,9 @@ public class EntityItem extends EntityVertical
|
||||||
private int pickup_time = 100;
|
private int pickup_time = 100;
|
||||||
|
|
||||||
public EntityItem(Vec2d pos, ItemStack stack) {
|
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.opaqueTile = true;
|
||||||
this.pos = pos;
|
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.angle = RandomHelpers.randrange(rand, 360);
|
this.angle = RandomHelpers.randrange(rand, 360);
|
||||||
height_speed = RandomHelpers.randrange(rand, 10000) / 200000.0;
|
height_speed = RandomHelpers.randrange(rand, 10000) / 200000.0;
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,9 @@ public class EntityParticle extends Entity
|
||||||
private double height;
|
private double height;
|
||||||
private double size;
|
private double size;
|
||||||
|
|
||||||
public EntityParticle(double size, double height)
|
public EntityParticle(Vec2d pos, double size, double height) {
|
||||||
{
|
super(pos);
|
||||||
|
|
||||||
// Set some settings
|
// Set some settings
|
||||||
this.opaqueTile = false;
|
this.opaqueTile = false;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,10 @@ public class EntityTnt extends EntityVertical
|
||||||
private double explode_damage;
|
private double explode_damage;
|
||||||
|
|
||||||
public EntityTnt(Vec2d pos, double angle, int explode_radius, 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));
|
Vec2d v = MathHelpers.moveTowards2(0.05, Math.toRadians(angle));
|
||||||
velocity = new Vec3d(v.x, v.y, 0.01);
|
velocity = new Vec3d(v.x, v.y, 0.01);
|
||||||
this.pos = pos;
|
|
||||||
this.explode_radius = explode_radius;
|
this.explode_radius = explode_radius;
|
||||||
this.crossUnWalkable = true;
|
this.crossUnWalkable = true;
|
||||||
this.goThroughSolid = false;
|
this.goThroughSolid = false;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,8 @@ public class EntityVertical extends Entity
|
||||||
private TextureReference tex;
|
private TextureReference tex;
|
||||||
private Vec2d size;
|
private Vec2d size;
|
||||||
|
|
||||||
public EntityVertical(TextureReference tex, Vec2d size) {
|
public EntityVertical(Vec2d pos, TextureReference tex, Vec2d size) {
|
||||||
|
super(pos);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.tex = tex;
|
this.tex = tex;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ public class EntityZombie extends EntityVertical implements EntityAlive
|
||||||
protected int gun_interval = 0;
|
protected int gun_interval = 0;
|
||||||
protected int gun_level = 0;
|
protected int gun_level = 0;
|
||||||
|
|
||||||
public EntityZombie() {
|
public EntityZombie(Vec2d pos) {
|
||||||
super(Textures.ENTITY_ZOMBIE, new Vec2d(1, 1));
|
super(pos, Textures.ENTITY_ZOMBIE, new Vec2d(1, 1));
|
||||||
noise_movement = new OpenSimplexNoise(rand.nextLong());
|
noise_movement = new OpenSimplexNoise(rand.nextLong());
|
||||||
noise_gun_fire = new OpenSimplexNoise(rand.nextLong());
|
noise_gun_fire = new OpenSimplexNoise(rand.nextLong());
|
||||||
noise_gun_angle = new OpenSimplexNoise(rand.nextLong());
|
noise_gun_angle = new OpenSimplexNoise(rand.nextLong());
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ public class EntityZombieArmored extends EntityZombie
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public EntityZombieArmored() {
|
public EntityZombieArmored(Vec2d pos) {
|
||||||
|
super(pos);
|
||||||
this.health_max *= 5;
|
this.health_max *= 5;
|
||||||
this.health = this.health_max;
|
this.health = this.health_max;
|
||||||
this.gun_level = 3;
|
this.gun_level = 3;
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,8 @@ public class ParticleBlood extends EntityParticle
|
||||||
private double height_velocity = 0;
|
private double height_velocity = 0;
|
||||||
|
|
||||||
public ParticleBlood(Random rand, Vec2d pos, double angle) {
|
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.angle = angle + RandomHelpers.randrange(rand, -100, 100);
|
||||||
this.speed = rand.nextDouble() / 10;
|
this.speed = rand.nextDouble() / 10;
|
||||||
this.height = rand.nextDouble();
|
this.height = rand.nextDouble();
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,8 @@ public class ParticleBreak extends EntityVertical
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleBreak(Vec2d pos, TileState ts) {
|
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.opaqueTile = ts.tile.opaqueTile;
|
||||||
this.pos = pos;
|
|
||||||
this.angle = RandomHelpers.randrange(rand, 360);
|
this.angle = RandomHelpers.randrange(rand, 360);
|
||||||
height_speed = RandomHelpers.randrange(rand, 10000) / 200000.0;
|
height_speed = RandomHelpers.randrange(rand, 10000) / 200000.0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,11 @@ public class ParticleLava extends EntityParticle
|
||||||
private double height = 0;
|
private double height = 0;
|
||||||
|
|
||||||
public ParticleLava(Vec2d pos) {
|
public ParticleLava(Vec2d pos) {
|
||||||
super(rand.nextDouble()/5, 0);
|
super(pos, rand.nextDouble()/5, 0);
|
||||||
|
|
||||||
// Set the velocity
|
// Set the velocity
|
||||||
velocity = MathHelpers.moveTowards3(0.05, new Vec2d(Math.toRadians(
|
velocity = MathHelpers.moveTowards3(0.05, new Vec2d(Math.toRadians(
|
||||||
RandomHelpers.randrange(rand, 360)), Math.toRadians(RandomHelpers.randrange(rand, 0, 45))));
|
RandomHelpers.randrange(rand, 360)), Math.toRadians(RandomHelpers.randrange(rand, 0, 45))));
|
||||||
|
|
||||||
this.pos = pos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public class ParticleSmoke extends EntityVertical
|
||||||
double disappear_speed;
|
double disappear_speed;
|
||||||
|
|
||||||
public ParticleSmoke(Vec2d pos) {
|
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(
|
this.pos = new Vec2d(
|
||||||
RandomHelpers.randrange(rand, 1000)/1000.0 - 0.5 + pos.x,
|
RandomHelpers.randrange(rand, 1000)/1000.0 - 0.5 + pos.x,
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@ public class ParticleSpark extends EntityParticle
|
||||||
private double size = 0.1;
|
private double size = 0.1;
|
||||||
|
|
||||||
public ParticleSpark(Vec2d pos, double height) {
|
public ParticleSpark(Vec2d pos, double height) {
|
||||||
super(1, height+0.4);
|
super(pos, 1, height+0.4);
|
||||||
this.pos = pos;
|
|
||||||
this.opaqueTile = false;
|
this.opaqueTile = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,11 @@ public class ParticleWater extends EntityParticle
|
||||||
private double height = 0;
|
private double height = 0;
|
||||||
|
|
||||||
public ParticleWater(Vec2d pos) {
|
public ParticleWater(Vec2d pos) {
|
||||||
super(rand.nextDouble()/5, 0);
|
super(pos, rand.nextDouble()/5, 0);
|
||||||
|
|
||||||
// Set the velocity
|
// Set the velocity
|
||||||
velocity = MathHelpers.moveTowards3(0.1, new Vec2d(Math.toRadians(
|
velocity = MathHelpers.moveTowards3(0.1, new Vec2d(Math.toRadians(
|
||||||
RandomHelpers.randrange(rand, 360)), Math.toRadians(RandomHelpers.randrange(rand, 0, 45))));
|
RandomHelpers.randrange(rand, 360)), Math.toRadians(RandomHelpers.randrange(rand, 0, 45))));
|
||||||
|
|
||||||
this.pos = pos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public class EntityPlayer extends EntityVertical implements EntityAlive, EntityI
|
||||||
private static final Vec2d size = new Vec2d(1, 1);
|
private static final Vec2d size = new Vec2d(1, 1);
|
||||||
|
|
||||||
public EntityPlayer() {
|
public EntityPlayer() {
|
||||||
super(TextureReference.EMPTY, size);
|
super(new Vec2d(0, 0), TextureReference.EMPTY, size);
|
||||||
|
|
||||||
this.angle = 45;
|
this.angle = 45;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,20 +84,7 @@ public class LayerGenCaves extends LayerGen
|
||||||
{
|
{
|
||||||
if(rand.nextDouble() > 0.95)
|
if(rand.nextDouble() > 0.95)
|
||||||
{
|
{
|
||||||
Entity zombie = new EntityZombie();
|
Entity zombie = new EntityZombie(new Vec2d(
|
||||||
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(
|
|
||||||
RandomHelpers.randrange(rand, (int)Main.player.pos.x - 128, (int)Main.player.pos.x + 128),
|
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)));
|
||||||
|
|
||||||
|
|
@ -105,7 +92,7 @@ public class LayerGenCaves extends LayerGen
|
||||||
(int)zombie.pos.y)).tile == getTileDestroyed().tile &&
|
(int)zombie.pos.y)).tile == getTileDestroyed().tile &&
|
||||||
zombie.pos.squareDistance(Main.player.pos) > 32)
|
zombie.pos.squareDistance(Main.player.pos) > 32)
|
||||||
layer.spawnEntity(zombie);
|
layer.spawnEntity(zombie);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,9 @@ public class LayerGenEarth extends LayerGen
|
||||||
{
|
{
|
||||||
if(rand.nextDouble() > 0.98)
|
if(rand.nextDouble() > 0.98)
|
||||||
{
|
{
|
||||||
Entity zombie = new EntityZombie();
|
Entity zombie = new EntityZombie(new Vec2d(
|
||||||
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.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)
|
if(zombie.pos.squareDistance(Main.player.pos) > 64)
|
||||||
layer.spawnEntity(zombie);
|
layer.spawnEntity(zombie);
|
||||||
|
|
|
||||||
|
|
@ -119,10 +119,9 @@ public class LayerGenLavaCaves extends LayerGen
|
||||||
{
|
{
|
||||||
if(rand.nextDouble() > 0.98)
|
if(rand.nextDouble() > 0.98)
|
||||||
{
|
{
|
||||||
Entity zombie = new EntityZombieArmored();
|
Entity zombie = new EntityZombieArmored(new Vec2d(
|
||||||
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.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,
|
TileState tsb = layer.getBackTile(new Vec2i((int)zombie.pos.x,
|
||||||
(int)zombie.pos.y));
|
(int)zombie.pos.y));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue