parent
c876ecbe35
commit
53d5ff873d
|
@ -22,7 +22,6 @@ public class Litecraft extends Game
|
||||||
{
|
{
|
||||||
private World world;
|
private World world;
|
||||||
private Ginger ginger3D;
|
private Ginger ginger3D;
|
||||||
private boolean isInWorld = false;
|
|
||||||
|
|
||||||
//temp stuff to test out fbo fixes
|
//temp stuff to test out fbo fixes
|
||||||
int oldWindowWidth = Window.width;
|
int oldWindowWidth = Window.width;
|
||||||
|
@ -96,7 +95,9 @@ public class Litecraft extends Game
|
||||||
Window.lockMouse();
|
Window.lockMouse();
|
||||||
playButton.hide(data.guis);
|
playButton.hide(data.guis);
|
||||||
if (world == null)
|
if (world == null)
|
||||||
|
{
|
||||||
world = new World((long) new Random().nextInt(), 10);
|
world = new World((long) new Random().nextInt(), 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,20 +8,33 @@ public class Block
|
||||||
public static class Properties
|
public static class Properties
|
||||||
{ // add properties to this builder!
|
{ // add properties to this builder!
|
||||||
private boolean visible = true;
|
private boolean visible = true;
|
||||||
|
private boolean fullCube = true;
|
||||||
|
|
||||||
public Properties visible(boolean visible)
|
public Properties visible(boolean visible)
|
||||||
{
|
{
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Properties fullCube(boolean fullCube)
|
||||||
|
{
|
||||||
|
this.fullCube = fullCube;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFullCube()
|
||||||
|
{ return fullCube; }
|
||||||
|
|
||||||
|
public boolean isVisible()
|
||||||
|
{ return visible; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Block AIR = new Block((TexturedModel) null, new Properties().visible(false));
|
public static final Block AIR = new Block(new Properties().visible(false));
|
||||||
|
|
||||||
public static final Block GRASS = new Block("block/cubes/soil/gravel.png", new Properties());
|
|
||||||
public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties());
|
public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties());
|
||||||
|
public static final Block STONE = new Block("block/cubes/stone/cobblestone.png", new Properties());
|
||||||
public final TexturedModel model;
|
public final TexturedModel model;
|
||||||
public final boolean visible;
|
public final boolean visible;
|
||||||
|
|
||||||
protected Block(String texture, Properties properties)
|
protected Block(String texture, Properties properties)
|
||||||
{ this(ModelLoader.loadGenericCube(texture), properties); }
|
{ this(ModelLoader.loadGenericCube(texture), properties); }
|
||||||
|
|
||||||
|
@ -30,4 +43,7 @@ public class Block
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.visible = properties.visible;
|
this.visible = properties.visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Block(Properties properties)
|
||||||
|
{ this((TexturedModel) null, properties); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class Chunk implements BlockAccess
|
||||||
for (int x = 0; x < CHUNK_SIZE; ++x) {
|
for (int x = 0; x < CHUNK_SIZE; ++x) {
|
||||||
for (int z = 0; z < CHUNK_SIZE; ++z) {
|
for (int z = 0; z < CHUNK_SIZE; ++z) {
|
||||||
for (int y = 0; y < CHUNK_SIZE; ++y) {
|
for (int y = 0; y < CHUNK_SIZE; ++y) {
|
||||||
result.setBlock(x, y, z, y == 7 ? Block.GRASS : Block.DIRT);
|
result.setBlock(x, y, z, y == 7 ? Block.DIRT : Block.STONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package com.github.halotroop.litecraft.world;
|
package com.github.halotroop.litecraft.world;
|
||||||
|
|
||||||
import com.github.halotroop.litecraft.types.block.Block;
|
import com.github.halotroop.litecraft.types.block.Block;
|
||||||
|
import com.github.hydos.ginger.engine.elements.objects.Player;
|
||||||
|
import com.github.hydos.ginger.engine.math.vectors.Vector3f;
|
||||||
|
import com.github.hydos.ginger.engine.obj.ModelLoader;
|
||||||
|
import com.github.hydos.ginger.engine.render.models.TexturedModel;
|
||||||
import com.github.hydos.ginger.engine.render.renderers.ObjectRenderer;
|
import com.github.hydos.ginger.engine.render.renderers.ObjectRenderer;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.longs.*;
|
import it.unimi.dsi.fastutil.longs.*;
|
||||||
|
@ -8,6 +12,7 @@ import it.unimi.dsi.fastutil.longs.*;
|
||||||
public class World implements BlockAccess
|
public class World implements BlockAccess
|
||||||
{
|
{
|
||||||
private final Long2ObjectMap<Chunk> chunks;
|
private final Long2ObjectMap<Chunk> chunks;
|
||||||
|
public Player player;
|
||||||
|
|
||||||
public World(long seed, int size)
|
public World(long seed, int size)
|
||||||
{
|
{
|
||||||
|
@ -16,6 +21,9 @@ public class World implements BlockAccess
|
||||||
for (int i = (0 - (size/2)); i < (size/2); i++)
|
for (int i = (0 - (size/2)); i < (size/2); i++)
|
||||||
for (int k = (0 - (size/2)); k < (size/2); k++)
|
for (int k = (0 - (size/2)); k < (size/2); k++)
|
||||||
this.getChunk(i, -1, k).setRender(true);
|
this.getChunk(i, -1, k).setRender(true);
|
||||||
|
|
||||||
|
TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/soil/dirt.png");
|
||||||
|
this.player = new Player(dirtModel, new Vector3f(0, 0, -3), 0, 180f, 0, new Vector3f(0.2f, 0.2f, 0.2f));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chunk getChunk(int chunkX, int chunkY, int chunkZ)
|
public Chunk getChunk(int chunkX, int chunkY, int chunkZ)
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
package com.github.hydos.ginger;
|
package com.github.hydos.ginger;
|
||||||
|
|
||||||
|
import org.lwjgl.Version;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import com.github.halotroop.litecraft.Litecraft;
|
import com.github.halotroop.litecraft.Litecraft;
|
||||||
|
|
||||||
public class Starter
|
public class Starter
|
||||||
{
|
{
|
||||||
// private static final boolean usingEclipse = false;
|
// private static final boolean usingEclipse = false;
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{ new Litecraft(); }
|
{
|
||||||
|
System.out.println("GLFW version: " + GLFW.glfwGetVersionString());
|
||||||
|
System.out.println("LWJGL version: " + Version.getVersion());
|
||||||
|
// Put SoundSystem version here
|
||||||
|
new Litecraft();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,9 +54,9 @@ public class Ginger
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIText registerText(String string, int textSize, Vector2f vector2f, float maxLineLength, boolean centered, String id)
|
public GUIText registerText(String string, int textSize, Vector2f position, float maxLineLength, boolean centered, String id)
|
||||||
{
|
{
|
||||||
GUIText text = new GUIText(string, textSize, globalFont, vector2f, maxLineLength, false);
|
GUIText text = new GUIText(string, textSize, globalFont, position, maxLineLength, false);
|
||||||
text.textID = id;
|
text.textID = id;
|
||||||
gingerRegister.registerText(text);
|
gingerRegister.registerText(text);
|
||||||
return text;
|
return text;
|
||||||
|
|
|
@ -5,7 +5,6 @@ import org.lwjgl.glfw.GLFW;
|
||||||
import com.github.hydos.ginger.engine.io.Window;
|
import com.github.hydos.ginger.engine.io.Window;
|
||||||
import com.github.hydos.ginger.engine.math.vectors.Vector3f;
|
import com.github.hydos.ginger.engine.math.vectors.Vector3f;
|
||||||
import com.github.hydos.ginger.engine.render.models.TexturedModel;
|
import com.github.hydos.ginger.engine.render.models.TexturedModel;
|
||||||
import com.github.hydos.ginger.engine.terrain.Terrain;
|
|
||||||
import com.github.hydos.ginger.main.settings.Constants;
|
import com.github.hydos.ginger.main.settings.Constants;
|
||||||
|
|
||||||
public class Player extends RenderObject
|
public class Player extends RenderObject
|
||||||
|
@ -42,9 +41,6 @@ public class Player extends RenderObject
|
||||||
{
|
{
|
||||||
jump();
|
jump();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void jump()
|
private void jump()
|
||||||
|
|
|
@ -16,7 +16,6 @@ public class Window
|
||||||
private static String title;
|
private static String title;
|
||||||
public static long window;
|
public static long window;
|
||||||
private static Vector3f backgroundColour = new Vector3f(0.2f, 0.2f, 0.2f);
|
private static Vector3f backgroundColour = new Vector3f(0.2f, 0.2f, 0.2f);
|
||||||
private static boolean[] keys = new boolean[GLFW.GLFW_KEY_LAST];
|
|
||||||
private static boolean[] mouseButtons = new boolean[GLFW.GLFW_MOUSE_BUTTON_LAST];
|
private static boolean[] mouseButtons = new boolean[GLFW.GLFW_MOUSE_BUTTON_LAST];
|
||||||
private static GLFWImage.Buffer iconBuffer = null;
|
private static GLFWImage.Buffer iconBuffer = null;
|
||||||
private static double fpsCap, time, processedTime = 0;
|
private static double fpsCap, time, processedTime = 0;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.github.hydos.ginger.engine.render.models.RawModel;
|
||||||
import com.github.hydos.ginger.engine.utils.Loader;
|
import com.github.hydos.ginger.engine.utils.Loader;
|
||||||
import com.github.hydos.ginger.main.settings.Constants;
|
import com.github.hydos.ginger.main.settings.Constants;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class Terrain
|
public class Terrain
|
||||||
{
|
{
|
||||||
private static final float MAX_PIXEL_COLOUR = 256 * 256 * 256;
|
private static final float MAX_PIXEL_COLOUR = 256 * 256 * 256;
|
||||||
|
|
Loading…
Reference in New Issue