Generate symetrical worlds of configurable size

pull/12/head
Caroline Bell 2020-02-25 16:42:35 -08:00
parent f096950bbd
commit 0433384b36
3 changed files with 13 additions and 21 deletions

View File

@ -88,14 +88,15 @@ public class Litecraft extends Game
@Override
public void update()
{
data.player.move(null);
data.player.updateMovement();
TextureButton playButton = ginger3D.gingerRegister.guiButtons.get(0);
playButton.update();
if (playButton.isClicked())
{
Window.lockMouse();
playButton.hide(data.guis);
world = new World((long) new Random().nextInt());
if (world == null)
world = new World((long) new Random().nextInt(), 10);
}
}
}

View File

@ -9,16 +9,13 @@ public class World implements BlockAccess
{
private final Long2ObjectMap<Chunk> chunks;
public World(long seed)
public World(long seed, int size)
{
chunks = new Long2ObjectArrayMap<>();
for(int i = 0; i<10;i++) {
for(int k = 0; k<10;k++) {
Chunk exampleManualChunk = this.getChunk(i, -1, k);
exampleManualChunk.setRender(true);
}
}
for (int i = (0 - (size/2)); i < (size/2); i++)
for (int k = (0 - (size/2)); k < (size/2); k++)
this.getChunk(i, -1, k).setRender(true);
}
public Chunk getChunk(int chunkX, int chunkY, int chunkZ)
@ -42,7 +39,6 @@ public class World implements BlockAccess
public Chunk optimiseChunk(Chunk chunk)
{
//TODO: use this
return null;
}

View File

@ -10,7 +10,6 @@ import com.github.hydos.ginger.main.settings.Constants;
public class Player extends RenderObject
{
private static float terrainHeight = 0;
private double currentSpeed = 0;
private float currentTurn = 0;
private float upwardsSpeed = 0;
@ -57,7 +56,7 @@ public class Player extends RenderObject
}
}
public void move(Terrain t)
public void updateMovement()
{
checkInputs();
super.increaseRotation(0, (float) ((currentTurn) * Window.getTime()), 0);
@ -65,15 +64,11 @@ public class Player extends RenderObject
float dx = (float) (distance * Math.sin(Math.toRadians(super.getRotY())));
float dz = (float) (distance * Math.cos(Math.toRadians(super.getRotY())));
super.increasePosition(dx, 0, dz);
if (t != null)
{ terrainHeight = t.getHeightOfTerrain(super.getPosition().x, super.getPosition().z); }
super.increasePosition(0, (float) (upwardsSpeed * (Window.getTime())), 0);
upwardsSpeed += Constants.gravity.y() * Window.getTime();
if (super.getPosition().y < terrainHeight)
{
isInAir = false;
upwardsSpeed = 0;
super.getPosition().y = terrainHeight;
}
isInAir = false;
upwardsSpeed = 0;
super.getPosition().y = 0;
}
}