diff --git a/src/projectzombie/audio/AudioObject.java b/src/projectzombie/audio/AudioObject.java index fd89462..589be10 100755 --- a/src/projectzombie/audio/AudioObject.java +++ b/src/projectzombie/audio/AudioObject.java @@ -27,6 +27,7 @@ import projectzombie.resources.Resource; public class AudioObject { + double volume; int bufferPointer; Resource resource; boolean error; @@ -34,10 +35,11 @@ public class AudioObject int sample_rate; int output; - public AudioObject(Resource resource) + public AudioObject(Resource resource, double volume) { // Store the argument values this.resource = resource; + this.volume = volume; this.error = false; } @@ -93,7 +95,7 @@ public class AudioObject int source = AudioSources.getSource(); alSourceStop(source); alSourcei(source, AL_BUFFER, bufferPointer); - alSourcef(source, AL_GAIN, (float)volume); + alSourcef(source, AL_GAIN, (float)(volume * this.volume)); alSource3f(source, AL_POSITION, (float)vec.x, (float)vec.y, (float)vec.z); alSourcePlay(source); } diff --git a/src/projectzombie/audio/AudioRandom.java b/src/projectzombie/audio/AudioRandom.java index 15015ab..91abd9f 100755 --- a/src/projectzombie/audio/AudioRandom.java +++ b/src/projectzombie/audio/AudioRandom.java @@ -10,7 +10,7 @@ public class AudioRandom extends AudioObject private static Random rand = new Random(); public AudioRandom(AudioObject ... audioObjects) { - super(null); + super(null, 0); // Set the specified parameters this.audioObjects = audioObjects; diff --git a/src/projectzombie/display/DisplayRender.java b/src/projectzombie/display/DisplayRender.java index 7e052d4..cf1adc1 100755 --- a/src/projectzombie/display/DisplayRender.java +++ b/src/projectzombie/display/DisplayRender.java @@ -21,6 +21,10 @@ public class DisplayRender glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, w, h); + GL33.glEnable(GL33.GL_DEPTH_TEST); + GL33.glUniform4f(Main.window.glsl_color, 1, 1, 1, 1); + GL33.glUniform2f(Main.window.glsl_tex_cut, 0, 0); + if(Main.menu.doGameRender) { if(ChunkEventHandler.loaded) @@ -49,9 +53,7 @@ public class DisplayRender if(!Main.player.dead) { Model model = player.getModel(); - Matrix4 matrix = Matrix4.translate(player.pos.x - 0.5, player.getHeight(), player.pos.y - 0.5); - GL33.glUniformMatrix4fv(Main.window.glsl_model, true, matrix.getArray()); - model.bind(); + model.setModel(Matrix4.translate(player.pos.x - 0.5, player.getHeight(), player.pos.y - 0.5)); model.render(); } } diff --git a/src/projectzombie/display/DisplayRenderUI.java b/src/projectzombie/display/DisplayRenderUI.java index 5ac3995..747e3df 100755 --- a/src/projectzombie/display/DisplayRenderUI.java +++ b/src/projectzombie/display/DisplayRenderUI.java @@ -2,11 +2,17 @@ package projectzombie.display; import org.lwjgl.opengl.GL33; +import gl_engine.MathHelpers; import gl_engine.matrix.Matrix4; import gl_engine.vec.Vec3d; import projectzombie.Main; import projectzombie.init.Models; +import projectzombie.inventory.Inventory; +import projectzombie.model.Model; +import projectzombie.model.ModelGui; +import projectzombie.text.Text; import projectzombie.util.gl.GlHelpers; +import projectzombie.util.math.ItemStack; public class DisplayRenderUI { @@ -14,17 +20,83 @@ public class DisplayRenderUI public static boolean showPos = false; public static int guiScale = 2; + public static void renderGameGui() + { + { + Matrix4 matrix = Matrix4.translate(-Models.UI_ITEM_SLOTS.getWidth() / 2, -9.5, 0); + Inventory inventory = Main.player.getInventory(); + + int slot = Main.player.inventory_hand; + double offset = Models.UI_ITEM_SLOTS.getWidth() / 10; + Matrix4 matrix_slot = Matrix4.multiply(matrix, Matrix4.translate(offset * slot, 0, 0)); + + Models.UI_ITEM_SLOTS.setModel(matrix); + Models.UI_ITEM_SLOTS.render(); + + Models.UI_ACTIVE_SLOT.setModel(matrix_slot); + Models.UI_ACTIVE_SLOT.render(); + + for(int i = 0; i < inventory.getSlotCount(); i++) + { + ItemStack stack = inventory.getItem(i); + + if(stack.isEmpty()) { + continue; + } + + Model model_item = stack.item.getModel(stack.meta).getGuiModel(); + double item_offset = (Models.UI_ACTIVE_SLOT.getHeight() - model_item.getHeight()) / 2; + + Matrix4 matrix_item = Matrix4.multiply(matrix, Matrix4.translate(i * offset + item_offset, item_offset, 0)); + + model_item.setModel(matrix_item); + model_item.render(); + + if(stack.count > 1) + { + matrix_item = Matrix4.multiply(matrix, Matrix4.translate(i * offset + 0.25, 0.28125, 0)); + matrix_item = Matrix4.multiply(Matrix4.scale(new Vec3d(0.4, 0.4, 0.4)), matrix_item); + + Text.render("" + stack.count, matrix_item); + } + } + } + + { + ModelGui model_health_f = Models.UI_HEALTH_FG; + ModelGui model_health_b = Models.UI_HEALTH_BG; + + Matrix4 matrix = Matrix4.translate(-model_health_f.getWidth() / 2, -8, 0); + + model_health_b.setModel(matrix); + model_health_b.render(); + + GL33.glUniform2f(Main.window.glsl_tex_cut, 1, (float)MathHelpers.map( + Main.player.getHealth(), + 0, Main.player.maxHealth(), + 0, model_health_f.getWidth())); + + model_health_f.setModel(matrix); + model_health_f.render(); + + GL33.glUniform2f(Main.window.glsl_tex_cut, 0, 0); + } + } + public static void render() { - Matrix4 matrix = Matrix4.identity(); - Matrix4 projection = Matrix4.scale(new Vec3d(1/GlHelpers.getAspectRatio(), 1, 1)); + Matrix4 camera = Matrix4.identity(); + Matrix4 projection = Matrix4.scale(new Vec3d(0.1/GlHelpers.getAspectRatio(), 0.1, 1)); GL33.glUniformMatrix4fv(Main.window.glsl_projection, true, projection.getArray()); - GL33.glUniformMatrix4fv(Main.window.glsl_camera, true, matrix.getArray()); - GL33.glUniformMatrix4fv(Main.window.glsl_model, true, matrix.getArray()); + GL33.glUniformMatrix4fv(Main.window.glsl_camera, true, camera.getArray()); - Models.UI_ITEM_SLOTS.bind(); - Models.UI_ITEM_SLOTS.render(); + GL33.glDisable(GL33.GL_DEPTH_TEST); + + if(Main.menu.doGameRender && Main.menu.showIngameGUI) + { + renderGameGui(); + } // Render the loaded menu //Main.menu.render(); diff --git a/src/projectzombie/display/DisplayWindow.java b/src/projectzombie/display/DisplayWindow.java index 344c3ff..effb382 100755 --- a/src/projectzombie/display/DisplayWindow.java +++ b/src/projectzombie/display/DisplayWindow.java @@ -33,6 +33,8 @@ public class DisplayWindow implements IMainloopTask public GraphicsShader environmentRenderer; + public int glsl_color; + public int glsl_tex_cut; public int glsl_model; public int glsl_projection; public int glsl_rotated; @@ -74,7 +76,7 @@ public class DisplayWindow implements IMainloopTask width = w.get()*4; height = h.get()*4; - //GLFW.glfwWindowHint(GLFW.GLFW_DOUBLEBUFFER, GLFW.GLFW_FALSE); + GLFW.glfwWindowHint(GLFW.GLFW_DOUBLEBUFFER, GLFW.GLFW_FALSE); // Create the window window = GraphicsHelpers.initWindow("Project Zombie", width, height, monitor); @@ -97,9 +99,6 @@ public class DisplayWindow implements IMainloopTask // Show the window //GLFW.glfwShowWindow(this.window); - GL33.glEnable(GL33.GL_DEPTH_TEST); - //GL33.glEnable(GL33.GL_BLEND); - environmentRenderer = new GraphicsShader("/resources/shader/environmentRenderer"); environmentRenderer.use(); @@ -108,6 +107,8 @@ public class DisplayWindow implements IMainloopTask glsl_rotated = GL33.glGetUniformLocation(environmentRenderer.program, "rotated"); glsl_projection = GL33.glGetUniformLocation(environmentRenderer.program, "projection"); glsl_time = GL33.glGetUniformLocation(environmentRenderer.program, "time"); + glsl_tex_cut = GL33.glGetUniformLocation(environmentRenderer.program, "tex_cut"); + glsl_color = GL33.glGetUniformLocation(environmentRenderer.program, "color"); } public void render() diff --git a/src/projectzombie/entity/player/EntityPlayer.java b/src/projectzombie/entity/player/EntityPlayer.java index 245897c..645c9e6 100755 --- a/src/projectzombie/entity/player/EntityPlayer.java +++ b/src/projectzombie/entity/player/EntityPlayer.java @@ -16,6 +16,7 @@ import projectzombie.entity.particle.ParticleBreak; import projectzombie.init.Items; import projectzombie.init.Models; import projectzombie.inventory.Inventory; +import projectzombie.items.spawner.ItemSpawnZombie; import projectzombie.menu.MenuDeath; import projectzombie.model.Model; import projectzombie.settings.Cheats; @@ -46,16 +47,12 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory private Inventory inventory; public int inventory_hand = 0; - public int ammo = 1000; - public int defence_level = 0; public int gun_level = 0; public double angle; public double speed; - private static final Vec2d size = new Vec2d(1, 1); - public EntityPlayer(BdfObject bdf) { super(bdf); } @@ -69,12 +66,15 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory health = nl.get("health").getDouble(); dead = nl.get("dead").getBoolean(); inventory = new Inventory(nl.get("inventory")); - ammo = nl.get("ammo").getInteger(); defence_level = nl.get("defence_level").getInteger(); gun_level = nl.get("gun_level").getInteger(); angle = nl.get("angle").getDouble(); } + public int getAmmo() { + return inventory.getItemCount(Items.AMMO); + } + @Override public void BdfClassSave(BdfObject bdf) { super.BdfClassSave(bdf); @@ -84,7 +84,6 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory nl.set("health", BdfObject.withDouble(health)); nl.set("dead", BdfObject.withBoolean(dead)); inventory.BdfClassSave(nl.get("inventory")); - nl.set("ammo", BdfObject.withInteger(ammo)); nl.set("defence_level", BdfObject.withInteger(defence_level)); nl.set("gun_level", BdfObject.withInteger(gun_level)); nl.set("angle", BdfObject.withDouble(angle)); @@ -104,10 +103,7 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory speed = 0.1; // Create the inventory - inventory = new Inventory(6); - - inventory.setItem(new ItemStack(Items.LANTERN, 99, (byte)0), 2); - inventory.setItem(new ItemStack(Items.SPAWN_ZOMBIE, 99, (byte)0), 3); + inventory = new Inventory(10); } @Override @@ -235,10 +231,10 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory bullet_frequency %= 10; // Is there enough ammo and are the bullets at the right frequency - if(bullet_frequency == 0 && ammo > 0) + if(bullet_frequency == 0 && getAmmo() > 0) { // Remove some ammo - ammo -= 1; + inventory.removeItem(Items.AMMO, 1); // Summon bullets at this angle relative to the player int d = (int)(1 + gun_level / 4.0); diff --git a/src/projectzombie/init/Items.java b/src/projectzombie/init/Items.java index 86d7ea6..1028477 100755 --- a/src/projectzombie/init/Items.java +++ b/src/projectzombie/init/Items.java @@ -13,6 +13,7 @@ import projectzombie.items.ItemHealthPotion; import projectzombie.items.ItemLantern; import projectzombie.items.ItemRock; import projectzombie.items.ItemTnt; +import projectzombie.items.spawner.ItemSpawnDummy; import projectzombie.items.spawner.ItemSpawnZombie; public class Items @@ -56,7 +57,7 @@ public class Items public static final Item GRAPPLING_HOOK = new ItemGrapplingHook(); public static final Item SPAWN_ZOMBIE = new ItemSpawnZombie(); - public static final Item SPAWN_DUMMY = new ItemSpawnZombie(); + public static final Item SPAWN_DUMMY = new ItemSpawnDummy(); public static final Item ROCK = new ItemRock(); } diff --git a/src/projectzombie/init/Models.java b/src/projectzombie/init/Models.java index 3933cbf..d4cabd8 100755 --- a/src/projectzombie/init/Models.java +++ b/src/projectzombie/init/Models.java @@ -53,16 +53,16 @@ public class Models new ModelVertical(Resources.ATLAS.get("/particle/smoke_4.png")), new ModelVertical(Resources.ATLAS.get("/particle/smoke_5.png"))); - public static final Model BUTTON = new ModelGui(Resources.ATLAS.get("/gui/button.png")); - public static final Model BUTTON_HOVER = new ModelGui(Resources.ATLAS.get("/tile/tree.png")); + public static final ModelGui UI_BUTTON = new ModelGui(Resources.ATLAS.get("/gui/button.png")); + public static final ModelGui UI_BUTTON_HOVER = new ModelGui(Resources.ATLAS.get("/tile/tree.png")); - public static final Model UI_HEALTH_FG = new ModelGui(Resources.ATLAS.get("/gui/health_full.png")); - public static final Model UI_HEALTH_BG = new ModelGui(Resources.ATLAS.get("/gui/health_empty.png")); - public static final Model UI_ITEM_SLOTS = new ModelGui(Resources.ATLAS.get("/gui/hotbar.png"), new Vec2d(6, 1)); - public static final Model UI_ACTIVE_SLOT = new ModelGui(Resources.ATLAS.get("/gui/hotbar_selected.png")); + public static final ModelGui UI_HEALTH_FG = new ModelGui(Resources.ATLAS.get("/gui/health_full.png"), new Vec2d(8, 0.5)); + public static final ModelGui UI_HEALTH_BG = new ModelGui(Resources.ATLAS.get("/gui/health_empty.png"), new Vec2d(8, 0.5)); + public static final ModelGui UI_ITEM_SLOTS = new ModelGui(Resources.ATLAS.get("/gui/hotbar.png"), new Vec2d(15, 1.5)); + public static final ModelGui UI_ACTIVE_SLOT = new ModelGui(Resources.ATLAS.get("/gui/hotbar_selected.png"), new Vec2d(1.5, 1.5)); - public static final Model UI_DEFENCE_LEVEL = new ModelGui(Resources.ATLAS.get("/gui/shield.png")); - public static final Model UI_GUN_LEVEL = new ModelGui(Resources.ATLAS.get("/gui/gun.png")); + public static final ModelGui UI_DEFENCE_LEVEL = new ModelGui(Resources.ATLAS.get("/gui/shield.png")); + public static final ModelGui UI_GUN_LEVEL = new ModelGui(Resources.ATLAS.get("/gui/gun.png")); public static final ModelItem ITEM_EMPTY = ModelItem.createEmpty(); public static final ModelItem ITEM_GRAPPLING_HOOK = new ModelItem(Resources.ATLAS.get("/item/grappling_hook.png")); diff --git a/src/projectzombie/init/Sounds.java b/src/projectzombie/init/Sounds.java index 4c7ac56..f565e5d 100755 --- a/src/projectzombie/init/Sounds.java +++ b/src/projectzombie/init/Sounds.java @@ -25,27 +25,27 @@ public class Sounds EXPLOSION.init(); } - public static final AudioObject GUN_0 = new AudioObject(Resources.GUN_OGG_0); - public static final AudioObject GUN_1 = new AudioObject(Resources.GUN_OGG_1); - public static final AudioObject GUN_2 = new AudioObject(Resources.GUN_OGG_2); - public static final AudioObject GUN_3 = new AudioObject(Resources.GUN_OGG_3); - public static final AudioObject GUN_4 = new AudioObject(Resources.GUN_OGG_4); - public static final AudioObject GUN_5 = new AudioObject(Resources.GUN_OGG_5); - public static final AudioObject GUN_6 = new AudioObject(Resources.GUN_OGG_6); - public static final AudioObject GUN_7 = new AudioObject(Resources.GUN_OGG_7); - public static final AudioObject GUN_8 = new AudioObject(Resources.GUN_OGG_8); - public static final AudioObject GUN_9 = new AudioObject(Resources.GUN_OGG_9); + public static final AudioObject GUN_0 = new AudioObject(Resources.GUN_OGG_0, 1); + public static final AudioObject GUN_1 = new AudioObject(Resources.GUN_OGG_1, 1); + public static final AudioObject GUN_2 = new AudioObject(Resources.GUN_OGG_2, 1); + public static final AudioObject GUN_3 = new AudioObject(Resources.GUN_OGG_3, 1); + public static final AudioObject GUN_4 = new AudioObject(Resources.GUN_OGG_4, 1); + public static final AudioObject GUN_5 = new AudioObject(Resources.GUN_OGG_5, 1); + public static final AudioObject GUN_6 = new AudioObject(Resources.GUN_OGG_6, 1); + public static final AudioObject GUN_7 = new AudioObject(Resources.GUN_OGG_7, 1); + public static final AudioObject GUN_8 = new AudioObject(Resources.GUN_OGG_8, 1); + public static final AudioObject GUN_9 = new AudioObject(Resources.GUN_OGG_9, 1); public static final AudioObject GUN = new AudioRandom( GUN_0,GUN_1,GUN_2,GUN_3,GUN_4, GUN_5,GUN_6,GUN_7,GUN_8,GUN_9); - public static final AudioObject HIT_0 = new AudioObject(Resources.HIT_OGG_0); - public static final AudioObject HIT_1 = new AudioObject(Resources.HIT_OGG_1); - public static final AudioObject HIT_2 = new AudioObject(Resources.HIT_OGG_2); + public static final AudioObject HIT_0 = new AudioObject(Resources.HIT_OGG_0, 1); + public static final AudioObject HIT_1 = new AudioObject(Resources.HIT_OGG_1, 1); + public static final AudioObject HIT_2 = new AudioObject(Resources.HIT_OGG_2, 1); public static final AudioObject HIT = new AudioRandom( HIT_0, HIT_1, HIT_2); - public static final AudioObject EXPLOSION = new AudioObject(Resources.EXPLOSION_OGG); + public static final AudioObject EXPLOSION = new AudioObject(Resources.EXPLOSION_OGG, 10); } diff --git a/src/projectzombie/input/KeyCallback.java b/src/projectzombie/input/KeyCallback.java index d96281c..5dea276 100755 --- a/src/projectzombie/input/KeyCallback.java +++ b/src/projectzombie/input/KeyCallback.java @@ -1,27 +1,7 @@ package projectzombie.input; -import static org.lwjgl.glfw.GLFW.GLFW_KEY_1; -import static org.lwjgl.glfw.GLFW.GLFW_KEY_2; -import static org.lwjgl.glfw.GLFW.GLFW_KEY_3; -import static org.lwjgl.glfw.GLFW.GLFW_KEY_4; -import static org.lwjgl.glfw.GLFW.GLFW_KEY_5; -import static org.lwjgl.glfw.GLFW.GLFW_KEY_6; -import static org.lwjgl.glfw.GLFW.GLFW_KEY_A; -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_ESCAPE; -import static org.lwjgl.glfw.GLFW.GLFW_KEY_F11; -import static org.lwjgl.glfw.GLFW.GLFW_KEY_Q; -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_RELEASE; -import static projectzombie.input.GameInput.backButton_last; -import static projectzombie.input.GameInput.fireGun; -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 static org.lwjgl.glfw.GLFW.*; +import static projectzombie.input.GameInput.*; import org.lwjgl.glfw.GLFWKeyCallbackI; @@ -80,6 +60,18 @@ public class KeyCallback implements GLFWKeyCallbackI, IMainloopTask if(key == GLFW_KEY_6 && pressed) { input.hotbarGoto(true, 5); } + if(key == GLFW_KEY_7 && pressed) { + input.hotbarGoto(true, 6); + } + if(key == GLFW_KEY_8 && pressed) { + input.hotbarGoto(true, 7); + } + if(key == GLFW_KEY_9 && pressed) { + input.hotbarGoto(true, 8); + } + if(key == GLFW_KEY_0 && pressed) { + input.hotbarGoto(true, 9); + } if(key == GLFW_KEY_E) { if(pressed) { diff --git a/src/projectzombie/input/types/InputGame.java b/src/projectzombie/input/types/InputGame.java index 8d24d8f..f3b7a00 100755 --- a/src/projectzombie/input/types/InputGame.java +++ b/src/projectzombie/input/types/InputGame.java @@ -67,7 +67,7 @@ public class InputGame implements Input @Override public void hotbarShift(boolean state, int amount) { Main.player.inventory_hand += amount; - Main.player.inventory_hand = MathHelpers.mod(Main.player.inventory_hand, 6); + Main.player.inventory_hand = MathHelpers.mod(Main.player.inventory_hand, Main.player.getInventory().getSlotCount()); } @Override diff --git a/src/projectzombie/inventory/Inventory.java b/src/projectzombie/inventory/Inventory.java index a06a9e3..d5eeae7 100755 --- a/src/projectzombie/inventory/Inventory.java +++ b/src/projectzombie/inventory/Inventory.java @@ -4,6 +4,7 @@ import bdf.classes.IBdfClassManager; import bdf.types.BdfArray; import bdf.types.BdfNamedList; import bdf.types.BdfObject; +import projectzombie.items.Item; import projectzombie.util.math.ItemStack; public class Inventory implements IInventory, IBdfClassManager @@ -15,7 +16,7 @@ public class Inventory implements IInventory, IBdfClassManager items = new ItemStack[size]; for(int i=0;i check.item.max) { + stack.count = (check.count + stack.count) - check.item.max; + check.count = check.item.max; + } + + else { + check.count += stack.count; + stack.count = 0; + return; + } + } + } + + for(ItemStack check : items) + { + if(check.isEmpty()) { + check.item = stack.item; + check.count = stack.count; + check.meta = stack.meta; + stack.count = 0; + return; + } + } + } + + public void removeItem(ItemStack stack) + { + for(ItemStack check : items) { + if(stack.stackEquals(check) && !stack.isEmpty()) + { + if(check.count < stack.count) { + stack.count -= check.count; + check.count = 0; + } + + else { + check.count -= stack.count; + stack.count = 0; + return; + } + } + } + } + + public void removeItem(Item item, int count) + { + for(ItemStack check : items) { + if(item == check.item) + { + if(check.count < count) { + count -= check.count; + check.count = 0; + } + + else { + check.count -= count; + return; + } + } + } + } @Override public void BdfClassLoad(BdfObject bdf) diff --git a/src/projectzombie/items/Item.java b/src/projectzombie/items/Item.java index 07890d1..52452e7 100755 --- a/src/projectzombie/items/Item.java +++ b/src/projectzombie/items/Item.java @@ -12,6 +12,7 @@ import projectzombie.world.layer.Layer; public abstract class Item { public int id; + public int max = 99; public void onPlayerAction(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) { stack.count -= 1; @@ -38,33 +39,8 @@ public abstract class Item // Get the entities inventory Inventory entity_i = ((EntityInventory) entity).getInventory(); - // Loop over the inventory - for(int i=0;i tex_cut.y && tex_cut.x > 0.5)) { discard; } } \ No newline at end of file diff --git a/src/resources/shader/environmentRenderer.vsh b/src/resources/shader/environmentRenderer.vsh index 2cbda35..5171b6b 100644 --- a/src/resources/shader/environmentRenderer.vsh +++ b/src/resources/shader/environmentRenderer.vsh @@ -7,6 +7,7 @@ layout (location = 3) in vec3 aTranslate; layout (location = 4) in vec3 aFlags; out vec3 pTexture; +out vec3 pPos; uniform mat4 projection; uniform mat4 model; @@ -14,9 +15,6 @@ uniform mat4 camera; uniform mat4 rotated; uniform int time; -uniform float tex_cut; -uniform int tex_cut_mode; - 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; } @@ -56,7 +54,8 @@ void main() mat4 no_rotation = mat4(1); gl_Position = vec4(aPos, 1) * (mod(type, 2) == 1 ? do_rotation : no_rotation) * - (translate(aTranslate) * model) * camera * projection; + translate(aTranslate) * model * camera * projection; pTexture = vec3(aTex.x, getTexY(), aTex.z); + pPos = aPos; } \ No newline at end of file diff --git a/src/resources/shader/guiRenderer.fsh b/src/resources/shader/guiRenderer.fsh deleted file mode 100644 index e75a316..0000000 --- a/src/resources/shader/guiRenderer.fsh +++ /dev/null @@ -1,10 +0,0 @@ -#version 330 - -in vec3 pTexture; -out vec4 color; - -uniform sampler3D tex; - -void main() { - color = texture(tex, pTexture); -} \ No newline at end of file diff --git a/src/resources/shader/guiRenderer.vsh b/src/resources/shader/guiRenderer.vsh deleted file mode 100644 index bf5c8af..0000000 --- a/src/resources/shader/guiRenderer.vsh +++ /dev/null @@ -1,54 +0,0 @@ -#version 330 - -layout (location = 0) in vec3 aPos; -layout (location = 1) in vec3 aTex; -layout (location = 2) in vec2 aTexY; -layout (location = 3) in vec3 aTranslate; -layout (location = 4) in vec3 aFlags; - -out vec3 pTexture; - -uniform mat4 projection; -uniform mat4 model; -uniform mat4 camera; -uniform mat4 rotated; -uniform float time; - -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; -} - -mat4 translate(vec3 vec) -{ - mat4 result = mat4(1); - - result[0][3] = vec.x; - result[1][3] = vec.y; - result[2][3] = vec.z; - - return result; -} - -float getTexY() -{ - float animate_count = aFlags.x; - float animate_speed = aFlags.y; - float animate_index = mod(time, animate_count); - - float tex_y_size = (aTexY.y - aTexY.x) / animate_count; - - float tex_y = map( - aTex.y, aTexY.x, aTexY.y, - aTexY.x + tex_y_size * animate_index, - aTexY.x + tex_y_size * (animate_index + 1)); - - return tex_y; -} - -void main() -{ - int type = int(aFlags.z); - - gl_Position = vec4(aPos, 1) * (translate(aTranslate) * model); - pTexture = vec3(aTex.x, getTexY(), aTex.z); -} \ No newline at end of file diff --git a/src/resources/sound/explosion.ogg b/src/resources/sound/explosion.ogg old mode 100755 new mode 100644 index cbd09fc..b4cdafa Binary files a/src/resources/sound/explosion.ogg and b/src/resources/sound/explosion.ogg differ diff --git a/src/resources/texture/gui/hotbar.png b/src/resources/texture/gui/hotbar.png index 905cd19..a4ca03a 100644 Binary files a/src/resources/texture/gui/hotbar.png and b/src/resources/texture/gui/hotbar.png differ diff --git a/src/resources/texture/gui/hotbar_selected.png b/src/resources/texture/gui/hotbar_selected.png index 3bd03de..740ed24 100644 Binary files a/src/resources/texture/gui/hotbar_selected.png and b/src/resources/texture/gui/hotbar_selected.png differ