Added a save menu, fixed issues with loading from saves, updated to BDF

3, started working on a crafting system.
This commit is contained in:
josua 2020-07-27 11:13:24 +10:00
parent fdf5fad146
commit 507e1ada0e
111 changed files with 1648 additions and 775 deletions

View File

@ -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.4.jar"/> <classpathentry kind="lib" path="/home/josua/code/Java Libraries/binary-data-format-v3.0.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

3
.gitignore vendored
View File

@ -1,4 +1,3 @@
/bin/ /bin/
hs_err_pid* hs_err_pid*
settings.bdf *.bdf
layer.bdf

View File

@ -1,5 +1,7 @@
package projectzombie; package projectzombie;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.io.IOException; import java.io.IOException;
import java.util.Random; import java.util.Random;
@ -9,14 +11,11 @@ import projectzombie.audio.AudioEngine;
import projectzombie.audio.AudioSources; import projectzombie.audio.AudioSources;
import projectzombie.display.DisplayStatsEventHandler; import projectzombie.display.DisplayStatsEventHandler;
import projectzombie.display.DisplayWindow; import projectzombie.display.DisplayWindow;
import projectzombie.display.bossbar.BossBars;
import projectzombie.entity.EntityEventHandler; import projectzombie.entity.EntityEventHandler;
import projectzombie.entity.player.EntityPlayer; import projectzombie.entity.player.EntityPlayer;
import projectzombie.init.Entities; import projectzombie.init.Entities;
import projectzombie.init.Items; import projectzombie.init.Items;
import projectzombie.init.LayerGenerators; import projectzombie.init.LayerGenerators;
import projectzombie.init.Layers;
import projectzombie.init.Models;
import projectzombie.init.Resources; import projectzombie.init.Resources;
import projectzombie.init.Sounds; import projectzombie.init.Sounds;
import projectzombie.init.Tasks; import projectzombie.init.Tasks;
@ -38,6 +37,7 @@ import projectzombie.world.chunk.ChunkEventHandler;
public class Main public class Main
{ {
public static Clipboard clipboard;
public static MainloopManager mainloop; public static MainloopManager mainloop;
public static DisplayWindow window; public static DisplayWindow window;
public static EntityPlayer player; public static EntityPlayer player;
@ -51,14 +51,18 @@ public class Main
public static void main(String[] args) throws IOException public static void main(String[] args) throws IOException
{ {
try
{
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
worker = new Worker();
worker.start();
MathHelpers.init(); MathHelpers.init();
Settings.init(); Settings.init();
Environment.init(args); Environment.init(args);
Cheats.init(args); Cheats.init(args);
worker = new Worker();
worker.start();
Items.init(); Items.init();
Entities.init(); Entities.init();
Tasks.init(); Tasks.init();
@ -99,8 +103,16 @@ public class Main
// Start the mainloop // Start the mainloop
menu = new MenuMain(); menu = new MenuMain();
mainloop.start(); mainloop.start();
}
catch(IOException e) {
e.printStackTrace();
}
finally
{
// Kill the worker thread // Kill the worker thread
worker.kill(); worker.kill();
} }
} }
}

View File

@ -3,9 +3,7 @@ package projectzombie.display;
import gl_engine.matrix.Matrix4; import gl_engine.matrix.Matrix4;
import gl_engine.vec.Vec3d; import gl_engine.vec.Vec3d;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.time.GameTimer;
import projectzombie.world.chunk.Chunk; import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer;
public class Camera public class Camera
{ {

View File

@ -26,7 +26,7 @@ public class DisplayLighting
int x, y; int x, y;
private int getID(int x, int y) { private int getID(int x, int y) {
return (x + y * w) * 4 + 1; return (x + y * w) * 3;
} }
} }
@ -87,7 +87,7 @@ public class DisplayLighting
lighting_dirty = false; lighting_dirty = false;
int size = (Chunk.RENDER_DISTANCE * 2 + 1) * 16; int size = (Chunk.RENDER_DISTANCE * 2 + 1) * 16;
float[] lights = new float[size * size * 3]; float[] lights = new float[size * size * 2];
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++)
@ -115,14 +115,11 @@ public class DisplayLighting
ft.tile.getLightLevel(ft, tpos), ft.tile.getLightLevel(ft, tpos),
bt.tile.getLightLevel(bt, tpos)); bt.tile.getLightLevel(bt, tpos));
float lightSun = ft.tile.passNaturalLight && bt.tile.passNaturalLight ? 1 : 0;
int id = ((cx * 16 + x + Chunk.RENDER_DISTANCE * 16) + int id = ((cx * 16 + x + Chunk.RENDER_DISTANCE * 16) +
(cy * 16 + y + Chunk.RENDER_DISTANCE * 16) * size) * 3; (cy * 16 + y + Chunk.RENDER_DISTANCE * 16) * size) * 2;
lights[id+0] = lightSun; lights[id+0] = lightSrc;
lights[id+1] = lightSrc; lights[id+1] = transparency;
lights[id+2] = transparency;
} }
} }
} }
@ -259,7 +256,7 @@ public class DisplayLighting
if(lighting_new) if(lighting_new)
{ {
for(int i=0;i<lighting.p.length/4;i++) for(int i=0;i<lighting.p.length/3;i++)
{ {
int x = i % lighting.w; int x = i % lighting.w;
int y = i / lighting.w; int y = i / lighting.w;
@ -267,8 +264,7 @@ public class DisplayLighting
Vec2i tpos = new Vec2i(x + lighting.x * 16, y + lighting.y * 16); Vec2i tpos = new Vec2i(x + lighting.x * 16, y + lighting.y * 16);
// Store light level data from the image // Store light level data from the image
layer.setDaylightLevel(lighting.p[i*4+0], tpos); layer.setLightLevel(lighting.p[i*3+1], tpos);
layer.setLightLevel(lighting.p[i*4+1], tpos);
} }
lighting_new = false; lighting_new = false;
@ -285,8 +281,8 @@ public class DisplayLighting
if(lighting_last_x != lighting.w || lighting_last_y != lighting.h) if(lighting_last_x != lighting.w || lighting_last_y != lighting.h)
{ {
GL33.glTexImage2D(GL33.GL_TEXTURE_2D, 0, GL33.GL_RGBA, GL33.glTexImage2D(GL33.GL_TEXTURE_2D, 0, GL33.GL_RGB,
lighting.w, lighting.h, 0, GL33.GL_RGBA, GL33.GL_UNSIGNED_BYTE, pixels_b); lighting.w, lighting.h, 0, GL33.GL_RGB, GL33.GL_UNSIGNED_BYTE, pixels_b);
lighting_last_x = lighting.w; lighting_last_x = lighting.w;
lighting_last_y = lighting.h; lighting_last_y = lighting.h;
@ -294,7 +290,7 @@ public class DisplayLighting
else { else {
GL33.glTexSubImage2D(GL33.GL_TEXTURE_2D, 0, 0, 0, GL33.glTexSubImage2D(GL33.GL_TEXTURE_2D, 0, 0, 0,
lighting.w, lighting.h, GL33.GL_RGBA, GL33.GL_UNSIGNED_BYTE, pixels_b); lighting.w, lighting.h, GL33.GL_RGB, GL33.GL_UNSIGNED_BYTE, pixels_b);
} }
GL33.glGenerateMipmap(GL33.GL_TEXTURE_2D); GL33.glGenerateMipmap(GL33.GL_TEXTURE_2D);
@ -331,11 +327,10 @@ public class DisplayLighting
int x = nl.get("x").getInteger(); int x = nl.get("x").getInteger();
int y = nl.get("y").getInteger(); int y = nl.get("y").getInteger();
float[] pixels = new float[width*height*4]; float[] pixels = new float[width*height*3];
for(int i=0;i<width*height;i++) { for(int i=0;i<width*height;i++) {
pixels[i*4+0] = light[i*2+0]; pixels[i*3] = light[i];
pixels[i*4+1] = light[i*2+1];
} }
Lighting lighting = new Lighting(); Lighting lighting = new Lighting();
@ -350,12 +345,12 @@ public class DisplayLighting
for(int x2=0;x2<lighting.w;x2++) { for(int x2=0;x2<lighting.w;x2++) {
for(int y2=0;y2<lighting.h;y2++) for(int y2=0;y2<lighting.h;y2++)
{ {
int i = (x2 + y2 * lighting.w) * 4; int i = (x2 + y2 * lighting.w) * 3;
// Send temperature and humidity data to the image // Send temperature and humidity data to the image
pixels[i+2] = (float)layer.layergen.getTemperatureStatic( pixels[i+1] = (float)layer.layergen.getTemperatureStatic(
layer, new Vec2d(x2 + lighting.x * 16, y2 + lighting.y * 16)); layer, new Vec2d(x2 + lighting.x * 16, y2 + lighting.y * 16));
pixels[i+3] = (float)layer.layergen.getHumidity( pixels[i+2] = (float)layer.layergen.getHumidity(
layer, new Vec2d(x2 + lighting.x * 16, y2 + lighting.y * 16)); layer, new Vec2d(x2 + lighting.x * 16, y2 + lighting.y * 16));
} }
} }

View File

@ -9,15 +9,11 @@ import java.nio.ByteBuffer;
import org.lwjgl.opengl.GL33; import org.lwjgl.opengl.GL33;
import gl_engine.MathHelpers;
import gl_engine.matrix.Matrix4; import gl_engine.matrix.Matrix4;
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.settings.SettingQuality; import projectzombie.settings.SettingQuality;
import projectzombie.util.math.ColorRange; import projectzombie.util.math.ColorRange;
import projectzombie.world.chunk.Chunk;
import projectzombie.world.chunk.ChunkEventHandler; import projectzombie.world.chunk.ChunkEventHandler;
import projectzombie.world.layer.layergen.LayerGen; import projectzombie.world.layer.layergen.LayerGen;

View File

@ -7,7 +7,6 @@ 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;

View File

@ -5,7 +5,6 @@ import java.lang.reflect.InvocationTargetException;
import java.util.Random; import java.util.Random;
import bdf.classes.IBdfClassManager; import bdf.classes.IBdfClassManager;
import bdf.types.BdfArray;
import bdf.types.BdfNamedList; import bdf.types.BdfNamedList;
import bdf.types.BdfObject; import bdf.types.BdfObject;
import gl_engine.MathHelpers; import gl_engine.MathHelpers;
@ -126,19 +125,17 @@ public abstract class Entity implements IBdfClassManager
} }
public Entity(BdfObject bdf) { public Entity(BdfObject bdf) {
this.BdfClassLoad(bdf);
} }
@Override @Override
public void BdfClassLoad(BdfObject bdf) { public void BdfClassLoad(BdfObject bdf) {
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
BdfArray e = nl.get("e").getArray(); pos = new Vec3d(nl.get("pos"));
pos = new Vec3d(e.get(0)); velocity = new Vec3d(nl.get("velocity"));
velocity = new Vec3d(e.get(1)); hitbox = nl.get("hitbox").getDouble();
hitbox = e.get(2).getDouble(); isSolid = nl.get("isSolid").getBoolean();
isSolid = e.get(3).getBoolean(); emitsLight = nl.get("emitsLight").getBoolean();
emitsLight = e.get(6).getBoolean(); hasGravity = nl.get("hasGravity").getBoolean();
hasGravity = e.get(8).getBoolean();
} }
@Override @Override
@ -149,20 +146,20 @@ public abstract class Entity implements IBdfClassManager
if(id == -1) return; if(id == -1) return;
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("id", BdfObject.withInteger(getID())); nl.set("id", bdf.newObject().setInteger(getID()));
BdfObject pos_bdf = new BdfObject(); BdfObject pos_bdf = bdf.newObject();
pos.BdfClassSave(pos_bdf); pos.BdfClassSave(pos_bdf);
BdfObject velocity_bdf = new BdfObject(); BdfObject velocity_bdf = bdf.newObject();
velocity.BdfClassSave(velocity_bdf); velocity.BdfClassSave(velocity_bdf);
nl.set("pos", pos_bdf); nl.set("pos", pos_bdf);
nl.set("velocity", velocity_bdf); nl.set("velocity", velocity_bdf);
nl.set("hitbox", BdfObject.withDouble(hitbox)); nl.set("hitbox", bdf.newObject().setDouble(hitbox));
nl.set("isSolid", BdfObject.withBoolean(isSolid)); nl.set("isSolid", bdf.newObject().setBoolean(isSolid));
nl.set("emitsLight", BdfObject.withBoolean(emitsLight)); nl.set("emitsLight", bdf.newObject().setBoolean(emitsLight));
nl.set("hasGravity", BdfObject.withBoolean(hasGravity)); nl.set("hasGravity", bdf.newObject().setBoolean(hasGravity));
} }
public void tick(Chunk chunk, Layer layer) public void tick(Chunk chunk, Layer layer)
@ -206,7 +203,7 @@ public abstract class Entity implements IBdfClassManager
if(new_pos.y > 0) { if(new_pos.y > 0) {
pos.y = new_pos.y; pos.y = new_pos.y;
} else { } else if(pos.y >= 0) {
velocity.y *= -0.25; velocity.y *= -0.25;
velocity.x *= slipperiness; velocity.x *= slipperiness;
velocity.z *= slipperiness; velocity.z *= slipperiness;

View File

@ -42,6 +42,8 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
public EntityBoss(BdfObject bdf) { public EntityBoss(BdfObject bdf) {
super(bdf); super(bdf);
BdfClassLoad(bdf);
} }
@Override @Override
@ -72,10 +74,10 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
super.BdfClassSave(bdf); super.BdfClassSave(bdf);
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("health", BdfObject.withDouble(health)); nl.set("health", bdf.newObject().setDouble(health));
nl.set("bullet_freq", BdfObject.withInteger(bullet_frequency)); nl.set("bullet_freq", bdf.newObject().setInteger(bullet_frequency));
nl.set("spawn_freq", BdfObject.withInteger(spawn_frequency)); nl.set("spawn_freq", bdf.newObject().setInteger(spawn_frequency));
nl.set("seed", BdfObject.withLong(seed)); nl.set("seed", bdf.newObject().setLong(seed));
} }
public EntityBoss(Vec3d pos, Vec3d velocity) { public EntityBoss(Vec3d pos, Vec3d velocity) {

View File

@ -7,10 +7,8 @@ import gl_engine.vec.Vec2d;
import gl_engine.vec.Vec2i; import gl_engine.vec.Vec2i;
import gl_engine.vec.Vec3d; import gl_engine.vec.Vec3d;
import projectzombie.entity.particle.ParticleBlood; import projectzombie.entity.particle.ParticleBlood;
import projectzombie.init.Models;
import projectzombie.init.Resources; import projectzombie.init.Resources;
import projectzombie.init.Sounds; import projectzombie.init.Sounds;
import projectzombie.model.Model;
import projectzombie.tiles.Tile; import projectzombie.tiles.Tile;
import projectzombie.tiles.TileBulletBreakable; import projectzombie.tiles.TileBulletBreakable;
import projectzombie.util.math.random.RandomHelpers; import projectzombie.util.math.random.RandomHelpers;
@ -28,6 +26,8 @@ public class EntityBullet extends EntityParticle
public EntityBullet(BdfObject bdf) { public EntityBullet(BdfObject bdf) {
super(bdf); super(bdf);
BdfClassLoad(bdf);
} }
@Override @Override
@ -44,8 +44,8 @@ public class EntityBullet extends EntityParticle
super.BdfClassSave(bdf); super.BdfClassSave(bdf);
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("time", BdfObject.withInteger(time)); nl.set("time", bdf.newObject().setInteger(time));
nl.set("damage", BdfObject.withDouble(damage)); nl.set("damage", bdf.newObject().setDouble(damage));
} }
public EntityBullet(Vec3d pos, Vec3d velocity, Entity parent, double damage, int despawn_time) { public EntityBullet(Vec3d pos, Vec3d velocity, Entity parent, double damage, int despawn_time) {

View File

@ -15,6 +15,8 @@ public class EntityContainer extends Entity implements EntityHoldsEntities
public EntityContainer(BdfObject bdf) { public EntityContainer(BdfObject bdf) {
super(bdf); super(bdf);
BdfClassLoad(bdf);
} }
public EntityContainer(Vec3d pos, Vec3d velocity, Entity[] entities) { public EntityContainer(Vec3d pos, Vec3d velocity, Entity[] entities) {
@ -77,9 +79,9 @@ public class EntityContainer extends Entity implements EntityHoldsEntities
super.BdfClassSave(bdf); super.BdfClassSave(bdf);
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
BdfArray array = new BdfArray(); BdfArray array = bdf.newArray();
nl.set("entities", BdfObject.withArray(array)); nl.set("entities", bdf.newObject().setArray(array));
for(int i=0;i<entities.length;i++) for(int i=0;i<entities.length;i++)
{ {
@ -89,7 +91,7 @@ public class EntityContainer extends Entity implements EntityHoldsEntities
continue; continue;
} }
BdfObject e_bdf = new BdfObject(); BdfObject e_bdf = bdf.newObject();
e.BdfClassSave(e_bdf); e.BdfClassSave(e_bdf);
array.add(e_bdf); array.add(e_bdf);

View File

@ -9,6 +9,8 @@ public class EntityDummy extends Entity implements EntityAlive
{ {
public EntityDummy(BdfObject bdf) { public EntityDummy(BdfObject bdf) {
super(bdf); super(bdf);
BdfClassLoad(bdf);
} }
public EntityDummy(Vec3d pos, Vec3d velocity) { public EntityDummy(Vec3d pos, Vec3d velocity) {

View File

@ -24,6 +24,8 @@ public class EntityExplosion extends Entity
public EntityExplosion(BdfObject bdf) { public EntityExplosion(BdfObject bdf) {
super(bdf); super(bdf);
BdfClassLoad(bdf);
} }
public EntityExplosion(Vec3d pos, int radius, double damage) { public EntityExplosion(Vec3d pos, int radius, double damage) {
@ -46,8 +48,8 @@ public class EntityExplosion extends Entity
super.BdfClassSave(bdf); super.BdfClassSave(bdf);
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("damage", BdfObject.withDouble(damage)); nl.set("damage", bdf.newObject().setDouble(damage));
nl.set("radius", BdfObject.withInteger(radius)); nl.set("radius", bdf.newObject().setInteger(radius));
} }
@Override @Override

View File

@ -19,6 +19,8 @@ public class EntityGrapplingHook extends Entity
public EntityGrapplingHook(BdfObject bdf) { public EntityGrapplingHook(BdfObject bdf) {
super(bdf); super(bdf);
BdfClassLoad(bdf);
} }
@Override @Override
@ -35,8 +37,8 @@ public class EntityGrapplingHook extends Entity
super.BdfClassSave(bdf); super.BdfClassSave(bdf);
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("layer", BdfObject.withInteger(layerId)); nl.set("layer", bdf.newObject().setInteger(layerId));
nl.set("height", BdfObject.withDouble(height)); nl.set("height", bdf.newObject().setDouble(height));
} }
public EntityGrapplingHook(Vec3d pos, int layerId, Entity entity) { public EntityGrapplingHook(Vec3d pos, int layerId, Entity entity) {

View File

@ -1,7 +1,6 @@
package projectzombie.entity; package projectzombie.entity;
import projectzombie.inventory.IInventoryArmor; import projectzombie.inventory.IInventoryArmor;
import projectzombie.inventory.InventoryArmor;
public interface EntityHasArmor { public interface EntityHasArmor {
public IInventoryArmor getInventoryArmor(); public IInventoryArmor getInventoryArmor();

View File

@ -1,8 +1,6 @@
package projectzombie.entity; package projectzombie.entity;
import projectzombie.inventory.IInventoryClothing; import projectzombie.inventory.IInventoryClothing;
import projectzombie.inventory.InventoryArmor;
import projectzombie.inventory.InventoryClothing;
public interface EntityHasClothing { public interface EntityHasClothing {
public IInventoryClothing getInventoryClothing(); public IInventoryClothing getInventoryClothing();

View File

@ -1,7 +1,6 @@
package projectzombie.entity; package projectzombie.entity;
import projectzombie.inventory.IInventory; import projectzombie.inventory.IInventory;
import projectzombie.inventory.Inventory;
public interface EntityHasInventory public interface EntityHasInventory
{ {

View File

@ -4,7 +4,6 @@ import bdf.types.BdfNamedList;
import bdf.types.BdfObject; import bdf.types.BdfObject;
import gl_engine.MathHelpers; import gl_engine.MathHelpers;
import gl_engine.vec.Vec3d; import gl_engine.vec.Vec3d;
import projectzombie.model.Model;
import projectzombie.model.ModelItem; import projectzombie.model.ModelItem;
import projectzombie.util.math.ItemStack; import projectzombie.util.math.ItemStack;
import projectzombie.world.chunk.Chunk; import projectzombie.world.chunk.Chunk;
@ -18,6 +17,8 @@ public class EntityItem extends EntityParticle
public EntityItem(BdfObject bdf) { public EntityItem(BdfObject bdf) {
super(bdf); super(bdf);
BdfClassLoad(bdf);
} }
@Override @Override
@ -40,8 +41,8 @@ public class EntityItem extends EntityParticle
stack.BdfClassSave(nl.get("stack")); stack.BdfClassSave(nl.get("stack"));
nl.set("pickup", BdfObject.withInteger(pickup_time)); nl.set("pickup", bdf.newObject().setInteger(pickup_time));
nl.set("age", BdfObject.withLong(age)); nl.set("age", bdf.newObject().setLong(age));
} }
public EntityItem(Vec3d pos, Vec3d velocity, ItemStack stack, double angle) { public EntityItem(Vec3d pos, Vec3d velocity, ItemStack stack, double angle) {

View File

@ -27,7 +27,8 @@ public class EntityTnt extends Entity implements EntityHoldsEntities
public EntityTnt(BdfObject bdf) { public EntityTnt(BdfObject bdf) {
super(bdf); super(bdf);
this.smoke_particles = new ParticleSmokeTrail(this); smoke_particles = new ParticleSmokeTrail(this);
BdfClassLoad(bdf);
} }
@Override @Override
@ -47,9 +48,9 @@ public class EntityTnt extends Entity implements EntityHoldsEntities
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
BdfNamedList explode = nl.get("explosion").getNamedList(); BdfNamedList explode = nl.get("explosion").getNamedList();
explode.set("time", BdfObject.withInteger(explode_time)); explode.set("time", bdf.newObject().setInteger(explode_time));
explode.set("radius", BdfObject.withInteger(explode_radius)); explode.set("radius", bdf.newObject().setInteger(explode_radius));
explode.set("damage", BdfObject.withDouble(explode_damage)); explode.set("damage", bdf.newObject().setDouble(explode_damage));
} }
public EntityTnt(Vec3d pos, Vec3d velocity, double angle, int explode_radius, double explode_damage) { public EntityTnt(Vec3d pos, Vec3d velocity, double angle, int explode_radius, double explode_damage) {

View File

@ -43,6 +43,8 @@ public class EntityZombie extends Entity implements EntityAlive, EntityKillWithP
// Set some settings // Set some settings
hitbox = 0.5; hitbox = 0.5;
isSolid = true; isSolid = true;
BdfClassLoad(bdf);
} }
@Override @Override
@ -71,11 +73,11 @@ public class EntityZombie extends Entity implements EntityAlive, EntityKillWithP
super.BdfClassSave(bdf); super.BdfClassSave(bdf);
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("max_health", BdfObject.withDouble(health_max)); nl.set("max_health", bdf.newObject().setDouble(health_max));
nl.set("health", BdfObject.withDouble(health)); nl.set("health", bdf.newObject().setDouble(health));
nl.set("gun_interval", BdfObject.withInteger(gun_interval)); nl.set("gun_interval", bdf.newObject().setInteger(gun_interval));
nl.set("gun_level", BdfObject.withInteger(gun_level)); nl.set("gun_level", bdf.newObject().setInteger(gun_level));
nl.set("seed", BdfObject.withLong(seed)); nl.set("seed", bdf.newObject().setLong(seed));
} }

View File

@ -1,7 +1,5 @@
package projectzombie.entity.particle; package projectzombie.entity.particle;
import java.util.Arrays;
import gl_engine.MathHelpers; import gl_engine.MathHelpers;
import gl_engine.texture.TextureRef3D; import gl_engine.texture.TextureRef3D;
import gl_engine.vec.Vec2d; import gl_engine.vec.Vec2d;
@ -10,7 +8,6 @@ import projectzombie.entity.Entity;
import projectzombie.entity.EntityParticle; import projectzombie.entity.EntityParticle;
import projectzombie.entity.EntityParticlePart; import projectzombie.entity.EntityParticlePart;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.util.math.comparator.Comparators;
import projectzombie.world.chunk.Chunk; import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer; import projectzombie.world.layer.Layer;

View File

@ -1,7 +1,6 @@
package projectzombie.entity.particle; package projectzombie.entity.particle;
import gl_engine.vec.Vec3d; import gl_engine.vec.Vec3d;
import projectzombie.entity.particle.ParticleBreak.Break;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.model.IModel; import projectzombie.model.IModel;

View File

@ -8,27 +8,22 @@ 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 gl_engine.vec.Vec3d;
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.EntityHasArmor; import projectzombie.entity.EntityHasArmor;
import projectzombie.entity.EntityHasClothing; import projectzombie.entity.EntityHasClothing;
import projectzombie.entity.EntityHasTasks;
import projectzombie.entity.EntityHasInventory; import projectzombie.entity.EntityHasInventory;
import projectzombie.entity.EntityHasTasks;
import projectzombie.entity.EntityItem; import projectzombie.entity.EntityItem;
import projectzombie.entity.particle.ParticleBreak; import projectzombie.entity.particle.ParticleBreak;
import projectzombie.init.Items; import projectzombie.init.Items;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.init.Tasks;
import projectzombie.init.Tiles;
import projectzombie.inventory.Inventory; import projectzombie.inventory.Inventory;
import projectzombie.inventory.InventoryArmor; import projectzombie.inventory.InventoryArmor;
import projectzombie.inventory.InventoryClothing; import projectzombie.inventory.InventoryClothing;
import projectzombie.items.ItemTool; import projectzombie.items.ItemTool;
import projectzombie.menu.MenuDeath;
import projectzombie.model.Model; import projectzombie.model.Model;
import projectzombie.model.ModelPlayer; import projectzombie.model.ModelPlayer;
import projectzombie.settings.Cheats; import projectzombie.settings.Cheats;
@ -73,7 +68,7 @@ public class EntityPlayer extends Entity implements
public EntityPlayer(BdfObject bdf) { public EntityPlayer(BdfObject bdf) {
super(bdf); super(bdf);
tasks = new ArrayList<Task>(); BdfClassLoad(bdf);
} }
@Override @Override
@ -88,6 +83,9 @@ public class EntityPlayer extends Entity implements
angle = nl.get("angle").getDouble(); angle = nl.get("angle").getDouble();
temperature = nl.get("temperature").getDouble(); temperature = nl.get("temperature").getDouble();
hydration = nl.get("hydration").getDouble(); hydration = nl.get("hydration").getDouble();
in_animation = nl.get("inAnimation").getBoolean();
moving = nl.get("moving").getBoolean();
inventory_hand = nl.get("hand").getInteger();
tasks = new ArrayList<Task>(); tasks = new ArrayList<Task>();
@ -106,15 +104,18 @@ public class EntityPlayer extends Entity implements
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("health", BdfObject.withDouble(health)); nl.set("health", bdf.newObject().setDouble(health));
nl.set("dead", BdfObject.withBoolean(dead)); nl.set("dead", bdf.newObject().setBoolean(dead));
inventory.BdfClassSave(nl.get("inventory")); inventory.BdfClassSave(nl.get("inventory"));
armor.BdfClassSave(nl.get("armor")); armor.BdfClassSave(nl.get("armor"));
clothing.BdfClassSave(nl.get("clothing")); clothing.BdfClassSave(nl.get("clothing"));
nl.set("angle", BdfObject.withDouble(angle)); nl.set("angle", bdf.newObject().setDouble(angle));
nl.set("temperature", BdfObject.withDouble(temperature)); nl.set("temperature", bdf.newObject().setDouble(temperature));
nl.set("hydration", BdfObject.withDouble(hydration)); nl.set("hydration", bdf.newObject().setDouble(hydration));
nl.set("tasks", Task.saveTasks(tasks.toArray(new Task[0]))); nl.set("tasks", Task.saveTasks(bdf.newObject(), tasks.toArray(new Task[0])));
nl.set("inAnimation", bdf.newObject().setBoolean(in_animation));
nl.set("moving", bdf.newObject().setBoolean(moving));
nl.set("hand", bdf.newObject().setInteger(inventory_hand));
} }
public EntityPlayer() { public EntityPlayer() {
@ -133,8 +134,6 @@ public class EntityPlayer extends Entity implements
inventory = new Inventory(42); inventory = new Inventory(42);
armor = new InventoryArmor(); armor = new InventoryArmor();
clothing = new InventoryClothing(); clothing = new InventoryClothing();
clothing.setShirt(new ItemStack(Items.SPAWN_ZOMBIE, 99, (short)0));
} }
@Override @Override

View File

@ -1,37 +1,9 @@
package projectzombie.init; package projectzombie.init;
import java.util.Random;
import projectzombie.Main;
import projectzombie.display.bossbar.BossBars;
import projectzombie.entity.player.EntityPlayer;
import projectzombie.time.GameTimer;
import projectzombie.world.World;
import projectzombie.world.layer.Layer; import projectzombie.world.layer.Layer;
import projectzombie.world.layer.layergen.LayerGenBossArena;
public class Layers public class Layers
{ {
public static void createWorld(String path, long seed)
{
// Create all the layers
EARTH = new Layer(new Random(seed), LayerGenerators.EARTH);
CAVES = new Layer(new Random(seed), LayerGenerators.CAVES);
LAVA_CAVES = new Layer(new Random(seed), LayerGenerators.LAVA_CAVES);
// Create the world and set the earth as the default layer
Main.world = new World(path);
Main.world.addLayer(EARTH);
Main.world.addLayer(CAVES);
Main.world.addLayer(LAVA_CAVES);
Main.world.setLayer(0);
// Initialize some other objects
Main.player = new EntityPlayer();
GameTimer.resetTime();
BossBars.clear();
}
public static Layer EARTH; public static Layer EARTH;
public static Layer CAVES; public static Layer CAVES;
public static Layer LAVA_CAVES; public static Layer LAVA_CAVES;

View File

@ -17,7 +17,6 @@ import projectzombie.model.ModelTile;
import projectzombie.model.ModelTree; import projectzombie.model.ModelTree;
import projectzombie.model.ModelTreeSnow; import projectzombie.model.ModelTreeSnow;
import projectzombie.model.ModelVertical; import projectzombie.model.ModelVertical;
import projectzombie.model.player.ModelPlayerHead;
public class Models public class Models
{ {
@ -94,6 +93,8 @@ public class Models
new ModelVertical(Resources.ATLAS.get("/particle/smoke_4.png")), new ModelVertical(Resources.ATLAS.get("/particle/smoke_4.png")),
new ModelVertical(Resources.ATLAS.get("/particle/smoke_5.png"))); new ModelVertical(Resources.ATLAS.get("/particle/smoke_5.png")));
public static final ModelGui UI_PIXEL_WHITE = new ModelGui(Resources.ATLAS.get("/gui/pixel_white.png"));
public static final ModelGui UI_PIXEL_BLACK = new ModelGui(Resources.ATLAS.get("/gui/pixel_black.png"));
public static final ModelGui UI_BUTTON = new ModelGui(Resources.ATLAS.get("/gui/button_normal.png"), new Vec2d(12, 1.5)); public static final ModelGui UI_BUTTON = new ModelGui(Resources.ATLAS.get("/gui/button_normal.png"), new Vec2d(12, 1.5));
public static final ModelGui UI_BUTTON_HOVER = new ModelGui(Resources.ATLAS.get("/gui/button_hover.png"), new Vec2d(12, 1.5)); public static final ModelGui UI_BUTTON_HOVER = new ModelGui(Resources.ATLAS.get("/gui/button_hover.png"), new Vec2d(12, 1.5));
public static final ModelGui UI_BUTTON_DELETE = new ModelGui(Resources.ATLAS.get("/gui/button_delete.png"), new Vec2d(1.875, 1.875)); public static final ModelGui UI_BUTTON_DELETE = new ModelGui(Resources.ATLAS.get("/gui/button_delete.png"), new Vec2d(1.875, 1.875));
@ -101,6 +102,10 @@ public class Models
public static final ModelGui UI_BUTTON_PLAY = new ModelGui(Resources.ATLAS.get("/gui/button_play.png"), new Vec2d(1.875, 1.875)); public static final ModelGui UI_BUTTON_PLAY = new ModelGui(Resources.ATLAS.get("/gui/button_play.png"), new Vec2d(1.875, 1.875));
public static final ModelGui UI_BUTTON_PLAY_HOVER = new ModelGui(Resources.ATLAS.get("/gui/button_play_hover.png"), new Vec2d(1.875, 1.875)); public static final ModelGui UI_BUTTON_PLAY_HOVER = new ModelGui(Resources.ATLAS.get("/gui/button_play_hover.png"), new Vec2d(1.875, 1.875));
public static final ModelGui UI_LABEL = new ModelGui(Resources.ATLAS.get("/gui/label.png"), new Vec2d(24, 3)); public static final ModelGui UI_LABEL = new ModelGui(Resources.ATLAS.get("/gui/label.png"), new Vec2d(24, 3));
public static final ModelGui UI_SELECTION_BOX_WIDE = new ModelGui(Resources.ATLAS.get("/gui/selection_box_wide.png"), new Vec2d(24, 12));
public static final ModelGui UI_SELECTION_BOX_BIG = new ModelGui(Resources.ATLAS.get("/gui/selection_box_big.png"), new Vec2d(12, 12));
public static final ModelGui UI_TEXT_BOX = new ModelGui(Resources.ATLAS.get("/gui/text_box.png"), new Vec2d(12, 1.5));
public static final ModelGui UI_TEXT_CURSOR = new ModelGui(Resources.ATLAS.get("/gui/text_cursor.png"), 2, 50);
public static final ModelGui UI_HEALTH_FG = new ModelGui(Resources.ATLAS.get("/gui/health_full.png"), new Vec2d(6, 0.375)); public static final ModelGui UI_HEALTH_FG = new ModelGui(Resources.ATLAS.get("/gui/health_full.png"), new Vec2d(6, 0.375));
public static final ModelGui UI_HEALTH_BG = new ModelGui(Resources.ATLAS.get("/gui/health_empty.png"), new Vec2d(6, 0.375)); public static final ModelGui UI_HEALTH_BG = new ModelGui(Resources.ATLAS.get("/gui/health_empty.png"), new Vec2d(6, 0.375));

View File

@ -11,11 +11,13 @@ public class CursorPosCallback implements GLFWCursorPosCallbackI
{ {
public static double mx, my; public static double mx, my;
public static Vec2d getCursorPos() {
return new Vec2d(mx, my);
}
@Override @Override
public void invoke(long window, double x, double y) public void invoke(long window, double x, double y)
{ {
Main.menu.input.mousePos(new Vec2d(x, y));
Main.window.setMouseVisibility(!Main.menu.keepMouse); Main.window.setMouseVisibility(!Main.menu.keepMouse);
InputMode.Controller = false; InputMode.Controller = false;

View File

@ -1,6 +1,15 @@
package projectzombie.input; package projectzombie.input;
import static projectzombie.input.GameInput.*; import static projectzombie.input.GameInput.activateItem_last;
import static projectzombie.input.GameInput.activate_last;
import static projectzombie.input.GameInput.backButton_last;
import static projectzombie.input.GameInput.dropItem_last;
import static projectzombie.input.GameInput.hotbar_l;
import static projectzombie.input.GameInput.hotbar_r;
import static projectzombie.input.GameInput.moveDown;
import static projectzombie.input.GameInput.moveUp;
import static projectzombie.input.GameInput.move_last;
import static projectzombie.input.GameInput.startButton_last;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;

View File

@ -15,11 +15,20 @@ import static org.lwjgl.glfw.GLFW.GLFW_KEY_D;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_E; import static org.lwjgl.glfw.GLFW.GLFW_KEY_E;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE; import static org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_F11; import static org.lwjgl.glfw.GLFW.GLFW_KEY_F11;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT_CONTROL;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_Q; import static org.lwjgl.glfw.GLFW.GLFW_KEY_Q;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_RIGHT_CONTROL;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_S; import static org.lwjgl.glfw.GLFW.GLFW_KEY_S;
import static org.lwjgl.glfw.GLFW.GLFW_KEY_W; import static org.lwjgl.glfw.GLFW.GLFW_KEY_W;
import static org.lwjgl.glfw.GLFW.GLFW_RELEASE; import static org.lwjgl.glfw.GLFW.GLFW_RELEASE;
import static projectzombie.input.GameInput.*; import static projectzombie.input.GameInput.backButton_last;
import static projectzombie.input.GameInput.buttonL;
import static projectzombie.input.GameInput.buttonR;
import static projectzombie.input.GameInput.moveDown;
import static projectzombie.input.GameInput.moveLeft;
import static projectzombie.input.GameInput.moveRight;
import static projectzombie.input.GameInput.moveUp;
import static projectzombie.input.GameInput.move_last;
import org.lwjgl.glfw.GLFWKeyCallbackI; import org.lwjgl.glfw.GLFWKeyCallbackI;
@ -27,7 +36,6 @@ import gl_engine.vec.Vec2d;
import mainloop.task.IMainloopTask; import mainloop.task.IMainloopTask;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.input.types.Input; import projectzombie.input.types.Input;
import projectzombie.menu.MenuInventory;
public class KeyCallback implements GLFWKeyCallbackI, IMainloopTask public class KeyCallback implements GLFWKeyCallbackI, IMainloopTask
{ {
@ -37,6 +45,8 @@ public class KeyCallback implements GLFWKeyCallbackI, IMainloopTask
private boolean buttonL_last = false; private boolean buttonL_last = false;
private boolean buttonR_last = false; private boolean buttonR_last = false;
private boolean inventory_last = false; private boolean inventory_last = false;
private boolean lctrl_pressed = false;
private boolean rctrl_pressed = false;
@Override @Override
public void invoke(long window, int key, int scancode, int action, int mods) public void invoke(long window, int key, int scancode, int action, int mods)
@ -46,6 +56,13 @@ public class KeyCallback implements GLFWKeyCallbackI, IMainloopTask
InputMode.Controller = false; InputMode.Controller = false;
if(key == GLFW_KEY_LEFT_CONTROL) {
lctrl_pressed = pressed;
}
if(key == GLFW_KEY_RIGHT_CONTROL) {
rctrl_pressed = pressed;
}
if(key == GLFW_KEY_W) { if(key == GLFW_KEY_W) {
moveUp = pressed; moveUp = pressed;
} }
@ -62,36 +79,45 @@ public class KeyCallback implements GLFWKeyCallbackI, IMainloopTask
moveRight = pressed; moveRight = pressed;
} }
if(key == GLFW_KEY_1 && pressed) { if(pressed)
{
input.key(key);
if(lctrl_pressed || rctrl_pressed) {
input.keyCtrl(key);
}
if(key == GLFW_KEY_1) {
input.hotbarGoto(true, 0); input.hotbarGoto(true, 0);
} }
if(key == GLFW_KEY_2 && pressed) { if(key == GLFW_KEY_2) {
input.hotbarGoto(true, 1); input.hotbarGoto(true, 1);
} }
if(key == GLFW_KEY_3 && pressed) { if(key == GLFW_KEY_3) {
input.hotbarGoto(true, 2); input.hotbarGoto(true, 2);
} }
if(key == GLFW_KEY_4 && pressed) { if(key == GLFW_KEY_4) {
input.hotbarGoto(true, 3); input.hotbarGoto(true, 3);
} }
if(key == GLFW_KEY_5 && pressed) { if(key == GLFW_KEY_5) {
input.hotbarGoto(true, 4); input.hotbarGoto(true, 4);
} }
if(key == GLFW_KEY_6 && pressed) { if(key == GLFW_KEY_6) {
input.hotbarGoto(true, 5); input.hotbarGoto(true, 5);
} }
if(key == GLFW_KEY_7 && pressed) { if(key == GLFW_KEY_7) {
input.hotbarGoto(true, 6); input.hotbarGoto(true, 6);
} }
if(key == GLFW_KEY_8 && pressed) { if(key == GLFW_KEY_8) {
input.hotbarGoto(true, 7); input.hotbarGoto(true, 7);
} }
if(key == GLFW_KEY_9 && pressed) { if(key == GLFW_KEY_9) {
input.hotbarGoto(true, 8); input.hotbarGoto(true, 8);
} }
if(key == GLFW_KEY_0 && pressed) { if(key == GLFW_KEY_0) {
input.hotbarGoto(true, 9); input.hotbarGoto(true, 9);
} }
}
if(key == GLFW_KEY_Q) { if(key == GLFW_KEY_Q) {
if(pressed) { if(pressed) {

View File

@ -2,12 +2,15 @@ package projectzombie.input;
import org.lwjgl.glfw.GLFWCharCallbackI; import org.lwjgl.glfw.GLFWCharCallbackI;
import projectzombie.Main;
public class KeyCharCallback implements GLFWCharCallbackI public class KeyCharCallback implements GLFWCharCallbackI
{ {
@Override @Override
public void invoke(long arg0, int arg1) { public void invoke(long window, int character) {
InputMode.Controller = false; InputMode.Controller = false;
Main.menu.input.type((char)(character));
} }
} }

View File

@ -3,8 +3,6 @@ package projectzombie.input;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWMouseButtonCallbackI; import org.lwjgl.glfw.GLFWMouseButtonCallbackI;
import projectzombie.Main;
public class MouseButtonCallback implements GLFWMouseButtonCallbackI public class MouseButtonCallback implements GLFWMouseButtonCallbackI
{ {

View File

@ -4,6 +4,7 @@ import gl_engine.vec.Vec2d;
public interface Input public interface Input
{ {
public void type(char character);
public void move(boolean state, double angle); public void move(boolean state, double angle);
public void fire(boolean state); public void fire(boolean state);
public void camera(boolean state, double amount); public void camera(boolean state, double amount);
@ -12,8 +13,9 @@ public interface Input
public void pause(boolean state); public void pause(boolean state);
public void hotbarGoto(boolean state, int pos); public void hotbarGoto(boolean state, int pos);
public void hotbarShift(boolean state, int amount); public void hotbarShift(boolean state, int amount);
public void mousePos(Vec2d pos);
public void back(boolean state); public void back(boolean state);
public void activate(boolean state); public void activate(boolean state);
public void openInventory(); public void openInventory();
public void key(int key);
public void keyCtrl(int key);
} }

View File

@ -15,6 +15,10 @@ public class InputGUI implements Input
this.gui = gui; this.gui = gui;
} }
public GUI getGUI() {
return gui;
}
@Override @Override
public void move(boolean state, double angle) { public void move(boolean state, double angle) {
this.gui.onMove(state, angle); this.gui.onMove(state, angle);
@ -61,15 +65,6 @@ public class InputGUI implements Input
gui.onScroll(amount); gui.onScroll(amount);
} }
@Override
public void mousePos(Vec2d pos)
{
double mx = (pos.x / Main.window.getWidth() * 20 - 10) * GlHelpers.getAspectRatio();
double my = -pos.y / Main.window.getHeight() * 20 + 10;
this.gui.updateMousePos(new Vec2d(mx, my));
}
@Override @Override
public void back(boolean state) { public void back(boolean state) {
gui.onBack(); gui.onBack();
@ -84,4 +79,19 @@ public class InputGUI implements Input
public void openInventory() { public void openInventory() {
} }
@Override
public void type(char character) {
gui.type(character);
}
@Override
public void key(int key) {
gui.keyPress(key);
}
@Override
public void keyCtrl(int key) {
gui.keyPressCtrl(key);
}
} }

View File

@ -0,0 +1,12 @@
package projectzombie.input.types;
public interface InputGUITextBox {
public void onBackspace();
public void onDelete();
public void onPressed(char character);
public void onMoveCursor(int direction);
public void setFocus(boolean focus);
public void onPaste();
public void onHome();
public void onEnd();
}

View File

@ -5,6 +5,7 @@ import gl_engine.vec.Vec2d;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.menu.MenuGamePause; import projectzombie.menu.MenuGamePause;
import projectzombie.menu.MenuInventory; import projectzombie.menu.MenuInventory;
import projectzombie.menu.MenuInventoryBasic;
import projectzombie.world.chunk.ChunkEventHandler; import projectzombie.world.chunk.ChunkEventHandler;
public class InputGame implements Input public class InputGame implements Input
@ -66,10 +67,6 @@ public class InputGame implements Input
Main.player.inventory_hand = MathHelpers.mod(Main.player.inventory_hand, 10); Main.player.inventory_hand = MathHelpers.mod(Main.player.inventory_hand, 10);
} }
@Override
public void mousePos(Vec2d pos) {
}
@Override @Override
public void back(boolean state) { public void back(boolean state) {
} }
@ -80,7 +77,19 @@ public class InputGame implements Input
@Override @Override
public void openInventory() { public void openInventory() {
Main.menu = new MenuInventory(Main.menu); Main.menu = new MenuInventoryBasic(Main.menu);
}
@Override
public void type(char character) {
}
@Override
public void key(int key) {
}
@Override
public void keyCtrl(int key) {
} }
} }

View File

@ -0,0 +1,5 @@
package projectzombie.inventory;
public enum Crafting {
BASIC
}

View File

@ -158,11 +158,11 @@ public class Inventory implements IInventory, IBdfClassManager
{ {
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("size", BdfObject.withInteger(items.length)); nl.set("size", bdf.newObject().setInteger(items.length));
BdfArray array = nl.get("items").getArray(); BdfArray array = nl.get("items").getArray();
for(ItemStack stack : items) { for(ItemStack stack : items) {
BdfObject stack_bdf = new BdfObject(); BdfObject stack_bdf = bdf.newObject();
stack.BdfClassSave(stack_bdf); stack.BdfClassSave(stack_bdf);
array.add(stack_bdf); array.add(stack_bdf);
} }

View File

@ -59,7 +59,7 @@ public class InventoryArmor implements IBdfClassManager, IInventoryArmor
@Override @Override
public void BdfClassSave(BdfObject bdf) { public void BdfClassSave(BdfObject bdf) {
BdfNamedList nl = new BdfNamedList(); BdfNamedList nl = bdf.newNamedList();
helmet.BdfClassSave(nl.get("helmet")); helmet.BdfClassSave(nl.get("helmet"));
chest.BdfClassSave(nl.get("chest")); chest.BdfClassSave(nl.get("chest"));
leggings.BdfClassSave(nl.get("leggings")); leggings.BdfClassSave(nl.get("leggings"));

View File

@ -59,7 +59,7 @@ public class InventoryClothing implements IBdfClassManager, IInventoryClothing
@Override @Override
public void BdfClassSave(BdfObject bdf) { public void BdfClassSave(BdfObject bdf) {
BdfNamedList nl = new BdfNamedList(); BdfNamedList nl = bdf.newNamedList();
shirt.BdfClassSave(nl.get("shirt")); shirt.BdfClassSave(nl.get("shirt"));
pants.BdfClassSave(nl.get("pants")); pants.BdfClassSave(nl.get("pants"));
boots.BdfClassSave(nl.get("boots")); boots.BdfClassSave(nl.get("boots"));

View File

@ -0,0 +1,13 @@
package projectzombie.inventory.recipe;
import projectzombie.inventory.Inventory;
import projectzombie.inventory.Crafting;
import projectzombie.util.math.ItemStack;
public abstract class Recipe
{
public abstract ItemStack getResult();
public abstract boolean canCraft(Crafting tool);
public abstract boolean hasResourcesToCraft(Inventory inventory);
public abstract ItemStack craftResult(Inventory inventory);
}

View File

@ -0,0 +1,57 @@
package projectzombie.inventory.recipe;
import projectzombie.inventory.Crafting;
import projectzombie.inventory.Inventory;
import projectzombie.util.math.ItemStack;
public class RecipeBasic extends Recipe
{
protected ItemStack[] stacks_required;
protected Crafting[] tools_required;
protected ItemStack result;
public RecipeBasic(ItemStack[] stacks_required, Crafting[] tools_required, ItemStack result)
{
this.stacks_required = stacks_required;
this.tools_required = tools_required;
}
@Override
public ItemStack getResult() {
return result.copy();
}
@Override
public boolean canCraft(Crafting tool)
{
for(Crafting tool_required : tools_required) {
if(tool == tool_required) {
return true;
}
}
return false;
}
@Override
public boolean hasResourcesToCraft(Inventory inventory)
{
for(ItemStack item : stacks_required) {
if(inventory.getItemCount(item) < item.count) {
return false;
}
}
return true;
}
@Override
public ItemStack craftResult(Inventory inventory)
{
for(ItemStack item : stacks_required) {
inventory.removeItem(item.copy());
}
return result.copy();
}
}

View File

@ -4,7 +4,6 @@ import projectzombie.entity.Entity;
import projectzombie.entity.EntityHasInventory; import projectzombie.entity.EntityHasInventory;
import projectzombie.entity.player.EntityPlayer; import projectzombie.entity.player.EntityPlayer;
import projectzombie.inventory.IInventory; import projectzombie.inventory.IInventory;
import projectzombie.inventory.Inventory;
import projectzombie.model.ModelItem; import projectzombie.model.ModelItem;
import projectzombie.util.math.ItemStack; import projectzombie.util.math.ItemStack;
import projectzombie.world.chunk.Chunk; import projectzombie.world.chunk.Chunk;

View File

@ -1,11 +1,7 @@
package projectzombie.items; package projectzombie.items;
import projectzombie.entity.player.EntityPlayer;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.model.ModelItem; import projectzombie.model.ModelItem;
import projectzombie.util.math.ItemStack;
import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer;
public class ItemAmmo extends Item public class ItemAmmo extends Item
{ {

View File

@ -1,7 +1,6 @@
package projectzombie.items; package projectzombie.items;
import projectzombie.entity.Entity; import projectzombie.entity.Entity;
import projectzombie.entity.player.EntityPlayer;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.model.ModelItem; import projectzombie.model.ModelItem;
import projectzombie.util.math.ItemStack; import projectzombie.util.math.ItemStack;

View File

@ -2,7 +2,6 @@ package projectzombie.items;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.model.ModelItem; import projectzombie.model.ModelItem;
import projectzombie.util.math.ItemStack;
public class ItemFlint extends Item public class ItemFlint extends Item
{ {

View File

@ -1,11 +1,8 @@
package projectzombie.items; package projectzombie.items;
import projectzombie.entity.player.EntityPlayer;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.model.ModelItem; import projectzombie.model.ModelItem;
import projectzombie.util.math.ItemStack; import projectzombie.util.math.ItemStack;
import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer;
public class ItemRock extends Item implements ItemTool public class ItemRock extends Item implements ItemTool
{ {

View File

@ -2,10 +2,10 @@ package projectzombie.menu;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.input.types.InputGUI; import projectzombie.input.types.InputGUI;
import projectzombie.menu.gui.GUIButtonGroup;
import projectzombie.menu.gui.GUIButtonGroupPause;
import projectzombie.menu.gui.GUI; import projectzombie.menu.gui.GUI;
import projectzombie.menu.gui.GUIButtonBasic; import projectzombie.menu.gui.GUIButtonBasic;
import projectzombie.menu.gui.GUIButtonGroup;
import projectzombie.menu.gui.GUIButtonGroupPause;
public class MenuDeath extends Menu public class MenuDeath extends Menu
{ {

View File

@ -1,17 +1,13 @@
package projectzombie.menu; package projectzombie.menu;
import java.io.FileOutputStream;
import java.util.zip.DeflaterOutputStream;
import bdf.types.BdfObject;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.input.types.InputGUI; import projectzombie.input.types.InputGUI;
import projectzombie.menu.gui.GUIButtonGroup;
import projectzombie.menu.gui.GUIButtonGroupPause;
import projectzombie.menu.gui.GUILabelPause;
import projectzombie.menu.gui.GUI; import projectzombie.menu.gui.GUI;
import projectzombie.menu.gui.GUIBackToMenu; import projectzombie.menu.gui.GUIBackToMenu;
import projectzombie.menu.gui.GUIButtonBasic; import projectzombie.menu.gui.GUIButtonBasic;
import projectzombie.menu.gui.GUIButtonGroup;
import projectzombie.menu.gui.GUIButtonGroupPause;
import projectzombie.menu.gui.GUILabelPause;
public class MenuGamePause extends Menu public class MenuGamePause extends Menu
{ {
@ -44,48 +40,7 @@ public class MenuGamePause extends Menu
public void saveAndQuit() public void saveAndQuit()
{ {
long now, cur = 0; Main.world.save();
BdfObject bdf = new BdfObject();
now = System.currentTimeMillis();
Main.world.BdfClassSave(bdf);
cur = System.currentTimeMillis();
System.out.println("Time for BdfClassSave: " + (cur - now));
now = cur;
System.out.println("Size on file: " + bdf.serialize().size());
//System.out.println(bdf.serializeHumanReadable());
try {
/*
FileOutputStream os = new FileOutputStream("./layer.hbdf");
os.write(bdf.serializeHumanReadable(new BdfIndent("\t", "\n")).getBytes());
os.close();
cur = System.currentTimeMillis();
System.out.println("Time for HBDF: " + (cur - now));
now = cur;
*/
FileOutputStream os2 = new FileOutputStream("./layer.bdf");
DeflaterOutputStream dos = new DeflaterOutputStream(os2);
dos.write(bdf.serialize().getBytes());
dos.close();
os2.close();
cur = System.currentTimeMillis();
System.out.println("Time for BDF: " + (cur - now));
now = cur;
}
catch(Exception e) {
e.printStackTrace();
}
Main.menu = new MenuMain(); Main.menu = new MenuMain();
} }
} }

View File

@ -1,12 +1,9 @@
package projectzombie.menu; package projectzombie.menu;
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 gl_engine.vec.Vec3d;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.display.Camera;
import projectzombie.init.Items;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.input.CursorPosCallback; import projectzombie.input.CursorPosCallback;
import projectzombie.input.types.InputGUI; import projectzombie.input.types.InputGUI;
@ -15,24 +12,25 @@ import projectzombie.inventory.InventoryArmor;
import projectzombie.inventory.InventoryClothing; import projectzombie.inventory.InventoryClothing;
import projectzombie.items.ItemArmor; import projectzombie.items.ItemArmor;
import projectzombie.items.ItemClothing; import projectzombie.items.ItemClothing;
import projectzombie.menu.gui.GUIButton; import projectzombie.menu.gui.GUI;
import projectzombie.menu.gui.GUIBackToMenu;
import projectzombie.menu.gui.GUIItemHolder; import projectzombie.menu.gui.GUIItemHolder;
import projectzombie.menu.gui.GUIItemSlot; import projectzombie.menu.gui.GUIItemSlot;
import projectzombie.menu.gui.GUIItemSlotGetter; import projectzombie.menu.gui.GUIItemSlotGetter;
import projectzombie.menu.gui.GUIItemSlotGetterStorage; import projectzombie.menu.gui.GUIItemSlotGetterStorage;
import projectzombie.menu.gui.GUI;
import projectzombie.menu.gui.GUIBackToMenu;
import projectzombie.model.Model; import projectzombie.model.Model;
import projectzombie.util.gl.GlHelpers; import projectzombie.model.ModelGui;
import projectzombie.util.math.ItemStack; import projectzombie.util.math.ItemStack;
public class MenuInventory extends Menu public abstract class MenuInventory extends Menu
{ {
private Menu parent; protected Menu parent;
private GUI gui; protected GUIItemHolder itemHolder;
protected GUI gui;
private GUI top_gui;
private GUIItemSlot[] item_slots; protected GUIItemSlot[] item_slots;
private GUIItemSlot[] armor_slots; protected GUIItemSlot[] armor_slots;
public MenuInventory(Menu parent) public MenuInventory(Menu parent)
{ {
@ -44,12 +42,13 @@ public class MenuInventory extends Menu
keepMouse = false; keepMouse = false;
gui = new GUIBackToMenu(parent); top_gui = new GUIBackToMenu(parent);
input = new InputGUI(gui); input = new InputGUI(top_gui);
gui = new GUI();
Inventory inventory = Main.player.getInventory(); Inventory inventory = Main.player.getInventory();
GUIItemHolder itemHolder = new GUIItemHolder();
itemHolder = new GUIItemHolder();
item_slots = new GUIItemSlot[42]; item_slots = new GUIItemSlot[42];
armor_slots = new GUIItemSlot[6]; armor_slots = new GUIItemSlot[6];
@ -185,9 +184,8 @@ public class MenuInventory extends Menu
} }
} }
top_gui.add(gui);
top_gui.add(itemHolder);
gui.add(itemHolder);
} }
@Override @Override
@ -230,14 +228,14 @@ public class MenuInventory extends Menu
player_matrix = Matrix4.multiply(Matrix4.rotate(ay, 1, 0, 0), player_matrix); player_matrix = Matrix4.multiply(Matrix4.rotate(ay, 1, 0, 0), player_matrix);
player_matrix = Matrix4.multiply(Matrix4.translate(-width * (10.8 / 256.0), -height * (10.8 / 256.0), 0), player_matrix);*/ player_matrix = Matrix4.multiply(Matrix4.translate(-width * (10.8 / 256.0), -height * (10.8 / 256.0), 0), player_matrix);*/
gui.render(); top_gui.render();
} }
@Override @Override
public void update() { public void update() {
super.update(); super.update();
gui.update(new Vec2d(CursorPosCallback.mx, CursorPosCallback.my)); top_gui.update(new Vec2d(CursorPosCallback.mx, CursorPosCallback.my));
} }
} }

View File

@ -0,0 +1,36 @@
package projectzombie.menu;
import gl_engine.matrix.Matrix4;
import gl_engine.vec.Vec2d;
import projectzombie.init.Models;
import projectzombie.menu.gui.GUIContainerSlider;
public class MenuInventoryBasic extends MenuInventory
{
private GUIContainerSlider slider;
public MenuInventoryBasic(Menu parent) {
super(parent);
slider = new GUIContainerSlider(new Vec2d(
Models.UI_INVENTORY.getWidth() * 1 / 256.0,
-Models.UI_INVENTORY.getHeight() * 127 / 256.0), new Vec2d(
Models.UI_INVENTORY.getWidth() * 254 / 256.0,
Models.UI_INVENTORY.getHeight() * 254 / 256.0), 100);
gui.add(slider);
}
@Override
public void render()
{
Matrix4 matrix = Matrix4.translate(0, -Models.UI_INVENTORY.getHeight() / 2, 0);
// Render the inventory gui
Models.UI_SELECTION_BOX_BIG.setModel(matrix);
Models.UI_SELECTION_BOX_BIG.render();
super.render();
}
}

View File

@ -2,14 +2,16 @@ package projectzombie.menu;
import java.util.Random; import java.util.Random;
import gl_engine.vec.Vec2d;
import gl_engine.vec.Vec3d; import gl_engine.vec.Vec3d;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.init.Layers;
import projectzombie.input.types.InputGUI; import projectzombie.input.types.InputGUI;
import projectzombie.menu.gui.GUIButtonGroup;
import projectzombie.menu.gui.GUILabelMain;
import projectzombie.menu.gui.GUI; import projectzombie.menu.gui.GUI;
import projectzombie.menu.gui.GUIButtonBasic; import projectzombie.menu.gui.GUIButtonBasic;
import projectzombie.menu.gui.GUIButtonGroup;
import projectzombie.menu.gui.GUILabelMain;
import projectzombie.menu.gui.GUITextBox;
import projectzombie.world.World;
public class MenuMain extends Menu public class MenuMain extends Menu
{ {
@ -45,7 +47,7 @@ public class MenuMain extends Menu
gui.add(group); gui.add(group);
gui.setSelected(group.get(0)); gui.setSelected(group.get(0));
Layers.createWorld(null, rand.nextLong()); World.createWorld(null, rand.nextLong());
Main.player.dead = true; Main.player.dead = true;
} }

View File

@ -1,33 +1,51 @@
package projectzombie.menu; package projectzombie.menu;
import java.io.File;
import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import org.lwjgl.opengl.GL33; import bdf.file.BdfFileManager;
import bdf.types.BdfArray;
import bdf.types.BdfNamedList;
import bdf.types.BdfObject;
import gl_engine.matrix.Matrix4;
import gl_engine.vec.Vec2d; import gl_engine.vec.Vec2d;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.init.Layers;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.input.types.InputGUI; import projectzombie.input.types.InputGUI;
import projectzombie.menu.gui.GUI; import projectzombie.menu.gui.GUI;
import projectzombie.menu.gui.GUIAlignment; import projectzombie.menu.gui.GUIAlignment;
import projectzombie.menu.gui.GUIButton; import projectzombie.menu.gui.GUIBackToMenu;
import projectzombie.menu.gui.GUIButtonBasic; import projectzombie.menu.gui.GUIButtonBasic;
import projectzombie.menu.gui.GUIButtonCallback; import projectzombie.menu.gui.GUIContainerSlider;
import projectzombie.menu.gui.GUILabel; import projectzombie.menu.gui.GUILabel;
import projectzombie.menu.gui.GUISavesCard; import projectzombie.menu.gui.GUISavesCard;
import projectzombie.menu.gui.GUIButtonModel; import projectzombie.model.ModelGui;
import projectzombie.menu.gui.GUIButtonSetting; import projectzombie.world.World;
import projectzombie.menu.gui.GUIContainerSlider;
public class MenuSaves extends Menu public class MenuSaves extends Menu
{ {
private static final Random rand = new Random(); private static final Random rand = new Random();
private BdfFileManager reader;
private ArrayList<SaveCard> saves;
private int saves_remove = -1;
private Menu parent; private Menu parent;
private GUIContainerSlider slider; private GUIContainerSlider slider;
private GUI gui; private GUI gui;
private class SaveCard
{
String text, filename;
public SaveCard(String text, String filename)
{
this.text = text;
this.filename = filename;
}
}
public MenuSaves(Menu parent) public MenuSaves(Menu parent)
{ {
this.parent = parent; this.parent = parent;
@ -36,8 +54,8 @@ public class MenuSaves extends Menu
doGameRender = parent.doGameRender; doGameRender = parent.doGameRender;
showIngameGUI = parent.showIngameGUI; showIngameGUI = parent.showIngameGUI;
gui = new GUI(); gui = new GUIBackToMenu(parent);
saves = new ArrayList<SaveCard>();
input = new InputGUI(gui); input = new InputGUI(gui);
keepMouse = false; keepMouse = false;
@ -47,14 +65,16 @@ public class MenuSaves extends Menu
}); });
GUIButtonBasic buttonCreate = new GUIButtonBasic("Create", button -> { GUIButtonBasic buttonCreate = new GUIButtonBasic("Create", button -> {
Layers.createWorld(null, rand.nextLong()); createWorld();
Main.menu = new MenuGame();
}); });
slider = new GUIContainerSlider(new Vec2d(-20, -5), new Vec2d(40, 10), 10); slider = new GUIContainerSlider(new Vec2d(
-Models.UI_SELECTION_BOX_WIDE.getWidth() * 127 / 256.0,
-Models.UI_SELECTION_BOX_WIDE.getHeight() * 63 / 128.0), new Vec2d(
Models.UI_SELECTION_BOX_WIDE.getWidth() * 254 / 256.0,
Models.UI_SELECTION_BOX_WIDE.getHeight() * 126 / 128.0), 10);
GUISavesCard savesCard = new GUISavesCard(new Vec2d(0, 0)); reloadDatabase();
slider.add(savesCard);
buttonBack.setAlign(GUIAlignment.RIGHT); buttonBack.setAlign(GUIAlignment.RIGHT);
buttonCreate.setAlign(GUIAlignment.LEFT); buttonCreate.setAlign(GUIAlignment.LEFT);
@ -73,9 +93,99 @@ public class MenuSaves extends Menu
gui.add(slider); gui.add(slider);
} }
private void createWorld() {
Main.menu = new MenuWorldNew(this);
}
private void loadSave(int index)
{
BdfObject bdf = reader.getObject();
BdfNamedList nl = bdf.getNamedList();
BdfArray array = nl.get("saves").getArray();
BdfObject save_bdf = array.remove(index);
array.add(save_bdf);
reader.saveDatabase();
Main.world = new World(saves.get(index).filename);
Main.menu = new MenuGame();
}
private void deleteSave(int index)
{
SaveCard save = saves.get(index);
Main.menu = new MenuWorldDelete(this, save.text, save.filename);
}
public void reloadDatabase()
{
saves.clear();
reader = new BdfFileManager("./saves.bdf", true);
BdfNamedList nl = reader.getObject().getNamedList();
BdfArray array = nl.get("saves").getArray();
for(BdfObject save_bdf : array)
{
BdfNamedList save_nl = save_bdf.getNamedList();
SaveCard save = new SaveCard(
save_nl.get("name").getString(),
save_nl.get("path").getString());
saves.add(save);
}
generateSaveCards();
}
private void generateSaveCards()
{
double slider_length = Models.UI_LABEL.getHeight() * 18.0 * saves.size() / 16.0;
double selection_length = Models.UI_SELECTION_BOX_WIDE.getHeight() * 248 / 256.0;
slider.clear();
slider.setLength(slider_length > selection_length ? slider_length - selection_length : 0);
for(int i=0;i<saves.size();i++)
{
int[] index = {saves.size() - i - 1};
SaveCard save = saves.get(index[0]);
GUISavesCard savesCard = new GUISavesCard(save.text, new Vec2d(
-Models.UI_LABEL.getWidth() / 2.0,
-Models.UI_LABEL.getHeight() +
Models.UI_SELECTION_BOX_WIDE.getHeight() * 60.0 / 128.0 -
Models.UI_LABEL.getHeight() * 18.0 * i / 16.0))
{
@Override
public void onDeletePressed() {
super.onDeletePressed();
deleteSave(index[0]);
}
@Override
public void onPlayPressed() {
super.onPlayPressed();
loadSave(index[0]);
}
};
slider.add(savesCard);
}
}
@Override @Override
public void render() public void render()
{ {
ModelGui selection_box = Models.UI_SELECTION_BOX_WIDE;
selection_box.setModel(Matrix4.translate(
-selection_box.getWidth() / 2,
-selection_box.getHeight() / 2, 0));
selection_box.render();
gui.render(); gui.render();
} }
@ -83,7 +193,6 @@ public class MenuSaves extends Menu
public void update() public void update()
{ {
parent.update(); parent.update();
super.update(); super.update();
} }

View File

@ -5,16 +5,15 @@ import projectzombie.Main;
import projectzombie.display.DisplayRender; import projectzombie.display.DisplayRender;
import projectzombie.display.DisplayRenderUI; import projectzombie.display.DisplayRenderUI;
import projectzombie.display.DisplayWindow; import projectzombie.display.DisplayWindow;
import projectzombie.entity.EntityParticle;
import projectzombie.input.types.InputGUI; import projectzombie.input.types.InputGUI;
import projectzombie.menu.gui.GUI;
import projectzombie.menu.gui.GUIBackToMenu;
import projectzombie.menu.gui.GUIButton; import projectzombie.menu.gui.GUIButton;
import projectzombie.menu.gui.GUIButtonBasic; import projectzombie.menu.gui.GUIButtonBasic;
import projectzombie.menu.gui.GUIButtonGroup; import projectzombie.menu.gui.GUIButtonGroup;
import projectzombie.menu.gui.GUIButtonSetting; import projectzombie.menu.gui.GUIButtonSetting;
import projectzombie.menu.gui.GUI;
import projectzombie.menu.gui.GUIBackToMenu;
import projectzombie.menu.gui.GUISelectableDirection;
import projectzombie.menu.gui.GUILabel; import projectzombie.menu.gui.GUILabel;
import projectzombie.menu.gui.GUISelectableDirection;
import projectzombie.settings.SettingQuality; import projectzombie.settings.SettingQuality;
import projectzombie.settings.Settings; import projectzombie.settings.Settings;
import projectzombie.world.chunk.Chunk; import projectzombie.world.chunk.Chunk;

View File

@ -0,0 +1,116 @@
package projectzombie.menu;
import java.io.File;
import bdf.file.BdfFileManager;
import bdf.types.BdfArray;
import bdf.types.BdfNamedList;
import bdf.types.BdfObject;
import bdf.types.BdfReader;
import gl_engine.vec.Vec2d;
import projectzombie.Main;
import projectzombie.init.Models;
import projectzombie.input.types.InputGUI;
import projectzombie.menu.gui.GUI;
import projectzombie.menu.gui.GUIAlignment;
import projectzombie.menu.gui.GUIBackToMenu;
import projectzombie.menu.gui.GUIButtonBasic;
import projectzombie.menu.gui.GUILabel;
import projectzombie.menu.gui.GUITextBox;
public class MenuWorldDelete extends Menu
{
private MenuSaves parent;
private String name;
private String path;
private GUI gui;
public MenuWorldDelete(MenuSaves parent, String name, String path)
{
this.parent = parent;
this.name = name;
this.path = path;
keepMouse = false;
doGameloop = parent.doGameloop;
doGameRender = parent.doGameRender;
showIngameGUI = parent.showIngameGUI;
gui = new GUIBackToMenu(parent);
input = new InputGUI(gui);
GUIButtonBasic buttonCancel = new GUIButtonBasic("Cancel", button -> {
Main.menu = parent;
});
GUIButtonBasic buttonDelete = new GUIButtonBasic("Delete", button -> {
deleteSave();
});
buttonCancel.setAlign(GUIAlignment.RIGHT);
buttonDelete.setAlign(GUIAlignment.LEFT);
buttonCancel.setPos(new Vec2d(-0.5, -4));
buttonDelete.setPos(new Vec2d(0.5, -4));
{
// Delete world title
GUILabel label = new GUILabel();
label.setText("Delete World");
label.setSize(new Vec2d(1, 1));
label.setPos(new Vec2d(0, 4));
gui.add(label);
}
{
// Delete world confirm message
GUILabel label = new GUILabel();
label.setText("Are you sure you want to delete \"" + name + "\"?");
label.setSize(new Vec2d(0.4, 0.4));
label.setPos(new Vec2d(0, 3));
gui.add(label);
}
gui.add(buttonCancel);
gui.add(buttonDelete);
}
private void deleteSave()
{
BdfFileManager reader = new BdfFileManager("./saves.bdf", true);
BdfObject bdf = reader.getObject();
BdfNamedList nl = bdf.getNamedList();
BdfArray array = nl.get("saves").getArray();
File save_file = new File("./saves/" + path + ".bdf");
save_file.delete();
for(int i=0;i<array.size();i++) {
BdfNamedList world_nl = array.get(i).getNamedList();
if(world_nl.get("path").getString().contentEquals(path)) {
array.remove(i);
break;
}
}
Main.menu = parent;
reader.saveDatabase();
parent.reloadDatabase();
}
@Override
public void render() {
gui.render();
}
@Override
public void update() {
super.update();
parent.update();
}
}

View File

@ -0,0 +1,176 @@
package projectzombie.menu;
import java.util.Random;
import bdf.file.BdfFileManager;
import bdf.types.BdfArray;
import bdf.types.BdfNamedList;
import bdf.types.BdfObject;
import gl_engine.vec.Vec2d;
import projectzombie.Main;
import projectzombie.init.Models;
import projectzombie.input.types.InputGUI;
import projectzombie.menu.gui.GUI;
import projectzombie.menu.gui.GUIAlignment;
import projectzombie.menu.gui.GUIBackToMenu;
import projectzombie.menu.gui.GUIButtonBasic;
import projectzombie.menu.gui.GUILabel;
import projectzombie.menu.gui.GUITextBox;
import projectzombie.world.World;
public class MenuWorldNew extends Menu
{
private static final Random rand = new Random();
private Menu parent;
private String name;
private long seed;
private GUI gui;
private GUITextBox world_name;
public MenuWorldNew(Menu parent)
{
this.parent = parent;
name = "World";
seed = rand.nextLong();
keepMouse = false;
doGameloop = parent.doGameloop;
doGameRender = parent.doGameRender;
showIngameGUI = parent.showIngameGUI;
gui = new GUIBackToMenu(parent);
input = new InputGUI(gui);
GUIButtonBasic buttonBack = new GUIButtonBasic("Back", button -> {
Main.menu = parent;
});
GUIButtonBasic buttonCreate = new GUIButtonBasic("Generate", button -> {
generateWorld();
});
buttonBack.setAlign(GUIAlignment.RIGHT);
buttonCreate.setAlign(GUIAlignment.LEFT);
buttonBack.setPos(new Vec2d(-0.5, -8));
buttonCreate.setPos(new Vec2d(0.5, -8));
{
// New world title label
GUILabel label = new GUILabel();
label.setText("Create New World");
label.setSize(new Vec2d(1, 1));
label.setPos(new Vec2d(0, 6.8));
gui.add(label);
}
{
// Set the world name
double offset = -Models.UI_TEXT_BOX.getWidth() / 2;
GUILabel label = new GUILabel();
label.setAlign(GUIAlignment.RIGHT);
label.setText("World Name");
label.setSize(new Vec2d(0.4, 0.4));
label.setPos(new Vec2d(offset + Models.UI_TEXT_BOX.getWidth() * 2 / 128.0, 4));
gui.add(label);
world_name = new GUITextBox(new Vec2d(offset, 3.8 - Models.UI_TEXT_BOX.getHeight()), true);
world_name.setText(name);
gui.add(world_name);
}
gui.add(buttonBack);
gui.add(buttonCreate);
}
private void generateWorld()
{
name = world_name.getText();
String path = name;
path = path.toLowerCase();
char[] path_chars = path.toCharArray();
for(int i=0;i<path_chars.length;i++)
{
char c = path_chars[i];
if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) {
path_chars[i] = c;
} else {
path_chars[i] = '_';
}
}
path = new String(path_chars);
if(name.length() == 0) {
return;
}
BdfFileManager reader = new BdfFileManager("./saves.bdf", true);
BdfObject bdf = reader.getObject();
BdfNamedList nl = bdf.getNamedList();
BdfArray array = nl.get("saves").getArray();
// Find a unique name and path
String name_new = name;
String path_new = path;
boolean duplicate = true;
for(int i=1;duplicate;i++)
{
duplicate = false;
for(BdfObject save_bdf : array)
{
BdfNamedList save_nl = save_bdf.getNamedList();
String save_name = save_nl.get("name").getString();
String save_path = save_nl.get("path").getString();
if(i > 1) {
name_new = name + " (" + i + ")";
path_new = path + "_" + i;
}
if(name_new.contentEquals(save_name) || path_new.contentEquals(save_path)) {
duplicate = true;
break;
}
}
}
BdfObject save_bdf = bdf.newObject();
BdfNamedList save_nl = save_bdf.getNamedList();
save_nl.set("name", bdf.newObject().setString(name_new));
save_nl.set("path", bdf.newObject().setString(path_new));
array.add(save_bdf);
reader.saveDatabase();
World.createWorld(path_new, seed);
Main.menu = new MenuGame();
}
@Override
public void update()
{
super.update();
parent.update();
}
@Override
public void render() {
gui.render();
}
}

View File

@ -2,18 +2,26 @@ package projectzombie.menu.gui;
import java.util.ArrayList; import java.util.ArrayList;
import org.lwjgl.glfw.GLFW;
import gl_engine.matrix.Matrix4; import gl_engine.matrix.Matrix4;
import gl_engine.vec.Vec2d; import gl_engine.vec.Vec2d;
import projectzombie.input.CursorPosCallback;
import projectzombie.input.types.InputGUITextBox;
public class GUI implements GUIContainer public class GUI implements GUIContainer
{ {
private ArrayList<GUIComponent> components = new ArrayList<GUIComponent>(); private ArrayList<GUIComponent> components = new ArrayList<GUIComponent>();
private Vec2d mousePos = new Vec2d(0, 0);
public GUISelectable selected; public GUISelectable selected;
private InputGUITextBox text_box;
private static boolean move_last = false; private static boolean move_last = false;
public void setTextBox(InputGUITextBox text_box) {
this.text_box = text_box;
}
public void setSelected(GUISelectable selected) { public void setSelected(GUISelectable selected) {
if(this.selected != null) { if(this.selected != null) {
this.selected.setSelected(false); this.selected.setSelected(false);
@ -31,8 +39,12 @@ public class GUI implements GUIContainer
} }
} }
public Vec2d getCursorPos() {
return CursorPosCallback.getCursorPos();
}
public void render() { public void render() {
this.render(Matrix4.identity(), mousePos, true); this.render(Matrix4.identity(), getCursorPos(), true);
} }
@Override @Override
@ -40,10 +52,6 @@ public class GUI implements GUIContainer
components.add(c); components.add(c);
} }
public void updateMousePos(Vec2d pos) {
this.mousePos = pos;
}
public void onMove(boolean status, double angle) public void onMove(boolean status, double angle)
{ {
if(this.selected == null) { if(this.selected == null) {
@ -96,38 +104,59 @@ public class GUI implements GUIContainer
} }
@Override @Override
public void onMouseClick(Vec2d pos) { public void onMouseClick(Vec2d pos)
{
if(text_box != null && text_box instanceof GUIComponent && !((GUIComponent)text_box).checkMouseHover(pos)) {
text_box.setFocus(false);
text_box = null;
}
Vec2d cursorPos = getCursorPos();
for(GUIComponent c : components) { for(GUIComponent c : components) {
if(c.checkMouseHover(mousePos)) { if(c.checkMouseHover(cursorPos)) {
c.onMouseClick(mousePos); c.onMouseClick(cursorPos);
} }
} }
} }
@Override @Override
public void onRightClick(Vec2d pos) { public void onRightClick(Vec2d pos)
{
Vec2d cursorPos = getCursorPos();
for(GUIComponent c : components) { for(GUIComponent c : components) {
if(c.checkMouseHover(mousePos)) { if(c.checkMouseHover(cursorPos)) {
c.onRightClick(mousePos); c.onRightClick(cursorPos);
} }
} }
} }
public void onMouseClick() { public void onMouseClick() {
this.onMouseClick(mousePos); this.onMouseClick(getCursorPos());
} }
public void onRightClick() { public void onRightClick() {
this.onRightClick(mousePos); this.onRightClick(getCursorPos());
} }
@Override @Override
public void onBack() { public void onBack()
{
if(text_box == null)
{
for(GUIComponent c : components) { for(GUIComponent c : components) {
c.onBack(); c.onBack();
} }
} }
else
{
text_box.setFocus(false);
text_box = null;
}
}
@Override @Override
public void onActivate() { public void onActivate() {
for(GUIComponent c : components) { for(GUIComponent c : components) {
@ -150,7 +179,63 @@ public class GUI implements GUIContainer
} }
public void onScroll(int amount) { public void onScroll(int amount) {
onScroll(mousePos, amount / 10.0); onScroll(getCursorPos(), amount);
}
@Override
public void clear() {
components.clear();
}
public void type(char character) {
if(text_box != null) {
text_box.onPressed(character);
}
}
public void pasteKey() {
if(text_box != null) {
text_box.onDelete();
}
}
public void keyPress(int key) {
if(text_box != null)
{
switch(key)
{
case GLFW.GLFW_KEY_LEFT:
text_box.onMoveCursor(-1);
break;
case GLFW.GLFW_KEY_RIGHT:
text_box.onMoveCursor(1);
break;
case GLFW.GLFW_KEY_DELETE:
text_box.onDelete();
break;
case GLFW.GLFW_KEY_BACKSPACE:
text_box.onBackspace();
break;
case GLFW.GLFW_KEY_HOME:
text_box.onHome();
break;
case GLFW.GLFW_KEY_END:
text_box.onEnd();
break;
}
}
}
public void keyPressCtrl(int key) {
if(text_box != null)
{
switch(key)
{
case GLFW.GLFW_KEY_V:
text_box.onPaste();
break;
}
}
} }
} }

View File

@ -3,12 +3,10 @@ package projectzombie.menu.gui;
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 gl_engine.vec.Vec3d;
import projectzombie.Main;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.input.InputMode; import projectzombie.input.InputMode;
import projectzombie.model.ModelGui; import projectzombie.model.ModelGui;
import projectzombie.text.Text; import projectzombie.text.Text;
import projectzombie.util.gl.GlHelpers;
public class GUIButton implements GUIComponent, GUISelectable public class GUIButton implements GUIComponent, GUISelectable
{ {

View File

@ -105,4 +105,9 @@ public class GUIButtonGroup implements GUIContainer
} }
} }
@Override
public void clear() {
buttons.clear();
}
} }

View File

@ -9,7 +9,6 @@ public class GUIButtonGroupPause extends GUIButtonGroup
public GUIButtonGroupPause() public GUIButtonGroupPause()
{ {
add(new GUIButtonBasic("Settings", button -> { add(new GUIButtonBasic("Settings", button -> {
Main.menu.input.mousePos(new Vec2d(0, 0));
Main.menu = new MenuSettings(Main.menu); Main.menu = new MenuSettings(Main.menu);
})); }));

View File

@ -3,4 +3,5 @@ package projectzombie.menu.gui;
public interface GUIContainer extends GUIComponent public interface GUIContainer extends GUIComponent
{ {
public void add(GUIComponent c); public void add(GUIComponent c);
public void clear();
} }

View File

@ -6,8 +6,9 @@ import org.lwjgl.opengl.GL33;
import gl_engine.matrix.Matrix4; import gl_engine.matrix.Matrix4;
import gl_engine.vec.Vec2d; import gl_engine.vec.Vec2d;
import gl_engine.vec.Vec4d; import gl_engine.vec.Vec3d;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.init.Models;
public class GUIContainerSlider implements GUIComponent, GUIContainer public class GUIContainerSlider implements GUIComponent, GUIContainer
{ {
@ -39,8 +40,8 @@ public class GUIContainerSlider implements GUIComponent, GUIContainer
canHover = false; canHover = false;
} }
matrix = Matrix4.multiply(matrix, Matrix4.translate(0, -scroll, 0)); matrix = Matrix4.multiply(matrix, Matrix4.translate(0, scroll, 0));
mousePos = mousePos.add(new Vec2d(0, scroll)); mousePos = mousePos.add(new Vec2d(0, -scroll));
GL33.glUniform1i(Main.window.glsl_do_discard_coords, 1); GL33.glUniform1i(Main.window.glsl_do_discard_coords, 1);
GL33.glUniform4f(Main.window.glsl_discard_coords, GL33.glUniform4f(Main.window.glsl_discard_coords,
@ -50,6 +51,26 @@ public class GUIContainerSlider implements GUIComponent, GUIContainer
c.render(matrix, mousePos, canHover); c.render(matrix, mousePos, canHover);
} }
if(length > 0)
{
GL33.glUniform4f(Main.window.glsl_color, 0.25f, 0.25f, 0.25f, 1);
double start = size.y * scroll / (length + size.y);
double end = size.y * (scroll + size.y) / (length + size.y);
Matrix4 matrix_scroll_bar = Matrix4.translate(
pos.x + size.x - 0.125f,
pos.y + size.y - end, 0);
matrix_scroll_bar = Matrix4.multiply(Matrix4.scale(
new Vec3d(1, (float)(end - start), 1)), matrix_scroll_bar);
Models.UI_PIXEL_WHITE.setModel(matrix_scroll_bar);
Models.UI_PIXEL_WHITE.render();
GL33.glUniform4f(Main.window.glsl_color, 1, 1, 1, 1);
}
GL33.glUniform1i(Main.window.glsl_do_discard_coords, 0); GL33.glUniform1i(Main.window.glsl_do_discard_coords, 0);
} }
@ -60,7 +81,7 @@ public class GUIContainerSlider implements GUIComponent, GUIContainer
return; return;
} }
mousePos = mousePos.add(new Vec2d(0, scroll)); mousePos = mousePos.add(new Vec2d(0, -scroll));
for(GUIComponent c : components) { for(GUIComponent c : components) {
c.update(mousePos); c.update(mousePos);
@ -79,7 +100,7 @@ public class GUIContainerSlider implements GUIComponent, GUIContainer
return; return;
} }
mousePos = mousePos.add(new Vec2d(0, scroll)); mousePos = mousePos.add(new Vec2d(0, -scroll));
for(GUIComponent c : components) { for(GUIComponent c : components) {
if(c.checkMouseHover(mousePos)) { if(c.checkMouseHover(mousePos)) {
@ -95,7 +116,7 @@ public class GUIContainerSlider implements GUIComponent, GUIContainer
return; return;
} }
mousePos = mousePos.add(new Vec2d(0, scroll)); mousePos = mousePos.add(new Vec2d(0, -scroll));
for(GUIComponent c : components) { for(GUIComponent c : components) {
if(c.checkMouseHover(mousePos)) { if(c.checkMouseHover(mousePos)) {
@ -142,4 +163,9 @@ public class GUIContainerSlider implements GUIComponent, GUIContainer
} }
} }
@Override
public void clear() {
components.clear();
}
} }

View File

@ -1,6 +1,5 @@
package projectzombie.menu.gui; package projectzombie.menu.gui;
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 gl_engine.vec.Vec3d;
@ -8,7 +7,6 @@ import projectzombie.Main;
import projectzombie.entity.EntityItem; import projectzombie.entity.EntityItem;
import projectzombie.model.Model; import projectzombie.model.Model;
import projectzombie.text.Text; import projectzombie.text.Text;
import projectzombie.util.gl.GlHelpers;
import projectzombie.util.math.ItemStack; import projectzombie.util.math.ItemStack;
import projectzombie.world.layer.Layer; import projectzombie.world.layer.Layer;

View File

@ -3,12 +3,10 @@ package projectzombie.menu.gui;
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 gl_engine.vec.Vec3d;
import projectzombie.Main;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.model.Model; import projectzombie.model.Model;
import projectzombie.model.ModelItem; import projectzombie.model.ModelItem;
import projectzombie.text.Text; import projectzombie.text.Text;
import projectzombie.util.gl.GlHelpers;
import projectzombie.util.math.ItemStack; import projectzombie.util.math.ItemStack;
public class GUIItemSlot implements GUIComponent public class GUIItemSlot implements GUIComponent

View File

@ -2,8 +2,10 @@ package projectzombie.menu.gui;
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.init.Models; import projectzombie.init.Models;
import projectzombie.model.ModelGui; import projectzombie.model.ModelGui;
import projectzombie.text.Text;
public class GUISavesCard implements GUIComponent public class GUISavesCard implements GUIComponent
{ {
@ -12,12 +14,12 @@ public class GUISavesCard implements GUIComponent
private Vec2d pos = new Vec2d(0, 0); private Vec2d pos = new Vec2d(0, 0);
private GUIButtonModel buttonDelete; private GUIButtonModel buttonDelete;
private GUIButtonModel buttonPlay; private GUIButtonModel buttonPlay;
private String text;
public GUISavesCard(Vec2d pos) public GUISavesCard(String text, Vec2d pos)
{ {
pos.x -= LABEL.getWidth() / 2;
this.pos = pos; this.pos = pos;
this.text = text;
buttonDelete = new GUIButtonModel(Models.UI_BUTTON_DELETE, Models.UI_BUTTON_DELETE_HOVER, button -> { buttonDelete = new GUIButtonModel(Models.UI_BUTTON_DELETE, Models.UI_BUTTON_DELETE_HOVER, button -> {
onDeletePressed(); onDeletePressed();
@ -27,8 +29,8 @@ public class GUISavesCard implements GUIComponent
onPlayPressed(); onPlayPressed();
}); });
buttonPlay.setPos(new Vec2d(-LABEL.getWidth()*122/256.0, LABEL.getHeight()*6/32.0)); buttonPlay.setPos(pos.add(new Vec2d(LABEL.getWidth()*10/256.0, LABEL.getHeight()*6/32.0)));
buttonDelete.setPos(new Vec2d(LABEL.getWidth()*102/256.0, LABEL.getHeight()*6/32.0)); buttonDelete.setPos(pos.add(new Vec2d(LABEL.getWidth()*226/256.0, LABEL.getHeight()*6/32.0)));
} }
public void onPlayPressed() { public void onPlayPressed() {
@ -42,9 +44,19 @@ public class GUISavesCard implements GUIComponent
@Override @Override
public void render(Matrix4 matrix, Vec2d mousePos, boolean canHover) public void render(Matrix4 matrix, Vec2d mousePos, boolean canHover)
{ {
LABEL.setModel(Matrix4.multiply(Matrix4.translate(pos.x, pos.y, 0), matrix)); Matrix4 label_matrix = Matrix4.multiply(Matrix4.translate(pos.x, pos.y, 0), matrix);
LABEL.setModel(label_matrix);
LABEL.render(); LABEL.render();
Matrix4 text_matrix = label_matrix;
text_matrix = Matrix4.multiply(text_matrix, Matrix4.translate(
LABEL.getWidth() * 38 / 256.0,
LABEL.getHeight() / 2 - 0.25, 0));
text_matrix = Matrix4.multiply(Matrix4.scale(new Vec3d(0.5, 0.5, 0.5)), text_matrix);
Text.render(text, text_matrix);
buttonDelete.render(matrix, mousePos, canHover); buttonDelete.render(matrix, mousePos, canHover);
buttonPlay.render(matrix, mousePos, canHover); buttonPlay.render(matrix, mousePos, canHover);
} }
@ -57,8 +69,7 @@ public class GUISavesCard implements GUIComponent
@Override @Override
public boolean checkMouseHover(Vec2d pos) { public boolean checkMouseHover(Vec2d pos) {
return (this.pos.x > pos.x && this.pos.x + LABEL.getWidth() < pos.x && return true;
this.pos.y > pos.y && this.pos.y + LABEL.getHeight() < pos.y);
} }
@Override @Override

View File

@ -0,0 +1,243 @@
package projectzombie.menu.gui;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import org.lwjgl.opengl.GL33;
import gl_engine.matrix.Matrix4;
import gl_engine.vec.Vec2d;
import gl_engine.vec.Vec3d;
import projectzombie.Main;
import projectzombie.init.Models;
import projectzombie.input.types.InputGUI;
import projectzombie.input.types.InputGUITextBox;
import projectzombie.model.ModelGui;
import projectzombie.text.Text;
public class GUITextBox implements GUIComponent, InputGUITextBox
{
private static final ModelGui BOX = Models.UI_TEXT_BOX;
private static final ModelGui CURSOR = Models.UI_TEXT_CURSOR;
private Vec2d pos;
private String text = "";
private int cursor_pos = 0;
private boolean in_focus = false;
private double offset = 0;
private int max;
public GUITextBox(Vec2d pos, int max) {
this.pos = pos;
this.max = max;
}
public GUITextBox(Vec2d pos, boolean max) {
this(pos, max ? 22 : -1);
}
public GUITextBox(Vec2d pos) {
this(pos, -1);
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@Override
public void render(Matrix4 matrix, Vec2d mousePos, boolean canHover)
{
Matrix4 box_matrix = Matrix4.multiply(matrix, Matrix4.translate(pos.x, pos.y, 0));
BOX.setModel(box_matrix);
BOX.render();
// Set text to black and make sure text gets clipped outside the text box
GL33.glUniform4f(Main.window.glsl_color, 0.1f, 0.1f, 0.1f, 1);
GL33.glUniform4f(Main.window.glsl_discard_coords,
(float)(pos.x + BOX.getWidth() * 2 / 128.0),
(float)(pos.y + BOX.getHeight() * 2 / 16.0),
(float)(pos.x + BOX.getWidth() * 126 / 128.0),
(float)(pos.y + BOX.getHeight() * 14 / 16.0));
GL33.glUniform1i(Main.window.glsl_do_discard_coords, 1);
Matrix4 text_matrix = box_matrix;
text_matrix = Matrix4.multiply(text_matrix, Matrix4.translate((1 - offset) * 0.5, 0.5, 0));
text_matrix = Matrix4.multiply(Matrix4.scale(new Vec3d(0.5, 0.5, 0.5)), text_matrix);
Text.render(text, text_matrix);
if(in_focus) {
CURSOR.setModel(Matrix4.multiply(text_matrix, Matrix4.translate(cursor_pos * 0.5, 0, 0)));
CURSOR.render();
}
// Reset the settings back to default
GL33.glUniform4f(Main.window.glsl_color, 1, 1, 1, 1);
GL33.glUniform1i(Main.window.glsl_do_discard_coords, 0);
}
@Override
public void update(Vec2d mousePos) {
}
@Override
public boolean checkMouseHover(Vec2d mousePos) {
return (mousePos.x > this.pos.x && mousePos.x < this.pos.x + BOX.getWidth() &&
mousePos.y > this.pos.y && mousePos.y < this.pos.y + BOX.getHeight());
}
@Override
public void onMouseClick(Vec2d mousePos)
{
((InputGUI)Main.menu.input).getGUI().setTextBox(this);
in_focus = true;
cursor_pos = (int)((mousePos.x - pos.x + offset * 0.5 - 0.5) * 2 + 0.5);
if(cursor_pos > text.length()) {
cursor_pos = text.length();
}
}
private void updateText()
{
// Update the text fields offset to
// keep the cursor in the text field
double o = BOX.getWidth() - 1;
if(cursor_pos - o < offset) {
offset = cursor_pos - o;
}
if(cursor_pos - o * 2 > offset) {
offset = cursor_pos - o * 2;
}
if(offset < 0) {
offset = 0;
}
}
@Override
public void onPaste()
{
try
{
String clipboard = (String)(Main.clipboard.getData(DataFlavor.stringFlavor));
if(max == -1 || text.length() + clipboard.length() <= max)
{
text = text.substring(0, cursor_pos) + clipboard + text.substring(cursor_pos, text.length());
cursor_pos += clipboard.length();
updateText();
}
else if(text.length() < max)
{
clipboard = clipboard.substring(0, max - text.length());
text = text.substring(0, cursor_pos) + clipboard + text.substring(cursor_pos, text.length());
cursor_pos += clipboard.length();
updateText();
}
}
catch (UnsupportedFlavorException | IOException e) {
e.printStackTrace();
}
}
@Override
public void onBackspace()
{
if(cursor_pos == 0) {
return;
}
text = text.substring(0, cursor_pos - 1) + text.substring(cursor_pos, text.length());
cursor_pos -= 1;
updateText();
}
@Override
public void onDelete()
{
if(cursor_pos == text.length()) {
return;
}
text = text.substring(0, cursor_pos) + text.substring(cursor_pos + 1, text.length());
updateText();
}
@Override
public void onMoveCursor(int direction)
{
cursor_pos += direction;
if(cursor_pos < 0) {
cursor_pos = 0;
}
if(cursor_pos > text.length()) {
cursor_pos = text.length();
}
updateText();
}
@Override
public void onHome() {
cursor_pos = 0;
updateText();
}
@Override
public void onEnd() {
cursor_pos = text.length();
updateText();
}
@Override
public void onPressed(char character)
{
if(max == -1 || text.length() < max)
{
text = text.substring(0, cursor_pos) + character + text.substring(cursor_pos, text.length());
cursor_pos += 1;
updateText();
}
}
@Override
public void setFocus(boolean focus) {
in_focus = focus;
}
@Override
public void onScroll(Vec2d mousePos, double amount) {
}
@Override
public void onRightClick(Vec2d mousePos) {
}
@Override
public void onActivate() {
}
@Override
public void onBack() {
}
}

View File

@ -19,14 +19,13 @@ 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 projectzombie.Main; import projectzombie.Main;
import projectzombie.init.Models;
import projectzombie.init.Resources; import projectzombie.init.Resources;
public abstract class Model implements IModel public abstract class Model implements IModel
{ {
private static final Random rand = new Random(); private static final Random rand = new Random();
public static final float OFFSET = 0.001f; public static final float OFFSET = 0.00001f;
public static final int SIZE = 16; public static final int SIZE = 16;
public static IModel bound = null; public static IModel bound = null;

View File

@ -1,6 +1,5 @@
package projectzombie.model; package projectzombie.model;
import gl_engine.texture.TextureRef3D;
import projectzombie.init.Resources; import projectzombie.init.Resources;
public class ModelGrass extends ModelTile public class ModelGrass extends ModelTile

View File

@ -1,7 +1,6 @@
package projectzombie.model; package projectzombie.model;
import gl_engine.texture.TextureRef3D; import gl_engine.texture.TextureRef3D;
import gl_engine.vec.Vec2d;
public class ModelRock extends Model public class ModelRock extends Model
{ {

View File

@ -1,6 +1,5 @@
package projectzombie.model; package projectzombie.model;
import gl_engine.texture.TextureRef3D;
import projectzombie.init.Resources; import projectzombie.init.Resources;
public class ModelTallGrass extends ModelCross public class ModelTallGrass extends ModelCross

View File

@ -1,21 +1,18 @@
package projectzombie.settings; package projectzombie.settings;
import bdf.classes.BdfClassManager;
import bdf.classes.IBdfClassManager; import bdf.classes.IBdfClassManager;
import bdf.file.BdfFileManager; import bdf.file.BdfFileManager;
import bdf.types.BdfNamedList; import bdf.types.BdfNamedList;
import bdf.types.BdfObject; import bdf.types.BdfObject;
import bdf.types.BdfTypes; import bdf.types.BdfTypes;
import projectzombie.Main;
import projectzombie.display.DisplayRender; import projectzombie.display.DisplayRender;
import projectzombie.display.DisplayRenderUI; import projectzombie.display.DisplayRenderUI;
import projectzombie.display.DisplayWindow; import projectzombie.display.DisplayWindow;
import projectzombie.entity.EntityParticle;
import projectzombie.world.chunk.Chunk; import projectzombie.world.chunk.Chunk;
public class Settings implements IBdfClassManager public class Settings implements IBdfClassManager
{ {
public static final BdfClassManager SETTINGS = new BdfClassManager(new Settings()); public static final Settings SETTINGS = new Settings();
private static BdfFileManager FILE_MANAGER; private static BdfFileManager FILE_MANAGER;
@Override @Override
@ -114,21 +111,21 @@ public class Settings implements IBdfClassManager
} }
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("render_distance", BdfObject.withInteger(Chunk.RENDER_DISTANCE)); nl.set("render_distance", bdf.newObject().setInteger(Chunk.RENDER_DISTANCE));
nl.set("show_fps", BdfObject.withBoolean(DisplayRenderUI.showFPS)); nl.set("show_fps", bdf.newObject().setBoolean(DisplayRenderUI.showFPS));
nl.set("debug", BdfObject.withBoolean(DisplayRenderUI.debug)); nl.set("debug", bdf.newObject().setBoolean(DisplayRenderUI.debug));
nl.set("shadow_size", BdfObject.withInteger(shadow_size)); nl.set("shadow_size", bdf.newObject().setInteger(shadow_size));
nl.set("fullscreen", BdfObject.withBoolean(DisplayWindow.fullscreen)); nl.set("fullscreen", bdf.newObject().setBoolean(DisplayWindow.fullscreen));
nl.set("vsync", BdfObject.withBoolean(DisplayWindow.vsync)); nl.set("vsync", bdf.newObject().setBoolean(DisplayWindow.vsync));
} }
public static void init() { public static void init() {
FILE_MANAGER = new BdfFileManager(Environment.gdir + "/settings.bdf", true); FILE_MANAGER = new BdfFileManager(Environment.gdir + "/settings.bdf", true);
SETTINGS.load(FILE_MANAGER); SETTINGS.BdfClassLoad(FILE_MANAGER.getObject());
} }
public static void update() { public static void update() {
SETTINGS.save(FILE_MANAGER); SETTINGS.BdfClassSave(FILE_MANAGER.getObject());
FILE_MANAGER.saveDatabase(); FILE_MANAGER.saveDatabase();
} }

View File

@ -2,14 +2,12 @@ package projectzombie.task;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import bdf.classes.IBdfClassManager; import bdf.classes.IBdfClassManager;
import bdf.types.BdfArray; import bdf.types.BdfArray;
import bdf.types.BdfNamedList; import bdf.types.BdfNamedList;
import bdf.types.BdfObject; import bdf.types.BdfObject;
import projectzombie.entity.Entity; import projectzombie.entity.Entity;
import projectzombie.init.Entities;
import projectzombie.init.Tasks; import projectzombie.init.Tasks;
public abstract class Task implements IBdfClassManager public abstract class Task implements IBdfClassManager
@ -50,7 +48,7 @@ public abstract class Task implements IBdfClassManager
// Send back null if the id is out of range // Send back null if the id is out of range
if(id < 0 || id >= Tasks.TASKS.size()) { if(id < 0 || id >= Tasks.TASKS.size()) {
System.out.println("Warning: Invalid ID detected: " + id); System.out.println("Invalid task ID found: " + id);
return null; return null;
} }
@ -85,7 +83,7 @@ public abstract class Task implements IBdfClassManager
@Override @Override
public void BdfClassSave(BdfObject bdf) { public void BdfClassSave(BdfObject bdf) {
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("id", BdfObject.withInteger(getID())); nl.set("id", bdf.newObject().setInteger(getID()));
} }
public static Task[] loadTasks(Entity parent, BdfObject bdf) public static Task[] loadTasks(Entity parent, BdfObject bdf)
@ -100,16 +98,17 @@ public abstract class Task implements IBdfClassManager
return tasks; return tasks;
} }
public static BdfObject saveTasks(Task[] tasks) public static BdfObject saveTasks(BdfObject bdf, Task[] tasks)
{ {
BdfArray array = new BdfArray(); BdfArray array = bdf.getArray();
bdf.setArray(array);
for(int i=0;i<tasks.length;i++) { for(int i=0;i<tasks.length;i++) {
BdfObject task_bdf = new BdfObject(); BdfObject task_bdf = bdf.newObject();
tasks[i].BdfClassSave(task_bdf); tasks[i].BdfClassSave(task_bdf);
array.add(task_bdf); array.add(task_bdf);
} }
return BdfObject.withArray(array); return bdf;
} }
} }

View File

@ -36,7 +36,7 @@ public class TaskDeathScreen extends Task
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("timer", BdfObject.withInteger(timer)); nl.set("timer", bdf.newObject().setInteger(timer));
} }
@Override @Override

View File

@ -43,8 +43,8 @@ public class TaskLadderDown extends Task
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("layerID", BdfObject.withInteger(layerID)); nl.set("layerID", bdf.newObject().setInteger(layerID));
nl.set("step", BdfObject.withInteger(step)); nl.set("step", bdf.newObject().setInteger(step));
} }
@Override @Override

View File

@ -2,14 +2,11 @@ package projectzombie.task;
import bdf.types.BdfNamedList; import bdf.types.BdfNamedList;
import bdf.types.BdfObject; import bdf.types.BdfObject;
import gl_engine.vec.Vec2i;
import gl_engine.vec.Vec3d; import gl_engine.vec.Vec3d;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.entity.Entity; import projectzombie.entity.Entity;
import projectzombie.entity.player.EntityPlayer; import projectzombie.entity.player.EntityPlayer;
import projectzombie.util.math.TileState;
import projectzombie.world.chunk.ChunkEventHandler; import projectzombie.world.chunk.ChunkEventHandler;
import projectzombie.world.layer.Layer;
public class TaskLadderUp extends Task public class TaskLadderUp extends Task
{ {
@ -43,8 +40,8 @@ public class TaskLadderUp extends Task
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("layerID", BdfObject.withInteger(layerID)); nl.set("layerID", bdf.newObject().setInteger(layerID));
nl.set("step", BdfObject.withInteger(step)); nl.set("step", bdf.newObject().setInteger(step));
} }
@Override @Override

View File

@ -89,6 +89,19 @@ public class Text
public static final Model CHAR_HASHTAG = new ModelGui(Resources.ATLAS.get("/text/char_hashtag.png")); public static final Model CHAR_HASHTAG = new ModelGui(Resources.ATLAS.get("/text/char_hashtag.png"));
public static final Model CHAR_L_THAN = new ModelGui(Resources.ATLAS.get("/text/char_lthan.png")); public static final Model CHAR_L_THAN = new ModelGui(Resources.ATLAS.get("/text/char_lthan.png"));
public static final Model CHAR_G_THAN = new ModelGui(Resources.ATLAS.get("/text/char_gthan.png")); public static final Model CHAR_G_THAN = new ModelGui(Resources.ATLAS.get("/text/char_gthan.png"));
public static final Model CHAR_APOSTROPHE = new ModelGui(Resources.ATLAS.get("/text/char_apostrophe.png"));
public static final Model CHAR_GRAVE = new ModelGui(Resources.ATLAS.get("/text/char_grave.png"));
public static final Model CHAR_QUOTATION = new ModelGui(Resources.ATLAS.get("/text/char_quotation.png"));
public static final Model CHAR_SEMICOLON = new ModelGui(Resources.ATLAS.get("/text/char_semicolon.png"));
public static final Model CHAR_TILDE = new ModelGui(Resources.ATLAS.get("/text/char_tilde.png"));
public static final Model CHAR_BRACKET_OC = new ModelGui(Resources.ATLAS.get("/text/char_ocbracket.png"));
public static final Model CHAR_BRACKET_CC = new ModelGui(Resources.ATLAS.get("/text/char_ccbracket.png"));
public static final Model CHAR_BRACKET_OS = new ModelGui(Resources.ATLAS.get("/text/char_osbracket.png"));
public static final Model CHAR_BRACKET_CS = new ModelGui(Resources.ATLAS.get("/text/char_csbracket.png"));
public static final Model CHAR_STAR = new ModelGui(Resources.ATLAS.get("/text/char_star.png"));
public static final Model CHAR_AND = new ModelGui(Resources.ATLAS.get("/text/char_and.png"));
public static final Model CHAR_AT = new ModelGui(Resources.ATLAS.get("/text/char_at.png"));
public static final Model CHAR_POW = new ModelGui(Resources.ATLAS.get("/text/char_pow.png"));
public static void render(String text, Matrix4 matrix) public static void render(String text, Matrix4 matrix)
{ {
@ -183,6 +196,19 @@ public class Text
case('#'): l = CHAR_HASHTAG; break; case('#'): l = CHAR_HASHTAG; break;
case('>'): l = CHAR_G_THAN; break; case('>'): l = CHAR_G_THAN; break;
case('<'): l = CHAR_L_THAN; break; case('<'): l = CHAR_L_THAN; break;
case('`'): l = CHAR_GRAVE; break;
case('~'): l = CHAR_TILDE; break;
case('\''): l = CHAR_APOSTROPHE; break;
case('"'): l = CHAR_QUOTATION; break;
case(';'): l = CHAR_SEMICOLON; break;
case('@'): l = CHAR_AT; break;
case('&'): l = CHAR_AND; break;
case('*'): l = CHAR_STAR; break;
case('^'): l = CHAR_POW; break;
case('['): l = CHAR_BRACKET_OS; break;
case(']'): l = CHAR_BRACKET_CS; break;
case('{'): l = CHAR_BRACKET_OC; break;
case('}'): l = CHAR_BRACKET_CC; break;
} }
if(l != null) if(l != null)

View File

@ -1,6 +1,5 @@
package projectzombie.tiles; package projectzombie.tiles;
import gl_engine.vec.Vec2d;
import gl_engine.vec.Vec2i; import gl_engine.vec.Vec2i;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.init.Tiles; import projectzombie.init.Tiles;

View File

@ -1,16 +1,13 @@
package projectzombie.tiles; package projectzombie.tiles;
import gl_engine.vec.Vec2i; import gl_engine.vec.Vec2i;
import mainloop.task.IMainloopTask;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.entity.Entity; import projectzombie.entity.Entity;
import projectzombie.entity.player.EntityPlayer; import projectzombie.entity.player.EntityPlayer;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.mainloop.MainloopEventHandler;
import projectzombie.model.Model; import projectzombie.model.Model;
import projectzombie.task.TaskLadderUp; import projectzombie.task.TaskLadderUp;
import projectzombie.util.math.TileState; import projectzombie.util.math.TileState;
import projectzombie.world.chunk.ChunkEventHandler;
import projectzombie.world.layer.Layer; import projectzombie.world.layer.Layer;
public class TileLadderUp extends Tile public class TileLadderUp extends Tile

View File

@ -1,16 +1,13 @@
package projectzombie.tiles; package projectzombie.tiles;
import gl_engine.vec.Vec2i; import gl_engine.vec.Vec2i;
import mainloop.task.IMainloopTask;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.entity.Entity; import projectzombie.entity.Entity;
import projectzombie.entity.player.EntityPlayer; import projectzombie.entity.player.EntityPlayer;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.mainloop.MainloopEventHandler;
import projectzombie.model.Model; import projectzombie.model.Model;
import projectzombie.task.TaskLadderDown; import projectzombie.task.TaskLadderDown;
import projectzombie.util.math.TileState; import projectzombie.util.math.TileState;
import projectzombie.world.chunk.ChunkEventHandler;
import projectzombie.world.layer.Layer; import projectzombie.world.layer.Layer;
public class TilePortalDown extends Tile public class TilePortalDown extends Tile

View File

@ -1,16 +1,11 @@
package projectzombie.tiles; package projectzombie.tiles;
import gl_engine.vec.Vec2i;
import gl_engine.vec.Vec3d;
import projectzombie.entity.Entity;
import projectzombie.entity.EntityItem;
import projectzombie.init.Items; import projectzombie.init.Items;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.items.ItemTool; import projectzombie.items.ItemTool;
import projectzombie.model.Model; import projectzombie.model.Model;
import projectzombie.util.math.ItemStack; import projectzombie.util.math.ItemStack;
import projectzombie.util.math.TileState; import projectzombie.util.math.TileState;
import projectzombie.world.layer.Layer;
public class TileRock extends Tile implements TileBulletBreakable public class TileRock extends Tile implements TileBulletBreakable
{ {

View File

@ -1,14 +1,11 @@
package projectzombie.tiles; package projectzombie.tiles;
import gl_engine.vec.Vec2i;
import projectzombie.entity.Entity;
import projectzombie.init.Items; import projectzombie.init.Items;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.items.ItemTool; import projectzombie.items.ItemTool;
import projectzombie.model.Model; import projectzombie.model.Model;
import projectzombie.util.math.ItemStack; import projectzombie.util.math.ItemStack;
import projectzombie.util.math.TileState; import projectzombie.util.math.TileState;
import projectzombie.world.layer.Layer;
public class TileTree extends Tile implements TileBulletBreakable public class TileTree extends Tile implements TileBulletBreakable
{ {

View File

@ -1,7 +1,6 @@
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.entity.player.EntityPlayer; import projectzombie.entity.player.EntityPlayer;

View File

@ -46,9 +46,9 @@ public class ItemStack implements IBdfClassManager
@Override @Override
public void BdfClassSave(BdfObject bdf) { public void BdfClassSave(BdfObject bdf) {
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("meta", BdfObject.withShort(meta)); nl.set("meta", bdf.newObject().setShort(meta));
nl.set("count", BdfObject.withInteger(count)); nl.set("count", bdf.newObject().setInteger(count));
nl.set("item", BdfObject.withInteger(item.id)); nl.set("item", bdf.newObject().setInteger(item.id));
} }
public ItemStack(BdfObject bdf) { public ItemStack(BdfObject bdf) {

View File

@ -6,9 +6,10 @@ import java.io.OutputStream;
import java.lang.ProcessBuilder.Redirect; import java.lang.ProcessBuilder.Redirect;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import bdf.data.BdfDatabase; import bdf.data.IBdfDatabase;
import bdf.types.BdfNamedList; import bdf.types.BdfNamedList;
import bdf.types.BdfObject; import bdf.types.BdfObject;
import bdf.types.BdfReader;
import projectzombie.display.DisplayLighting; import projectzombie.display.DisplayLighting;
public class Worker extends Thread public class Worker extends Thread
@ -24,9 +25,9 @@ public class Worker extends Thread
public Worker() throws IOException public Worker() throws IOException
{ {
pb = new ProcessBuilder("java", "-jar", "worker.jar"); pb = new ProcessBuilder("java", "-jar", "worker.jar");
pb.redirectError(Redirect.INHERIT);
pb.redirectOutput(Redirect.PIPE); pb.redirectOutput(Redirect.PIPE);
pb.redirectInput(Redirect.PIPE); pb.redirectInput(Redirect.PIPE);
pb.redirectError(Redirect.INHERIT);
process = pb.start(); process = pb.start();
@ -38,39 +39,41 @@ public class Worker extends Thread
public void processLighting(float[] lights, int width, int height, int x, int y) public void processLighting(float[] lights, int width, int height, int x, int y)
{ {
BdfObject bdf = new BdfObject(); BdfReader reader = new BdfReader();
BdfObject bdf = reader.getObject();
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("task", BdfObject.withString("light")); nl.set("task", bdf.newObject().setString("light"));
nl.set("light", BdfObject.withFloatArray(lights)); nl.set("light", bdf.newObject().setFloatArray(lights));
nl.set("w", BdfObject.withInteger(width)); nl.set("w", bdf.newObject().setInteger(width));
nl.set("h", BdfObject.withInteger(height)); nl.set("h", bdf.newObject().setInteger(height));
nl.set("x", BdfObject.withInteger(x)); nl.set("x", bdf.newObject().setInteger(x));
nl.set("y", BdfObject.withInteger(y)); nl.set("y", bdf.newObject().setInteger(y));
sendData(bdf); sendData(reader);
} }
public void updateTime() public void updateTime()
{ {
BdfObject bdf = new BdfObject(); BdfReader reader = new BdfReader();
BdfObject bdf = reader.getObject();
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("task", BdfObject.withString("time")); nl.set("task", bdf.newObject().setString("time"));
nl.set("millis", BdfObject.withLong(System.currentTimeMillis())); nl.set("millis", bdf.newObject().setLong(System.currentTimeMillis()));
sendData(bdf); sendData(reader);
} }
private void sendData(BdfObject bdf) private void sendData(BdfReader reader)
{ {
byte[] data = bdf.serialize().getBytes(); IBdfDatabase data = reader.serialize();
ByteBuffer size_buff = ByteBuffer.allocate(4); ByteBuffer size_buff = ByteBuffer.allocate(4);
size_buff.putInt(0, data.length); size_buff.putInt(0, data.size());
try try
{ {
out.write(size_buff.array()); out.write(size_buff.array());
out.write(data); data.writeToStream(out);
out.write('\n'); out.write('\n');
out.flush(); out.flush();
} }
@ -97,7 +100,8 @@ public class Worker extends Thread
in.read(data); in.read(data);
in.read(new byte[1]); in.read(new byte[1]);
BdfObject bdf = new BdfObject(new BdfDatabase(data)); BdfReader reader = new BdfReader(data);
BdfObject bdf = reader.getObject();
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
switch(nl.get("task").getString()) switch(nl.get("task").getString())

View File

@ -1,13 +1,15 @@
package projectzombie.world; package projectzombie.world;
import java.io.File;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL33; import org.lwjgl.opengl.GL33;
import bdf.classes.IBdfClassManager; import bdf.classes.IBdfClassManager;
import bdf.file.BdfFileManager;
import bdf.types.BdfArray; import bdf.types.BdfArray;
import bdf.types.BdfNamedList; import bdf.types.BdfNamedList;
import bdf.types.BdfObject; import bdf.types.BdfObject;
@ -16,7 +18,10 @@ import gl_engine.vec.Vec3d;
import projectzombie.Main; import projectzombie.Main;
import projectzombie.display.Camera; import projectzombie.display.Camera;
import projectzombie.display.DisplayLighting; import projectzombie.display.DisplayLighting;
import projectzombie.display.bossbar.BossBars;
import projectzombie.entity.player.EntityPlayer; import projectzombie.entity.player.EntityPlayer;
import projectzombie.init.LayerGenerators;
import projectzombie.init.Layers;
import projectzombie.model.Model; import projectzombie.model.Model;
import projectzombie.time.GameTimer; import projectzombie.time.GameTimer;
import projectzombie.world.chunk.ChunkEventHandler; import projectzombie.world.chunk.ChunkEventHandler;
@ -28,6 +33,7 @@ public class World implements IBdfClassManager
private Layer loaded; private Layer loaded;
private ArrayList<Layer> layers = new ArrayList<Layer>(); private ArrayList<Layer> layers = new ArrayList<Layer>();
private BdfFileManager file_manager;
private String path; private String path;
private int pool_vao, pool_vbo, pool_ibo; private int pool_vao, pool_vbo, pool_ibo;
@ -37,6 +43,48 @@ public class World implements IBdfClassManager
public World(String path) { public World(String path) {
this.path = path; this.path = path;
if(path != null)
{
path = "./saves/" + path + ".bdf";
File save_file = new File(path);
File save_dir = save_file.getParentFile();
if(!save_dir.exists()) {
save_dir.mkdirs();
}
if(save_file.exists()) {
file_manager = new BdfFileManager(path);
BdfClassLoad(file_manager.getObject());
}
else {
file_manager = new BdfFileManager(path);
}
}
}
public static void createWorld(String path, long seed)
{
// Create all the layers
Layers.EARTH = new Layer(new Random(seed), LayerGenerators.EARTH);
Layers.CAVES = new Layer(new Random(seed), LayerGenerators.CAVES);
Layers.LAVA_CAVES = new Layer(new Random(seed), LayerGenerators.LAVA_CAVES);
// Create the world and set the earth as the default layer
Main.world = new World(path);
Main.world.addLayer(Layers.EARTH);
Main.world.addLayer(Layers.CAVES);
Main.world.addLayer(Layers.LAVA_CAVES);
Main.world.setLayer(0);
// Initialize some other objects
Main.player = new EntityPlayer();
GameTimer.resetTime();
BossBars.clear();
Main.world.save();
} }
public String getSavePath() { public String getSavePath() {
@ -182,6 +230,24 @@ public class World implements IBdfClassManager
return loaded; return loaded;
} }
public void save()
{
if(file_manager != null)
{
BdfObject bdf = file_manager.resetObject();
BdfClassSave(bdf);
file_manager.saveDatabase();
}
}
public void free()
{
for(Layer layer : layers) {
layer.free();
}
}
@Override @Override
public void BdfClassLoad(BdfObject bdf) public void BdfClassLoad(BdfObject bdf)
{ {
@ -219,32 +285,25 @@ public class World implements IBdfClassManager
} }
// Save layer data // Save layer data
BdfArray layers_bdf = new BdfArray(); BdfArray layers_bdf = bdf.newArray();
nl.set("loaded", BdfObject.withInteger(loaded_id)); nl.set("loaded", bdf.newObject().setInteger(loaded_id));
nl.set("layers", BdfObject.withArray(layers_bdf)); nl.set("layers", bdf.newObject().setArray(layers_bdf));
for(Layer l : layers) { for(Layer l : layers) {
BdfObject o = new BdfObject(); BdfObject o = bdf.newObject();
l.BdfClassSave(o); l.BdfClassSave(o);
layers_bdf.add(o); layers_bdf.add(o);
} }
// Save player data // Save player data
BdfArray players = new BdfArray(); BdfArray players = bdf.newArray();
nl.set("players", BdfObject.withArray(players)); nl.set("players", bdf.newObject().setArray(players));
BdfObject player = new BdfObject(); BdfObject player = bdf.newObject();
Main.player.BdfClassSave(player); Main.player.BdfClassSave(player);
players.add(player); players.add(player);
// Save the game timer // Save the game timer
nl.set("time", BdfObject.withLong(GameTimer.getTime())); nl.set("time", bdf.newObject().setLong(GameTimer.getTime()));
}
public void free()
{
for(Layer layer : layers) {
layer.free();
}
} }
} }

View File

@ -49,8 +49,7 @@ public class Chunk implements IBdfClassManager
private Tile tiles_front[] = new Tile[CHUNK_INDEX]; private Tile tiles_front[] = new Tile[CHUNK_INDEX];
private byte tiles_front_meta[] = new byte[CHUNK_INDEX]; private byte tiles_front_meta[] = new byte[CHUNK_INDEX];
private byte tiles_back_meta[] = new byte[CHUNK_INDEX]; private byte tiles_back_meta[] = new byte[CHUNK_INDEX];
private byte tiles_lighting_src[] = new byte[CHUNK_INDEX]; private byte tiles_lighting[] = new byte[CHUNK_INDEX];
private byte tiles_lighting_day[] = new byte[CHUNK_INDEX];
public ArrayList<Entity> entities = new ArrayList<Entity>(); public ArrayList<Entity> entities = new ArrayList<Entity>();
private Layer layer; private Layer layer;
public Vec2i c_pos; public Vec2i c_pos;
@ -93,10 +92,10 @@ public class Chunk implements IBdfClassManager
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
// Load all the tiles and meta // Load all the tiles and meta
short[] tb = nl.get("tb").getShortArray(); short[] tb = nl.get("tilesBack").getShortArray();
short[] tf = nl.get("tf").getShortArray(); short[] tf = nl.get("tilesFront").getShortArray();
byte[] mb = nl.get("mb").getByteArray(); byte[] mb = nl.get("metaBack").getByteArray();
byte[] mf = nl.get("mf").getByteArray(); byte[] mf = nl.get("metaFront").getByteArray();
for(int i=0;i<CHUNK_INDEX;i++) for(int i=0;i<CHUNK_INDEX;i++)
{ {
@ -104,8 +103,7 @@ public class Chunk implements IBdfClassManager
tiles_front[i] = Tiles.tiles.get(tf[i]); tiles_front[i] = Tiles.tiles.get(tf[i]);
tiles_back_meta[i] = mb[i]; tiles_back_meta[i] = mb[i];
tiles_front_meta[i] = mf[i]; tiles_front_meta[i] = mf[i];
tiles_lighting_src[i] = 0; tiles_lighting[i] = 0;
tiles_lighting_day[i] = 0;
} }
// Load all the entities // Load all the entities
@ -135,18 +133,18 @@ public class Chunk implements IBdfClassManager
tf[i] = tiles_front[i].id; tf[i] = tiles_front[i].id;
} }
nl.set("tb", BdfObject.withShortArray(tb)); nl.set("tilesBack", bdf.newObject().setShortArray(tb));
nl.set("tf", BdfObject.withShortArray(tf)); nl.set("tilesFront", bdf.newObject().setShortArray(tf));
nl.set("mb", BdfObject.withByteArray(tiles_back_meta)); nl.set("metaBack", bdf.newObject().setByteArray(tiles_back_meta));
nl.set("mf", BdfObject.withByteArray(tiles_front_meta)); nl.set("metaFront", bdf.newObject().setByteArray(tiles_front_meta));
// Save all the saveable entity data // Save all the saveable entity data
BdfArray bdf_entities = new BdfArray(); BdfArray bdf_entities = bdf.newArray();
nl.set("entities", BdfObject.withArray(bdf_entities)); nl.set("entities", bdf.newObject().setArray(bdf_entities));
for(Entity e : entities) { for(Entity e : entities) {
if(e.getID() == -1) if(e.getID() == -1)
continue; continue;
BdfObject bdf_e = new BdfObject(); BdfObject bdf_e = bdf.newObject();
e.BdfClassSave(bdf_e); e.BdfClassSave(bdf_e);
bdf_entities.add(bdf_e); bdf_entities.add(bdf_e);
} }
@ -179,8 +177,7 @@ public class Chunk implements IBdfClassManager
tiles_front_meta[i] = 0; tiles_front_meta[i] = 0;
// Set the light level to 0 // Set the light level to 0
tiles_lighting_src[i] = 0; tiles_lighting[i] = 0;
tiles_lighting_day[i] = 0;
} }
} }
@ -531,7 +528,7 @@ public class Chunk implements IBdfClassManager
{ {
// Send back the back tile // Send back the back tile
TileState ts = new TileState(this.tiles_back[id], this.tiles_back_meta[id]); TileState ts = new TileState(this.tiles_back[id], this.tiles_back_meta[id]);
ts.light = MathHelpers.biggest(getLightLevel(id), getDaylightLevel(id)); ts.light = getLightLevel(id);
return ts; return ts;
} }
@ -550,7 +547,7 @@ public class Chunk implements IBdfClassManager
{ {
// Send back the front tile // Send back the front tile
TileState ts = new TileState(this.tiles_front[id], this.tiles_front_meta[id]); TileState ts = new TileState(this.tiles_front[id], this.tiles_front_meta[id]);
ts.light = MathHelpers.biggest(getLightLevel(id), getDaylightLevel(id)); ts.light = getLightLevel(id);
return ts; return ts;
} }
@ -577,7 +574,7 @@ public class Chunk implements IBdfClassManager
} }
public double getLightLevel(int id) { public double getLightLevel(int id) {
return tiles_lighting_src[id] / (double)Byte.MAX_VALUE; return tiles_lighting[id] / (double)Byte.MAX_VALUE;
} }
public double getLightLevel(Vec2i pos) public double getLightLevel(Vec2i pos)
@ -591,23 +588,8 @@ public class Chunk implements IBdfClassManager
return getLightLevel(id); return getLightLevel(id);
} }
public double getDaylightLevel(int id) {
return tiles_lighting_day[id] / (double)Byte.MAX_VALUE;
}
public double getDaylightLevel(Vec2i pos)
{
// Get the id
Vec2i cpos = new Vec2i(0, 0);
cpos.x = MathHelpers.mod(pos.x, CHUNK_SIZE.mx);
cpos.y = MathHelpers.mod(pos.y, CHUNK_SIZE.my);
int id = cpos.getId(CHUNK_SIZE);
return getDaylightLevel(id);
}
public void setLightLevel(double light, int id) { public void setLightLevel(double light, int id) {
this.tiles_lighting_src[id] = (byte)(light * Byte.MAX_VALUE); this.tiles_lighting[id] = (byte)(light * Byte.MAX_VALUE);
} }
public void setLightLevel(double light, Vec2i pos) public void setLightLevel(double light, Vec2i pos)
@ -621,21 +603,6 @@ public class Chunk implements IBdfClassManager
setLightLevel(light, id); setLightLevel(light, id);
} }
public void setDaylightLevel(double light, int id) {
this.tiles_lighting_day[id] = (byte)(light * Byte.MAX_VALUE);
}
public void setDaylightLevel(double light, Vec2i pos)
{
// Get the id
Vec2i cpos = new Vec2i(0, 0);
cpos.x = MathHelpers.mod(pos.x, CHUNK_SIZE.mx);
cpos.y = MathHelpers.mod(pos.y, CHUNK_SIZE.my);
int id = cpos.getId(CHUNK_SIZE);
setDaylightLevel(light, id);
}
public void killEntity(Entity e) public void killEntity(Entity e)
{ {
if(e instanceof EntityKillWithParticles) { if(e instanceof EntityKillWithParticles) {

View File

@ -130,25 +130,6 @@ public class ChunkEmpty extends Chunk
@Override @Override
public void tickRandomly() { public void tickRandomly() {
} }
@Override
public double getDaylightLevel(int id) {
return 0;
}
@Override
public double getDaylightLevel(Vec2i pos) {
return 0;
}
@Override
public void setDaylightLevel(double light, int id) {
}
@Override
public void setDaylightLevel(double light, Vec2i pos) {
}
@Override @Override
public void clearDirty() { public void clearDirty() {
} }

View File

@ -11,7 +11,6 @@ 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;
@ -193,24 +192,6 @@ public class Layer implements IBdfClassManager
chunks.get(c_pos).setLightLevel(light, pos); chunks.get(c_pos).setLightLevel(light, pos);
} }
public double getDaylightLevel(Vec2i pos)
{
// Get the chunk pos
Vec2i c_pos = getChunkPosFromPos(pos);
// Get the chunks front tile
return chunks.get(c_pos).getDaylightLevel(pos);
}
public void setDaylightLevel(double light, Vec2i pos)
{
// Get the chunk pos
Vec2i c_pos = getChunkPosFromPos(pos);
// Get the chunks front tile
chunks.get(c_pos).setDaylightLevel(light, pos);
}
public void spawnEntity(Entity entity) public void spawnEntity(Entity entity)
{ {
// Get the chunk pos // Get the chunk pos
@ -303,6 +284,8 @@ public class Layer implements IBdfClassManager
Chunk chunk = new Chunk(this, cpos, chunk_nl.get("chunk")); Chunk chunk = new Chunk(this, cpos, chunk_nl.get("chunk"));
dirty_chunks.set(cpos, chunk); dirty_chunks.set(cpos, chunk);
} }
layergen.init(this);
} }
@Override @Override
@ -310,18 +293,18 @@ public class Layer implements IBdfClassManager
{ {
BdfNamedList nl = bdf.getNamedList(); BdfNamedList nl = bdf.getNamedList();
nl.set("lseed", BdfObject.withLong(lseed)); nl.set("lseed", bdf.newObject().setLong(lseed));
nl.set("seed", BdfObject.withLong(seed)); nl.set("seed", bdf.newObject().setLong(seed));
nl.set("id", BdfObject.withInteger(id)); nl.set("id", bdf.newObject().setInteger(id));
nl.set("lgen", BdfObject.withInteger(LayerGenerators.getLGID(this.layergen))); nl.set("lgen", bdf.newObject().setInteger(LayerGenerators.getLGID(this.layergen)));
BdfArray bdf_chunks = nl.get("chunks").getArray(); BdfArray bdf_chunks = nl.get("chunks").getArray();
for(Map2DElement<Chunk> chunk : dirty_chunks) { for(Map2DElement<Chunk> chunk : dirty_chunks) {
BdfNamedList chunk_nl = new BdfNamedList(); BdfNamedList chunk_nl = bdf.newNamedList();
chunk.pos.BdfClassSave(chunk_nl.get("pos")); chunk.pos.BdfClassSave(chunk_nl.get("pos"));
chunk.o.BdfClassSave(chunk_nl.get("chunk")); chunk.o.BdfClassSave(chunk_nl.get("chunk"));
bdf_chunks.add(BdfObject.withNamedList(chunk_nl)); bdf_chunks.add(bdf.newObject().setNamedList(chunk_nl));
} }
for(Map2DElement<Chunk> chunk : chunks) { for(Map2DElement<Chunk> chunk : chunks) {
@ -330,10 +313,10 @@ public class Layer implements IBdfClassManager
if(!chunk.o.isDirty()) if(!chunk.o.isDirty())
continue; continue;
BdfNamedList chunk_nl = new BdfNamedList(); BdfNamedList chunk_nl = bdf.newNamedList();
chunk.pos.BdfClassSave(chunk_nl.get("pos")); chunk.pos.BdfClassSave(chunk_nl.get("pos"));
chunk.o.BdfClassSave(chunk_nl.get("chunk")); chunk.o.BdfClassSave(chunk_nl.get("chunk"));
bdf_chunks.add(BdfObject.withNamedList(chunk_nl)); bdf_chunks.add(bdf.newObject().setNamedList(chunk_nl));
} }
} }

View File

@ -2,7 +2,6 @@ package projectzombie.world.layer.layergen;
import java.util.Random; import java.util.Random;
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 gl_engine.vec.Vec3d;
@ -19,7 +18,6 @@ import projectzombie.world.layer.Layer;
public class LayerGenBossArena extends LayerGen implements LayerGenRememberPlayerPos public class LayerGenBossArena extends LayerGen implements LayerGenRememberPlayerPos
{ {
private final Vec2i center = new Vec2i(0, 0);
private final int size = 10; private final int size = 10;
private Vec3d player_pos = new Vec3d(0, 0, 0); private Vec3d player_pos = new Vec3d(0, 0, 0);
private Random rand = new Random(); private Random rand = new Random();

View File

@ -15,7 +15,6 @@ import projectzombie.util.math.ColorRange;
import projectzombie.util.math.TileState; import projectzombie.util.math.TileState;
import projectzombie.util.math.random.NoiseGenerator; import projectzombie.util.math.random.NoiseGenerator;
import projectzombie.util.math.random.NoiseGeneratorSimplex; import projectzombie.util.math.random.NoiseGeneratorSimplex;
import projectzombie.util.math.random.OpenSimplexNoise;
import projectzombie.util.math.random.RandomHelpers; import projectzombie.util.math.random.RandomHelpers;
import projectzombie.world.World; import projectzombie.world.World;
import projectzombie.world.chunk.Chunk; import projectzombie.world.chunk.Chunk;

View File

@ -10,7 +10,6 @@ import projectzombie.Main;
import projectzombie.entity.Entity; import projectzombie.entity.Entity;
import projectzombie.entity.EntityZombie; import projectzombie.entity.EntityZombie;
import projectzombie.init.Tiles; import projectzombie.init.Tiles;
import projectzombie.tiles.Tile;
import projectzombie.time.GameTimer; import projectzombie.time.GameTimer;
import projectzombie.util.math.ColorRange; import projectzombie.util.math.ColorRange;
import projectzombie.util.math.TileState; import projectzombie.util.math.TileState;

View File

@ -14,7 +14,6 @@ import projectzombie.util.math.ColorRange;
import projectzombie.util.math.TileState; import projectzombie.util.math.TileState;
import projectzombie.util.math.random.NoiseGenerator; import projectzombie.util.math.random.NoiseGenerator;
import projectzombie.util.math.random.NoiseGeneratorSimplex; import projectzombie.util.math.random.NoiseGeneratorSimplex;
import projectzombie.util.math.random.OpenSimplexNoise;
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;

View File

@ -35,7 +35,7 @@ vec3 color_grass_hot_dry = vec3(1, 0.6, 0);
vec3 color_grass_cold_wet = vec3(0.075, 0.533, 0.047); vec3 color_grass_cold_wet = vec3(0.075, 0.533, 0.047);
vec3 color_grass_cold_dry = vec3(0.812, 0.761, 0); vec3 color_grass_cold_dry = vec3(0.812, 0.761, 0);
float depth_c = 0.001; float depth_c = 0.0001;
float map(float x, float in_min, float in_max, float out_min, float out_max) { float map(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
@ -81,11 +81,11 @@ void main()
vec3 light_day = pSunDepth.z < (texture(depthmap, sunDepthTexPos).r * 2 - 1 + depth_c vec3 light_day = pSunDepth.z < (texture(depthmap, sunDepthTexPos).r * 2 - 1 + depth_c
) ? lighting_day_high : lighting_day_low; ) ? lighting_day_high : lighting_day_low;
vec3 light_src = vec3(1, 1, 1) * (scaleLight(max(0, light.g)) - abs(pLightMapPos.y) * 0.1); vec3 light_src = vec3(1, 1, 1) * (scaleLight(max(0, light.r)) - abs(pLightMapPos.y) * 0.1);
vec4 rgb = vec4((pRGB % 64) / 64.0, ((pRGB >> 6) % 64) / 64.0, ((pRGB >> 12) % 64) / 64.0, 1); vec4 rgb = vec4((pRGB % 64) / 64.0, ((pRGB >> 6) % 64) / 64.0, ((pRGB >> 12) % 64) / 64.0, 1);
vec4 color_grass = vec4(interpolate2RGB( vec4 color_grass = vec4(interpolate2RGB(
smoothStep(light.b), smoothStep(light.a), smoothStep(light.g), smoothStep(light.b),
color_grass_cold_dry, color_grass_hot_dry, color_grass_cold_dry, color_grass_hot_dry,
color_grass_cold_wet, color_grass_hot_wet), 1); color_grass_cold_wet, color_grass_hot_wet), 1);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

View File

@ -1,216 +1,232 @@
./tile/hemp6.png ./text/char_question.png
./tile/hemp7.png ./text/char_l_a.png
./tile/hemp1.png ./text/char_u_j.png
./tile/rock.png ./text/char_l_u.png
./tile/rock_ice.png ./text/char_u_s.png
./tile/sapling3.png ./text/char_l_s.png
./tile/ladder.png ./text/char_apostrophe.png
./tile/tree_leaves_snow.png ./text/char_plus.png
./tile/ice_wall.png ./text/char_l_e.png
./tile/water.png ./text/char_7.png
./tile/sandstone_wall.png ./text/char_minus.png
./tile/ladder_up.png ./text/char_u_r.png
./tile/cactus4.png ./text/char_u_l.png
./tile/tall_grass.png ./text/char_obracket.png
./tile/cactus2.png ./text/char_pow.png
./tile/grass_infested.png ./text/char_u_m.png
./tile/tree_branch_leaves.png ./text/char_l_t.png
./tile/dirt.png ./text/char_percent.png
./tile/wall.png ./text/char_l_y.png
./tile/tree_base.png ./text/char_0.png
./tile/cactus1.png ./text/char_4.png
./tile/sapling4.png ./text/char_l_r.png
./tile/hemp3.png ./text/char_l_m.png
./tile/cactus_top.png ./text/char_cbracket.png
./tile/tunnel_down.png ./text/char_u_g.png
./tile/stone.png ./text/char_u_q.png
./tile/snow.png ./text/char_u_i.png
./tile/boss_portal.png ./text/char_tilde.png
./tile/hemp4.png ./text/char_l_w.png
./tile/sand.png ./text/char_l_v.png
./tile/lantern.png ./text/char_fslash.png
./tile/ice.png ./text/char_u_p.png
./tile/sapling1.png ./text/char_gthan.png
./tile/chest.png ./text/char_8.png
./tile/hemp2.png ./text/char_unknown.png
./tile/hemp8.png ./text/char_and.png
./tile/cactus3.png ./text/char_osbracket.png
./tile/lava.png ./text/char_u_n.png
./tile/tree_leaves.png ./text/char_l_i.png
./tile/hemp5.png ./text/char_u_y.png
./tile/lava_flow.png ./text/char_l_p.png
./tile/grass.png ./text/char_lthan.png
./tile/tree_branch.png ./text/char_l_g.png
./tile/sandstone.png ./text/char_bslash.png
./tile/tree_branch_leaves_snow.png ./text/char_1.png
./tile/rock_sandstone.png ./text/char_u_z.png
./tile/sapling2.png ./text/char_l_f.png
./text/char_u_w.png
./text/char_9.png
./text/char_l_x.png
./text/char_ccbracket.png
./text/char_l_o.png
./text/char_equals.png
./text/char_l_d.png
./text/char_dollar.png
./text/char_hashtag.png
./text/char_l_q.png
./text/char_u_o.png
./text/char_6.png
./text/char_u_d.png
./text/char_u_e.png
./text/char_exclamation.png
./text/char_vertical.png
./text/char_ocbracket.png
./text/char_u_k.png
./text/char_u_c.png
./text/char_l_n.png
./text/char_semicolon.png
./text/char_u_b.png
./text/char_u_f.png
./text/char_l_h.png
./text/char_l_k.png
./text/char_u_t.png
./text/char_3.png
./text/char_u_v.png
./text/char_u_h.png
./text/char_quotation.png
./text/char_u_a.png
./text/char_l_b.png
./text/char_underscore.png
./text/char_u_x.png
./text/char_comma.png
./text/char_csbracket.png
./text/char_l_l.png
./text/char_5.png
./text/char_star.png
./text/char_colon.png
./text/char_l_z.png
./text/char_space.png
./text/char_2.png
./text/char_at.png
./text/char_grave.png
./text/char_l_j.png
./text/char_fullstop.png
./text/char_l_c.png
./text/char_u_u.png
./list.txt ./list.txt
./item/log.png ./player/player_white_front_moving.png
./item/rock.png ./player/player_white_back_moving.png
./item/acorn.png ./player/player_black_back_moving.png
./item/ammo_box.png ./player/player_black_back_still.png
./item/plant_fibre.png
./item/hemp_seed.png
./item/shield_upgrade.png
./item/grappling_hook.png
./item/log_snow.png
./item/health_potion.png
./item/snow_pile.png
./item/gun_upgrade.png
./item/sandstone.png
./item/flint.png
./player/player_white_back_still.png ./player/player_white_back_still.png
./player/player_white_front_still.png ./player/player_white_front_still.png
./player/player_black_front_moving.png ./player/player_black_front_moving.png
./player/player_black_front_still.png ./player/player_black_front_still.png
./player/player_black_back_moving.png ./particle/smoke_trail.png
./player/player_black_back_still.png ./particle/water.png
./player/player_white_back_moving.png ./particle/smoke_0.png
./player/player_white_front_moving.png ./particle/smoke_1.png
./gui/pixel_white.png ./particle/blood.png
./gui/water.png ./particle/lava.png
./gui/gun.png ./particle/bullet.png
./gui/button_delete.png ./particle/smoke_2.png
./gui/button_delete_hover.png ./particle/snow.png
./gui/slot_armor_chest.png ./particle/rain.png
./gui/pixel_black.png ./particle/smoke_4.png
./gui/slot_clothing_shirt.png ./particle/smoke_3.png
./gui/button_play.png ./particle/smoke_5.png
./gui/slot_armor_legs.png
./gui/inventory.png
./gui/selection_box.png
./gui/label.png
./gui/slot_clothing_pants.png
./gui/health_empty.png
./gui/hotbar_selected.png
./gui/health_full.png
./gui/temperature.png ./gui/temperature.png
./gui/button_play_hover.png ./gui/slot_armor_chest.png
./gui/slot_armor_helmet.png ./gui/health_empty.png
./gui/slot_clothing_boots.png
./gui/hotbar.png
./gui/button_normal.png
./gui/shield.png
./gui/button_hover.png ./gui/button_hover.png
./text/char_bslash.png ./gui/water.png
./text/char_dollar.png ./gui/slot_armor_legs.png
./text/char_l_w.png ./gui/selection_box_big.png
./text/char_u_d.png ./gui/button_normal.png
./text/char_u_t.png ./gui/label.png
./text/char_space.png ./gui/hotbar.png
./text/char_l_x.png ./gui/slot_armor_helmet.png
./text/char_l_k.png ./gui/button_delete.png
./text/char_6.png ./gui/text_cursor.png
./text/char_unknown.png ./gui/inventory.png
./text/char_comma.png ./gui/button_delete_hover.png
./text/char_obracket.png ./gui/button_play_hover.png
./text/char_u_w.png ./gui/health_full.png
./text/char_7.png ./gui/hotbar_selected.png
./text/char_l_f.png ./gui/slot_clothing_shirt.png
./text/char_vertical.png ./gui/pixel_white.png
./text/char_plus.png ./gui/pixel_black.png
./text/char_u_a.png ./gui/slot_clothing_pants.png
./text/char_9.png ./gui/text_box.png
./text/char_u_k.png ./gui/shield.png
./text/char_u_n.png ./gui/slot_clothing_boots.png
./text/char_percent.png ./gui/selection_box_wide.png
./text/char_u_m.png ./gui/gun.png
./text/char_exclamation.png ./gui/button_play.png
./text/char_1.png ./tile/cactus4.png
./text/char_l_q.png ./tile/hemp1.png
./text/char_l_z.png ./tile/dirt.png
./text/char_l_h.png ./tile/lantern.png
./text/char_u_c.png ./tile/hemp8.png
./text/char_l_g.png ./tile/wall.png
./text/char_l_s.png ./tile/cactus_top.png
./text/char_fullstop.png ./tile/cactus2.png
./text/char_u_j.png ./tile/rock.png
./text/char_l_m.png ./tile/water.png
./text/char_l_t.png ./tile/hemp4.png
./text/char_u_v.png ./tile/stone.png
./text/char_colon.png ./tile/tree_leaves.png
./text/char_l_i.png ./tile/sapling2.png
./text/char_l_y.png ./tile/ladder_up.png
./text/char_u_l.png ./tile/sapling3.png
./text/char_u_e.png ./tile/lava_flow.png
./text/char_5.png ./tile/ice_wall.png
./text/char_2.png ./tile/grass.png
./text/char_3.png ./tile/chest.png
./text/char_l_p.png ./tile/sapling4.png
./text/char_fslash.png ./tile/lava.png
./text/char_l_u.png ./tile/tall_grass.png
./text/char_u_f.png ./tile/hemp5.png
./text/char_u_u.png ./tile/sapling1.png
./text/char_l_e.png ./tile/snow.png
./text/char_l_l.png ./tile/sandstone_wall.png
./text/char_u_g.png ./tile/rock_sandstone.png
./text/char_u_q.png ./tile/hemp6.png
./text/char_u_b.png ./tile/cactus1.png
./text/char_l_o.png ./tile/tree_branch_leaves.png
./text/char_minus.png ./tile/tunnel_down.png
./text/char_l_v.png ./tile/tree_branch_leaves_snow.png
./text/char_lthan.png ./tile/tree_leaves_snow.png
./text/char_u_s.png ./tile/rock_ice.png
./text/char_equals.png ./tile/boss_portal.png
./text/char_8.png ./tile/ladder.png
./text/char_underscore.png ./tile/hemp7.png
./text/char_u_x.png ./tile/grass_infested.png
./text/char_0.png ./tile/tree_branch.png
./text/char_l_d.png ./tile/sand.png
./text/char_l_c.png ./tile/tree_base.png
./text/char_l_j.png ./tile/cactus3.png
./text/char_u_z.png ./tile/sandstone.png
./text/char_u_h.png ./tile/hemp3.png
./text/char_hashtag.png ./tile/hemp2.png
./text/char_gthan.png ./tile/ice.png
./text/char_cbracket.png
./text/char_u_i.png
./text/char_question.png
./text/char_u_o.png
./text/char_u_y.png
./text/char_l_r.png
./text/char_l_b.png
./text/char_l_a.png
./text/char_l_n.png
./text/char_u_p.png
./text/char_u_r.png
./text/char_4.png
./entity/armored_zombie_back_moving.png
./entity/zombie_front_still.png
./entity/tnt.png
./entity/flare.png ./entity/flare.png
./entity/boss1/boss_walking.png ./entity/grappling_hook.png
./entity/zombie_back_moving.png
./entity/tnt.png
./entity/armored_zombie_back_moving.png
./entity/armored_zombie_front_moving.png
./entity/player/hair_side.png
./entity/player/head_top.png
./entity/player/head_side.png
./entity/player/head_back.png
./entity/player/head_bottom.png
./entity/player/hair_front.png
./entity/player/head_front.png
./entity/player/hair_back.png
./entity/player/hair_top.png
./entity/dummy.png
./entity/armored_zombie_front_still.png
./entity/armored_zombie_back_still.png
./entity/zombie_front_moving.png
./entity/boss1/boss_walking_firing.png
./entity/boss1/boss_firing.png ./entity/boss1/boss_firing.png
./entity/boss1/boss_still.png ./entity/boss1/boss_still.png
./entity/boss1/boss_walking_firing.png ./entity/boss1/boss_walking.png
./entity/armored_zombie_back_still.png
./entity/armored_zombie_front_moving.png
./entity/player/head_back.png
./entity/player/hair_top.png
./entity/player/head_front.png
./entity/player/head_top.png
./entity/player/hair_side.png
./entity/player/head_side.png
./entity/player/hair_back.png
./entity/player/hair_front.png
./entity/player/head_bottom.png
./entity/grappling_hook.png
./entity/zombie_back_still.png ./entity/zombie_back_still.png
./entity/dummy.png ./entity/zombie_front_still.png
./entity/zombie_back_moving.png ./item/acorn.png
./entity/armored_zombie_front_still.png ./item/grappling_hook.png
./entity/zombie_front_moving.png ./item/gun_upgrade.png
./particle/smoke_1.png ./item/shield_upgrade.png
./particle/water.png ./item/rock.png
./particle/rain.png ./item/log.png
./particle/blood.png ./item/log_snow.png
./particle/snow.png ./item/hemp_seed.png
./particle/smoke_3.png ./item/ammo_box.png
./particle/smoke_4.png ./item/plant_fibre.png
./particle/smoke_2.png ./item/health_potion.png
./particle/smoke_0.png ./item/snow_pile.png
./particle/bullet.png ./item/flint.png
./particle/lava.png ./item/sandstone.png
./particle/smoke_trail.png
./particle/smoke_5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Some files were not shown because too many files have changed in this diff Show More