Search in sources :

Example 6 with Chunk

use of org.asassecreations.voxelgame.world.chunk.Chunk in project Voxel_Game by ASasseCreations.

the class ChunkModelQueue method contains.

private static final boolean contains(final Chunk chunk) {
    if (chunk == null)
        return false;
    for (int i = 0; i < LIST.size(); i++) {
        final ChunkModelQueue queue = LIST.get(i);
        if (queue == null)
            continue;
        final Chunk temp = queue.chunk;
        if (temp == null)
            continue;
        if (temp.x == chunk.x && temp.z == chunk.z)
            return true;
    }
    return false;
}
Also used : Chunk(org.asassecreations.voxelgame.world.chunk.Chunk)

Example 7 with Chunk

use of org.asassecreations.voxelgame.world.chunk.Chunk in project Voxel_Game by ASasseCreations.

the class ChunkOccludeQueue method queue.

private static final void queue() {
    for (int i = 0; i < LIST.size(); i++) {
        final ChunkOccludeQueue queue = LIST.get(i);
        if (queue == null)
            continue;
        if (!Chunk.CHUNKS.contains(queue.chunk)) {
            LIST.remove(queue);
            continue;
        }
        final Chunk chunk = queue.chunk;
        if (chunk == null)
            continue;
        if (chunk.operation == null)
            chunk.operation = ChunkOperation.OCCLUDING;
        if (chunk.occlude())
            LIST.remove(queue);
    }
}
Also used : Chunk(org.asassecreations.voxelgame.world.chunk.Chunk)

Example 8 with Chunk

use of org.asassecreations.voxelgame.world.chunk.Chunk in project Voxel_Game by ASasseCreations.

the class GameState method tick.

public void tick() {
    ChunkSystem.removeDistantChunks();
    final int cameraChunkX = (int) (GameCamera.position.x / Chunk.H_SIZE);
    final int cameraChunkZ = (int) (GameCamera.position.z / Chunk.H_SIZE);
    ChunkSystem.addNewChunks(cameraChunkX, cameraChunkZ);
    player.tick();
    if (MouseInput.isButtonJustPressed(0))
        ChunkSystem.checkLeftClick(inventory);
    if (MouseInput.isButtonJustPressed(1))
        ChunkSystem.checkRightClick();
    ChunkModelQueue.queue();
    ChunkSaveQueue.queue();
    Time.updateTime(1200);
    final float time = Mathf.sinNormalized(Time.rawTime);
    sun.position.y = -time;
    sun.position.x = Mathf.cosNormalized(Time.rawTime) * .2f;
    sun.position.z = Mathf.cosNormalized(Time.rawTime);
    sun.brightness = Mathf.map(Mathf.max(time, -.4f), 1f, -.4f, 1f, 0f);
    Settings.CURRENT_SKY_COLOR = new Color(ImageBilinearFilter.getColor(AMBIENT, sun.brightness, 0));
    final Color sunColor = new Color(ImageBilinearFilter.getColor(AMBIENT, sun.brightness, 1));
    sun.color = new Vec3(sunColor.getRed(), sunColor.getGreen(), sunColor.getBlue());
    Debugger.chunksLoaded = Chunk.CHUNKS.size();
    Debugger.playerPosition = player.position;
    GameCamera.updateMatrix(Player.sprinting);
    if (autosaveTimer.isComplete()) {
        autosaveTimer.reset();
        for (final Chunk c : Chunk.CHUNKS) new ChunkSaveQueue(c);
        PlayerSave.save(player);
        inventory.save();
        System.out.println("Autosave");
    }
}
Also used : ChunkSaveQueue(org.asassecreations.voxelgame.world.chunk.queue.ChunkSaveQueue) Color(org.asassecreations.engine.render.Color) Vec3(org.asassecreations.engine.math.vector.Vec3) Chunk(org.asassecreations.voxelgame.world.chunk.Chunk)

Example 9 with Chunk

use of org.asassecreations.voxelgame.world.chunk.Chunk in project Voxel_Game by ASasseCreations.

the class ChunkModelQueue method queue.

public static final void queue() {
    int amount = 0;
    for (int i = 0; i < LIST.size(); i++) {
        final ChunkModelQueue queue = LIST.get(i);
        if (queue == null)
            continue;
        if (!Chunk.CHUNKS.contains(queue.chunk)) {
            LIST.remove(queue);
            continue;
        }
        final Chunk chunk = queue.chunk;
        if (chunk == null)
            continue;
        if (chunk.operation == null)
            chunk.operation = ChunkOperation.MODELING;
        if (chunk.model())
            LIST.remove(queue);
        amount++;
        if (amount >= MAX_SIZE)
            break;
    }
}
Also used : Chunk(org.asassecreations.voxelgame.world.chunk.Chunk)

Example 10 with Chunk

use of org.asassecreations.voxelgame.world.chunk.Chunk in project Voxel_Game by ASasseCreations.

the class ChunkOccludeQueue method contains.

private static final boolean contains(final Chunk chunk) {
    if (chunk == null)
        return false;
    for (int i = 0; i < LIST.size(); i++) {
        final ChunkOccludeQueue queue = LIST.get(i);
        if (queue == null)
            continue;
        final Chunk temp = queue.chunk;
        if (temp == null)
            continue;
        if (temp.x == chunk.x && temp.z == chunk.z)
            return true;
    }
    return false;
}
Also used : Chunk(org.asassecreations.voxelgame.world.chunk.Chunk)

Aggregations

Chunk (org.asassecreations.voxelgame.world.chunk.Chunk)12 Vec3 (org.asassecreations.engine.math.vector.Vec3)2 Color (org.asassecreations.engine.render.Color)1 TextureProperties (org.asassecreations.engine.texture.TextureProperties)1 BlockModeled (org.asassecreations.voxelgame.world.block.BlockModeled)1 ChunkSaveQueue (org.asassecreations.voxelgame.world.chunk.queue.ChunkSaveQueue)1