From 3ac06e30b191c630850d2440f163fbee3354a736 Mon Sep 17 00:00:00 2001 From: hYdos Date: Mon, 24 Feb 2020 07:45:18 +1000 Subject: [PATCH] Waht is collision --- .../java/io/github/hydos/ginger/Example.java | 44 +++++++++--------- .../engine/elements/objects/Player.java | 10 ++-- .../java/io/github/hydos/litecraft/Block.java | 2 +- .../textures/block/cubes/soil/gravel.png | Bin 1190 -> 1033 bytes 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/main/java/io/github/hydos/ginger/Example.java b/src/main/java/io/github/hydos/ginger/Example.java index 788eb3b..03df14b 100644 --- a/src/main/java/io/github/hydos/ginger/Example.java +++ b/src/main/java/io/github/hydos/ginger/Example.java @@ -41,7 +41,7 @@ public class Example extends Game{ //TODO: block register class to register blockzz //TODO: could also probally pull the mesh from 1 place to lower memory usage in the future TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/soil/dirt.png"); - TexturedModel grassModel = ModelLoader.loadGenericCube("block/cubes/soil/dirt.png"); + TexturedModel grassModel = ModelLoader.loadGenericCube("block/cubes/soil/gravel.png"); @@ -56,16 +56,16 @@ public class Example extends Game{ ginger3D.setup(new MasterRenderer(data.camera), data); - float blockSpacing = 1.2f; - float blockLineSpacing = 1.2f; - float blockUpwardsSpacing = 1.2f; + float blockSpacing = 1f; + float blockLineSpacing = 1f; + float blockUpwardsSpacing = 1f; //TODO: rename entity class to object class because not just entities List chunk = new ArrayList(); //Basic chunk generation TexturedModel activeModel = dirtModel; for(int k = 0; k<8;k++) { - if(k == 8) { + if(k == 7) { activeModel = grassModel; } for(int i = 0; i<8;i++) { @@ -91,9 +91,7 @@ public class Example extends Game{ GUIText text = new GUIText("LiteCraft", 3, font, new Vector2f(0,0), 1f, true); text.setColour(0, 0, 0); - - Terrain terrain = handleFlatTerrain(); - + Light sun = new Light(new Vector3f(100,105,-100), new Vector3f(1.3f, 1.3f, 1.3f), new Vector3f(0.0001f, 0.0001f, 0.0001f)); data.lights.add(sun); @@ -117,7 +115,7 @@ public class Example extends Game{ ginger3D.masterRenderer.renderShadowMap(data.entities, sun); camera.move(); - player.move(terrain); + player.move(null); system.generateParticles(new Vector3f(0,-2,0)); @@ -157,18 +155,18 @@ public class Example extends Game{ } - private Terrain handleFlatTerrain() { - TerrainTexture backgroundTexture = Loader.loadTerrainTexture("grass.png"); - TerrainTexture rTexture = Loader.loadTerrainTexture("mud.png"); - TerrainTexture gTexture = Loader.loadTerrainTexture("grassFlowers.png"); - TerrainTexture bTexture = Loader.loadTerrainTexture("path.png"); - TerrainTexturePack texturePack = new TerrainTexturePack(backgroundTexture, rTexture, gTexture, bTexture); - - TerrainTexture blendMap = Loader.loadTerrainTexture("blendMap.png"); - - Terrain terrain = new Terrain(-0.5f, -0.5f, texturePack, blendMap, "heightmap.png"); - data.flatTerrains.add(terrain); - return terrain; - } - +// private Terrain handleFlatTerrain() { +// TerrainTexture backgroundTexture = Loader.loadTerrainTexture("grass.png"); +// TerrainTexture rTexture = Loader.loadTerrainTexture("mud.png"); +// TerrainTexture gTexture = Loader.loadTerrainTexture("grassFlowers.png"); +// TerrainTexture bTexture = Loader.loadTerrainTexture("path.png"); +// TerrainTexturePack texturePack = new TerrainTexturePack(backgroundTexture, rTexture, gTexture, bTexture); +// +// TerrainTexture blendMap = Loader.loadTerrainTexture("blendMap.png"); +// +// Terrain terrain = new Terrain(-0.5f, -0.5f, texturePack, blendMap, "heightmap.png"); +// data.flatTerrains.add(terrain); +// return terrain; +// } +// } diff --git a/src/main/java/io/github/hydos/ginger/engine/elements/objects/Player.java b/src/main/java/io/github/hydos/ginger/engine/elements/objects/Player.java index 375ce31..e63b903 100644 --- a/src/main/java/io/github/hydos/ginger/engine/elements/objects/Player.java +++ b/src/main/java/io/github/hydos/ginger/engine/elements/objects/Player.java @@ -25,12 +25,12 @@ public class Player extends RenderObject{ public void move(Terrain t) { checkInputs(); + super.increaseRotation(0, (float) ((currentTurn) * Window.getTime() ), 0); + float distance = (float) ((currentSpeed) * (Window.getTime())); + 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) { - super.increaseRotation(0, (float) ((currentTurn) * Window.getTime() ), 0); - float distance = (float) ((currentSpeed) * (Window.getTime())); - 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); super.increasePosition(0, (float) (upwardsSpeed * (Window.getTime())), 0); terrainHeight = t.getHeightOfTerrain(super.getPosition().x, super.getPosition().z); upwardsSpeed += Constants.gravity * Window.getTime(); diff --git a/src/main/java/io/github/hydos/litecraft/Block.java b/src/main/java/io/github/hydos/litecraft/Block.java index 4f3cea0..9301a12 100644 --- a/src/main/java/io/github/hydos/litecraft/Block.java +++ b/src/main/java/io/github/hydos/litecraft/Block.java @@ -7,7 +7,7 @@ import io.github.hydos.ginger.engine.render.models.TexturedModel; public class Block extends RenderObject{ public Block(TexturedModel blockModel, Vector3f position) { - super(blockModel, position, 0, 0, 0, new Vector3f(0.2f,0.2f,0.2f)); + super(blockModel, position, 0, 0, 0, new Vector3f(1f,1f,1f)); } } diff --git a/src/main/resources/textures/block/cubes/soil/gravel.png b/src/main/resources/textures/block/cubes/soil/gravel.png index 6f8404a7ad7bf9e0216fb5d74a5cc41327dfab4f..9565a4d362949c78f43909f39ed71ec3ffbad8d2 100644 GIT binary patch delta 1011 zcmVr=U|p`lT91A3GR&*JOr%lGH5u=Ba+*%2E{es&gl+3B1t z_!c4a18VE)Xz%JLV0|Fk8%@Y^b20=~`E?E?9i-&DA4z%VAS};QQ=_K)cDGo#9=U88 z#eFhDPsuMfAvf;`vdva5tgM6fX^n8>Ioe!Fs+CbgP1o}Rps7|+bi z47CmI%*`*bd(R7W-TWJ~(MU#GD(+!n;e>`hf>xtJ(|^)TRYipae(~i5R>|cOc;_>_ z@bg{EuGkpLN-tuySXk}hL4RK_ZX&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