Started adding RGB light sources, cleaned up some code for faded tiles.
This commit is contained in:
parent
888e359f9c
commit
b15b396935
|
|
@ -16,6 +16,7 @@ import org.lwjgl.opengl.GL;
|
|||
import org.lwjgl.system.MemoryStack;
|
||||
|
||||
import shootergame.Main;
|
||||
import shootergame.display.lighting.LightingManager;
|
||||
import shootergame.display.transparent.TransparentObjects;
|
||||
import shootergame.entity.player.EntityPlayer;
|
||||
import shootergame.init.Textures;
|
||||
|
|
@ -82,8 +83,12 @@ public class DisplayRender
|
|||
GlHelpers.rotate(camera.angle.x, 0, 0, 1);
|
||||
GlHelpers.translate(-camera.pos.x, -camera.pos.y, -camera.pos.z);
|
||||
|
||||
// Process all the light sources
|
||||
LightingManager.update();
|
||||
|
||||
// Render the world and the player
|
||||
Main.world.render(camera);
|
||||
player.chunk = Main.world.getLayer().getChunk(player.pos);
|
||||
player.doRender(player.pos, camera);
|
||||
|
||||
// Render the sorted transparent objects
|
||||
|
|
|
|||
|
|
@ -0,0 +1,159 @@
|
|||
package shootergame.display.lighting;
|
||||
|
||||
import shootergame.Main;
|
||||
import shootergame.display.Camera;
|
||||
import shootergame.entity.Entity;
|
||||
import shootergame.entity.player.EntityPlayer;
|
||||
import shootergame.util.math.MathHelpers;
|
||||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.map.Map2DElement;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
public class LightingManager
|
||||
{
|
||||
@Deprecated
|
||||
public static void markDirty() {
|
||||
}
|
||||
|
||||
public static void update()
|
||||
{
|
||||
// Do nothing if nothing has changed
|
||||
//if(!isDirty) return;
|
||||
//isDirty = false;
|
||||
|
||||
int r = Camera.camera.renderDistance;
|
||||
Layer layer = Main.world.getLayer();
|
||||
Vec3d light_clear = layer.layergen.getLightLevel();
|
||||
EntityPlayer player = Main.player;
|
||||
|
||||
// Loop over all the loaded blocks and reset the light level
|
||||
for(int x=-r*16;x<r*16;x++) {
|
||||
for(int y=-r*16;y<r*16;y++) {
|
||||
Vec2i pos = new Vec2i(x + (int)player.pos.x, y + (int)player.pos.y);
|
||||
layer.setLightLevel(light_clear, pos);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over every entity to scan for light sources
|
||||
for(Map2DElement<Chunk> mce : layer.chunks)
|
||||
{
|
||||
if(mce.pos.squareDistance(new Vec2i((int)(player.pos.x/16), (int)(player.pos.y/16))) < r)
|
||||
{
|
||||
// Loop over all the entities
|
||||
Chunk chunk = mce.o;
|
||||
for(Entity e : chunk.entities)
|
||||
{
|
||||
// Does this entity emit light
|
||||
if(e.emitsLight)
|
||||
{
|
||||
// Create some light
|
||||
addLightToTiles(layer, new Vec2i(
|
||||
MathHelpers.floor(e.pos.x),
|
||||
MathHelpers.floor(e.pos.y)),
|
||||
e.getLightLevel());
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over all the tiles
|
||||
for(int x=0;x<16;x++) {
|
||||
for(int y=0;y<16;y++)
|
||||
{
|
||||
// Get the tile position
|
||||
Vec2i tpos = new Vec2i(x + mce.pos.x * 16, y + mce.pos.y * 16);
|
||||
int tid = tpos.getId(Chunk.CHUNK_SIZE);
|
||||
|
||||
// Get the front and back tiles
|
||||
TileState fts = chunk.getFrontTile(tid);
|
||||
TileState bts = chunk.getBackTile(tid);
|
||||
|
||||
// Do any of these emit light
|
||||
if(fts.tile.emitsLight || bts.tile.emitsLight)
|
||||
{
|
||||
// Calculate the light given off by the tile
|
||||
Vec3d light_tile = chunk.getLightLevel(tid);
|
||||
Vec3d light_tile2 = light_tile.copy();
|
||||
Vec3d ftsl = fts.tile.getLightLevel(fts);
|
||||
Vec3d btsl = fts.tile.getLightLevel(bts);
|
||||
if(ftsl.x > light_tile.x) light_tile.x = ftsl.x;
|
||||
if(ftsl.y > light_tile.y) light_tile.y = ftsl.y;
|
||||
if(ftsl.z > light_tile.z) light_tile.z = ftsl.z;
|
||||
if(btsl.x > light_tile.x) light_tile.x = btsl.x;
|
||||
if(btsl.y > light_tile.y) light_tile.y = btsl.y;
|
||||
if(btsl.z > light_tile.z) light_tile.z = btsl.z;
|
||||
|
||||
// Has the light level changed; add light to this tile
|
||||
if(!light_tile.equal(light_tile2)) {
|
||||
addLightToTiles(layer, tpos, light_tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Does the player emit light
|
||||
if(player.emitsLight) {
|
||||
addLightToTiles(layer, new Vec2i(
|
||||
MathHelpers.floor(player.pos.x),
|
||||
MathHelpers.floor(player.pos.y)),
|
||||
player.getLightLevel());
|
||||
}
|
||||
}
|
||||
|
||||
private static void addLightToTiles(Layer layer, Vec2i lpos, Vec3d light)
|
||||
{
|
||||
// Get the light pos id
|
||||
int lid = lpos.getId(Chunk.CHUNK_SIZE);
|
||||
|
||||
// Get the light dissipation amount
|
||||
Chunk chunk = layer.getChunk(lpos);
|
||||
TileState bt = chunk.getBackTile(lid);
|
||||
TileState ft = chunk.getFrontTile(lid);
|
||||
Vec3d light_dissipation = bt.tile.getLightDissipation(bt);
|
||||
Vec3d light_dissipation2 = ft.tile.getLightDissipation(ft);
|
||||
if(light_dissipation2.x > light_dissipation.x) light_dissipation.x = light_dissipation2.x;
|
||||
if(light_dissipation2.y > light_dissipation.y) light_dissipation.y = light_dissipation2.y;
|
||||
if(light_dissipation2.z > light_dissipation.z) light_dissipation.z = light_dissipation2.z;
|
||||
|
||||
// Set the light dissipation
|
||||
light = light.subtract(light_dissipation);
|
||||
if(light.x < 0) light.x = 0;
|
||||
if(light.y < 0) light.y = 0;
|
||||
if(light.z < 0) light.z = 0;
|
||||
|
||||
if(light.x == 0 && light.y == 0 && light.z == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate the light level
|
||||
Vec3d light_tile = chunk.getLightLevel(lid);
|
||||
if(
|
||||
light.x <= light_tile.x &&
|
||||
light.y <= light_tile.y &&
|
||||
light.z <= light_tile.z) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Merge the light and the light tile values
|
||||
if(light.x > light_tile.x) light_tile.x = light.x;
|
||||
if(light.y > light_tile.y) light_tile.y = light.y;
|
||||
if(light.z > light_tile.z) light_tile.z = light.z;
|
||||
chunk.setLightLevel(light_tile, lid);
|
||||
|
||||
// Get all the adjacent positions of the light tiles to flow onto
|
||||
Vec2i positions[] = {
|
||||
new Vec2i(lpos.x+1, lpos.y),
|
||||
new Vec2i(lpos.x-1, lpos.y),
|
||||
new Vec2i(lpos.x, lpos.y+1),
|
||||
new Vec2i(lpos.x, lpos.y-1)
|
||||
};
|
||||
|
||||
// Add the light to all the adjacent positions
|
||||
for(Vec2i position : positions) {
|
||||
addLightToTiles(layer, position, light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package shootergame.display.transparent;
|
||||
|
||||
import shootergame.display.Camera;
|
||||
import shootergame.tiles.Tile;
|
||||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import shootergame.util.math.MathHelpers;
|
|||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
|
|
@ -29,6 +30,7 @@ public class Entity implements ITransparentObject
|
|||
public boolean crossUnWalkable = true;
|
||||
public boolean goThroughSolid = true;
|
||||
protected static final Random rand = new Random();
|
||||
public boolean emitsLight = false;
|
||||
|
||||
public Entity(Vec2d pos, double angle)
|
||||
{
|
||||
|
|
@ -214,4 +216,8 @@ public class Entity implements ITransparentObject
|
|||
public Vec2d getRenderOffset(TileState state) {
|
||||
return new Vec2d(0, 0);
|
||||
}
|
||||
|
||||
public Vec3d getLightLevel() {
|
||||
return new Vec3d(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,9 +116,12 @@ public class EntityBullet extends EntityParticle
|
|||
public void render(Vec2d pos, Camera camera)
|
||||
{
|
||||
// Set the colour
|
||||
GlHelpers.color3(1, 0.8, 0.3);
|
||||
Vec3d light = chunk.getLightLevel(new Vec2i(
|
||||
MathHelpers.floor(pos.x), MathHelpers.floor(pos.y)));
|
||||
GlHelpers.color3(1 * light.x, 0.8 * light.y, 0.3 * light.z);
|
||||
|
||||
// Call super
|
||||
super.render(pos, camera);
|
||||
GlHelpers.color3(1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ public class EntityParticle extends Entity
|
|||
|
||||
// Pop the matrix, remove the colour, and enable textures
|
||||
GlHelpers.enableTexture2d();
|
||||
GlHelpers.color3(1, 1, 1);
|
||||
GlHelpers.popMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
package shootergame.entity;
|
||||
|
||||
import shootergame.display.Camera;
|
||||
import shootergame.util.gl.GlHelpers;
|
||||
import shootergame.util.gl.VerticalRender;
|
||||
import shootergame.util.gl.texture.TextureReference;
|
||||
import shootergame.util.math.MathHelpers;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
|
||||
public class EntityVertical extends Entity
|
||||
{
|
||||
|
|
@ -22,6 +26,10 @@ public class EntityVertical extends Entity
|
|||
|
||||
@Override
|
||||
public void render(Vec2d pos, Camera camera) {
|
||||
Vec3d light = chunk.getLightLevel(new Vec2i(
|
||||
MathHelpers.floor(pos.x), MathHelpers.floor(pos.y)));
|
||||
GlHelpers.color3(light.x, light.y, light.z);
|
||||
this.render(pos, camera, tex, size);
|
||||
GlHelpers.color3(1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@ import java.util.Random;
|
|||
import shootergame.display.Camera;
|
||||
import shootergame.entity.EntityParticle;
|
||||
import shootergame.util.gl.GlHelpers;
|
||||
import shootergame.util.math.MathHelpers;
|
||||
import shootergame.util.math.random.RandomHelpers;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
|
|
@ -57,13 +60,18 @@ public class ParticleBlood extends EntityParticle
|
|||
@Override
|
||||
public void render(Vec2d pos, Camera camera)
|
||||
{
|
||||
// Get the light level
|
||||
Vec3d light = chunk.getLightLevel(new Vec2i(
|
||||
MathHelpers.floor(pos.x), MathHelpers.floor(pos.y)));
|
||||
|
||||
// Set some settings
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.color3(r_color, 0, 0);
|
||||
GlHelpers.color3(r_color * light.x, 0, 0);
|
||||
GlHelpers.translate(0, 0, height);
|
||||
|
||||
// Call super
|
||||
super.render(pos, camera);
|
||||
GlHelpers.color3(1, 1, 1);
|
||||
GlHelpers.popMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ import shootergame.entity.EntityVertical;
|
|||
import shootergame.util.gl.GlHelpers;
|
||||
import shootergame.util.gl.texture.IHasTexture;
|
||||
import shootergame.util.gl.texture.TextureReference;
|
||||
import shootergame.util.math.MathHelpers;
|
||||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.random.RandomHelpers;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
|
|
@ -66,9 +69,13 @@ public class ParticleBreak extends EntityVertical
|
|||
|
||||
@Override
|
||||
public void render(Vec2d pos, Camera camera, TextureReference tex, Vec2d size) {
|
||||
Vec3d light = chunk.getLightLevel(new Vec2i(
|
||||
MathHelpers.floor(pos.x), MathHelpers.floor(pos.y)));
|
||||
GlHelpers.color3(light.x, light.y, light.z);
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate(0, 0, height);
|
||||
super.render(pos, camera, tex, size);
|
||||
GlHelpers.color3(1, 1, 1);
|
||||
GlHelpers.popMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@ import shootergame.display.Camera;
|
|||
import shootergame.entity.EntityVertical;
|
||||
import shootergame.init.Textures;
|
||||
import shootergame.util.gl.GlHelpers;
|
||||
import shootergame.util.math.MathHelpers;
|
||||
import shootergame.util.math.random.RandomHelpers;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
|
|
@ -33,7 +36,9 @@ public class ParticleSmoke extends EntityVertical
|
|||
if(opacity <= 0) return;
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate(0, 0, height);
|
||||
GlHelpers.color4(1, 1, 1, opacity);
|
||||
Vec3d light = chunk.getLightLevel(new Vec2i(
|
||||
MathHelpers.floor(pos.x), MathHelpers.floor(pos.y)));
|
||||
GlHelpers.color4(light.x, light.y, light.z, opacity);
|
||||
super.render(pos, camera);
|
||||
GlHelpers.color4(1, 1, 1, 1);
|
||||
GlHelpers.popMatrix();
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class ParticleSpark extends EntityParticle
|
|||
|
||||
// Call super
|
||||
super.render(pos, camera);
|
||||
GlHelpers.color3(1, 1, 1);
|
||||
GlHelpers.popMatrix();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import shootergame.util.gl.GlHelpers;
|
|||
import shootergame.util.math.MathHelpers;
|
||||
import shootergame.util.math.random.RandomHelpers;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
|
@ -48,7 +49,9 @@ public class ParticleWater extends EntityParticle
|
|||
public void render(Vec2d pos, Camera camera) {
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate(0, 0, height);
|
||||
GlHelpers.color4(0, 0, 1, 0.4);
|
||||
Vec3d light = chunk.getLightLevel(new Vec2i(
|
||||
MathHelpers.floor(pos.x), MathHelpers.floor(pos.y)));
|
||||
GlHelpers.color4(0, 0, light.z, 0.4);
|
||||
super.render(pos, camera);
|
||||
GlHelpers.color4(1, 1, 1, 1);
|
||||
GlHelpers.popMatrix();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import shootergame.entity.EntityBullet;
|
|||
import shootergame.entity.EntityInventory;
|
||||
import shootergame.entity.EntityItem;
|
||||
import shootergame.entity.EntityVertical;
|
||||
import shootergame.init.Items;
|
||||
import shootergame.init.Textures;
|
||||
import shootergame.inventory.Inventory;
|
||||
import shootergame.util.gl.GlHelpers;
|
||||
|
|
@ -17,6 +16,8 @@ import shootergame.util.gl.texture.TextureReference;
|
|||
import shootergame.util.math.ItemStack;
|
||||
import shootergame.util.math.MathHelpers;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
|
|
@ -57,10 +58,16 @@ public class EntityPlayer extends EntityVertical implements EntityAlive, EntityI
|
|||
isSolid = true;
|
||||
goThroughSolid = false;
|
||||
crossUnWalkable = false;
|
||||
emitsLight = true;
|
||||
|
||||
inventory = new Inventory(6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getLightLevel() {
|
||||
return new Vec3d(1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Chunk chunk, Layer layer)
|
||||
{
|
||||
|
|
@ -149,6 +156,11 @@ public class EntityPlayer extends EntityVertical implements EntityAlive, EntityI
|
|||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate(0, 0, height);
|
||||
|
||||
// Set the colour due to the lighting
|
||||
Vec3d light = chunk.getLightLevel(new Vec2i(
|
||||
MathHelpers.floor(pos.x), MathHelpers.floor(pos.y)));
|
||||
GlHelpers.color3(light.x, light.y, light.z);
|
||||
|
||||
// Moving
|
||||
if(MOVE_BACKWARD || MOVE_FORWARD || moving)
|
||||
super.render(pos, camera, Textures.ENTITY_PLAYER_MOVING, size);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,21 @@
|
|||
package shootergame.input;
|
||||
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
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_ENTER;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_Q;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_RIGHT_SHIFT;
|
||||
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 org.lwjgl.glfw.GLFWKeyCallbackI;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import shootergame.entity.Entity;
|
|||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
|
|
@ -19,6 +20,8 @@ public class Tile implements ITransparentObject
|
|||
public double tileHitbox = 0;
|
||||
public double slowness = 0;
|
||||
public boolean unbreakable = false;
|
||||
protected Vec3d light_dissipation = new Vec3d(1/12.0, 1/12.0, 1/12.0);
|
||||
public boolean emitsLight = true;
|
||||
|
||||
public Tile(String id) {
|
||||
this.id = id;
|
||||
|
|
@ -62,4 +65,12 @@ public class Tile implements ITransparentObject
|
|||
|
||||
public void onActivated(Layer layer, Vec2i tpos, Entity entity, TileState state) {
|
||||
}
|
||||
|
||||
public Vec3d getLightDissipation(TileState state) {
|
||||
return light_dissipation;
|
||||
}
|
||||
|
||||
public Vec3d getLightLevel(TileState state) {
|
||||
return new Vec3d(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,12 @@
|
|||
package shootergame.tiles;
|
||||
|
||||
import shootergame.display.Camera;
|
||||
import shootergame.init.Textures;
|
||||
import shootergame.util.gl.GlHelpers;
|
||||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
|
||||
public class TileDirt extends TileFlat
|
||||
public class TileDirt extends TileFlatFaded
|
||||
{
|
||||
|
||||
public TileDirt(String id) {
|
||||
super(id, Textures.TILE_DIRT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Vec2d pos, Camera camera, TileState state) {
|
||||
GlHelpers.color4(1, 1, 1, (Byte.MAX_VALUE - (double)state.meta) / Byte.MAX_VALUE);
|
||||
super.render(pos, camera, state);
|
||||
GlHelpers.color4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,23 +6,26 @@ import shootergame.util.gl.texture.IHasTexture;
|
|||
import shootergame.util.gl.texture.TextureReference;
|
||||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
|
||||
public class TileFlat extends Tile implements IHasTexture
|
||||
{
|
||||
private TextureReference tex;
|
||||
protected boolean rotates = false;
|
||||
private static final Vec3d default_tile_color = new Vec3d(1, 1, 1);
|
||||
|
||||
public TileFlat(String id, TextureReference tex) {
|
||||
super(id);
|
||||
this.tex = tex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Vec2d pos, Camera camera, TileState state)
|
||||
public void render(Vec2d pos, Camera camera, TileState state, Vec3d color)
|
||||
{
|
||||
// Call super
|
||||
super.render(pos, camera, state);
|
||||
|
||||
// Render the tile
|
||||
GlHelpers.color3(state.light.x*color.x, state.light.y*color.y, state.light.z*color.z);
|
||||
GlHelpers.begin();
|
||||
tex.texCoord(1, 1); GlHelpers.vertex3(pos.x+0, pos.y+0, 0);
|
||||
tex.texCoord(0, 1); GlHelpers.vertex3(pos.x+1, pos.y+0, 0);
|
||||
|
|
@ -31,6 +34,11 @@ public class TileFlat extends Tile implements IHasTexture
|
|||
GlHelpers.end();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Vec2d pos, Camera camera, TileState state) {
|
||||
this.render(pos, camera, state, default_tile_color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureReference getTexture() {
|
||||
return tex;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package shootergame.tiles;
|
||||
|
||||
import shootergame.display.Camera;
|
||||
import shootergame.util.gl.texture.TextureReference;
|
||||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
|
||||
public class TileFlatFaded extends TileFlat
|
||||
{
|
||||
|
||||
public TileFlatFaded(String id, TextureReference tex) {
|
||||
super(id, tex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Vec2d pos, Camera camera, TileState state) {
|
||||
double fade_amount = (Byte.MAX_VALUE - (double)state.meta) / Byte.MAX_VALUE;
|
||||
super.render(pos, camera, state, new Vec3d(fade_amount, fade_amount, fade_amount));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,23 +1,12 @@
|
|||
package shootergame.tiles;
|
||||
|
||||
import shootergame.display.Camera;
|
||||
import shootergame.init.Textures;
|
||||
import shootergame.util.gl.GlHelpers;
|
||||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
|
||||
public class TileStone extends TileFlat
|
||||
public class TileStone extends TileFlatFaded
|
||||
{
|
||||
|
||||
public TileStone(String id) {
|
||||
super(id, Textures.TILE_STONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Vec2d pos, Camera camera, TileState state) {
|
||||
GlHelpers.color4(1, 1, 1, (Byte.MAX_VALUE - (double)state.meta) / Byte.MAX_VALUE);
|
||||
super.render(pos, camera, state);
|
||||
GlHelpers.color4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
package shootergame.tiles;
|
||||
|
||||
import shootergame.init.Textures;
|
||||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
|
||||
public class TileTree extends TileVertical
|
||||
{
|
||||
private static final Vec3d light_dissipation = new Vec3d(1/4.0, 1/4.0, 1/4.0);
|
||||
|
||||
public TileTree(String id) {
|
||||
super(id, Textures.TILE_TREE, new Vec2d(1, 4));
|
||||
|
|
@ -15,4 +18,11 @@ public class TileTree extends TileVertical
|
|||
this.tileHitbox = 0.3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getLightDissipation(TileState state) {
|
||||
return light_dissipation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package shootergame.tiles;
|
||||
|
||||
import shootergame.display.Camera;
|
||||
import shootergame.util.gl.GlHelpers;
|
||||
import shootergame.util.gl.VerticalRender;
|
||||
import shootergame.util.gl.texture.IHasTexture;
|
||||
import shootergame.util.gl.texture.TextureReference;
|
||||
|
|
@ -23,6 +24,7 @@ public class TileVertical extends Tile implements IHasTexture
|
|||
@Override
|
||||
public void render(Vec2d pos, Camera camera, TileState state) {
|
||||
super.render(pos, camera, state);
|
||||
GlHelpers.color3(state.light.x, state.light.y, state.light.z);
|
||||
VerticalRender.render(pos, camera, tex, size);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package shootergame.tiles;
|
||||
|
||||
import shootergame.init.Textures;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
|
||||
public class TileWall extends TileFlat
|
||||
{
|
||||
|
|
@ -11,6 +12,8 @@ public class TileWall extends TileFlat
|
|||
this.tileWalkable = false;
|
||||
this.tileSolid = true;
|
||||
this.tileHitbox = 1;
|
||||
|
||||
this.light_dissipation = new Vec3d(1/4.0, 1/4.0, 1/4.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public class TileWater extends TileFlat
|
|||
public TileWater(String id) {
|
||||
super(id, Textures.TILE_WATER);
|
||||
this.slowness = 0.5;
|
||||
this.rotates = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package shootergame.util.math;
|
|||
|
||||
import shootergame.init.Tiles;
|
||||
import shootergame.tiles.Tile;
|
||||
import shootergame.util.math.vec.Vec3i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
|
||||
public class TileState
|
||||
{
|
||||
|
|
@ -10,7 +10,7 @@ public class TileState
|
|||
|
||||
public Tile tile;
|
||||
public byte meta;
|
||||
public Vec3i light = new Vec3i(0, 0, 0);
|
||||
public Vec3d light = new Vec3d(0, 0, 0);
|
||||
|
||||
public TileState(Tile tile, byte meta) {
|
||||
this.tile = tile;
|
||||
|
|
@ -21,7 +21,7 @@ public class TileState
|
|||
this(tile, (byte)meta);
|
||||
}
|
||||
|
||||
public TileState withLightLevel(Vec3i light) {
|
||||
public TileState withLightLevel(Vec3d light) {
|
||||
TileState ts = new TileState(tile, meta);
|
||||
ts.light = light;
|
||||
return ts;
|
||||
|
|
@ -29,7 +29,7 @@ public class TileState
|
|||
|
||||
public TileState withLightLevel(int r, int g, int b) {
|
||||
TileState ts = new TileState(tile, meta);
|
||||
ts.light = new Vec3i(r, g, b);
|
||||
ts.light = new Vec3d(r, g, b);
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import shootergame.util.math.vec.Vec2i;
|
|||
public class Map2D<T> implements Iterable<Map2DElement<T>>
|
||||
{
|
||||
private ArrayList<Map2DElement<T>> elements;
|
||||
private Map2DElement<T> element_last = null;
|
||||
private IMap2D<T> map2d_i;
|
||||
|
||||
public Map2D(IMap2D<T> map2d_i)
|
||||
|
|
@ -19,11 +20,19 @@ public class Map2D<T> implements Iterable<Map2DElement<T>>
|
|||
|
||||
public void set(Vec2i pos, T o)
|
||||
{
|
||||
if(element_last != null) {
|
||||
if(element_last.pos.equal(pos)) {
|
||||
element_last.o = o;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over the elements
|
||||
for(Map2DElement<T> e : this.elements)
|
||||
{
|
||||
// Set the object if these positions are the same
|
||||
if(e.pos.equal(pos)) {
|
||||
element_last = e;
|
||||
e.o = o;
|
||||
return;
|
||||
}
|
||||
|
|
@ -32,15 +41,23 @@ public class Map2D<T> implements Iterable<Map2DElement<T>>
|
|||
// Create an element and add it
|
||||
Map2DElement<T> e = new Map2DElement<T>(pos, o);
|
||||
this.elements.add(e);
|
||||
element_last = e;
|
||||
}
|
||||
|
||||
public T get(Vec2i pos)
|
||||
{
|
||||
if(element_last != null) {
|
||||
if(element_last.pos.equal(pos)) {
|
||||
return element_last.o;
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over the elements
|
||||
for(Map2DElement<T> e : this.elements)
|
||||
{
|
||||
// Send back the object if these positions are the same
|
||||
if(e.pos.equal(pos)) {
|
||||
element_last = e;
|
||||
return e.o;
|
||||
}
|
||||
}
|
||||
|
|
@ -51,6 +68,12 @@ public class Map2D<T> implements Iterable<Map2DElement<T>>
|
|||
|
||||
public void remove(Vec2i pos)
|
||||
{
|
||||
if(element_last != null) {
|
||||
if(element_last.pos.equal(pos)) {
|
||||
this.elements.remove(element_last);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over the elements
|
||||
for(int i=0;i<elements.size();i++)
|
||||
{
|
||||
|
|
@ -62,10 +85,18 @@ public class Map2D<T> implements Iterable<Map2DElement<T>>
|
|||
this.elements.remove(e);
|
||||
}
|
||||
}
|
||||
|
||||
element_last = null;
|
||||
}
|
||||
|
||||
public boolean contains(Vec2i pos)
|
||||
{
|
||||
if(element_last != null) {
|
||||
if(element_last.pos.equal(pos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over the elements
|
||||
for(int i=0;i<elements.size();i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ public class Vec2i
|
|||
public int x;
|
||||
public int y;
|
||||
|
||||
public Vec2i(int x, int y)
|
||||
public Vec2i(int d, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.x = d;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
|
|
@ -24,6 +24,9 @@ public class Vec2i
|
|||
|
||||
public int getId(Range2i range)
|
||||
{
|
||||
int x = MathHelpers.mod(this.x, range.mx);
|
||||
int y = MathHelpers.mod(this.y, range.my);
|
||||
|
||||
int id = 0;
|
||||
int m = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ public class Vec3i
|
|||
|
||||
public int getId(Range3i range)
|
||||
{
|
||||
int x = MathHelpers.mod(this.x, range.mx);
|
||||
int y = MathHelpers.mod(this.y, range.my);
|
||||
int z = MathHelpers.mod(this.z, range.mz);
|
||||
|
||||
int id = 0;
|
||||
int m = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package shootergame.world;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import shootergame.Main;
|
||||
import shootergame.display.Camera;
|
||||
import shootergame.world.chunk.ChunkEventHandler;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import shootergame.util.math.TileState;
|
|||
import shootergame.util.math.range.Range2i;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
public class Chunk
|
||||
|
|
@ -48,9 +49,12 @@ public class Chunk
|
|||
tiles_front[i] = Tiles.VOID;
|
||||
tiles_back_meta[i] = 0;
|
||||
tiles_front_meta[i] = 0;
|
||||
tiles_lighting_b[i] = 0;
|
||||
tiles_lighting_g[i] = 0;
|
||||
tiles_lighting_r[i] = 0;
|
||||
|
||||
// Set the light level
|
||||
Vec3d light_level = layer.layergen.getLightLevel();
|
||||
tiles_lighting_r[i] = (byte)(light_level.x*Byte.MAX_VALUE);
|
||||
tiles_lighting_g[i] = (byte)(light_level.y*Byte.MAX_VALUE);
|
||||
tiles_lighting_b[i] = (byte)(light_level.z*Byte.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,9 +183,9 @@ public class Chunk
|
|||
{
|
||||
// Send back the back tile
|
||||
TileState ts = new TileState(this.tiles_back[id], this.tiles_back_meta[id]);
|
||||
ts.light.x = this.tiles_lighting_r[id];
|
||||
ts.light.y = this.tiles_lighting_g[id];
|
||||
ts.light.z = this.tiles_lighting_b[id];
|
||||
ts.light.x = this.tiles_lighting_r[id] / (double) Byte.MAX_VALUE;
|
||||
ts.light.y = this.tiles_lighting_g[id] / (double) Byte.MAX_VALUE;
|
||||
ts.light.z = this.tiles_lighting_b[id] / (double) Byte.MAX_VALUE;
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
|
@ -200,9 +204,9 @@ public class Chunk
|
|||
{
|
||||
// Send back the front tile
|
||||
TileState ts = new TileState(this.tiles_front[id], this.tiles_front_meta[id]);
|
||||
ts.light.x = this.tiles_lighting_r[id];
|
||||
ts.light.y = this.tiles_lighting_g[id];
|
||||
ts.light.z = this.tiles_lighting_b[id];
|
||||
ts.light.x = this.tiles_lighting_r[id] / (double) Byte.MAX_VALUE;
|
||||
ts.light.y = this.tiles_lighting_g[id] / (double) Byte.MAX_VALUE;
|
||||
ts.light.z = this.tiles_lighting_b[id] / (double) Byte.MAX_VALUE;
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
|
@ -218,6 +222,41 @@ public class Chunk
|
|||
}
|
||||
}
|
||||
|
||||
public Vec3d getLightLevel(int id) {
|
||||
return new Vec3d(
|
||||
this.tiles_lighting_r[id] / (double)Byte.MAX_VALUE,
|
||||
this.tiles_lighting_g[id] / (double)Byte.MAX_VALUE,
|
||||
this.tiles_lighting_b[id] / (double)Byte.MAX_VALUE);
|
||||
}
|
||||
|
||||
public Vec3d getLightLevel(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 getLightLevel(id);
|
||||
}
|
||||
|
||||
public void setLightLevel(Vec3d light, int id) {
|
||||
this.tiles_lighting_r[id] = (byte)(light.x * Byte.MAX_VALUE);
|
||||
this.tiles_lighting_g[id] = (byte)(light.y * Byte.MAX_VALUE);
|
||||
this.tiles_lighting_b[id] = (byte)(light.z * Byte.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void setLightLevel(Vec3d 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);
|
||||
|
||||
setLightLevel(light, id);
|
||||
}
|
||||
|
||||
public void breakFrontTile(Vec2i pos)
|
||||
{
|
||||
TileState ts = getFrontTile(pos);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import shootergame.entity.Entity;
|
|||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
|
||||
public class ChunkEmpty extends Chunk
|
||||
{
|
||||
|
|
@ -53,5 +54,50 @@ public class ChunkEmpty extends Chunk
|
|||
public void killEntity(Entity e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBackTile(Vec2i pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakFrontTile(Vec2i pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileState getBackTile(int id) {
|
||||
return TileState.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileState getFrontTile(int id) {
|
||||
return TileState.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getLightLevel(int id) {
|
||||
return new Vec3d(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getLightLevel(Vec2i pos) {
|
||||
return new Vec3d(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLightLevel(Vec3d light, int id) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLightLevel(Vec3d light, Vec2i pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackTile(TileState tile, int id) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrontTile(TileState tile, int id) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import shootergame.util.math.map.Map2D;
|
|||
import shootergame.util.math.map.Map2DElement;
|
||||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.layergen.LayerGen;
|
||||
|
||||
|
|
@ -117,6 +118,24 @@ public class Layer
|
|||
MathHelpers.floor(pos.y / (double)Chunk.CHUNK_SIZE.my));
|
||||
}
|
||||
|
||||
public Vec3d getLightLevel(Vec2i pos)
|
||||
{
|
||||
// Get the chunk pos
|
||||
Vec2i c_pos = getChunkPosFromPos(pos);
|
||||
|
||||
// Get the chunks front tile
|
||||
return chunks.get(c_pos).getLightLevel(pos);
|
||||
}
|
||||
|
||||
public void setLightLevel(Vec3d light, Vec2i pos)
|
||||
{
|
||||
// Get the chunk pos
|
||||
Vec2i c_pos = getChunkPosFromPos(pos);
|
||||
|
||||
// Get the chunks front tile
|
||||
chunks.get(c_pos).setLightLevel(light, pos);
|
||||
}
|
||||
|
||||
public TileState getFrontTile(Vec2i pos)
|
||||
{
|
||||
// Get the chunk pos
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import shootergame.util.math.TileState;
|
|||
import shootergame.util.math.map.IMap2D;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.util.math.vec.Vec3i;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
|
|
@ -15,7 +14,7 @@ public abstract class LayerGen implements IMap2D<Chunk>
|
|||
public abstract void generateChunk(Chunk chunk, Layer layer, long seed, Random rand, Vec2i pos);
|
||||
public abstract void spawnEntities(Layer layer, Random rand);
|
||||
public abstract TileState getTileDestroyed();
|
||||
public abstract Vec3i getLightLevel();
|
||||
public abstract Vec3d getLightLevel();
|
||||
|
||||
@Override
|
||||
public Chunk getEmpty(Vec2i pos) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import shootergame.util.math.random.RandomHelpers;
|
|||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.util.math.vec.Vec3i;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
|
|
@ -23,13 +22,20 @@ public class LayerGenCaves extends LayerGen
|
|||
@Override
|
||||
public void generateChunk(Chunk chunk, Layer layer, long seed, Random rand, Vec2i c_pos)
|
||||
{
|
||||
// Is there going to be a portal in this chunk
|
||||
// Is there going to be a portal up in this chunk
|
||||
boolean portal = RandomHelpers.randrange(rand, 10) == 0;
|
||||
Vec2i portal_pos = null;
|
||||
if(portal) portal_pos = new Vec2i(
|
||||
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.mx),
|
||||
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.my));
|
||||
|
||||
// Is there going to be a portal down in this chunk
|
||||
boolean portal_down = RandomHelpers.randrange(rand, 10) == 0;
|
||||
Vec2i portal_down_pos = null;
|
||||
if(portal_down) portal_down_pos = new Vec2i(
|
||||
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.mx),
|
||||
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.my));
|
||||
|
||||
// Get some noise generators
|
||||
OpenSimplexNoise noisegen_n = new OpenSimplexNoise(seed);
|
||||
|
||||
|
|
@ -59,6 +65,11 @@ public class LayerGenCaves extends LayerGen
|
|||
chunk.setFrontTile(new TileState(Tiles.LADDER_UP, (short)0), portal_pos);
|
||||
}
|
||||
|
||||
if(portal_down) {
|
||||
chunk.setBackTile(new TileState(Tiles.PORTAL_DOWN, (short)2), portal_down_pos);
|
||||
chunk.setFrontTile(Tiles.LADDER.getDefaultState(), portal_down_pos);
|
||||
}
|
||||
|
||||
Vec2i chest_pos = new Vec2i(
|
||||
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.mx),
|
||||
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.my));
|
||||
|
|
@ -104,8 +115,8 @@ public class LayerGenCaves extends LayerGen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vec3i getLightLevel() {
|
||||
return new Vec3i(0, 0, 0);
|
||||
public Vec3d getLightLevel() {
|
||||
return new Vec3d(0, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import shootergame.util.math.random.RandomHelpers;
|
|||
import shootergame.util.math.vec.Vec2d;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.util.math.vec.Vec3i;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
|
|
@ -59,13 +58,13 @@ public class LayerGenEarth extends LayerGen
|
|||
else if(noise_n < 70) chunk.setBackTile(Tiles.GRASS.getDefaultState(), pos);
|
||||
else if(noise_n < 90) chunk.setBackTile(Tiles.DIRT.getDefaultState(), pos);
|
||||
else chunk.setBackTile(Tiles.STONE.getDefaultState(), pos);
|
||||
|
||||
if(portal) {
|
||||
chunk.setBackTile(new TileState(Tiles.PORTAL_DOWN, (short)1), portal_pos);
|
||||
chunk.setFrontTile(Tiles.LADDER.getDefaultState(), portal_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(portal) {
|
||||
chunk.setBackTile(new TileState(Tiles.PORTAL_DOWN, (short)1), portal_pos);
|
||||
chunk.setFrontTile(Tiles.LADDER.getDefaultState(), portal_pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -89,7 +88,7 @@ public class LayerGenEarth extends LayerGen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vec3i getLightLevel() {
|
||||
return new Vec3i(200, 200, 200);
|
||||
public Vec3d getLightLevel() {
|
||||
return new Vec3d(0.3, 0.3, 0.3);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package shootergame.world.layer.layergen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import shootergame.init.Tiles;
|
||||
import shootergame.util.math.TileState;
|
||||
import shootergame.util.math.vec.Vec2i;
|
||||
import shootergame.util.math.vec.Vec3d;
|
||||
import shootergame.world.chunk.Chunk;
|
||||
import shootergame.world.layer.Layer;
|
||||
|
||||
public class LayerGenLavaCaves extends LayerGen
|
||||
{
|
||||
|
||||
@Override
|
||||
public void generateChunk(Chunk chunk, Layer layer, long seed, Random rand, Vec2i pos)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnEntities(Layer layer, Random rand) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileState getTileDestroyed() {
|
||||
return Tiles.LAVA.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getLightLevel() {
|
||||
return new Vec3d(0.1, 0.1, 0.1);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue