Search in sources :

Example 6 with Color

use of org.asassecreations.engine.render.Color 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)

Aggregations

Color (org.asassecreations.engine.render.Color)6 Font (java.awt.Font)2 GuiButton (org.asassecreations.engine.gui.GuiButton)2 GuiImage (org.asassecreations.engine.gui.GuiImage)2 GuiPanel (org.asassecreations.engine.gui.GuiPanel)2 Square (org.asassecreations.engine.math.Square)2 Vec3 (org.asassecreations.engine.math.vector.Vec3)2 SoftwareImage (org.asassecreations.engine.tools.SoftwareImage)2 MouseInput (org.asassecreations.engine.input.MouseInput)1 Vec2 (org.asassecreations.engine.math.vector.Vec2)1 State (org.asassecreations.engine.state.State)1 StateManager (org.asassecreations.engine.state.StateManager)1 Texture (org.asassecreations.engine.texture.Texture)1 TextureLoader (org.asassecreations.engine.texture.TextureLoader)1 VoxelGame (org.asassecreations.voxelgame.VoxelGame)1 GuiSystem (org.asassecreations.voxelgame.gui.GuiSystem)1 MouseSystem (org.asassecreations.voxelgame.input.MouseSystem)1 GameState (org.asassecreations.voxelgame.state.GameState)1 MenuState (org.asassecreations.voxelgame.state.MenuState)1 Chunk (org.asassecreations.voxelgame.world.chunk.Chunk)1