Started fixing floating point errors in the shaders, optimised particles and path finding
This commit is contained in:
parent
3838754611
commit
afd16a7389
|
|
@ -41,6 +41,6 @@
|
||||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-natives-macos.jar"/>
|
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-natives-macos.jar"/>
|
||||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-natives-windows.jar"/>
|
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-natives-windows.jar"/>
|
||||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-sources.jar"/>
|
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-sources.jar"/>
|
||||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/binary-data-format-v2.1.jar"/>
|
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/binary-data-format-v2.2.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
||||||
|
|
@ -63,17 +63,14 @@ public class Main
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException
|
public static void main(String[] args) throws IOException
|
||||||
{
|
{
|
||||||
// Initialize math
|
|
||||||
MathHelpers.init();
|
MathHelpers.init();
|
||||||
|
Settings.init();
|
||||||
|
Environment.init(args);
|
||||||
|
Cheats.init(args);
|
||||||
|
|
||||||
worker = new Worker();
|
worker = new Worker();
|
||||||
worker.start();
|
worker.start();
|
||||||
|
|
||||||
// Initialize cheats, settings, and environment
|
|
||||||
Environment.init(args);
|
|
||||||
Cheats.init(args);
|
|
||||||
Settings.init();
|
|
||||||
|
|
||||||
Items.init();
|
Items.init();
|
||||||
Entities.init();
|
Entities.init();
|
||||||
Tiles.init();
|
Tiles.init();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
package projectzombie.display;
|
package projectzombie.display;
|
||||||
|
|
||||||
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.matrix.Matrix4;
|
import gl_engine.matrix.Matrix4;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
|
|
||||||
public class Camera
|
public class Camera
|
||||||
{
|
{
|
||||||
|
public int cx, cy;
|
||||||
public double angle = 45;
|
public double angle = 45;
|
||||||
private Matrix4 matrix;
|
private Matrix4 matrix;
|
||||||
|
|
||||||
|
|
@ -14,10 +17,14 @@ public class Camera
|
||||||
public Camera()
|
public Camera()
|
||||||
{
|
{
|
||||||
Matrix4 identity = Matrix4.identity();
|
Matrix4 identity = Matrix4.identity();
|
||||||
Vec2d pos = Main.player.pos;
|
Vec3d pos = Main.player.getPos();
|
||||||
angle = Main.player.angle;
|
angle = Main.player.angle;
|
||||||
|
|
||||||
identity = Matrix4.multiply(identity, Matrix4.translate(-pos.x + 0.5, 0, -pos.y + 0.5));
|
cx = MathHelpers.floor((pos.x - 0.5) / 16.0) + 1;
|
||||||
|
cy = MathHelpers.floor((pos.z - 0.5) / 16.0) + 1;
|
||||||
|
|
||||||
|
identity = Matrix4.multiply(identity, Matrix4.translate(
|
||||||
|
MathHelpers.mod(-pos.x + 0.5, 16), 0, MathHelpers.mod(-pos.z + 0.5, 16)));
|
||||||
identity = Matrix4.multiply(identity, Matrix4.rotate(angle + 180, 0, 1, 0));
|
identity = Matrix4.multiply(identity, Matrix4.rotate(angle + 180, 0, 1, 0));
|
||||||
identity = Matrix4.multiply(identity, Matrix4.rotate(-45, 1, 0, 0));
|
identity = Matrix4.multiply(identity, Matrix4.rotate(-45, 1, 0, 0));
|
||||||
identity = Matrix4.multiply(identity, Matrix4.translate(0, 0, -16));
|
identity = Matrix4.multiply(identity, Matrix4.translate(0, 0, -16));
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ public class DisplayLighting
|
||||||
if(!ChunkEventHandler.loaded) return;
|
if(!ChunkEventHandler.loaded) return;
|
||||||
Layer layer = Main.world.getLayer();
|
Layer layer = Main.world.getLayer();
|
||||||
EntityPlayer player = Main.player;
|
EntityPlayer player = Main.player;
|
||||||
|
Vec2d ppos = player.getPos().xz();
|
||||||
|
|
||||||
boolean dirty = lighting_dirty;
|
boolean dirty = lighting_dirty;
|
||||||
|
|
||||||
|
|
@ -69,8 +70,8 @@ public class DisplayLighting
|
||||||
for(int cx=-Chunk.RENDER_DISTANCE;cx<=Chunk.RENDER_DISTANCE;cx++) {
|
for(int cx=-Chunk.RENDER_DISTANCE;cx<=Chunk.RENDER_DISTANCE;cx++) {
|
||||||
for(int cy=-Chunk.RENDER_DISTANCE;cy<=Chunk.RENDER_DISTANCE;cy++) {
|
for(int cy=-Chunk.RENDER_DISTANCE;cy<=Chunk.RENDER_DISTANCE;cy++) {
|
||||||
Vec2i cpos = new Vec2i(
|
Vec2i cpos = new Vec2i(
|
||||||
cx + MathHelpers.floor(player.pos.x / 16),
|
cx + MathHelpers.floor(ppos.x / 16),
|
||||||
cy + MathHelpers.floor(player.pos.y / 16));
|
cy + MathHelpers.floor(ppos.y / 16));
|
||||||
Chunk chunk = layer.chunks.get(cpos);
|
Chunk chunk = layer.chunks.get(cpos);
|
||||||
if(chunk.isLightDirty()) {
|
if(chunk.isLightDirty()) {
|
||||||
chunk.resetLightDirty();
|
chunk.resetLightDirty();
|
||||||
|
|
@ -92,8 +93,8 @@ public class DisplayLighting
|
||||||
for(int cy=-Chunk.RENDER_DISTANCE;cy<=Chunk.RENDER_DISTANCE;cy++)
|
for(int cy=-Chunk.RENDER_DISTANCE;cy<=Chunk.RENDER_DISTANCE;cy++)
|
||||||
{
|
{
|
||||||
Vec2i cpos = new Vec2i(
|
Vec2i cpos = new Vec2i(
|
||||||
cx + MathHelpers.floor(player.pos.x / 16),
|
cx + MathHelpers.floor(ppos.x / 16),
|
||||||
cy + MathHelpers.floor(player.pos.y / 16));
|
cy + MathHelpers.floor(ppos.y / 16));
|
||||||
|
|
||||||
Chunk chunk = layer.chunks.get(cpos);
|
Chunk chunk = layer.chunks.get(cpos);
|
||||||
|
|
||||||
|
|
@ -128,13 +129,13 @@ public class DisplayLighting
|
||||||
}
|
}
|
||||||
|
|
||||||
Main.worker.processLighting(lights, size, size,
|
Main.worker.processLighting(lights, size, size,
|
||||||
MathHelpers.floor(player.pos.x / 16) - Chunk.RENDER_DISTANCE,
|
MathHelpers.floor(ppos.x / 16) - Chunk.RENDER_DISTANCE,
|
||||||
MathHelpers.floor(player.pos.y / 16) - Chunk.RENDER_DISTANCE);
|
MathHelpers.floor(ppos.y / 16) - Chunk.RENDER_DISTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void calculateLight(Layer layer, Lighting lighting, float[] pixels, int x, int y, float level)
|
private static void calculateLight(Layer layer, Lighting lighting, float[] pixels, int x, int y, float level)
|
||||||
{
|
{
|
||||||
if(x < 0 || y < 0 || x >= lighting.w || y >= lighting.h) {
|
if(x < 0 || y < 0 || x >= lighting.w || y >= lighting.h || level <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,10 +193,12 @@ public class DisplayLighting
|
||||||
0, 1
|
0, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Vec2d epos = entity.getPos().xz();
|
||||||
|
|
||||||
for(int i=0;i<positions.length;i+=2)
|
for(int i=0;i<positions.length;i+=2)
|
||||||
{
|
{
|
||||||
int x = (int)Math.round(entity.pos.x) - positions[i+0];
|
int x = (int)Math.round(epos.x) - positions[i+0];
|
||||||
int y = (int)Math.round(entity.pos.y) - positions[i+1];
|
int y = (int)Math.round(epos.y) - positions[i+1];
|
||||||
|
|
||||||
Vec2i lpos = new Vec2i(x, y).subtract(new Vec2i(lighting.x * 16, lighting.y * 16));
|
Vec2i lpos = new Vec2i(x, y).subtract(new Vec2i(lighting.x * 16, lighting.y * 16));
|
||||||
|
|
||||||
|
|
@ -218,9 +221,7 @@ public class DisplayLighting
|
||||||
TileState bt = chunk.getBackTile(tid);
|
TileState bt = chunk.getBackTile(tid);
|
||||||
|
|
||||||
double dissipation = Math.max(ft.tile.getLightDissipation(ft), bt.tile.getLightDissipation(bt));
|
double dissipation = Math.max(ft.tile.getLightDissipation(ft), bt.tile.getLightDissipation(bt));
|
||||||
double level2 = level - dissipation * (Math.abs(x + 0.5 - entity.pos.x) + Math.abs(y + 0.5 - entity.pos.y));
|
double level2 = level - dissipation * (Math.abs(x + 0.5 - epos.x) + Math.abs(y + 0.5 - epos.y));
|
||||||
|
|
||||||
//pixels[id] = (float)level2;
|
|
||||||
|
|
||||||
calculateLight(layer, lighting, pixels, lpos.x, lpos.y, (float)level2);
|
calculateLight(layer, lighting, pixels, lpos.x, lpos.y, (float)level2);
|
||||||
}
|
}
|
||||||
|
|
@ -237,6 +238,7 @@ public class DisplayLighting
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer layer = Main.world.getLayer();
|
Layer layer = Main.world.getLayer();
|
||||||
|
Vec2d ppos = Main.player.getPos().xz();
|
||||||
|
|
||||||
calculateEntityLighting(layer, lighting, Main.player, pixels);
|
calculateEntityLighting(layer, lighting, Main.player, pixels);
|
||||||
|
|
||||||
|
|
@ -244,8 +246,8 @@ public class DisplayLighting
|
||||||
for(int cy=-Chunk.RENDER_DISTANCE;cy<=Chunk.RENDER_DISTANCE;cy++)
|
for(int cy=-Chunk.RENDER_DISTANCE;cy<=Chunk.RENDER_DISTANCE;cy++)
|
||||||
{
|
{
|
||||||
Vec2i cpos = new Vec2i(
|
Vec2i cpos = new Vec2i(
|
||||||
cx + MathHelpers.floor(Main.player.pos.x / 16),
|
cx + MathHelpers.floor(ppos.x / 16),
|
||||||
cy + MathHelpers.floor(Main.player.pos.y / 16));
|
cy + MathHelpers.floor(ppos.y / 16));
|
||||||
|
|
||||||
Chunk chunk = layer.chunks.get(cpos);
|
Chunk chunk = layer.chunks.get(cpos);
|
||||||
|
|
||||||
|
|
@ -297,8 +299,15 @@ public class DisplayLighting
|
||||||
|
|
||||||
GL33.glGenerateMipmap(GL33.GL_TEXTURE_2D);
|
GL33.glGenerateMipmap(GL33.GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
int cx = 0, cy = 0;
|
||||||
|
|
||||||
|
if(Camera.camera != null) {
|
||||||
|
cx = Camera.camera.cx;
|
||||||
|
cy = Camera.camera.cy;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the texture location data
|
// Set the texture location data
|
||||||
GL33.glUniform2f(Main.window.glsl_lightmap_offset, lighting.x * 16 - 0.5f, lighting.y * 16 - 0.5f);
|
GL33.glUniform2f(Main.window.glsl_lightmap_offset, (lighting.x - cx) * 16 - 0.5f, (lighting.y - cy) * 16 - 0.5f);
|
||||||
GL33.glUniform2f(Main.window.glsl_lightmap_size, lighting.w, lighting.h);
|
GL33.glUniform2f(Main.window.glsl_lightmap_size, lighting.w, lighting.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import static org.lwjgl.opengl.GL11.glViewport;
|
||||||
import org.lwjgl.opengl.GL33;
|
import org.lwjgl.opengl.GL33;
|
||||||
|
|
||||||
import gl_engine.matrix.Matrix4;
|
import gl_engine.matrix.Matrix4;
|
||||||
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
|
|
@ -56,13 +58,16 @@ public class DisplayRender
|
||||||
GL33.glUniform1i(Main.window.glsl_time, (int)((System.currentTimeMillis() / 10) % 1000));
|
GL33.glUniform1i(Main.window.glsl_time, (int)((System.currentTimeMillis() / 10) % 1000));
|
||||||
|
|
||||||
// Render the world and the player
|
// Render the world and the player
|
||||||
|
Vec3d ppos = Main.player.getPos();
|
||||||
Main.world.render(camera);
|
Main.world.render(camera);
|
||||||
player.chunk = Main.world.getLayer().getChunk(player.pos);
|
player.chunk = Main.world.getLayer().getChunk(player.getPos().xz());
|
||||||
|
|
||||||
if(!Main.player.dead)
|
if(!Main.player.dead)
|
||||||
{
|
{
|
||||||
Model model = player.getModel();
|
Model model = player.getModel();
|
||||||
model.setModel(Matrix4.translate(player.pos.x - 0.5, player.getHeight(), player.pos.y - 0.5));
|
model.setModel(Matrix4.translate(
|
||||||
|
(ppos.x - Camera.camera.cx * 16) - 0.5, ppos.y,
|
||||||
|
(ppos.z - Camera.camera.cy * 16) - 0.5));
|
||||||
model.render();
|
model.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import org.lwjgl.opengl.GL33;
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.matrix.Matrix4;
|
import gl_engine.matrix.Matrix4;
|
||||||
import gl_engine.vec.Vec3d;
|
import gl_engine.vec.Vec3d;
|
||||||
|
import gl_engine.vec.Vec3i;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.inventory.Inventory;
|
import projectzombie.inventory.Inventory;
|
||||||
|
|
@ -124,6 +125,21 @@ public class DisplayRenderUI
|
||||||
renderGameGui();
|
renderGameGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double aspect = (double)Main.window.getWidth() / (double)Main.window.getHeight();
|
||||||
|
Matrix4 matrix = Matrix4.scale(new Vec3d(0.35, 0.35, 0.35));
|
||||||
|
matrix = Matrix4.multiply(matrix, Matrix4.translate(-10 * aspect, 9.5, 0));
|
||||||
|
|
||||||
|
if(showFPS) {
|
||||||
|
Text.render("Fps: " + DisplayStatsEventHandler.fps, matrix);
|
||||||
|
matrix = Matrix4.multiply(matrix, Matrix4.translate(0, -0.35, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(showPos) {
|
||||||
|
Vec3i pos = Main.player.getPos().toInt();
|
||||||
|
Text.render("x="+pos.x+", y="+pos.y+", z="+pos.z, matrix);
|
||||||
|
matrix = Matrix4.multiply(matrix, Matrix4.translate(0, -0.35, 0));
|
||||||
|
}
|
||||||
|
|
||||||
// Render the loaded menu
|
// Render the loaded menu
|
||||||
Main.menu.render();
|
Main.menu.render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import bdf.types.BdfObject;
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.init.Entities;
|
import projectzombie.init.Entities;
|
||||||
|
|
@ -23,7 +24,6 @@ import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public abstract class Entity implements IBdfClassManager
|
public abstract class Entity implements IBdfClassManager
|
||||||
{
|
{
|
||||||
public Vec2d pos;
|
|
||||||
public double hitbox = 1;
|
public double hitbox = 1;
|
||||||
public boolean isSolid = false;
|
public boolean isSolid = false;
|
||||||
public Chunk chunk;
|
public Chunk chunk;
|
||||||
|
|
@ -35,6 +35,10 @@ public abstract class Entity implements IBdfClassManager
|
||||||
public boolean emitsLight = false;
|
public boolean emitsLight = false;
|
||||||
public int stepOnTileCooldown = 0;
|
public int stepOnTileCooldown = 0;
|
||||||
private boolean dead = false;
|
private boolean dead = false;
|
||||||
|
protected boolean gravity = true;
|
||||||
|
|
||||||
|
private Vec3d pos;
|
||||||
|
private Vec3d velocity;
|
||||||
|
|
||||||
public abstract IModel getModel();
|
public abstract IModel getModel();
|
||||||
|
|
||||||
|
|
@ -42,21 +46,34 @@ public abstract class Entity implements IBdfClassManager
|
||||||
return dead;
|
return dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec3d getPos() {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPos(Vec3d pos) {
|
||||||
|
this.pos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3d getVelocity() {
|
||||||
|
return velocity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVelocity(Vec3d velocity) {
|
||||||
|
this.velocity = velocity;
|
||||||
|
}
|
||||||
|
|
||||||
protected double getTilesLightDissipation() {
|
protected double getTilesLightDissipation() {
|
||||||
if(chunk == null) return 0;
|
if(chunk == null) return 0;
|
||||||
TileState tsf = chunk.getFrontTile(pos.toInt());
|
TileState tsf = chunk.getFrontTile(pos.xz().toInt());
|
||||||
TileState tsb = chunk.getBackTile(pos.toInt());
|
TileState tsb = chunk.getBackTile(pos.xz().toInt());
|
||||||
return MathHelpers.biggest(
|
return MathHelpers.biggest(
|
||||||
tsf.tile.getLightDissipation(tsf),
|
tsf.tile.getLightDissipation(tsf),
|
||||||
tsb.tile.getLightDissipation(tsb));
|
tsb.tile.getLightDissipation(tsb));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double getLightWithHeight(double light) {
|
protected double getLightWithHeight(double light) {
|
||||||
double height = 1;
|
double height = Math.abs(getVelocity().y) + 1;
|
||||||
if(this instanceof EntityHeight) {
|
return light - (this.getTilesLightDissipation() * height);
|
||||||
height *= ((EntityHeight)this).getHeight();
|
|
||||||
}
|
|
||||||
return light - (this.getTilesLightDissipation() * Math.abs(height));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getID() {
|
public int getID() {
|
||||||
|
|
@ -106,10 +123,11 @@ public abstract class Entity implements IBdfClassManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity(Vec2d pos)
|
public Entity(Vec3d pos, Vec3d velocity)
|
||||||
{
|
{
|
||||||
// Store the specified values
|
// Store the specified values
|
||||||
this.pos = pos;
|
this.velocity = velocity.copy();
|
||||||
|
this.pos = pos.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity(BdfObject bdf) {
|
public Entity(BdfObject bdf) {
|
||||||
|
|
@ -120,13 +138,15 @@ public abstract class Entity implements IBdfClassManager
|
||||||
public void BdfClassLoad(BdfObject bdf) {
|
public void BdfClassLoad(BdfObject bdf) {
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
BdfArray e = nl.get("e").getArray();
|
BdfArray e = nl.get("e").getArray();
|
||||||
pos = new Vec2d(e.get(0));
|
pos = new Vec3d(e.get(0));
|
||||||
|
velocity = new Vec3d(e.get(1));
|
||||||
hitbox = e.get(2).getDouble();
|
hitbox = e.get(2).getDouble();
|
||||||
isSolid = e.get(3).getBoolean();
|
isSolid = e.get(3).getBoolean();
|
||||||
crossUnWalkable = e.get(4).getBoolean();
|
crossUnWalkable = e.get(4).getBoolean();
|
||||||
goThroughSolid = e.get(5).getBoolean();
|
goThroughSolid = e.get(5).getBoolean();
|
||||||
emitsLight = e.get(6).getBoolean();
|
emitsLight = e.get(6).getBoolean();
|
||||||
stepOnTileCooldown = e.get(7).getInteger();
|
stepOnTileCooldown = e.get(7).getInteger();
|
||||||
|
gravity = e.get(8).getBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -142,23 +162,29 @@ public abstract class Entity implements IBdfClassManager
|
||||||
BdfObject pos_bdf = new BdfObject();
|
BdfObject pos_bdf = new BdfObject();
|
||||||
pos.BdfClassSave(pos_bdf);
|
pos.BdfClassSave(pos_bdf);
|
||||||
|
|
||||||
|
BdfObject velocity_bdf = new BdfObject();
|
||||||
|
velocity.BdfClassSave(velocity_bdf);
|
||||||
|
|
||||||
BdfArray e = new BdfArray();
|
BdfArray e = new BdfArray();
|
||||||
nl.set("e", BdfObject.withArray(e));
|
nl.set("e", BdfObject.withArray(e));
|
||||||
|
|
||||||
e.add(pos_bdf);
|
e.add(pos_bdf);
|
||||||
|
e.add(velocity_bdf);
|
||||||
e.add(BdfObject.withDouble(hitbox));
|
e.add(BdfObject.withDouble(hitbox));
|
||||||
e.add(BdfObject.withBoolean(isSolid));
|
e.add(BdfObject.withBoolean(isSolid));
|
||||||
e.add(BdfObject.withBoolean(crossUnWalkable));
|
e.add(BdfObject.withBoolean(crossUnWalkable));
|
||||||
e.add(BdfObject.withBoolean(goThroughSolid));
|
e.add(BdfObject.withBoolean(goThroughSolid));
|
||||||
e.add(BdfObject.withBoolean(emitsLight));
|
e.add(BdfObject.withBoolean(emitsLight));
|
||||||
e.add(BdfObject.withInteger(stepOnTileCooldown));
|
e.add(BdfObject.withInteger(stepOnTileCooldown));
|
||||||
|
e.add(BdfObject.withBoolean(gravity));
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0);
|
Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0);
|
||||||
if(chunk == null) chunk = layer.getChunk(pos);
|
if(chunk == null) chunk = layer.getChunk(pos.xz());
|
||||||
this.chunk = chunk;
|
this.chunk = chunk;
|
||||||
tile_back = chunk.getBackTile(tpos);
|
tile_back = chunk.getBackTile(tpos);
|
||||||
tile_front = chunk.getFrontTile(tpos);
|
tile_front = chunk.getFrontTile(tpos);
|
||||||
|
|
@ -167,59 +193,64 @@ public abstract class Entity implements IBdfClassManager
|
||||||
stepOnTileCooldown -= 1;
|
stepOnTileCooldown -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveAwayFromSolidEntities(layer);
|
Vec3d new_pos = pos.add(velocity);
|
||||||
|
|
||||||
|
if(isSolid) {
|
||||||
|
if(moveIsLegal(new Vec2d(new_pos.x, pos.z))) {
|
||||||
|
pos.x = new_pos.x;
|
||||||
|
} else {
|
||||||
|
velocity.x *= 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(moveIsLegal(new Vec2d(pos.x, new_pos.z))) {
|
||||||
|
pos.z = new_pos.z;
|
||||||
|
} else {
|
||||||
|
velocity.z *= 0.5;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pos.x = new_pos.x;
|
||||||
|
pos.z = new_pos.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(new_pos.y > 0) {
|
||||||
|
pos.y = new_pos.y;
|
||||||
|
} else {
|
||||||
|
velocity.y = 0;
|
||||||
|
velocity.x *= 0.75;
|
||||||
|
velocity.z *= 0.75;
|
||||||
|
pos.y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(gravity) {
|
||||||
|
velocity.y -= MathHelpers.FallSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isSolid) {
|
||||||
|
moveAwayFromSolidEntities(layer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveAwayFromSolidEntities(Layer layer)
|
protected void moveAwayFromSolidEntities(Layer layer)
|
||||||
{
|
{
|
||||||
if(!goThroughSolid)
|
if(!goThroughSolid)
|
||||||
{
|
{
|
||||||
for(Entity e : layer.getNearbyEntities(pos, hitbox))
|
for(Entity e : layer.getNearbyEntities(pos.xz(), hitbox))
|
||||||
{
|
{
|
||||||
if(e.isSolid && e != this) {
|
if(e.isSolid && !e.goThroughSolid && e != this)
|
||||||
double angle = Math.toDegrees(Math.atan2(
|
{
|
||||||
pos.y - e.pos.y,
|
double distance = pos.distance(e.pos);
|
||||||
pos.x - e.pos.x));
|
double angle = MathHelpers.atan2(e.pos.z - pos.z, e.pos.x - pos.x);
|
||||||
moveTowards(angle + 180, 0.1);
|
|
||||||
|
Vec3d vec_push = MathHelpers.moveTowards2(distance == 0 ? 1 : (0.5 / distance), angle).xny();
|
||||||
|
|
||||||
|
push(vec_push.multiply(-0.125));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveTowards(double angle, double speed)
|
public void push(Vec3d vec) {
|
||||||
{
|
velocity = velocity.add(vec);
|
||||||
if(chunk == null) {
|
|
||||||
chunk = Main.world.getLayer().getChunk(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate the new position
|
|
||||||
speed *= 1 - MathHelpers.biggest(
|
|
||||||
chunk.getFrontTile(pos.toInt()).tile.slowness,
|
|
||||||
chunk.getBackTile(pos.toInt()).tile.slowness);
|
|
||||||
Vec2d pos = this.pos.add(MathHelpers.moveTowards2(speed, Math.toRadians(angle)));
|
|
||||||
|
|
||||||
// Check if the new position is legal
|
|
||||||
if(this.moveIsLegal(new Vec2d(this.pos.x, pos.y))) this.pos.y = pos.y;
|
|
||||||
if(this.moveIsLegal(new Vec2d(pos.x, this.pos.y))) this.pos.x = pos.x;
|
|
||||||
|
|
||||||
// Activate stepped on tiles if the entity is "solid"
|
|
||||||
if(this.isSolid) activateSteppedOnTile();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void moveInVector(Vec2d vec, double speed)
|
|
||||||
{
|
|
||||||
// Calculate the new position
|
|
||||||
speed *= 1 - MathHelpers.biggest(
|
|
||||||
chunk.getFrontTile(pos.toInt()).tile.slowness,
|
|
||||||
chunk.getBackTile(pos.toInt()).tile.slowness);
|
|
||||||
Vec2d pos = vec.multiply(speed).add(this.pos);
|
|
||||||
|
|
||||||
// Check if the new position is legal
|
|
||||||
if(this.moveIsLegal(new Vec2d(this.pos.x, pos.y))) this.pos.y = pos.y;
|
|
||||||
if(this.moveIsLegal(new Vec2d(pos.x, this.pos.y))) this.pos.x = pos.x;
|
|
||||||
|
|
||||||
// Activate stepped on tiles if the entity is "solid"
|
|
||||||
if(this.isSolid) activateSteppedOnTile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kill() {
|
public void kill() {
|
||||||
|
|
@ -231,7 +262,7 @@ public abstract class Entity implements IBdfClassManager
|
||||||
{
|
{
|
||||||
// Get the tile position and the layer
|
// Get the tile position and the layer
|
||||||
Layer layer = Main.world.getLayer();
|
Layer layer = Main.world.getLayer();
|
||||||
Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0);
|
Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.z)+0);
|
||||||
|
|
||||||
// Activate both tiles
|
// Activate both tiles
|
||||||
tile_front.tile.onActivated(layer, tpos, this, tile_front);
|
tile_front.tile.onActivated(layer, tpos, this, tile_front);
|
||||||
|
|
@ -245,7 +276,7 @@ public abstract class Entity implements IBdfClassManager
|
||||||
{
|
{
|
||||||
// Get the tile position and the layer
|
// Get the tile position and the layer
|
||||||
Layer layer = Main.world.getLayer();
|
Layer layer = Main.world.getLayer();
|
||||||
Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0);
|
Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.z)+0);
|
||||||
|
|
||||||
// Activate both tiles
|
// Activate both tiles
|
||||||
tile_front.tile.onWalkedOn(chunk, layer, tpos, this, tile_front);
|
tile_front.tile.onWalkedOn(chunk, layer, tpos, this, tile_front);
|
||||||
|
|
@ -256,7 +287,7 @@ public abstract class Entity implements IBdfClassManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean moveIsLegal(Vec2d pos)
|
private boolean moveIsLegal(Vec2d pos)
|
||||||
{
|
{
|
||||||
Vec2i t_pos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0);
|
Vec2i t_pos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0);
|
||||||
Chunk chunk = Main.world.getLayer().getChunk(pos);
|
Chunk chunk = Main.world.getLayer().getChunk(pos);
|
||||||
|
|
@ -316,41 +347,7 @@ public abstract class Entity implements IBdfClassManager
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec2d getRenderOffset(TileState state) {
|
|
||||||
return new Vec2d(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLightLevel() {
|
public double getLightLevel() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void push(double amount, double angle)
|
|
||||||
{
|
|
||||||
double[] a = {amount};
|
|
||||||
|
|
||||||
Main.mainloop.register(new IMainloopTask() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void MainLoopUpdate() {
|
|
||||||
if(!ChunkEventHandler.loaded)
|
|
||||||
return;
|
|
||||||
if(chunk == null)
|
|
||||||
chunk = Main.world.getLayer().getChunk(pos);
|
|
||||||
if(Main.menu.doGameloop) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,8 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
|
||||||
nl.set("seed", BdfObject.withLong(seed));
|
nl.set("seed", BdfObject.withLong(seed));
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityBoss(Vec2d pos) {
|
public EntityBoss(Vec3d pos, Vec3d velocity) {
|
||||||
super(pos);
|
super(pos, velocity);
|
||||||
|
|
||||||
this.isSolid = true;
|
this.isSolid = true;
|
||||||
this.goThroughSolid = false;
|
this.goThroughSolid = false;
|
||||||
|
|
@ -103,11 +103,14 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
public void tick(Chunk chunk, Layer layer) {
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
|
Vec3d bpos = getPos();
|
||||||
|
Vec3d ppos = Main.player.getPos();
|
||||||
|
|
||||||
double angle = Math.atan2(
|
double angle = Math.atan2(
|
||||||
pos.x - Main.player.pos.x + noise_target_x.eval(
|
bpos.x - ppos.x + noise_target_x.eval(
|
||||||
time*2, Main.player.pos.x/25, Main.player.pos.y/25)*10,
|
time*2, ppos.x/25, ppos.z/25)*10,
|
||||||
pos.y - Main.player.pos.y + noise_target_y.eval(
|
bpos.z - ppos.z + noise_target_y.eval(
|
||||||
time*2, Main.player.pos.y/25, Main.player.pos.y/25)*10);
|
time*2, ppos.x/25, ppos.z/25)*10);
|
||||||
angle = Math.toDegrees(angle) + 180;
|
angle = Math.toDegrees(angle) + 180;
|
||||||
|
|
||||||
if(this.noise_spawn.eval(GameTimer.getTime() / 500.0, 0) > 0.2) {
|
if(this.noise_spawn.eval(GameTimer.getTime() / 500.0, 0) > 0.2) {
|
||||||
|
|
@ -122,7 +125,7 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
|
||||||
if(
|
if(
|
||||||
layer.getBackTile(zombie_tpos).tile == layer.layergen.getTileDestroyed().tile &&
|
layer.getBackTile(zombie_tpos).tile == layer.layergen.getTileDestroyed().tile &&
|
||||||
layer.getFrontTile(zombie_tpos).tile == Tiles.VOID) {
|
layer.getFrontTile(zombie_tpos).tile == Tiles.VOID) {
|
||||||
layer.spawnEntity(new EntityZombie(this.pos.add(zombie_pos)));
|
layer.spawnEntity(new EntityZombie(bpos.add(zombie_pos.xny()), getVelocity()));
|
||||||
}
|
}
|
||||||
spawn_frequency = 50;
|
spawn_frequency = 50;
|
||||||
}
|
}
|
||||||
|
|
@ -131,25 +134,8 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
|
||||||
|
|
||||||
if(this.noise_gun.eval(GameTimer.getTime() / 500.0, 0) > 0 && !Main.player.dead && !Main.player.in_animation) {
|
if(this.noise_gun.eval(GameTimer.getTime() / 500.0, 0) > 0 && !Main.player.dead && !Main.player.in_animation) {
|
||||||
|
|
||||||
if(bullet_frequency == 0)
|
if(bullet_frequency == 0) {
|
||||||
{
|
chunk.spawnEntity(new EntityBullet(bpos, bpos.subtract(ppos).normalize(), this, 20, 1000));
|
||||||
Vec2d gun_offset = MathHelpers.moveTowards2(1, Math.toRadians(90));
|
|
||||||
|
|
||||||
Vec3d pos1 = new Vec3d(pos.x + gun_offset.x, pos.y + gun_offset.y, 1);
|
|
||||||
double distance_1 = pos1.distance(new Vec3d(pos.x, pos.y, pos1.z));
|
|
||||||
double angle1_0 = Math.toDegrees(Math.atan2(
|
|
||||||
pos1.x - Main.player.pos.x, pos1.y - Main.player.pos.y)) + 180;
|
|
||||||
double angle1_1 = Math.toDegrees(Math.atan2(distance_1, pos1.z - 1)) - 90;
|
|
||||||
|
|
||||||
Vec3d pos2 = new Vec3d(pos.x - gun_offset.x, pos.y - gun_offset.y, 1);
|
|
||||||
double distance_2 = pos2.distance(new Vec3d(pos.x, pos.y, pos2.z));
|
|
||||||
double angle2_0 = Math.toDegrees(Math.atan2(pos2.x - Main.player.pos.x, pos2.y - Main.player.pos.y)) + 180;
|
|
||||||
double angle2_1 = Math.toDegrees(Math.atan2(distance_2, pos2.z - 1)) - 90;
|
|
||||||
|
|
||||||
layer.spawnEntity(new EntityBullet(pos.add(gun_offset), this, angle1_0, 20, 1000
|
|
||||||
).withHeight(angle1_1, pos1.z));
|
|
||||||
layer.spawnEntity(new EntityBullet(pos.subtract(gun_offset), this, angle2_0, 20, 1000
|
|
||||||
).withHeight(angle2_1, pos2.z));
|
|
||||||
bullet_frequency = 10;
|
bullet_frequency = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,7 +214,7 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveTowards(double angle) {
|
public void moveTowards(double angle) {
|
||||||
this.moveTowards(angle, 0.02);
|
this.push(MathHelpers.moveTowards2(0.01, Math.toRadians(angle)).xny());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -248,16 +234,12 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawn the loot
|
// Spawn the loot
|
||||||
layer.spawnEntity(new EntityItem(pos.copy(), stack));
|
layer.spawnEntity(new EntityItem(getPos(), getVelocity(), stack));
|
||||||
layer.spawnEntity(new EntityItem(pos.copy(), new ItemStack(
|
layer.spawnEntity(new EntityItem(getPos(), getVelocity(), new ItemStack(
|
||||||
Items.HEALTH_POTION, RandomHelpers.randrange(rand, 20), (byte)50)));
|
Items.HEALTH_POTION, RandomHelpers.randrange(rand, 20), (byte)50)));
|
||||||
layer.spawnEntity(new EntityItem(pos.copy(), new ItemStack(
|
layer.spawnEntity(new EntityItem(getPos(), getVelocity(), new ItemStack(
|
||||||
Items.AMMO, RandomHelpers.randrange(rand, 200), (byte)50)));
|
Items.AMMO, RandomHelpers.randrange(rand, 200), (byte)50)));
|
||||||
layer.spawnEntity(new EntityItem(pos.copy(), new ItemStack(Items.GRAPPLING_HOOK, 1, (byte)2)));
|
layer.spawnEntity(new EntityItem(getPos(), getVelocity(), new ItemStack(Items.GRAPPLING_HOOK, 1, (byte)2)));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void push(double amount, double angle) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,6 @@ public class EntityBullet extends EntityParticle
|
||||||
|
|
||||||
private double damage;
|
private double damage;
|
||||||
|
|
||||||
private double height = 0.2;
|
|
||||||
private double height_angle = 0;
|
|
||||||
private double angle = 0;
|
|
||||||
private Vec3d velocity;
|
|
||||||
|
|
||||||
public EntityBullet(BdfObject bdf) {
|
public EntityBullet(BdfObject bdf) {
|
||||||
super(bdf);
|
super(bdf);
|
||||||
}
|
}
|
||||||
|
|
@ -39,10 +34,6 @@ public class EntityBullet extends EntityParticle
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
time = nl.get("time").getInteger();
|
time = nl.get("time").getInteger();
|
||||||
damage = nl.get("damage").getDouble();
|
damage = nl.get("damage").getDouble();
|
||||||
height = nl.get("height").getDouble();
|
|
||||||
height_angle = nl.get("angle_h").getDouble();
|
|
||||||
angle = nl.get("angle").getDouble();
|
|
||||||
velocity = new Vec3d(nl.get("velocity"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -52,62 +43,31 @@ public class EntityBullet extends EntityParticle
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
nl.set("time", BdfObject.withInteger(time));
|
nl.set("time", BdfObject.withInteger(time));
|
||||||
nl.set("damage", BdfObject.withDouble(damage));
|
nl.set("damage", BdfObject.withDouble(damage));
|
||||||
nl.set("height", BdfObject.withDouble(height));
|
|
||||||
nl.set("angle_h", BdfObject.withDouble(height_angle));
|
|
||||||
nl.set("angle", BdfObject.withDouble(angle));
|
|
||||||
velocity.BdfClassSave(nl.get("velocity"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityBullet(Vec2d pos, Entity parent, double angle, double damage, int despawn_time) {
|
public EntityBullet(Vec3d pos, Vec3d velocity, Entity parent, double damage, int despawn_time) {
|
||||||
super(pos);
|
super(pos, velocity);
|
||||||
|
|
||||||
// Store some specified values
|
// Store some specified values
|
||||||
this.angle = angle;
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
this.time = despawn_time;
|
this.time = despawn_time;
|
||||||
|
this.gravity = false;
|
||||||
// Calculate the velocity vector
|
|
||||||
this.velocity = MathHelpers.moveTowards3(0.2, new Vec2d(
|
|
||||||
Math.toRadians(this.angle), Math.toRadians(this.height_angle)));
|
|
||||||
|
|
||||||
// Play the gun sound
|
// Play the gun sound
|
||||||
Sounds.GUN.play(new Vec3d(pos.x, 0.4, pos.y), 2);
|
Sounds.GUN.play(pos, 2);
|
||||||
}
|
|
||||||
|
|
||||||
public EntityBullet withHeight(double angle, double height) {
|
|
||||||
this.height_angle = angle;
|
|
||||||
this.height = height;
|
|
||||||
this.velocity = MathHelpers.moveTowards3(0.2, new Vec2d(
|
|
||||||
Math.toRadians(this.angle), Math.toRadians(this.height_angle)));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
public void tick(Chunk chunk, Layer layer) {
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
// Move forward in the bullets angle, very quickly
|
chunk = layer.getChunk(getPos().xz());
|
||||||
Vec3d pos3 = velocity.add(new Vec3d(pos.x, pos.y, height));
|
|
||||||
height = pos3.z;
|
|
||||||
|
|
||||||
if(moveIsLegal(new Vec2d(pos3.x, pos.y))) {
|
|
||||||
pos.x = pos3.x;
|
|
||||||
} if(moveIsLegal(new Vec2d(pos.x, pos3.x))) {
|
|
||||||
pos.y = pos3.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(height < 0 || height > 16) {
|
|
||||||
kill();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
chunk = layer.getChunk(pos);
|
|
||||||
|
|
||||||
// Is the bullets new position intersecting a solid object
|
// Is the bullets new position intersecting a solid object
|
||||||
{
|
{
|
||||||
// Get the position of the tile the bullet is over
|
// Get the position of the tile the bullet is over
|
||||||
Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x), MathHelpers.floor(pos.y));
|
Vec2i tpos = getPos().xz().toInt();
|
||||||
|
|
||||||
// Get the foreground tile and the background tile
|
// Get the foreground tile and the background tile
|
||||||
Tile tile_f = chunk.getFrontTile(tpos).tile;
|
Tile tile_f = chunk.getFrontTile(tpos).tile;
|
||||||
|
|
@ -115,7 +75,7 @@ public class EntityBullet extends EntityParticle
|
||||||
|
|
||||||
// Is the tile solid and has the bullet crashed into it
|
// Is the tile solid and has the bullet crashed into it
|
||||||
if(tile_f.tileSolid) {
|
if(tile_f.tileSolid) {
|
||||||
if(pos.squareDistance(new Vec2d(tpos.x + 0.5, tpos.y + 0.5)) < tile_f.tileHitbox)
|
if(getPos().xz().squareDistance(new Vec2d(tpos.x + 0.5, tpos.y + 0.5)) < tile_f.tileHitbox)
|
||||||
{
|
{
|
||||||
// Break the block
|
// Break the block
|
||||||
if(tile_f instanceof TileBulletBreakable && RandomHelpers.randrange(rand,
|
if(tile_f instanceof TileBulletBreakable && RandomHelpers.randrange(rand,
|
||||||
|
|
@ -127,7 +87,7 @@ public class EntityBullet extends EntityParticle
|
||||||
kill();
|
kill();
|
||||||
}
|
}
|
||||||
} if(tile_b.tileSolid) {
|
} if(tile_b.tileSolid) {
|
||||||
if(pos.squareDistance(new Vec2d(tpos.x + 0.5, tpos.y + 0.5)) < tile_b.tileHitbox)
|
if(getPos().xz().squareDistance(new Vec2d(tpos.x + 0.5, tpos.y + 0.5)) < tile_b.tileHitbox)
|
||||||
{
|
{
|
||||||
// Break the block
|
// Break the block
|
||||||
if(tile_f instanceof TileBulletBreakable && RandomHelpers.randrange(rand,
|
if(tile_f instanceof TileBulletBreakable && RandomHelpers.randrange(rand,
|
||||||
|
|
@ -142,24 +102,26 @@ public class EntityBullet extends EntityParticle
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop over the nearby entities
|
// Loop over the nearby entities
|
||||||
for(Entity e : layer.getNearbyEntities(pos, 1))
|
for(Entity e : layer.getNearbyEntities(getPos().xz(), 1))
|
||||||
{
|
{
|
||||||
// Is this entity alive and not the parent
|
// Is this entity alive and not the parent
|
||||||
if(e instanceof EntityAlive && e != parent && e.pos.squareDistance(this.pos) < e.hitbox)
|
if(e instanceof EntityAlive && e != parent && e.getPos().squareDistance(this.getPos()) < e.hitbox)
|
||||||
{
|
{
|
||||||
// Get the alive entity
|
// Get the alive entity
|
||||||
EntityAlive ea = (EntityAlive)e;
|
EntityAlive ea = (EntityAlive)e;
|
||||||
|
|
||||||
// Knock the entity back abit
|
|
||||||
e.push(1, angle);
|
|
||||||
|
|
||||||
// Spawn some blood particles
|
// Spawn some blood particles
|
||||||
if(!EntityParticle.DISABLED) {
|
if(!EntityParticle.DISABLED) {
|
||||||
chunk.spawnEntity(new ParticleBlood(pos));
|
chunk.spawnEntity(new ParticleBlood(getPos(), e.getVelocity().add(getVelocity()).divide(8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Knock the entity back abit
|
||||||
|
e.push(getVelocity());
|
||||||
|
|
||||||
|
Vec3d pos = getPos();
|
||||||
|
|
||||||
// Play the hit noise
|
// Play the hit noise
|
||||||
Sounds.HIT.play(new Vec3d(pos.x, pos.y, 0.4), 1);
|
Sounds.HIT.play(new Vec3d(pos.x, pos.y, pos.z), 1);
|
||||||
|
|
||||||
// Harm the entity
|
// Harm the entity
|
||||||
ea.removeHealth(damage);
|
ea.removeHealth(damage);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import bdf.types.BdfArray;
|
||||||
import bdf.types.BdfNamedList;
|
import bdf.types.BdfNamedList;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
@ -17,8 +18,8 @@ public class EntityContainer extends Entity implements EntityHoldsEntities
|
||||||
super(bdf);
|
super(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityContainer(Vec2d pos, Entity[] entities) {
|
public EntityContainer(Vec3d pos, Vec3d velocity, Entity[] entities) {
|
||||||
super(pos);
|
super(pos, velocity);
|
||||||
|
|
||||||
this.entities = entities;
|
this.entities = entities;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.entity;
|
||||||
|
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
|
|
||||||
|
|
@ -11,8 +12,8 @@ public class EntityDummy extends Entity implements EntityAlive
|
||||||
super(bdf);
|
super(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityDummy(Vec2d pos) {
|
public EntityDummy(Vec3d pos, Vec3d velocity) {
|
||||||
super(pos);
|
super(pos, velocity);
|
||||||
|
|
||||||
this.hitbox = 0.5;
|
this.hitbox = 0.5;
|
||||||
this.isSolid = true;
|
this.isSolid = true;
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ public class EntityExplosion extends Entity
|
||||||
super(bdf);
|
super(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityExplosion(Vec2d pos, int radius, double damage) {
|
public EntityExplosion(Vec3d pos, int radius, double damage) {
|
||||||
super(pos);
|
super(pos, new Vec3d(0, 0, 0));
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
|
@ -55,6 +55,7 @@ public class EntityExplosion extends Entity
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
boolean killed_entities = false;
|
boolean killed_entities = false;
|
||||||
|
Vec2d pos = getPos().xy();
|
||||||
|
|
||||||
// Kill all the nearby entities
|
// Kill all the nearby entities
|
||||||
for(Entity e : layer.getNearbyEntities(pos, radius))
|
for(Entity e : layer.getNearbyEntities(pos, radius))
|
||||||
|
|
@ -66,7 +67,7 @@ public class EntityExplosion extends Entity
|
||||||
|
|
||||||
// Remove some health from the entity based on were the entity is
|
// Remove some health from the entity based on were the entity is
|
||||||
killed_entities = true;
|
killed_entities = true;
|
||||||
double distance = e.pos.distance(pos);
|
double distance = e.getPos().distance(getPos());
|
||||||
|
|
||||||
if(distance == 0) {
|
if(distance == 0) {
|
||||||
ea.removeHealth(damage);
|
ea.removeHealth(damage);
|
||||||
|
|
@ -126,17 +127,17 @@ public class EntityExplosion extends Entity
|
||||||
|
|
||||||
// Spawn some blood if entities were killed
|
// Spawn some blood if entities were killed
|
||||||
if(killed_entities)
|
if(killed_entities)
|
||||||
entities[upto + 1] = new ParticleBlood(new Vec2d(px, py));
|
entities[upto + 1] = new ParticleBlood(new Vec3d(px, 0, py), new Vec3d(0, 0, 0));
|
||||||
|
|
||||||
// Spawn some smoke
|
// Spawn some smoke
|
||||||
entities[upto] = new ParticleSmoke(new Vec2d(px, py));
|
entities[upto] = new ParticleSmoke(new Vec3d(px, 0, py), new Vec3d(0, 0, 0));
|
||||||
|
|
||||||
upto += multiplier;
|
upto += multiplier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.spawnEntity(new EntityContainer(pos, entities));
|
layer.spawnEntity(new EntityContainer(getPos(), getVelocity(), entities));
|
||||||
|
|
||||||
// Play the explosion sound
|
// Play the explosion sound
|
||||||
Sounds.EXPLOSION.play(new Vec3d(pos.x, pos.y, 0), 1);
|
Sounds.EXPLOSION.play(new Vec3d(pos.x, pos.y, 0), 1);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.entity;
|
||||||
|
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
@ -16,8 +17,8 @@ public class EntityFlare extends EntityTnt
|
||||||
protected void explode(Layer layer) {
|
protected void explode(Layer layer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityFlare(Vec2d pos, double angle) {
|
public EntityFlare(Vec3d pos, Vec3d velocity, double angle) {
|
||||||
super(pos, angle, 0, 0);
|
super(pos, velocity, angle, 0, 0);
|
||||||
|
|
||||||
this.explode_time = 2000;
|
this.explode_time = 2000;
|
||||||
this.emitsLight = true;
|
this.emitsLight = true;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.entity;
|
||||||
import bdf.types.BdfNamedList;
|
import bdf.types.BdfNamedList;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
|
@ -39,8 +40,8 @@ public class EntityGrapplingHook extends Entity
|
||||||
nl.set("height", BdfObject.withDouble(height));
|
nl.set("height", BdfObject.withDouble(height));
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityGrapplingHook(Vec2d pos, int layerId, Entity entity) {
|
public EntityGrapplingHook(Vec3d pos, int layerId, Entity entity) {
|
||||||
super(pos);
|
super(pos, new Vec3d(0, 0, 0));
|
||||||
|
|
||||||
this.layerId = layerId;
|
this.layerId = layerId;
|
||||||
this.height = -16;
|
this.height = -16;
|
||||||
|
|
@ -56,50 +57,48 @@ public class EntityGrapplingHook extends Entity
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
public void tick(Chunk chunk, Layer layer) {
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
if(entity instanceof EntityHeight) {
|
if(height >= -8)
|
||||||
EntityHeight ea = (EntityHeight)entity;
|
{
|
||||||
|
Vec3d epos = entity.getPos();
|
||||||
|
|
||||||
if(height >= -8)
|
double h = epos.y;
|
||||||
|
epos.y += 0.02;
|
||||||
|
|
||||||
|
if(entity instanceof EntityPlayer) {
|
||||||
|
EntityPlayer ep = (EntityPlayer)entity;
|
||||||
|
ep.moving = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(h >= 8)
|
||||||
{
|
{
|
||||||
double h = ea.getHeight();
|
epos.y = 0;
|
||||||
ea.setHeight(h + 0.02);
|
Main.world.setLayer(layerId);
|
||||||
|
|
||||||
if(entity instanceof EntityPlayer) {
|
if(layer.layergen.destroyOnLeave) {
|
||||||
EntityPlayer ep = (EntityPlayer)entity;
|
Main.world.removeLayer(layerId);
|
||||||
ep.moving = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(h >= 8)
|
if(entity instanceof EntityPlayer)
|
||||||
{
|
{
|
||||||
ea.setHeight(0);
|
EntityPlayer ep = (EntityPlayer)entity;
|
||||||
Main.world.setLayer(layerId);
|
ep.in_animation = false;
|
||||||
|
ep.moving = false;
|
||||||
if(layer.layergen.destroyOnLeave) {
|
|
||||||
Main.world.removeLayer(layerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(entity instanceof EntityPlayer)
|
|
||||||
{
|
|
||||||
EntityPlayer ep = (EntityPlayer)entity;
|
|
||||||
ep.in_animation = false;
|
|
||||||
ep.moving = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(layer.layergen instanceof LayerGenRememberPlayerPos) {
|
|
||||||
LayerGenRememberPlayerPos lgrpp = (LayerGenRememberPlayerPos)layer.layergen;
|
|
||||||
entity.pos = lgrpp.getPlayerPos();
|
|
||||||
}
|
|
||||||
|
|
||||||
kill();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
height += 0.05;
|
if(layer.layergen instanceof LayerGenRememberPlayerPos) {
|
||||||
|
LayerGenRememberPlayerPos lgrpp = (LayerGenRememberPlayerPos)layer.layergen;
|
||||||
|
entity.setPos(lgrpp.getPlayerPos());
|
||||||
|
}
|
||||||
|
|
||||||
|
kill();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
height += 0.05;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
package projectzombie.entity;
|
|
||||||
|
|
||||||
public interface EntityHeight
|
|
||||||
{
|
|
||||||
public double getHeight();
|
|
||||||
public void setHeight(double height);
|
|
||||||
}
|
|
||||||
|
|
@ -2,33 +2,21 @@ package projectzombie.entity;
|
||||||
|
|
||||||
import bdf.types.BdfNamedList;
|
import bdf.types.BdfNamedList;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.util.math.random.RandomHelpers;
|
import projectzombie.util.math.random.RandomHelpers;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class EntityItem extends Entity implements EntityHeight
|
public class EntityItem extends Entity
|
||||||
{
|
{
|
||||||
private ItemStack stack;
|
private ItemStack stack;
|
||||||
private double height = 0;
|
|
||||||
private double height_speed;
|
|
||||||
private int pickup_time = 200;
|
private int pickup_time = 200;
|
||||||
private long age = 0;
|
private long age = 0;
|
||||||
|
|
||||||
public double angle;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeight(double height) {
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityItem(BdfObject bdf) {
|
public EntityItem(BdfObject bdf) {
|
||||||
super(bdf);
|
super(bdf);
|
||||||
}
|
}
|
||||||
|
|
@ -38,12 +26,11 @@ public class EntityItem extends Entity implements EntityHeight
|
||||||
super.BdfClassLoad(bdf);
|
super.BdfClassLoad(bdf);
|
||||||
|
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
|
|
||||||
stack = new ItemStack(nl.get("stack"));
|
stack = new ItemStack(nl.get("stack"));
|
||||||
height = nl.get("height").getDouble();
|
|
||||||
height_speed = nl.get("speed_h").getDouble();
|
|
||||||
pickup_time = nl.get("pickup").getInteger();
|
pickup_time = nl.get("pickup").getInteger();
|
||||||
age = nl.get("age").getLong();
|
age = nl.get("age").getLong();
|
||||||
angle = nl.get("angle").getDouble();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -51,21 +38,24 @@ public class EntityItem extends Entity implements EntityHeight
|
||||||
super.BdfClassSave(bdf);
|
super.BdfClassSave(bdf);
|
||||||
|
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
|
|
||||||
stack.BdfClassSave(nl.get("stack"));
|
stack.BdfClassSave(nl.get("stack"));
|
||||||
nl.set("height", BdfObject.withDouble(height));
|
|
||||||
nl.set("speed_h", BdfObject.withDouble(height_speed));
|
|
||||||
nl.set("pickup", BdfObject.withInteger(pickup_time));
|
nl.set("pickup", BdfObject.withInteger(pickup_time));
|
||||||
nl.set("age", BdfObject.withLong(age));
|
nl.set("age", BdfObject.withLong(age));
|
||||||
nl.set("angle", BdfObject.withDouble(angle));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityItem(Vec2d pos, ItemStack stack) {
|
public EntityItem(Vec3d pos, Vec3d velocity, ItemStack stack, double angle) {
|
||||||
super(pos);
|
super(pos, velocity);
|
||||||
|
|
||||||
this.emitsLight = true;
|
this.emitsLight = true;
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.angle = RandomHelpers.randrange(rand, 360);
|
|
||||||
height_speed = RandomHelpers.randrange(rand, 10000) / 200000.0;
|
push(new Vec3d(MathHelpers.moveTowards2(0.025, angle), 0.025));
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityItem(Vec3d pos, Vec3d velocity, ItemStack stack) {
|
||||||
|
this(pos, velocity, stack, rand.nextDouble() * MathHelpers.TWO_PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -80,24 +70,8 @@ public class EntityItem extends Entity implements EntityHeight
|
||||||
|
|
||||||
age += 1;
|
age += 1;
|
||||||
|
|
||||||
height += height_speed;
|
|
||||||
height_speed -= 0.001;
|
|
||||||
|
|
||||||
pickup_time -= 1;
|
|
||||||
if(pickup_time < 0) {
|
|
||||||
pickup_time = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(height <= 0) {
|
|
||||||
height_speed = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
moveTowards(angle, 0.01);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Merge nearby stacks
|
// Merge nearby stacks
|
||||||
for(Entity e : layer.getNearbyEntities(pos, 1))
|
for(Entity e : layer.getNearbyEntities(getPos().xz(), 1))
|
||||||
{
|
{
|
||||||
if(e instanceof EntityItem && e != this) {
|
if(e instanceof EntityItem && e != this) {
|
||||||
EntityItem ei = (EntityItem) e;
|
EntityItem ei = (EntityItem) e;
|
||||||
|
|
@ -109,11 +83,8 @@ public class EntityItem extends Entity implements EntityHeight
|
||||||
) {
|
) {
|
||||||
this.pickup_time = 200;
|
this.pickup_time = 200;
|
||||||
this.stack.count += ei.stack.count;
|
this.stack.count += ei.stack.count;
|
||||||
this.pos = new Vec2d(
|
setPos(ei.getPos().divide(2).add(getPos().divide(2)));
|
||||||
ei.pos.x / 2 + this.pos.x / 2,
|
setVelocity(ei.getVelocity().divide(2).add(getVelocity().divide(2)));
|
||||||
ei.pos.y / 2 + this.pos.y / 2);
|
|
||||||
this.height = ei.height / 2 + this.height / 2;
|
|
||||||
this.height_speed = ei.height_speed / 2 + this.height_speed / 2;
|
|
||||||
ei.kill();
|
ei.kill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -121,7 +92,7 @@ public class EntityItem extends Entity implements EntityHeight
|
||||||
|
|
||||||
if(pickup_time == 0)
|
if(pickup_time == 0)
|
||||||
{
|
{
|
||||||
for(Entity e : layer.getNearbyEntities(pos, 1))
|
for(Entity e : layer.getNearbyEntities(getPos().xz(), 1))
|
||||||
{
|
{
|
||||||
if(e instanceof EntityInventory)
|
if(e instanceof EntityInventory)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.entity;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import gl_engine.texture.TextureRef3D;
|
import gl_engine.texture.TextureRef3D;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
@ -16,8 +17,8 @@ public abstract class EntityParticle extends Entity
|
||||||
super(bdf);
|
super(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityParticle(Vec2d pos) {
|
public EntityParticle(Vec3d pos, Vec3d velocity) {
|
||||||
super(pos);
|
super(pos, velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -25,6 +26,6 @@ public abstract class EntityParticle extends Entity
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
// Kill the particle if the player can't see it to reduce lag
|
// Kill the particle if the player can't see it to reduce lag
|
||||||
if(Main.player.pos.squareDistance(pos) > Chunk.RENDER_DISTANCE * 16) this.kill();
|
if(Main.player.getPos().squareDistance(getPos()) > Chunk.RENDER_DISTANCE * 16) this.kill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,9 @@ import projectzombie.model.Model;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class EntityTnt extends Entity implements EntityHeight, EntityHoldsEntities
|
public class EntityTnt extends Entity implements EntityHoldsEntities
|
||||||
{
|
{
|
||||||
protected boolean active = true;
|
protected boolean active = true;
|
||||||
protected double height = 0.4;
|
|
||||||
protected Vec3d velocity;
|
|
||||||
protected int explode_time;
|
protected int explode_time;
|
||||||
private int explode_radius;
|
private int explode_radius;
|
||||||
private double explode_damage;
|
private double explode_damage;
|
||||||
|
|
@ -26,16 +24,6 @@ public class EntityTnt extends Entity implements EntityHeight, EntityHoldsEntiti
|
||||||
return smoke_particles;
|
return smoke_particles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeight(double height) {
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityTnt(BdfObject bdf) {
|
public EntityTnt(BdfObject bdf) {
|
||||||
super(bdf);
|
super(bdf);
|
||||||
|
|
||||||
|
|
@ -47,9 +35,6 @@ public class EntityTnt extends Entity implements EntityHeight, EntityHoldsEntiti
|
||||||
super.BdfClassLoad(bdf);
|
super.BdfClassLoad(bdf);
|
||||||
|
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
height = nl.get("height").getDouble();
|
|
||||||
velocity = new Vec3d(nl.get("velocity"));
|
|
||||||
|
|
||||||
BdfNamedList explode = nl.get("explosion").getNamedList();
|
BdfNamedList explode = nl.get("explosion").getNamedList();
|
||||||
explode_time = explode.get("time").getInteger();
|
explode_time = explode.get("time").getInteger();
|
||||||
explode_radius = explode.get("radius").getInteger();
|
explode_radius = explode.get("radius").getInteger();
|
||||||
|
|
@ -61,20 +46,17 @@ public class EntityTnt extends Entity implements EntityHeight, EntityHoldsEntiti
|
||||||
super.BdfClassSave(bdf);
|
super.BdfClassSave(bdf);
|
||||||
|
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
nl.set("height", BdfObject.withDouble(height));
|
|
||||||
velocity.BdfClassSave(nl.get("velocity"));
|
|
||||||
|
|
||||||
BdfNamedList explode = nl.get("explosion").getNamedList();
|
BdfNamedList explode = nl.get("explosion").getNamedList();
|
||||||
explode.set("time", BdfObject.withInteger(explode_time));
|
explode.set("time", BdfObject.withInteger(explode_time));
|
||||||
explode.set("radius", BdfObject.withInteger(explode_radius));
|
explode.set("radius", BdfObject.withInteger(explode_radius));
|
||||||
explode.set("damage", BdfObject.withDouble(explode_damage));
|
explode.set("damage", BdfObject.withDouble(explode_damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityTnt(Vec2d pos, double angle, int explode_radius, double explode_damage) {
|
public EntityTnt(Vec3d pos, Vec3d velocity, double angle, int explode_radius, double explode_damage) {
|
||||||
super(pos);
|
super(pos, velocity);
|
||||||
|
|
||||||
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 = velocity.add(new Vec3d(v.x, v.y, 0.01));
|
||||||
this.explode_radius = explode_radius;
|
this.explode_radius = explode_radius;
|
||||||
this.crossUnWalkable = true;
|
this.crossUnWalkable = true;
|
||||||
this.goThroughSolid = false;
|
this.goThroughSolid = false;
|
||||||
|
|
@ -87,7 +69,7 @@ public class EntityTnt extends Entity implements EntityHeight, EntityHoldsEntiti
|
||||||
|
|
||||||
protected void explode(Layer layer)
|
protected void explode(Layer layer)
|
||||||
{
|
{
|
||||||
layer.spawnEntity(new EntityExplosion(pos, explode_radius, explode_damage));
|
layer.spawnEntity(new EntityExplosion(getPos(), explode_radius, explode_damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -119,30 +101,6 @@ public class EntityTnt extends Entity implements EntityHeight, EntityHoldsEntiti
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a downward gravitational pull
|
|
||||||
height += velocity.z;
|
|
||||||
velocity.z -= 0.001;
|
|
||||||
|
|
||||||
// Move forwards
|
|
||||||
Vec2d pos_copy = pos.copy();
|
|
||||||
pos.x += velocity.x;
|
|
||||||
pos.y += velocity.y;
|
|
||||||
|
|
||||||
if(!moveIsLegal(new Vec2d(pos.x, pos_copy.y))) {
|
|
||||||
pos.x = pos_copy.x;
|
|
||||||
velocity.x *= -1;
|
|
||||||
}
|
|
||||||
if(!moveIsLegal(new Vec2d(pos_copy.x, pos.y))) {
|
|
||||||
pos.y = pos_copy.y;
|
|
||||||
velocity.y *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the tnt bounce on the ground
|
|
||||||
if(height < 0) {
|
|
||||||
height = 0;
|
|
||||||
velocity.z *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Explode if it is time for the tnt to blow up
|
// Explode if it is time for the tnt to blow up
|
||||||
explode_time -= 1;
|
explode_time -= 1;
|
||||||
if(explode_time < 0) {
|
if(explode_time < 0) {
|
||||||
|
|
@ -150,7 +108,7 @@ public class EntityTnt extends Entity implements EntityHeight, EntityHoldsEntiti
|
||||||
explode(layer);
|
explode(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
smoke_particles[dead_particle] = new ParticleSpark(new Vec3d(pos, height + 1));
|
smoke_particles[dead_particle] = new ParticleSpark(getPos().add(new Vec3d(0, 1, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ import java.util.Random;
|
||||||
|
|
||||||
import bdf.types.BdfNamedList;
|
import bdf.types.BdfNamedList;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
|
|
@ -31,7 +33,7 @@ public class EntityZombie extends Entity implements EntityAlive, EntityKillWithP
|
||||||
protected int gun_interval = 0;
|
protected int gun_interval = 0;
|
||||||
protected int gun_level = 0;
|
protected int gun_level = 0;
|
||||||
|
|
||||||
private Vec2i walk_direction;
|
private Vec3d walk_to;
|
||||||
private int walk_scan_cooldown = 0;
|
private int walk_scan_cooldown = 0;
|
||||||
private boolean can_see_player = false;
|
private boolean can_see_player = false;
|
||||||
private int walking_for = 0;
|
private int walking_for = 0;
|
||||||
|
|
@ -81,8 +83,8 @@ public class EntityZombie extends Entity implements EntityAlive, EntityKillWithP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityZombie(Vec2d pos) {
|
public EntityZombie(Vec3d pos, Vec3d velocity) {
|
||||||
super(pos);
|
super(pos, velocity);
|
||||||
|
|
||||||
seed = rand.nextLong();
|
seed = rand.nextLong();
|
||||||
Random rand = new Random(seed);
|
Random rand = new Random(seed);
|
||||||
|
|
@ -107,62 +109,58 @@ public class EntityZombie extends Entity implements EntityAlive, EntityKillWithP
|
||||||
|
|
||||||
//System.out.println(walk_direction != null ? (walk_direction.x + ", " + walk_direction.y + ": " + pos.toInt().x + ", " + pos.toInt().y) : "null");
|
//System.out.println(walk_direction != null ? (walk_direction.x + ", " + walk_direction.y + ": " + pos.toInt().x + ", " + pos.toInt().y) : "null");
|
||||||
|
|
||||||
if(walk_direction == null) {
|
if(walk_to == null) {
|
||||||
walk_scan_cooldown -= 1;
|
walk_scan_cooldown -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double player_distance = pos.squareDistance(Main.player.pos);
|
double player_distance = getPos().squareDistance(Main.player.getPos());
|
||||||
|
|
||||||
// Only pathfind if in range of the player
|
// Only pathfind if in range of the player
|
||||||
if(player_distance < 16)
|
if(player_distance < 16)
|
||||||
{
|
{
|
||||||
if(
|
if(
|
||||||
(walk_direction != null && pos.toInt().equal(walk_direction) &&
|
(walk_to != null && getPos().toInt().equal(walk_to.toInt()) &&
|
||||||
player_distance > 2) || walk_scan_cooldown < 1 || walking_for > 200)
|
player_distance > 2) || walk_scan_cooldown < 1 || walking_for > 200)
|
||||||
{
|
{
|
||||||
AStar astar = new AStar(pos.toInt(), 16, new AStarSearcher(layer, crossUnWalkable));
|
AStar astar = new AStar(getPos().xz().toInt(), 16, new AStarSearcher(layer, crossUnWalkable));
|
||||||
Vec2i path[] = astar.getPath(Main.player.pos.toInt());
|
Vec2i path[] = astar.getPath(Main.player.getPos().xz().toInt());
|
||||||
|
|
||||||
walk_scan_cooldown = 100;
|
walk_scan_cooldown = 100;
|
||||||
walking_for = 0;
|
walking_for = 0;
|
||||||
|
|
||||||
if(path != null && path.length > 1) {
|
if(path != null && path.length > 1) {
|
||||||
walk_direction = path[1];
|
walk_to = new Vec3d(path[0].x, 0, path[0].y);
|
||||||
} else {
|
} else {
|
||||||
walk_direction = Main.player.pos.toInt();
|
walk_to = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
can_see_player = (path != null);
|
can_see_player = (path != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walk towards the player
|
// Walk towards the player
|
||||||
if(walk_direction != null)
|
if(walk_to != null)
|
||||||
{
|
{
|
||||||
double angle = Math.toDegrees(Math.atan2(
|
push(walk_to.subtract(getPos()).normalize().multiply(0.016));
|
||||||
walk_direction.x - (this.pos.x - 0.5) + noise_target_x.eval(time, pos.x/10, pos.y/10),
|
|
||||||
walk_direction.y - (this.pos.y - 0.5) + noise_target_y.eval(time, pos.x/10, pos.y/10)));
|
if(Double.isNaN(walk_to.x + walk_to.y + walk_to.z + getPos().x + getPos().y + getPos().z + getVelocity().x + getVelocity().y + getVelocity().z)) {
|
||||||
this.moveTowards(angle);
|
Double.isFinite(0);
|
||||||
|
}
|
||||||
|
|
||||||
walking_for += 1;
|
walking_for += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(can_see_player && noise_gun_fire.eval(time, 0) > 0 && !Main.player.dead && !Main.player.in_animation)
|
if(can_see_player && noise_gun_fire.eval(time, 0) > 0 && !Main.player.dead && !Main.player.in_animation)
|
||||||
{
|
{
|
||||||
// Get the angle between the player and the zombie
|
|
||||||
double angle_fire = Math.atan2(pos.x - Main.player.pos.x, pos.y - Main.player.pos.y);
|
|
||||||
|
|
||||||
gun_interval += 1;
|
gun_interval += 1;
|
||||||
gun_interval %= 10;
|
gun_interval %= 10;
|
||||||
|
|
||||||
if(gun_interval == 0)
|
if(gun_interval == 0)
|
||||||
{
|
{
|
||||||
// Aim the gun at the player
|
|
||||||
double angle_gun = Math.toDegrees(angle_fire) + 180;
|
|
||||||
angle_gun += noise_gun_angle.eval(time, 0)*20;
|
|
||||||
|
|
||||||
// Fire the gun
|
// Fire the gun
|
||||||
int d = (int)(1 + gun_level / 5.0);
|
int d = (int)(1 + gun_level / 5.0);
|
||||||
layer.spawnEntity(new EntityBullet(pos.copy(), this, angle_gun, 20*d*d, 60));
|
Vec3d bullet_velocity = getVelocity().add(Main.player.getPos().subtract(getPos())).normalize().multiply(0.2);
|
||||||
|
Vec3d bullet_pos = getPos().add(new Vec3d(0, 0.4, 0));
|
||||||
|
//Main.world.getLayer().spawnEntity(new EntityBullet(bullet_pos, bullet_velocity, this, 20*d*d, 60));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -176,14 +174,6 @@ public class EntityZombie extends Entity implements EntityAlive, EntityKillWithP
|
||||||
return Models.ENTITY_ZOMBIE_F;
|
return Models.ENTITY_ZOMBIE_F;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveInVector(Vec2d vec) {
|
|
||||||
super.moveInVector(vec, 0.06);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void moveTowards(double angle) {
|
|
||||||
super.moveTowards(angle, 0.06);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addHealth(double amount) {
|
public void addHealth(double amount) {
|
||||||
health += amount;
|
health += amount;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.entity;
|
||||||
|
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
|
|
||||||
|
|
@ -11,8 +12,8 @@ public class EntityZombieArmored extends EntityZombie
|
||||||
super(bdf);
|
super(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityZombieArmored(Vec2d pos) {
|
public EntityZombieArmored(Vec3d pos, Vec3d velocity) {
|
||||||
super(pos);
|
super(pos, velocity);
|
||||||
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;
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,22 @@
|
||||||
package projectzombie.entity.particle;
|
package projectzombie.entity.particle;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
|
||||||
public class ParticleBlood extends ParticleBreak
|
public class ParticleBlood extends ParticleBreak
|
||||||
{
|
{
|
||||||
public ParticleBlood(Vec2d pos, int size) {
|
public ParticleBlood(Vec3d pos, Vec3d velocity, int size) {
|
||||||
super(pos, Models.PARTICLE_BLOOD, size, 0.1);
|
super(pos, velocity, Models.PARTICLE_BLOOD, size, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleBlood(Vec2d pos) {
|
public ParticleBlood(Vec3d pos, Vec3d velocity) {
|
||||||
this(pos, 200);
|
this(pos, velocity, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vec2d getParticleSize() {
|
||||||
|
return new Vec2d(0.05, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import gl_engine.MathHelpers;
|
||||||
import gl_engine.matrix.Matrix4;
|
import gl_engine.matrix.Matrix4;
|
||||||
import gl_engine.texture.TextureRef3D;
|
import gl_engine.texture.TextureRef3D;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec2i;
|
||||||
import gl_engine.vec.Vec3d;
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.EntityParticle;
|
import projectzombie.entity.EntityParticle;
|
||||||
|
|
@ -31,24 +32,29 @@ public class ParticleBreak extends EntityParticle implements IModel
|
||||||
Vec3d pos;
|
Vec3d pos;
|
||||||
boolean moving;
|
boolean moving;
|
||||||
int flags;
|
int flags;
|
||||||
int life;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Break[] particles;
|
private Break[] particles;
|
||||||
private int ibo, vbo, vao;
|
private int ibo, vbo, vao;
|
||||||
private boolean generated;
|
private boolean generated;
|
||||||
private int dead;
|
private int dead, still, time;
|
||||||
|
|
||||||
public ParticleBreak(Vec2d pos, IModel model) {
|
public Vec2d getParticleSize() {
|
||||||
this(pos, model, 200, 0.05);
|
return new Vec2d(0.1, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleBreak(Vec2d pos, IModel model, int count) {
|
public ParticleBreak(Vec3d pos, Vec3d velocity, IModel model) {
|
||||||
this(pos, model, count, 0.05);
|
this(pos, velocity, model, 200, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ParticleBreak(Vec2d pos, IModel model, int count, double velocity_up_multiplier) {
|
public ParticleBreak(Vec3d pos, Vec3d velocity, IModel model, int count) {
|
||||||
super(pos);
|
this(pos, velocity, model, count, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ParticleBreak(Vec3d pos, Vec3d velocity, IModel model, int count, double velocity_up_multiplier) {
|
||||||
|
super(pos, new Vec3d(0, 0, 0));
|
||||||
|
|
||||||
|
this.gravity = false;
|
||||||
|
|
||||||
double model_height = model.getHeight();
|
double model_height = model.getHeight();
|
||||||
TextureRef3D[] textures = model.getTextures();
|
TextureRef3D[] textures = model.getTextures();
|
||||||
|
|
@ -78,11 +84,10 @@ public class ParticleBreak extends EntityParticle implements IModel
|
||||||
ref.texmap = texture.texmap;
|
ref.texmap = texture.texmap;
|
||||||
ref.z = texture.z;
|
ref.z = texture.z;
|
||||||
|
|
||||||
particle.life = (int)(rand.nextDouble() * 200 + 800);
|
particle.pos = pos.add(new Vec3d(0, rand.nextDouble() * model_height, 0));
|
||||||
particle.pos = new Vec3d(pos, rand.nextDouble() * model_height);
|
particle.velocity = velocity.multiply(rand.nextDouble()).add(
|
||||||
particle.velocity = new Vec3d(
|
MathHelpers.moveTowards2(0.01, rand.nextDouble() * MathHelpers.TWO_PI).xny().add(
|
||||||
MathHelpers.moveTowards2(0.01, rand.nextDouble() * MathHelpers.TWO_PI),
|
new Vec3d(0, rand.nextDouble() * velocity_up_multiplier, 0)));
|
||||||
rand.nextDouble() * velocity_up_multiplier);
|
|
||||||
particle.ref = ref;
|
particle.ref = ref;
|
||||||
particle.moving = true;
|
particle.moving = true;
|
||||||
particle.flags = (int)verticies[tex_id * Model.SIZE + Model.SIZE - 1] | 0b1000;
|
particle.flags = (int)verticies[tex_id * Model.SIZE + Model.SIZE - 1] | 0b1000;
|
||||||
|
|
@ -90,7 +95,9 @@ public class ParticleBreak extends EntityParticle implements IModel
|
||||||
particles[i] = particle;
|
particles[i] = particle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time = 1000;
|
||||||
generated = false;
|
generated = false;
|
||||||
|
still = 0;
|
||||||
dead = 0;
|
dead = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,37 +105,44 @@ public class ParticleBreak extends EntityParticle implements IModel
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
public void tick(Chunk chunk, Layer layer) {
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
dead = 0;
|
time -= 1;
|
||||||
|
|
||||||
for(int i=0;i<particles.length;i++)
|
|
||||||
{
|
|
||||||
Break particle = particles[i];
|
|
||||||
|
|
||||||
if(particle.life <= 0) {
|
|
||||||
dead += 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
particle.life -= 1;
|
|
||||||
|
|
||||||
if(!particle.moving) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(particle.pos.z < 0) {
|
|
||||||
particle.moving = false;
|
|
||||||
particle.pos.z = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
particle.velocity.z -= MathHelpers.FallSpeed;
|
|
||||||
particle.pos = particle.pos.add(particle.velocity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dead == particles.length - 1) {
|
if(dead == particles.length - 1) {
|
||||||
kill();
|
kill();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(time < 0 && still == particles.length) {
|
||||||
|
if(rand.nextDouble() > 0.75) {
|
||||||
|
dead += 1;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0;i<particles.length;i++)
|
||||||
|
{
|
||||||
|
Break particle = particles[i];
|
||||||
|
|
||||||
|
if(!particle.moving) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(particle.pos.y < 0) {
|
||||||
|
particle.moving = false;
|
||||||
|
particle.pos.y = 0;
|
||||||
|
still += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
particle.velocity.y -= MathHelpers.FallSpeed;
|
||||||
|
particle.pos = particle.pos.add(particle.velocity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void kill() {
|
||||||
|
this.free();
|
||||||
|
super.kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -160,33 +174,36 @@ public class ParticleBreak extends EntityParticle implements IModel
|
||||||
public float[] getVerticies()
|
public float[] getVerticies()
|
||||||
{
|
{
|
||||||
float[] verticies = new float[getSize() * Model.SIZE];
|
float[] verticies = new float[getSize() * Model.SIZE];
|
||||||
|
Vec3d ppos = getPos();
|
||||||
|
|
||||||
int upto = 0;
|
int upto = 0;
|
||||||
|
float k = Model.OFFSET;
|
||||||
|
float x = (float)getParticleSize().x/2;
|
||||||
|
float y = (float)getParticleSize().y;
|
||||||
|
|
||||||
for(int i=0;i<particles.length;i++)
|
for(int i=0;i<particles.length;i++)
|
||||||
{
|
{
|
||||||
Break particle = particles[i];
|
Break particle = particles[i];
|
||||||
|
|
||||||
if(particle.life <= 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureRef3D ref = particle.ref;
|
TextureRef3D ref = particle.ref;
|
||||||
|
|
||||||
float f = particle.flags;
|
float f = particle.flags;
|
||||||
float k = Model.OFFSET;
|
float px = (float)(particle.pos.x - ppos.x);
|
||||||
float x = 0.05f;
|
float py = (float)(particle.pos.y - ppos.y);
|
||||||
float y = 0.1f;
|
float pz = (float)(particle.pos.z - ppos.z);
|
||||||
|
float a = y, b = 0, c = 0;
|
||||||
|
|
||||||
float px = (float)(pos.x - particle.pos.x);
|
if(!particle.moving) {
|
||||||
float py = (float)(particle.pos.z);
|
f = particle.flags & 0b0110;
|
||||||
float pz = (float)(pos.y - particle.pos.y);
|
a = 0.001f;
|
||||||
|
b = y / 2;
|
||||||
|
c = a;
|
||||||
|
}
|
||||||
|
|
||||||
float[] p = {
|
float[] p = {
|
||||||
-x, 0, 0, ref.sx+k, ref.sy+k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
-x, c,-b, ref.sx+k, ref.sy+k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
||||||
x, 0, 0, ref.ex-k, ref.sy+k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
x, c,-b, ref.ex-k, ref.sy+k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
||||||
x, y, 0, ref.ex-k, ref.ey-k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
x, a, b, ref.ex-k, ref.ey-k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
||||||
-x, y, 0, ref.sx+k, ref.ey-k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
-x, a, b, ref.sx+k, ref.ey-k, ref.z, ref.sy, ref.ey, px, py, pz, 1, 1, f,
|
||||||
};
|
};
|
||||||
|
|
||||||
for(int j=0;j<p.length;j++) {
|
for(int j=0;j<p.length;j++) {
|
||||||
|
|
@ -206,7 +223,6 @@ public class ParticleBreak extends EntityParticle implements IModel
|
||||||
int upto = 0;
|
int upto = 0;
|
||||||
|
|
||||||
for(int i=0;i<particles.length;i++) {
|
for(int i=0;i<particles.length;i++) {
|
||||||
if(particles[i].life <= 0) continue;
|
|
||||||
textures[upto+0] = particles[i].ref;
|
textures[upto+0] = particles[i].ref;
|
||||||
textures[upto+1] = particles[i].ref;
|
textures[upto+1] = particles[i].ref;
|
||||||
textures[upto+2] = particles[i].ref;
|
textures[upto+2] = particles[i].ref;
|
||||||
|
|
@ -268,8 +284,11 @@ public class ParticleBreak extends EntityParticle implements IModel
|
||||||
bind();
|
bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
GL33.glBindBuffer(GL33.GL_ARRAY_BUFFER, vbo);
|
if(still != particles.length) {
|
||||||
GL33.glBufferSubData(GL33.GL_ARRAY_BUFFER, 0, getVerticies());
|
GL33.glBindBuffer(GL33.GL_ARRAY_BUFFER, vbo);
|
||||||
|
GL33.glBufferSubData(GL33.GL_ARRAY_BUFFER, 0, getVerticies());
|
||||||
|
}
|
||||||
|
|
||||||
GL33.glDrawElements(GL33.GL_TRIANGLES, getIndexSize(), GL33.GL_UNSIGNED_INT, 0);
|
GL33.glDrawElements(GL33.GL_TRIANGLES, getIndexSize(), GL33.GL_UNSIGNED_INT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import java.util.Random;
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec3d;
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.EntityHeight;
|
|
||||||
import projectzombie.entity.EntityParticle;
|
import projectzombie.entity.EntityParticle;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
|
|
@ -13,42 +12,21 @@ import projectzombie.util.math.random.RandomHelpers;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class ParticleLava extends EntityParticle implements EntityHeight
|
public class ParticleLava extends EntityParticle
|
||||||
{
|
{
|
||||||
private static Random rand = new Random();
|
private static Random rand = new Random();
|
||||||
private Vec3d velocity;
|
|
||||||
private double height = 0;
|
|
||||||
|
|
||||||
@Override
|
public ParticleLava(Vec3d pos, Vec3d velocity) {
|
||||||
public double getHeight() {
|
super(pos, velocity.add(MathHelpers.moveTowards3(0.05, new Vec2d(Math.toRadians(
|
||||||
return height;
|
RandomHelpers.randrange(rand, 360)), Math.toRadians(RandomHelpers.randrange(rand, 0, 45))))));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeight(double height) {
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ParticleLava(Vec2d pos) {
|
|
||||||
super(pos);
|
|
||||||
|
|
||||||
// Set the velocity
|
|
||||||
velocity = MathHelpers.moveTowards3(0.05, new Vec2d(Math.toRadians(
|
|
||||||
RandomHelpers.randrange(rand, 360)), Math.toRadians(RandomHelpers.randrange(rand, 0, 45))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
public void tick(Chunk chunk, Layer layer) {
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
// Add the velocity
|
|
||||||
velocity.z -= MathHelpers.FallSpeed;
|
|
||||||
pos.x += velocity.x;
|
|
||||||
pos.y += velocity.y;
|
|
||||||
height += velocity.z;
|
|
||||||
|
|
||||||
// Is the height below 0; destroy this particle
|
// Is the height below 0; destroy this particle
|
||||||
if(height < -1) {
|
if(getPos().y < -1) {
|
||||||
kill();
|
kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package projectzombie.entity.particle;
|
package projectzombie.entity.particle;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.EntityHeight;
|
|
||||||
import projectzombie.entity.EntityParticle;
|
import projectzombie.entity.EntityParticle;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
|
|
@ -10,33 +10,19 @@ import projectzombie.util.math.random.RandomHelpers;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class ParticleSmoke extends EntityParticle implements EntityHeight
|
public class ParticleSmoke extends EntityParticle
|
||||||
{
|
{
|
||||||
double height = 0;
|
|
||||||
double opacity = 1;
|
double opacity = 1;
|
||||||
double height_speed;
|
|
||||||
double disappear_speed;
|
double disappear_speed;
|
||||||
|
|
||||||
private Model model;
|
private Model model;
|
||||||
|
|
||||||
@Override
|
public ParticleSmoke(Vec3d pos, Vec3d velocity) {
|
||||||
public double getHeight() {
|
super(pos.add(new Vec3d(
|
||||||
return height;
|
RandomHelpers.randrange(rand, 1000)/1000.0 - 0.5 + pos.x, 0,
|
||||||
}
|
RandomHelpers.randrange(rand, 1000)/1000.0 - 0.5 + pos.y)),
|
||||||
|
velocity.add(new Vec3d(0, (rand.nextDouble() + 0.5) / 250, 0)));
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeight(double height) {
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ParticleSmoke(Vec2d pos) {
|
|
||||||
super(pos);
|
|
||||||
|
|
||||||
this.pos = new Vec2d(
|
|
||||||
RandomHelpers.randrange(rand, 1000)/1000.0 - 0.5 + pos.x,
|
|
||||||
RandomHelpers.randrange(rand, 1000)/1000.0 - 0.5 + pos.y);
|
|
||||||
|
|
||||||
height_speed = (rand.nextDouble() + 0.5) / 250;
|
|
||||||
disappear_speed = (rand.nextDouble() + 0.5) / 1000;
|
disappear_speed = (rand.nextDouble() + 0.5) / 1000;
|
||||||
model = Models.PARTICLE_SMOKE_RANDOM.getModel();
|
model = Models.PARTICLE_SMOKE_RANDOM.getModel();
|
||||||
}
|
}
|
||||||
|
|
@ -45,11 +31,10 @@ public class ParticleSmoke extends EntityParticle implements EntityHeight
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
public void tick(Chunk chunk, Layer layer) {
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
if(pos.squareDistance(Main.player.pos) > 32 || opacity <= 0 || height > 16) {
|
if(getPos().squareDistance(Main.player.getPos()) > 32 || opacity <= 0 || getPos().y > 16) {
|
||||||
kill();
|
kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
height += height_speed;
|
|
||||||
opacity -= disappear_speed;
|
opacity -= disappear_speed;
|
||||||
|
|
||||||
if(DISABLED) {
|
if(DISABLED) {
|
||||||
|
|
|
||||||
|
|
@ -3,40 +3,24 @@ package projectzombie.entity.particle;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import gl_engine.vec.Vec3d;
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.EntityHeight;
|
|
||||||
import projectzombie.entity.EntityParticle;
|
import projectzombie.entity.EntityParticle;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class ParticleSpark extends EntityParticle implements EntityHeight
|
public class ParticleSpark extends EntityParticle
|
||||||
{
|
{
|
||||||
private int time;
|
private int time;
|
||||||
private double height;
|
|
||||||
private Vec3d velocity;
|
|
||||||
|
|
||||||
private static final Random rand = new Random();
|
private static final Random rand = new Random();
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeight(double height) {
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ParticleSpark(Vec3d pos) {
|
public ParticleSpark(Vec3d pos) {
|
||||||
super(pos.xy());
|
super(pos, new Vec3d(
|
||||||
|
|
||||||
velocity = new Vec3d(
|
|
||||||
rand.nextDouble() * 0.02 - 0.01,
|
rand.nextDouble() * 0.02 - 0.01,
|
||||||
rand.nextDouble() * 0.02 - 0.01,
|
rand.nextDouble() * 0.02 - 0.01,
|
||||||
rand.nextDouble() * 0.02);
|
rand.nextDouble() * 0.02));
|
||||||
|
|
||||||
height = pos.z;
|
|
||||||
time = 100;
|
time = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,9 +28,7 @@ public class ParticleSpark extends EntityParticle implements EntityHeight
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
public void tick(Chunk chunk, Layer layer) {
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
// Reduce the size
|
// Reduce the time
|
||||||
pos = pos.add(velocity.xy());
|
|
||||||
height += velocity.z;
|
|
||||||
time -= 1;
|
time -= 1;
|
||||||
|
|
||||||
// Kill if at the end of life
|
// Kill if at the end of life
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec3d;
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityContainer;
|
import projectzombie.entity.EntityContainer;
|
||||||
import projectzombie.entity.EntityHeight;
|
|
||||||
import projectzombie.entity.EntityParticle;
|
import projectzombie.entity.EntityParticle;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.IModel;
|
import projectzombie.model.IModel;
|
||||||
|
|
@ -15,12 +14,12 @@ import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class ParticleWater extends ParticleBreak
|
public class ParticleWater extends ParticleBreak
|
||||||
{
|
{
|
||||||
public ParticleWater(Vec2d pos) {
|
public ParticleWater(Vec3d pos, Vec3d velocity) {
|
||||||
this(pos, 50);
|
this(pos, velocity, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleWater(Vec2d pos, int count) {
|
public ParticleWater(Vec3d pos, Vec3d velocity, int count) {
|
||||||
super(pos, Models.TILE_WATER, count, 0.01);
|
super(pos, velocity, Models.TILE_WATER, count, 0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ import bdf.types.BdfObject;
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.display.DisplayLighting;
|
import projectzombie.display.DisplayLighting;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityAlive;
|
import projectzombie.entity.EntityAlive;
|
||||||
import projectzombie.entity.EntityBullet;
|
import projectzombie.entity.EntityBullet;
|
||||||
import projectzombie.entity.EntityHeight;
|
|
||||||
import projectzombie.entity.EntityInventory;
|
import projectzombie.entity.EntityInventory;
|
||||||
import projectzombie.entity.EntityItem;
|
import projectzombie.entity.EntityItem;
|
||||||
import projectzombie.entity.particle.ParticleBreak;
|
import projectzombie.entity.particle.ParticleBreak;
|
||||||
|
|
@ -25,7 +25,7 @@ import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class EntityPlayer extends Entity implements EntityAlive, EntityInventory, EntityHeight
|
public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
{
|
{
|
||||||
public boolean MOVE_FORWARD = false;
|
public boolean MOVE_FORWARD = false;
|
||||||
public boolean MOVE_BACKWARD = false;
|
public boolean MOVE_BACKWARD = false;
|
||||||
|
|
@ -37,8 +37,6 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
public Model PLAYER_MOVING = Models.ENTITY_PLAYER_B_W_MOVING;
|
public Model PLAYER_MOVING = Models.ENTITY_PLAYER_B_W_MOVING;
|
||||||
public Model PLAYER_STILL = Models.ENTITY_PLAYER_B_W_STILL;
|
public Model PLAYER_STILL = Models.ENTITY_PLAYER_B_W_STILL;
|
||||||
|
|
||||||
public double height = 0;
|
|
||||||
|
|
||||||
private int bullet_frequency = 0;
|
private int bullet_frequency = 0;
|
||||||
private double health_max = 1000;
|
private double health_max = 1000;
|
||||||
private double health = health_max;
|
private double health = health_max;
|
||||||
|
|
@ -54,7 +52,6 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
public int gun_level = 0;
|
public int gun_level = 0;
|
||||||
|
|
||||||
public double angle;
|
public double angle;
|
||||||
public double speed;
|
|
||||||
|
|
||||||
private Vec2i last_chunk;
|
private Vec2i last_chunk;
|
||||||
|
|
||||||
|
|
@ -66,7 +63,6 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
public void BdfClassLoad(BdfObject bdf) {
|
public void BdfClassLoad(BdfObject bdf) {
|
||||||
super.BdfClassLoad(bdf);
|
super.BdfClassLoad(bdf);
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
height = nl.get("height").getDouble();
|
|
||||||
bullet_frequency = nl.get("bullet_frequency").getInteger();
|
bullet_frequency = nl.get("bullet_frequency").getInteger();
|
||||||
health = nl.get("health").getDouble();
|
health = nl.get("health").getDouble();
|
||||||
dead = nl.get("dead").getBoolean();
|
dead = nl.get("dead").getBoolean();
|
||||||
|
|
@ -86,7 +82,6 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
public void BdfClassSave(BdfObject bdf) {
|
public void BdfClassSave(BdfObject bdf) {
|
||||||
super.BdfClassSave(bdf);
|
super.BdfClassSave(bdf);
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
nl.set("height", BdfObject.withDouble(height));
|
|
||||||
nl.set("bullet_frequency", BdfObject.withInteger(bullet_frequency));
|
nl.set("bullet_frequency", BdfObject.withInteger(bullet_frequency));
|
||||||
nl.set("health", BdfObject.withDouble(health));
|
nl.set("health", BdfObject.withDouble(health));
|
||||||
nl.set("dead", BdfObject.withBoolean(dead));
|
nl.set("dead", BdfObject.withBoolean(dead));
|
||||||
|
|
@ -99,7 +94,7 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityPlayer() {
|
public EntityPlayer() {
|
||||||
super(new Vec2d(0, 0));
|
super(new Vec3d(0, 0, 0), new Vec3d(0, 0, 0));
|
||||||
|
|
||||||
this.angle = 45;
|
this.angle = 45;
|
||||||
|
|
||||||
|
|
@ -109,7 +104,6 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
goThroughSolid = false;
|
goThroughSolid = false;
|
||||||
crossUnWalkable = false;
|
crossUnWalkable = false;
|
||||||
emitsLight = true;
|
emitsLight = true;
|
||||||
speed = 0.1;
|
|
||||||
|
|
||||||
// Create the inventory
|
// Create the inventory
|
||||||
inventory = new Inventory(10);
|
inventory = new Inventory(10);
|
||||||
|
|
@ -141,7 +135,7 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
@Override
|
@Override
|
||||||
public void tick(Chunk chunk, Layer layer)
|
public void tick(Chunk chunk, Layer layer)
|
||||||
{
|
{
|
||||||
chunk = layer.getChunk(pos);
|
chunk = layer.getChunk(getPos().xz());
|
||||||
|
|
||||||
if(chunk != null && chunk.c_pos != null && (last_chunk == null || !chunk.c_pos.equal(last_chunk))) {
|
if(chunk != null && chunk.c_pos != null && (last_chunk == null || !chunk.c_pos.equal(last_chunk))) {
|
||||||
last_chunk = chunk.c_pos;
|
last_chunk = chunk.c_pos;
|
||||||
|
|
@ -153,7 +147,7 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
// Handle player deaths
|
// Handle player deaths
|
||||||
if(health <= 0)
|
if(health <= 0)
|
||||||
{
|
{
|
||||||
chunk.spawnEntity(new ParticleBreak(pos, getModel()));
|
chunk.spawnEntity(new ParticleBreak(getPos(), getVelocity(), getModel()));
|
||||||
|
|
||||||
if(Cheats.god_mode) {
|
if(Cheats.god_mode) {
|
||||||
this.resetHealth();
|
this.resetHealth();
|
||||||
|
|
@ -192,8 +186,8 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
super.tick(chunk, layer);
|
super.tick(chunk, layer);
|
||||||
|
|
||||||
double temp_diff = MathHelpers.biggest(
|
double temp_diff = MathHelpers.biggest(
|
||||||
layer.layergen.getTemperatureDynamic(layer, pos),
|
layer.layergen.getTemperatureDynamic(layer, getPos().xz()),
|
||||||
chunk.getLightLevel(pos.toInt()) * 0.6) - temperature;
|
chunk.getLightLevel(getPos().xz().toInt()) * 0.6) - temperature;
|
||||||
|
|
||||||
temperature += temp_diff / 1000;
|
temperature += temp_diff / 1000;
|
||||||
hydration -= Math.sqrt(Math.abs(temperature - 0.5)) / 5000;
|
hydration -= Math.sqrt(Math.abs(temperature - 0.5)) / 5000;
|
||||||
|
|
@ -247,19 +241,18 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk.spawnEntity(new ParticleBreak(pos, getModel()));
|
chunk.spawnEntity(new ParticleBreak(getPos(), getVelocity(), getModel()));
|
||||||
|
|
||||||
dead = true;
|
dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void moveTowards(double angle, double speed) {
|
public void moveTowards(double angle, double speed) {
|
||||||
if(dead || in_animation) return;
|
if(dead || in_animation) return;
|
||||||
super.moveTowards(angle, speed);
|
super.push(MathHelpers.moveTowards2(speed, Math.toRadians(angle)).xny());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveTowards(double angle) {
|
public void moveTowards(double angle) {
|
||||||
this.moveTowards(angle, 0.08);
|
this.moveTowards(angle, 0.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireBullet(double angle)
|
public void fireBullet(double angle)
|
||||||
|
|
@ -277,8 +270,9 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
|
|
||||||
// Summon bullets at this angle relative to the player
|
// Summon bullets at this angle relative to the player
|
||||||
int d = (int)(1 + gun_level / 4.0);
|
int d = (int)(1 + gun_level / 4.0);
|
||||||
Main.world.getLayer().spawnEntity(new EntityBullet(pos.copy(), this, angle + this.angle,
|
Vec3d bullet_velocity = getVelocity().add(MathHelpers.moveTowards2(0.2, Math.toRadians(angle + this.angle)).xny());
|
||||||
20*d*d, 60).withHeight(0, height));
|
Vec3d bullet_pos = getPos().add(new Vec3d(0, 0.4, 0));
|
||||||
|
Main.world.getLayer().spawnEntity(new EntityBullet(bullet_pos, bullet_velocity, this, 20*d*d, 60));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -340,32 +334,17 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
||||||
|
|
||||||
if(!i.isEmpty())
|
if(!i.isEmpty())
|
||||||
{
|
{
|
||||||
EntityItem e = new EntityItem(pos.copy(), new ItemStack(i.item, 1, i.meta));
|
EntityItem e = new EntityItem(getPos(), getVelocity(), new ItemStack(i.item, 1, i.meta), Math.toRadians(angle));
|
||||||
e.angle = angle;
|
|
||||||
Main.world.getLayer().spawnEntity(e);
|
Main.world.getLayer().spawnEntity(e);
|
||||||
i.count -= 1;
|
i.count -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void push(double amount, double angle) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int bloodParticles() {
|
public int bloodParticles() {
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeight(double height) {
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getModel() {
|
public Model getModel() {
|
||||||
return moving ? PLAYER_MOVING : PLAYER_STILL;
|
return moving ? PLAYER_MOVING : PLAYER_STILL;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public class Models
|
||||||
public static final Model ENTITY_DUMMY = new ModelVertical(Resources.ATLAS.get("/entity/dummy.png"));
|
public static final Model ENTITY_DUMMY = new ModelVertical(Resources.ATLAS.get("/entity/dummy.png"));
|
||||||
public static final Model ENTITY_GRAPPLING_HOOK = new ModelVertical(Resources.ATLAS.get("/entity/grappling_hook.png"));
|
public static final Model ENTITY_GRAPPLING_HOOK = new ModelVertical(Resources.ATLAS.get("/entity/grappling_hook.png"));
|
||||||
|
|
||||||
public static final Model PARTICLE_BLOOD = new ModelVertical(Resources.ATLAS.get("/particle/blood.png"), new Vec2d(0.1, 0.1));
|
public static final Model PARTICLE_BLOOD = new ModelVertical(Resources.ATLAS.get("/particle/blood.png"), new Vec2d(1, 1));
|
||||||
public static final Model PARTICLE_LAVA = new ModelVertical(Resources.ATLAS.get("/particle/lava.png"), new Vec2d(0.1, 0.1));
|
public static final Model PARTICLE_LAVA = new ModelVertical(Resources.ATLAS.get("/particle/lava.png"), new Vec2d(0.1, 0.1));
|
||||||
public static final Model PARTICLE_WATER = new ModelVertical(Resources.ATLAS.get("/particle/water.png"), new Vec2d(0.1, 0.1));
|
public static final Model PARTICLE_WATER = new ModelVertical(Resources.ATLAS.get("/particle/water.png"), new Vec2d(0.1, 0.1));
|
||||||
public static final Model PARTICLE_SMOKE_TRAIL = new ModelVertical(Resources.ATLAS.get("/particle/smoke_trail.png"), new Vec2d(0.1, 0.1));
|
public static final Model PARTICLE_SMOKE_TRAIL = new ModelVertical(Resources.ATLAS.get("/particle/smoke_trail.png"), new Vec2d(0.1, 0.1));
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class ItemFlare extends Item
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
||||||
super.onPlayerAction(stack, layer, chunk, player);
|
super.onPlayerAction(stack, layer, chunk, player);
|
||||||
layer.spawnEntity(new EntityFlare(player.pos.copy(), player.angle));
|
layer.spawnEntity(new EntityFlare(player.getPos(), player.getVelocity(), player.angle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.items;
|
||||||
|
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.EntityGrapplingHook;
|
import projectzombie.entity.EntityGrapplingHook;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
|
@ -27,8 +28,7 @@ public class ItemGrapplingHook extends Item
|
||||||
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
||||||
super.onPlayerAction(stack, layer, chunk, player);
|
super.onPlayerAction(stack, layer, chunk, player);
|
||||||
|
|
||||||
Vec2d pos = player.pos.add(MathHelpers.moveTowards2(0.01, Math.toRadians(player.angle)));
|
layer.spawnEntity(new EntityGrapplingHook(player.getPos(), stack.meta, player));
|
||||||
layer.spawnEntity(new EntityGrapplingHook(new Vec2d(pos.x, pos.y), stack.meta, player));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class ItemLantern extends Item
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player)
|
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player)
|
||||||
{
|
{
|
||||||
Vec2i tpos = new Vec2i(MathHelpers.floor(player.pos.x), MathHelpers.floor(player.pos.y));
|
Vec2i tpos = new Vec2i(MathHelpers.floor(player.getPos().x), MathHelpers.floor(player.getPos().z));
|
||||||
if(layer.getFrontTile(tpos).tile == Tiles.VOID) {
|
if(layer.getFrontTile(tpos).tile == Tiles.VOID) {
|
||||||
layer.setFrontTile(Tiles.LANTERN.getDefaultState(), tpos);
|
layer.setFrontTile(Tiles.LANTERN.getDefaultState(), tpos);
|
||||||
super.onPlayerAction(stack, layer, chunk, player);
|
super.onPlayerAction(stack, layer, chunk, player);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package projectzombie.items;
|
package projectzombie.items;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
@ -12,10 +13,10 @@ public abstract class ItemSpawn extends Item
|
||||||
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
||||||
super.onPlayerAction(stack, layer, chunk, player);
|
super.onPlayerAction(stack, layer, chunk, player);
|
||||||
|
|
||||||
this.spawnEntity(layer, chunk, player.pos);
|
this.spawnEntity(layer, chunk, player.getPos(), player.getVelocity());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnEntity(Layer layer, Chunk chunk, Vec2d pos) {
|
public void spawnEntity(Layer layer, Chunk chunk, Vec3d pos, Vec3d velocity) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public class ItemTnt extends Item
|
||||||
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
||||||
super.onPlayerAction(stack, layer, chunk, player);
|
super.onPlayerAction(stack, layer, chunk, player);
|
||||||
|
|
||||||
layer.spawnEntity(new EntityTnt(player.pos.copy(), player.angle, stack.meta, 5000));
|
layer.spawnEntity(new EntityTnt(player.getPos(), player.getVelocity(), player.angle, stack.meta, 5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package projectzombie.items.spawner;
|
package projectzombie.items.spawner;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.EntityDummy;
|
import projectzombie.entity.EntityDummy;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.items.ItemSpawn;
|
import projectzombie.items.ItemSpawn;
|
||||||
|
|
@ -17,8 +18,8 @@ public class ItemSpawnDummy extends ItemSpawn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnEntity(Layer layer, Chunk chunk, Vec2d pos) {
|
public void spawnEntity(Layer layer, Chunk chunk, Vec3d pos, Vec3d velocity) {
|
||||||
chunk.spawnEntity(new EntityDummy(new Vec2d(pos.x, pos.y)));
|
chunk.spawnEntity(new EntityDummy(pos, velocity));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package projectzombie.items.spawner;
|
package projectzombie.items.spawner;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.EntityZombie;
|
import projectzombie.entity.EntityZombie;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.items.ItemSpawn;
|
import projectzombie.items.ItemSpawn;
|
||||||
|
|
@ -17,8 +18,8 @@ public class ItemSpawnZombie extends ItemSpawn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnEntity(Layer layer, Chunk chunk, Vec2d pos) {
|
public void spawnEntity(Layer layer, Chunk chunk, Vec3d pos, Vec3d velocity) {
|
||||||
chunk.spawnEntity(new EntityZombie(new Vec2d(pos.x, pos.y)));
|
chunk.spawnEntity(new EntityZombie(pos, velocity));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package projectzombie.menu;
|
package projectzombie.menu;
|
||||||
|
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.input.types.InputGUI;
|
import projectzombie.input.types.InputGUI;
|
||||||
import projectzombie.menu.gui.ButtonGroup;
|
import projectzombie.menu.gui.ButtonGroup;
|
||||||
|
|
@ -56,7 +57,8 @@ public class MenuMain extends Menu
|
||||||
|
|
||||||
Main.player.angle += 0.05;
|
Main.player.angle += 0.05;
|
||||||
Main.player.angle %= 360;
|
Main.player.angle %= 360;
|
||||||
Main.player.pos.x += 0.005;
|
|
||||||
|
Main.player.setPos(new Vec3d(Main.player.getPos().x + 0.005, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import projectzombie.menu.gui.components.ButtonBasic;
|
||||||
import projectzombie.menu.gui.components.ButtonSetting;
|
import projectzombie.menu.gui.components.ButtonSetting;
|
||||||
import projectzombie.menu.gui.components.GUIBackToMenu;
|
import projectzombie.menu.gui.components.GUIBackToMenu;
|
||||||
import projectzombie.menu.gui.components.OverlayBackground;
|
import projectzombie.menu.gui.components.OverlayBackground;
|
||||||
|
import projectzombie.settings.Settings;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
||||||
public class MenuSettings extends Menu
|
public class MenuSettings extends Menu
|
||||||
|
|
@ -41,6 +42,7 @@ public class MenuSettings extends Menu
|
||||||
group.add(new ButtonSetting("FPS: " + (DisplayRenderUI.showFPS ? "On" : "Off"), button -> {
|
group.add(new ButtonSetting("FPS: " + (DisplayRenderUI.showFPS ? "On" : "Off"), button -> {
|
||||||
DisplayRenderUI.showFPS = !DisplayRenderUI.showFPS;
|
DisplayRenderUI.showFPS = !DisplayRenderUI.showFPS;
|
||||||
button.setText("FPS: " + (DisplayRenderUI.showFPS ? "On" : "Off"));
|
button.setText("FPS: " + (DisplayRenderUI.showFPS ? "On" : "Off"));
|
||||||
|
Settings.update();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
group.add(new ButtonSetting("Pos Indicator: " + (DisplayRenderUI.showPos ? "On" : "Off"),
|
group.add(new ButtonSetting("Pos Indicator: " + (DisplayRenderUI.showPos ? "On" : "Off"),
|
||||||
|
|
@ -48,6 +50,7 @@ public class MenuSettings extends Menu
|
||||||
{
|
{
|
||||||
DisplayRenderUI.showPos = !DisplayRenderUI.showPos;
|
DisplayRenderUI.showPos = !DisplayRenderUI.showPos;
|
||||||
button.setText("Pos Indicator: " + (DisplayRenderUI.showPos ? "On" : "Off"));
|
button.setText("Pos Indicator: " + (DisplayRenderUI.showPos ? "On" : "Off"));
|
||||||
|
Settings.update();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
group.add(new ButtonSetting("Render Distance: "+Chunk.RENDER_DISTANCE, button -> {
|
group.add(new ButtonSetting("Render Distance: "+Chunk.RENDER_DISTANCE, button -> {
|
||||||
|
|
@ -56,20 +59,14 @@ public class MenuSettings extends Menu
|
||||||
Chunk.RENDER_DISTANCE = 2;
|
Chunk.RENDER_DISTANCE = 2;
|
||||||
}
|
}
|
||||||
button.setText("Render Distance: "+Chunk.RENDER_DISTANCE);
|
button.setText("Render Distance: "+Chunk.RENDER_DISTANCE);
|
||||||
|
Settings.update();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
group.add(new ButtonSetting("GUI Scale: " + DisplayRenderUI.guiScale, button -> {
|
group.add(new ButtonSetting("Particles: " + qualitySettingToString(!EntityParticle.DISABLED), button ->
|
||||||
DisplayRenderUI.guiScale += 1;
|
|
||||||
if(DisplayRenderUI.guiScale > 4) {
|
|
||||||
DisplayRenderUI.guiScale = 1;
|
|
||||||
}
|
|
||||||
button.setText("GUI Scale: " + DisplayRenderUI.guiScale);
|
|
||||||
}));
|
|
||||||
|
|
||||||
group.add(new ButtonSetting("Particles: " + qualitySettingToString(EntityParticle.DISABLED), button ->
|
|
||||||
{
|
{
|
||||||
EntityParticle.DISABLED = !EntityParticle.DISABLED;
|
EntityParticle.DISABLED = !EntityParticle.DISABLED;
|
||||||
button.setText("Particles: " + qualitySettingToString(EntityParticle.DISABLED));
|
button.setText("Particles: " + qualitySettingToString(!EntityParticle.DISABLED));
|
||||||
|
Settings.update();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/*group.add(new ButtonSetting("Dynamic Lighting: " + (LightingManager.lightingMode == 0 ? "Fast" : "Fancy"),
|
/*group.add(new ButtonSetting("Dynamic Lighting: " + (LightingManager.lightingMode == 0 ? "Fast" : "Fancy"),
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,11 @@ public class Settings implements IBdfClassManager
|
||||||
DisplayRenderUI.showPos = false;
|
DisplayRenderUI.showPos = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nl.get("gui_scale").getType() == BdfTypes.INTEGER) {
|
if(nl.get("particles").getType() == BdfTypes.BOOLEAN) {
|
||||||
DisplayRenderUI.guiScale = nl.get("gui_scale").getInteger();
|
EntityParticle.DISABLED = nl.get("particles").getBoolean();
|
||||||
} else {
|
} else {
|
||||||
DisplayRenderUI.guiScale = 2;
|
EntityParticle.DISABLED = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityParticle.DISABLED = nl.get("particles").getBoolean();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -52,7 +50,6 @@ public class Settings implements IBdfClassManager
|
||||||
nl.set("render_distance", BdfObject.withInteger(Chunk.RENDER_DISTANCE));
|
nl.set("render_distance", BdfObject.withInteger(Chunk.RENDER_DISTANCE));
|
||||||
nl.set("show_fps", BdfObject.withBoolean(DisplayRenderUI.showFPS));
|
nl.set("show_fps", BdfObject.withBoolean(DisplayRenderUI.showFPS));
|
||||||
nl.set("show_pos", BdfObject.withBoolean(DisplayRenderUI.showPos));
|
nl.set("show_pos", BdfObject.withBoolean(DisplayRenderUI.showPos));
|
||||||
nl.set("gui_scale", BdfObject.withInteger(DisplayRenderUI.guiScale));
|
|
||||||
nl.set("particles", BdfObject.withBoolean(EntityParticle.DISABLED));
|
nl.set("particles", BdfObject.withBoolean(EntityParticle.DISABLED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
|
|
@ -42,13 +43,13 @@ public class TileBossPortal extends Tile
|
||||||
{
|
{
|
||||||
// Get the player and set some player variables
|
// Get the player and set some player variables
|
||||||
EntityPlayer ep = (EntityPlayer)entity;
|
EntityPlayer ep = (EntityPlayer)entity;
|
||||||
ep.height = 5;
|
ep.getPos().y = 5;
|
||||||
|
|
||||||
// Create the boss arena
|
// Create the boss arena
|
||||||
LayerGenBossArena layergen = (LayerGenBossArena) LayerGenerators.BOSS_ARENA;
|
LayerGenBossArena layergen = (LayerGenBossArena) LayerGenerators.BOSS_ARENA;
|
||||||
layergen.spawnPlayer(ep);
|
layergen.spawnPlayer(ep);
|
||||||
layer.setFrontTile(TileState.EMPTY, tpos);
|
layer.setFrontTile(TileState.EMPTY, tpos);
|
||||||
layer.spawnEntity(new ParticleBreak(tpos.toDouble(), getModel(state.meta)));
|
layer.spawnEntity(new ParticleBreak(tpos.toDouble().xny(), new Vec3d(0, 0, 0), getModel(state.meta)));
|
||||||
|
|
||||||
int id = Main.world.addLayer(new Layer(rand, layergen));
|
int id = Main.world.addLayer(new Layer(rand, layergen));
|
||||||
Main.world.setLayer(id);
|
Main.world.setLayer(id);
|
||||||
|
|
@ -68,11 +69,11 @@ public class TileBossPortal extends Tile
|
||||||
if(ChunkEventHandler.loaded)
|
if(ChunkEventHandler.loaded)
|
||||||
{
|
{
|
||||||
this.velocity -= MathHelpers.FallSpeed;
|
this.velocity -= MathHelpers.FallSpeed;
|
||||||
ep.height += this.velocity;
|
ep.getPos().y += this.velocity;
|
||||||
if(ep.height <= 0) {
|
if(ep.getPos().y <= 0) {
|
||||||
this.velocity *= -0.6;
|
this.velocity *= -0.6;
|
||||||
if(this.velocity <= 0.001) {
|
if(this.velocity <= 0.001) {
|
||||||
ep.height = 0;
|
ep.getPos().y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +82,7 @@ public class TileBossPortal extends Tile
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean MainLoopRepeat() {
|
public boolean MainLoopRepeat() {
|
||||||
return ep.height > 0 || this.velocity > 0.001;
|
return ep.getPos().y > 0 || this.velocity > 0.001;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityItem;
|
import projectzombie.entity.EntityItem;
|
||||||
|
|
@ -29,7 +30,7 @@ public class TileChest extends Tile implements TileBulletBreakable
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnItem(Chunk chunk, Vec2i pos, ItemStack stack) {
|
private void spawnItem(Chunk chunk, Vec2i pos, ItemStack stack) {
|
||||||
chunk.spawnEntity(new EntityItem(new Vec2d(pos.x+0.5, pos.y+0.5), stack));
|
chunk.spawnEntity(new EntityItem(pos.xny().toDouble(), new Vec3d(0, 0, 0), stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class TileLadderUp extends Tile
|
||||||
// Cast to player
|
// Cast to player
|
||||||
EntityPlayer player = (EntityPlayer)entity;
|
EntityPlayer player = (EntityPlayer)entity;
|
||||||
if(player.in_animation) return;
|
if(player.in_animation) return;
|
||||||
player.height = 0;
|
player.getPos().y = 0;
|
||||||
player.in_animation = true;
|
player.in_animation = true;
|
||||||
|
|
||||||
// Register the animation
|
// Register the animation
|
||||||
|
|
@ -47,18 +47,18 @@ public class TileLadderUp extends Tile
|
||||||
player.moving = true;
|
player.moving = true;
|
||||||
|
|
||||||
if(movingPlayer == 0) {
|
if(movingPlayer == 0) {
|
||||||
player.height += 0.04;
|
player.getPos().y += 0.04;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(movingPlayer == 2) {
|
else if(movingPlayer == 2) {
|
||||||
player.height += 0.02;
|
player.getPos().y += 0.02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.height >= 6 && movingPlayer == 0)
|
if(player.getPos().y >= 8 && movingPlayer == 0)
|
||||||
{
|
{
|
||||||
movingPlayer = 1;
|
movingPlayer = 1;
|
||||||
Main.world.setLayer(state.meta);
|
Main.world.setLayer(state.meta);
|
||||||
player.height = -1;
|
player.getPos().y = -1;
|
||||||
|
|
||||||
if(layer.layergen.destroyOnLeave) {
|
if(layer.layergen.destroyOnLeave) {
|
||||||
Main.world.removeLayer(state.meta);
|
Main.world.removeLayer(state.meta);
|
||||||
|
|
@ -71,10 +71,10 @@ public class TileLadderUp extends Tile
|
||||||
MainloopEventHandler.MAINLOOP_EVENT_HANDLER.mspf = 1000/60;
|
MainloopEventHandler.MAINLOOP_EVENT_HANDLER.mspf = 1000/60;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(player.height >= 0 && movingPlayer == 2)
|
else if(player.getPos().y >= 0 && movingPlayer == 2)
|
||||||
{
|
{
|
||||||
movingPlayer = 3;
|
movingPlayer = 3;
|
||||||
player.height = 0;
|
player.getPos().y = 0;
|
||||||
player.moving = false;
|
player.moving = false;
|
||||||
player.in_animation = false;
|
player.in_animation = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.tiles;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityItem;
|
import projectzombie.entity.EntityItem;
|
||||||
import projectzombie.init.Items;
|
import projectzombie.init.Items;
|
||||||
|
|
@ -29,7 +30,7 @@ public class TileLantern extends Tile
|
||||||
super.onActivated(layer, tpos, entity, state);
|
super.onActivated(layer, tpos, entity, state);
|
||||||
|
|
||||||
layer.breakFrontTile(tpos);
|
layer.breakFrontTile(tpos);
|
||||||
layer.spawnEntity(new EntityItem(new Vec2d(tpos.x + 0.5, tpos.y + 0.5),
|
layer.spawnEntity(new EntityItem(tpos.toDouble().xny(), new Vec3d(0, 0, 0),
|
||||||
new ItemStack(Items.LANTERN, 1, (byte)0)));
|
new ItemStack(Items.LANTERN, 1, (byte)0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.particle.ParticleLava;
|
import projectzombie.entity.particle.ParticleLava;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
|
@ -41,15 +42,15 @@ public class TileLava extends Tile
|
||||||
super.onWalkedOn(chunk, layer, pos, entity, state);
|
super.onWalkedOn(chunk, layer, pos, entity, state);
|
||||||
|
|
||||||
// Create a lava particle
|
// Create a lava particle
|
||||||
layer.spawnEntity(new ParticleLava(entity.pos.copy()));
|
layer.spawnEntity(new ParticleLava(entity.getPos(), entity.getVelocity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tickRandomly(Layer layer, Chunk chunk, TileState state, Vec2i pos) {
|
public void tickRandomly(Layer layer, Chunk chunk, TileState state, Vec2i pos) {
|
||||||
super.tickRandomly(layer, chunk, state, pos);
|
super.tickRandomly(layer, chunk, state, pos);
|
||||||
|
|
||||||
chunk.spawnEntity(new ParticleLava(new Vec2d(
|
chunk.spawnEntity(new ParticleLava(new Vec3d(
|
||||||
pos.x + rand.nextDouble(), pos.y + rand.nextDouble())));
|
pos.x + rand.nextDouble(), 0, pos.y + rand.nextDouble()), new Vec3d(0, 0, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.particle.ParticleSmoke;
|
import projectzombie.entity.particle.ParticleSmoke;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
|
|
@ -32,8 +33,9 @@ public class TileLavaFlow extends Tile
|
||||||
super.tickRandomly(layer, chunk, state, pos);
|
super.tickRandomly(layer, chunk, state, pos);
|
||||||
|
|
||||||
if(RandomHelpers.randrange(rand, 5) == 0) {
|
if(RandomHelpers.randrange(rand, 5) == 0) {
|
||||||
chunk.spawnEntity(new ParticleSmoke(new Vec2d(
|
chunk.spawnEntity(new ParticleSmoke(new Vec3d(
|
||||||
pos.x + rand.nextDouble(), pos.y + rand.nextDouble())));
|
pos.x + rand.nextDouble(), 0, pos.y + rand.nextDouble()),
|
||||||
|
new Vec3d(0, 0, 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class TilePortalDown extends Tile
|
||||||
EntityPlayer player = (EntityPlayer)entity;
|
EntityPlayer player = (EntityPlayer)entity;
|
||||||
if(player.in_animation) return;
|
if(player.in_animation) return;
|
||||||
player.in_animation = true;
|
player.in_animation = true;
|
||||||
player.height = 0;
|
player.getPos().y = 0;
|
||||||
|
|
||||||
// Register the animation
|
// Register the animation
|
||||||
Main.mainloop.register(new IMainloopTask() {
|
Main.mainloop.register(new IMainloopTask() {
|
||||||
|
|
@ -46,18 +46,18 @@ public class TilePortalDown extends Tile
|
||||||
player.moving = true;
|
player.moving = true;
|
||||||
|
|
||||||
if(movingPlayer == 0) {
|
if(movingPlayer == 0) {
|
||||||
player.height -= 0.02;
|
player.getPos().y -= 0.02;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(movingPlayer == 2) {
|
else if(movingPlayer == 2) {
|
||||||
player.height -= 0.04;
|
player.getPos().y -= 0.04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.height < -1 && movingPlayer == 0)
|
if(player.getPos().y < -1 && movingPlayer == 0)
|
||||||
{
|
{
|
||||||
movingPlayer = 1;
|
movingPlayer = 1;
|
||||||
Main.world.setLayer(state.meta);
|
Main.world.setLayer(state.meta);
|
||||||
player.height = 6;
|
player.getPos().y = 8;
|
||||||
|
|
||||||
if(layer.layergen.destroyOnLeave) {
|
if(layer.layergen.destroyOnLeave) {
|
||||||
Main.world.removeLayer(state.meta);
|
Main.world.removeLayer(state.meta);
|
||||||
|
|
@ -104,10 +104,10 @@ public class TilePortalDown extends Tile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(player.height < 0 && movingPlayer == 2)
|
else if(player.getPos().y < 0 && movingPlayer == 2)
|
||||||
{
|
{
|
||||||
movingPlayer = 3;
|
movingPlayer = 3;
|
||||||
player.height = 0;
|
player.getPos().y = 0;
|
||||||
player.moving = false;
|
player.moving = false;
|
||||||
player.in_animation = false;
|
player.in_animation = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.tiles;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityItem;
|
import projectzombie.entity.EntityItem;
|
||||||
import projectzombie.init.Items;
|
import projectzombie.init.Items;
|
||||||
|
|
@ -31,7 +32,9 @@ public class TileRock extends Tile implements TileBulletBreakable
|
||||||
super.onActivated(layer, tpos, entity, state);
|
super.onActivated(layer, tpos, entity, state);
|
||||||
|
|
||||||
layer.breakFrontTile(tpos);
|
layer.breakFrontTile(tpos);
|
||||||
layer.spawnEntity(new EntityItem(new Vec2d(tpos.x + 0.5, tpos.y + 0.5), new ItemStack(Items.ROCK, 1, (byte)0)));
|
layer.spawnEntity(
|
||||||
|
new EntityItem(new Vec3d(tpos.x + 0.5, 0, tpos.y + 0.5),
|
||||||
|
new Vec3d(0, 0, 0), new ItemStack(Items.ROCK, 1, (byte)state.meta)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package projectzombie.tiles;
|
package projectzombie.tiles;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.particle.ParticleWater;
|
import projectzombie.entity.particle.ParticleWater;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
|
@ -24,7 +25,7 @@ public class TileWater extends Tile
|
||||||
super.onWalkedOn(chunk, layer, pos, entity, state);
|
super.onWalkedOn(chunk, layer, pos, entity, state);
|
||||||
|
|
||||||
// Spawn some water particles
|
// Spawn some water particles
|
||||||
layer.spawnEntity(new ParticleWater(pos.toDouble()));
|
layer.spawnEntity(new ParticleWater(pos.toDouble().xny(), new Vec3d(0, 0, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,22 @@ package projectzombie.util.math.astar;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
|
||||||
class Node
|
class Node
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
int g, h;
|
int g, h, s;
|
||||||
Node parent;
|
Node parent;
|
||||||
|
|
||||||
public Node(Node parent, int x, int y, int g, int h) {
|
public Node(Node parent, int x, int y, int g, int h, int s) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.g = g;
|
this.g = g;
|
||||||
this.h = h;
|
this.h = h;
|
||||||
|
this.s = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,10 +55,10 @@ public class AStar
|
||||||
}
|
}
|
||||||
|
|
||||||
this.goal = goal;
|
this.goal = goal;
|
||||||
this.open = new ArrayList<Node>();
|
this.open = new ArrayList<Node>(radius*4);
|
||||||
this.closed = new ArrayList<Node>();
|
this.closed = new ArrayList<Node>(radius*4);
|
||||||
|
|
||||||
now = new Node(null, start.x, start.y, 0, 0);
|
now = new Node(null, start.x, start.y, 0, 0, 1);
|
||||||
closed.add(now);
|
closed.add(now);
|
||||||
|
|
||||||
addNeighboursToList();
|
addNeighboursToList();
|
||||||
|
|
@ -67,21 +69,14 @@ public class AStar
|
||||||
if(found != null)
|
if(found != null)
|
||||||
{
|
{
|
||||||
Node n = found;
|
Node n = found;
|
||||||
|
Vec2i[] path = new Vec2i[n.s];
|
||||||
|
|
||||||
ArrayList<Vec2i> path = new ArrayList<Vec2i>();
|
for(int i=0;n!=null;i++) {
|
||||||
|
path[i] = new Vec2i(n.x, n.y);
|
||||||
while(n != null) {
|
|
||||||
path.add(new Vec2i(n.x, n.y));
|
|
||||||
n = n.parent;
|
n = n.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2i[] path2 = new Vec2i[path.size()];
|
return path;
|
||||||
|
|
||||||
for(int i=0;i<path2.length;i++) {
|
|
||||||
path2[(path2.length - 1) - i] = path.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return path2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int nid = getEasiestNode();
|
int nid = getEasiestNode();
|
||||||
|
|
@ -146,7 +141,7 @@ public class AStar
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new node
|
// Create a new node
|
||||||
Node node = new Node(now, x, y, g(weight, x, y), h(x, y));
|
Node node = new Node(now, x, y, g(weight, x, y), h(x, y), now.s + 1);
|
||||||
|
|
||||||
if(x == goal.x && y == goal.y) {
|
if(x == goal.x && y == goal.y) {
|
||||||
found = node;
|
found = node;
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,11 @@ public class AStarSearcher implements AStarSearch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tsf.tile.tileSolid || tsb.tile.tileSolid) {
|
if(tsf.tile.tileHitbox > 0 || tsb.tile.tileHitbox > 0) {
|
||||||
return 100;
|
return 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tsf.tile.tileHitbox > 0 || tsb.tile.tileHitbox > 0) {
|
if(tsf.tile.tileSolid || tsb.tile.tileSolid) {
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,11 @@ import gl_engine.range.Range2i;
|
||||||
import gl_engine.texture.TextureRef3D;
|
import gl_engine.texture.TextureRef3D;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
|
import projectzombie.Main;
|
||||||
import projectzombie.display.Camera;
|
import projectzombie.display.Camera;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityAlive;
|
import projectzombie.entity.EntityAlive;
|
||||||
import projectzombie.entity.EntityHeight;
|
|
||||||
import projectzombie.entity.EntityHoldsEntities;
|
import projectzombie.entity.EntityHoldsEntities;
|
||||||
import projectzombie.entity.EntityKillWithParticles;
|
import projectzombie.entity.EntityKillWithParticles;
|
||||||
import projectzombie.entity.particle.ParticleBreak;
|
import projectzombie.entity.particle.ParticleBreak;
|
||||||
|
|
@ -192,7 +193,7 @@ public class Chunk implements IBdfClassManager
|
||||||
}
|
}
|
||||||
|
|
||||||
IModel model = e.getModel();
|
IModel model = e.getModel();
|
||||||
double h = 0;
|
Vec3d pos = e.getPos();
|
||||||
|
|
||||||
if(e instanceof EntityHoldsEntities) {
|
if(e instanceof EntityHoldsEntities) {
|
||||||
renderEntities(((EntityHoldsEntities) e).getEntities());
|
renderEntities(((EntityHoldsEntities) e).getEntities());
|
||||||
|
|
@ -203,12 +204,10 @@ public class Chunk implements IBdfClassManager
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e instanceof EntityHeight) {
|
|
||||||
h = ((EntityHeight)e).getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render the model
|
// Render the model
|
||||||
model.setModel(Matrix4.translate(e.pos.x - 0.5, h, e.pos.y - 0.5));
|
model.setModel(Matrix4.translate(
|
||||||
|
(pos.x - Camera.camera.cx * 16) - 0.5, pos.y,
|
||||||
|
(pos.z - Camera.camera.cy * 16) - 0.5));
|
||||||
model.render();
|
model.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -291,7 +290,7 @@ public class Chunk implements IBdfClassManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render all the tiles in the chunk as a block
|
// Render all the tiles in the chunk as a block
|
||||||
model.setModel(Matrix4.translate(c_pos.x * 16, 0, c_pos.y * 16));
|
model.setModel(Matrix4.translate((c_pos.x - Camera.camera.cx) * 16, 0, (c_pos.y - Camera.camera.cy) * 16));
|
||||||
model.render();
|
model.render();
|
||||||
|
|
||||||
renderEntities(entities.toArray());
|
renderEntities(entities.toArray());
|
||||||
|
|
@ -338,8 +337,8 @@ public class Chunk implements IBdfClassManager
|
||||||
// Has the entity left the chunk
|
// Has the entity left the chunk
|
||||||
int cx = c_pos.x * CHUNK_SIZE.mx;
|
int cx = c_pos.x * CHUNK_SIZE.mx;
|
||||||
int cy = c_pos.y * CHUNK_SIZE.my;
|
int cy = c_pos.y * CHUNK_SIZE.my;
|
||||||
double px = e.pos.x;
|
double px = e.getPos().x;
|
||||||
double py = e.pos.y;
|
double py = e.getPos().z;
|
||||||
if(px > cx + CHUNK_SIZE.mx || px < cx || py > cy + CHUNK_SIZE.my || py < cy)
|
if(px > cx + CHUNK_SIZE.mx || px < cx || py > cy + CHUNK_SIZE.my || py < cy)
|
||||||
{
|
{
|
||||||
// Process the entity by layer and remove the entity from the array
|
// Process the entity by layer and remove the entity from the array
|
||||||
|
|
@ -435,7 +434,7 @@ public class Chunk implements IBdfClassManager
|
||||||
|
|
||||||
if(!ts.tile.unbreakable) {
|
if(!ts.tile.unbreakable) {
|
||||||
setBackTile(layer.layergen.getTileDestroyed(), pos);
|
setBackTile(layer.layergen.getTileDestroyed(), pos);
|
||||||
spawnEntity(new ParticleBreak(new Vec2d(pos.x + 0.5, pos.y + 0.5), ts.tile.getModel(ts.meta)));
|
spawnEntity(new ParticleBreak(new Vec3d(pos.x + 0.5, 0, pos.y + 0.5), new Vec3d(0, 0, 0), ts.tile.getModel(ts.meta)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -446,7 +445,7 @@ public class Chunk implements IBdfClassManager
|
||||||
|
|
||||||
if(!ts.tile.unbreakable) {
|
if(!ts.tile.unbreakable) {
|
||||||
setFrontTile(Tiles.VOID.getDefaultState(), pos);
|
setFrontTile(Tiles.VOID.getDefaultState(), pos);
|
||||||
spawnEntity(new ParticleBreak(new Vec2d(pos.x + 0.5, pos.y + 0.5), ts.tile.getModel(ts.meta)));
|
spawnEntity(new ParticleBreak(new Vec3d(pos.x + 0.5, 0, pos.y + 0.5), new Vec3d(0, 0, 0), ts.tile.getModel(ts.meta)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -527,13 +526,15 @@ public class Chunk implements IBdfClassManager
|
||||||
// Loop over the entities
|
// Loop over the entities
|
||||||
for(Entity e : entities)
|
for(Entity e : entities)
|
||||||
{
|
{
|
||||||
|
Vec2d epos = e.getPos().xz();
|
||||||
|
|
||||||
if(
|
if(
|
||||||
e.pos.x + distance > pos.x &&
|
epos.x + distance > pos.x &&
|
||||||
e.pos.x - distance < pos.x &&
|
epos.x - distance < pos.x &&
|
||||||
e.pos.y + distance > pos.y &&
|
epos.y + distance > pos.y &&
|
||||||
e.pos.y - distance < pos.y
|
epos.y - distance < pos.y
|
||||||
) {
|
) {
|
||||||
if(MathHelpers.distance2d(e.pos.x, e.pos.y, pos.x, pos.y) < distance) {
|
if(MathHelpers.distance2d(pos.x, pos.y, pos.x, pos.y) < distance) {
|
||||||
nearby_entities.add(e);
|
nearby_entities.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.world.chunk;
|
||||||
|
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.display.DisplayLighting;
|
import projectzombie.display.DisplayLighting;
|
||||||
|
|
@ -27,6 +28,7 @@ public class ChunkEventHandler implements IMainloopTask
|
||||||
public void MainLoopUpdate()
|
public void MainLoopUpdate()
|
||||||
{
|
{
|
||||||
// Get the layer
|
// Get the layer
|
||||||
|
Vec3d ppos = Main.player.getPos();
|
||||||
Layer layer = Main.world.getLayer();
|
Layer layer = Main.world.getLayer();
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
|
|
@ -34,8 +36,8 @@ public class ChunkEventHandler implements IMainloopTask
|
||||||
for(Map2DElement<Chunk> ce : layer.chunks)
|
for(Map2DElement<Chunk> ce : layer.chunks)
|
||||||
{
|
{
|
||||||
// Convert the player pos to x and y
|
// Convert the player pos to x and y
|
||||||
int px = (int)Main.player.pos.x / 16;
|
int px = (int)ppos.x / 16;
|
||||||
int py = (int)Main.player.pos.y / 16;
|
int py = (int)ppos.z / 16;
|
||||||
|
|
||||||
if(
|
if(
|
||||||
// Is this chunk beyond the simulation distance
|
// Is this chunk beyond the simulation distance
|
||||||
|
|
@ -54,8 +56,8 @@ public class ChunkEventHandler implements IMainloopTask
|
||||||
for(int y=-Chunk.SIMULATION_DISTANCE;y<Chunk.SIMULATION_DISTANCE;y++)
|
for(int y=-Chunk.SIMULATION_DISTANCE;y<Chunk.SIMULATION_DISTANCE;y++)
|
||||||
{
|
{
|
||||||
// Get the chunk based on the player position
|
// Get the chunk based on the player position
|
||||||
int cx = MathHelpers.floor(Main.player.pos.x / 16) + x;
|
int cx = MathHelpers.floor(ppos.x / 16) + x;
|
||||||
int cy = MathHelpers.floor(Main.player.pos.y / 16) + y;
|
int cy = MathHelpers.floor(ppos.z / 16) + y;
|
||||||
Vec2i c_pos = new Vec2i(cx, cy);
|
Vec2i c_pos = new Vec2i(cx, cy);
|
||||||
|
|
||||||
// Is this chunk not loaded
|
// Is this chunk not loaded
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import bdf.types.BdfObject;
|
||||||
import gl_engine.MathHelpers;
|
import gl_engine.MathHelpers;
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import gl_engine.vec.Vec2i;
|
import gl_engine.vec.Vec2i;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.display.Camera;
|
import projectzombie.display.Camera;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
|
|
@ -51,14 +52,16 @@ public class Layer implements IBdfClassManager
|
||||||
|
|
||||||
public void render(Camera camera)
|
public void render(Camera camera)
|
||||||
{
|
{
|
||||||
|
Vec2d ppos = Main.player.getPos().xz();
|
||||||
|
|
||||||
// Render every chunk in the players render distance
|
// Render every chunk in the players render distance
|
||||||
int r = Chunk.RENDER_DISTANCE;
|
int r = Chunk.RENDER_DISTANCE;
|
||||||
for(int x=-r;x<=r;x++) {
|
for(int x=-r;x<=r;x++) {
|
||||||
for(int y=-r;y<=r;y++)
|
for(int y=-r;y<=r;y++)
|
||||||
{
|
{
|
||||||
// Get the chunk x and y
|
// Get the chunk x and y
|
||||||
int cx = MathHelpers.floor(Main.player.pos.x / 16) + x;
|
int cx = MathHelpers.floor(ppos.x / 16) + x;
|
||||||
int cy = MathHelpers.floor(Main.player.pos.y / 16) + y;
|
int cy = MathHelpers.floor(ppos.y / 16) + y;
|
||||||
|
|
||||||
// Render the chunk
|
// Render the chunk
|
||||||
chunks.get(new Vec2i(cx, cy)).render(camera);
|
chunks.get(new Vec2i(cx, cy)).render(camera);
|
||||||
|
|
@ -186,7 +189,7 @@ public class Layer implements IBdfClassManager
|
||||||
public void spawnEntity(Entity entity)
|
public void spawnEntity(Entity entity)
|
||||||
{
|
{
|
||||||
// Get the chunk pos
|
// Get the chunk pos
|
||||||
Vec2i c_pos = getChunkPosFromPos(entity.pos);
|
Vec2i c_pos = getChunkPosFromPos(entity.getPos().xz().toInt());
|
||||||
|
|
||||||
// Spawn the entity in the specified chunk
|
// Spawn the entity in the specified chunk
|
||||||
chunks.get(c_pos).spawnEntity(entity);
|
chunks.get(c_pos).spawnEntity(entity);
|
||||||
|
|
@ -245,15 +248,17 @@ public class Layer implements IBdfClassManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vec3d ppos = Main.player.getPos();
|
||||||
|
|
||||||
// Check if the player is close enough
|
// Check if the player is close enough
|
||||||
if(
|
if(
|
||||||
Main.player.pos.x + distance > pos.x &&
|
ppos.x + distance > pos.x &&
|
||||||
Main.player.pos.x - distance < pos.x &&
|
ppos.x - distance < pos.x &&
|
||||||
Main.player.pos.y + distance > pos.y &&
|
ppos.z + distance > pos.y &&
|
||||||
Main.player.pos.y - distance < pos.y
|
ppos.z - distance < pos.y
|
||||||
) {
|
) {
|
||||||
// Add the player to the list of entities
|
// Add the player to the list of entities
|
||||||
if(MathHelpers.distance2d(Main.player.pos.x, Main.player.pos.y, pos.x, pos.y) < distance) {
|
if(MathHelpers.distance2d(ppos.x, ppos.z, pos.x, pos.y) < distance) {
|
||||||
entities.add(Main.player);
|
entities.add(Main.player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class LayerGenBossArena extends LayerGen implements LayerGenRememberPlaye
|
||||||
{
|
{
|
||||||
private final Vec2i center = new Vec2i(0, 0);
|
private final Vec2i center = new Vec2i(0, 0);
|
||||||
private final int size = 10;
|
private final int size = 10;
|
||||||
private Vec2d player_pos = new Vec2d(0, 0);
|
private Vec3d player_pos = new Vec3d(0, 0, 0);
|
||||||
private Random rand = new Random();
|
private Random rand = new Random();
|
||||||
|
|
||||||
public LayerGenBossArena() {
|
public LayerGenBossArena() {
|
||||||
|
|
@ -66,7 +66,7 @@ public class LayerGenBossArena extends LayerGen implements LayerGenRememberPlaye
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tpos.x == 0 && tpos.y == 0) {
|
if(tpos.x == 0 && tpos.y == 0) {
|
||||||
chunk.spawnEntity(new EntityBoss(new Vec2d(0, 0)));
|
chunk.spawnEntity(new EntityBoss(new Vec3d(0, 0, 0), new Vec3d(0, 0, 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -103,16 +103,16 @@ public class LayerGenBossArena extends LayerGen implements LayerGenRememberPlaye
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec2d getPlayerPos() {
|
public Vec3d getPlayerPos() {
|
||||||
return player_pos;
|
return player_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnPlayer(EntityPlayer player) {
|
public void spawnPlayer(EntityPlayer player) {
|
||||||
this.player_pos = player.pos;
|
this.player_pos = player.getPos();
|
||||||
player.pos = new Vec2d(
|
player.setPos(new Vec3d(
|
||||||
RandomHelpers.randrange(rand, -size + 2, size - 2),
|
RandomHelpers.randrange(rand, -size + 2, size - 2), 0,
|
||||||
RandomHelpers.randrange(rand, -size + 2, size - 2));
|
RandomHelpers.randrange(rand, -size + 2, size - 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -114,13 +114,14 @@ public class LayerGenCaves extends LayerGen
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawn entities
|
// Spawn entities
|
||||||
Entity zombie = new EntityZombie(new Vec2d(
|
Entity zombie = new EntityZombie(new Vec3d(
|
||||||
chunk.c_pos.x * 16 + RandomHelpers.randrange(rand, 0, 16),
|
chunk.c_pos.x * 16 + RandomHelpers.randrange(rand, 0, 16), 0,
|
||||||
chunk.c_pos.y * 16 + RandomHelpers.randrange(rand, 0, 16)));
|
chunk.c_pos.y * 16 + RandomHelpers.randrange(rand, 0, 16)),
|
||||||
|
new Vec3d(0, 0, 0));
|
||||||
|
|
||||||
if(
|
if(
|
||||||
chunk.getBackTile(new Vec2i((int)zombie.pos.x,
|
chunk.getBackTile(new Vec2i((int)zombie.getPos().x,
|
||||||
(int)zombie.pos.y)).tile == getTileDestroyed().tile
|
(int)zombie.getPos().z)).tile == getTileDestroyed().tile
|
||||||
) {
|
) {
|
||||||
chunk.spawnEntity(zombie);
|
chunk.spawnEntity(zombie);
|
||||||
}
|
}
|
||||||
|
|
@ -131,13 +132,17 @@ public class LayerGenCaves extends LayerGen
|
||||||
{
|
{
|
||||||
if(rand.nextDouble() > 0.9)
|
if(rand.nextDouble() > 0.9)
|
||||||
{
|
{
|
||||||
Entity zombie = new EntityZombie(new Vec2d(
|
Vec3d ppos = Main.player.getPos();
|
||||||
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)));
|
|
||||||
|
|
||||||
|
Entity zombie = new EntityZombie(new Vec3d(
|
||||||
|
RandomHelpers.randrange(rand, (int)ppos.x - 128, (int)ppos.x + 128), 0,
|
||||||
|
RandomHelpers.randrange(rand, (int)ppos.z - 128, (int)ppos.z + 128)),
|
||||||
|
new Vec3d(0, 0, 0));
|
||||||
|
|
||||||
|
Vec3d zpos = zombie.getPos();
|
||||||
boolean exists = false;
|
boolean exists = false;
|
||||||
|
|
||||||
for(Entity e : layer.getChunk(zombie.pos).entities) {
|
for(Entity e : layer.getChunk(zpos.xz()).entities) {
|
||||||
if(e.getClass() == zombie.getClass()) {
|
if(e.getClass() == zombie.getClass()) {
|
||||||
exists = true;
|
exists = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -145,9 +150,9 @@ public class LayerGenCaves extends LayerGen
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
!exists && layer.getBackTile(new Vec2i((int)zombie.pos.x,
|
!exists && layer.getBackTile(new Vec2i((int)zpos.x,
|
||||||
(int)zombie.pos.y)).tile == getTileDestroyed().tile &&
|
(int)zpos.z)).tile == getTileDestroyed().tile &&
|
||||||
zombie.pos.squareDistance(Main.player.pos) > 32
|
zpos.squareDistance(ppos) > 32
|
||||||
) {
|
) {
|
||||||
layer.spawnEntity(zombie);
|
layer.spawnEntity(zombie);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,20 +120,23 @@ public class LayerGenEarth extends LayerGen
|
||||||
{
|
{
|
||||||
if(rand.nextDouble() > 0.98 && getEarthLight() < -0.3)
|
if(rand.nextDouble() > 0.98 && getEarthLight() < -0.3)
|
||||||
{
|
{
|
||||||
Entity zombie = new EntityZombie(new Vec2d(
|
Vec3d ppos = Main.player.getPos();
|
||||||
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)));
|
Entity zombie = new EntityZombie(new Vec3d(
|
||||||
|
RandomHelpers.randrange(rand, (int)ppos.x - 128, (int)ppos.x + 128), 0,
|
||||||
|
RandomHelpers.randrange(rand, (int)ppos.y - 128, (int)ppos.y + 128)),
|
||||||
|
new Vec3d(0, 0, 0));
|
||||||
|
|
||||||
boolean exists = false;
|
boolean exists = false;
|
||||||
|
|
||||||
for(Entity e : layer.getChunk(zombie.pos).entities) {
|
for(Entity e : layer.getChunk(zombie.getPos().xz()).entities) {
|
||||||
if(e.getClass() == zombie.getClass()) {
|
if(e.getClass() == zombie.getClass()) {
|
||||||
exists = true;
|
exists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!exists && zombie.pos.squareDistance(Main.player.pos) > 64) {
|
if(!exists && zombie.getPos().squareDistance(ppos) > 64) {
|
||||||
layer.spawnEntity(zombie);
|
layer.spawnEntity(zombie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,13 +121,17 @@ public class LayerGenLavaCaves extends LayerGen
|
||||||
{
|
{
|
||||||
if(rand.nextDouble() > 0.9)
|
if(rand.nextDouble() > 0.9)
|
||||||
{
|
{
|
||||||
Entity zombie = new EntityZombieArmored(new Vec2d(
|
Vec3d ppos = Main.player.getPos();
|
||||||
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)));
|
|
||||||
|
|
||||||
|
Entity zombie = new EntityZombieArmored(new Vec3d(
|
||||||
|
RandomHelpers.randrange(rand, (int)ppos.x - 128, (int)ppos.x + 128), 0,
|
||||||
|
RandomHelpers.randrange(rand, (int)ppos.z - 128, (int)ppos.z + 128)),
|
||||||
|
new Vec3d(0, 0, 0));
|
||||||
|
|
||||||
|
Vec3d zpos = zombie.getPos();
|
||||||
boolean exists = false;
|
boolean exists = false;
|
||||||
|
|
||||||
for(Entity e : layer.getChunk(zombie.pos).entities) {
|
for(Entity e : layer.getChunk(zpos.xz()).entities) {
|
||||||
if(e.getClass() == zombie.getClass()) {
|
if(e.getClass() == zombie.getClass()) {
|
||||||
exists = true;
|
exists = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -136,15 +140,15 @@ public class LayerGenLavaCaves extends LayerGen
|
||||||
|
|
||||||
if(!exists)
|
if(!exists)
|
||||||
{
|
{
|
||||||
TileState tsb = layer.getBackTile(new Vec2i((int)zombie.pos.x,
|
TileState tsb = layer.getBackTile(new Vec2i((int)zpos.x,
|
||||||
(int)zombie.pos.y));
|
(int)zpos.z));
|
||||||
TileState tsf = layer.getFrontTile(new Vec2i((int)zombie.pos.x,
|
TileState tsf = layer.getFrontTile(new Vec2i((int)zpos.x,
|
||||||
(int)zombie.pos.y));
|
(int)zpos.z));
|
||||||
|
|
||||||
if(
|
if(
|
||||||
tsb.tile == getTileDestroyed().tile &&
|
tsb.tile == getTileDestroyed().tile &&
|
||||||
tsf.tile == Tiles.VOID &&
|
tsf.tile == Tiles.VOID &&
|
||||||
zombie.pos.squareDistance(Main.player.pos) > 32) {
|
zpos.squareDistance(ppos) > 32) {
|
||||||
layer.spawnEntity(zombie);
|
layer.spawnEntity(zombie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
package projectzombie.world.layer.layergen;
|
package projectzombie.world.layer.layergen;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
|
|
||||||
public interface LayerGenRememberPlayerPos
|
public interface LayerGenRememberPlayerPos
|
||||||
{
|
{
|
||||||
public Vec2d getPlayerPos();
|
public Vec3d getPlayerPos();
|
||||||
public void spawnPlayer(EntityPlayer player);
|
public void spawnPlayer(EntityPlayer player);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ vec3 interpolate2RGB(float x, float y, vec3 v00, vec3 v01, vec3 v10, vec3 v11) {
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 light = texture(lightmap, vec2(
|
vec4 light = texture(lightmap, vec2(
|
||||||
map((pLightMapPos.x), lightmap_offset.x, lightmap_offset.x + lightmap_size.x, 0, 1),
|
map(pLightMapPos.x, lightmap_offset.x, lightmap_offset.x + lightmap_size.x, 0, 1),
|
||||||
map((pLightMapPos.z), lightmap_offset.y, lightmap_offset.y + lightmap_size.y, 0, 1)));
|
map(pLightMapPos.z, lightmap_offset.y, lightmap_offset.y + lightmap_size.y, 0, 1)));
|
||||||
|
|
||||||
vec3 light_day = mapVec(scaleLight(light.r), 0, 1, lighting_day_low, lighting_day_high);
|
vec3 light_day = mapVec(scaleLight(light.r), 0, 1, lighting_day_low, lighting_day_high);
|
||||||
vec3 light_src = vec3(1, 1, 1) * (scaleLight(light.g) - abs(pLightMapPos.y) * 0.1);
|
vec3 light_src = vec3(1, 1, 1) * (scaleLight(light.g) - abs(pLightMapPos.y) * 0.1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue