hid player and first person camera
parent
97f7d48b64
commit
183a71fbd8
|
@ -3,7 +3,7 @@ package com.github.hydos.ginger;
|
|||
import com.github.halotroop.litecraft.world.*;
|
||||
import com.github.hydos.ginger.engine.api.*;
|
||||
import com.github.hydos.ginger.engine.api.game.*;
|
||||
import com.github.hydos.ginger.engine.cameras.Camera;
|
||||
import com.github.hydos.ginger.engine.cameras.*;
|
||||
import com.github.hydos.ginger.engine.elements.buttons.TextureButton;
|
||||
import com.github.hydos.ginger.engine.elements.objects.*;
|
||||
import com.github.hydos.ginger.engine.font.*;
|
||||
|
@ -38,7 +38,10 @@ public class Litecraft extends Game
|
|||
TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/soil/gravel.png");
|
||||
StaticCube.scaleCube(1);
|
||||
Player player = new Player(dirtModel, new Vector3f(0, 0, -3), 0, 180f, 0, new Vector3f(0.2f, 0.2f, 0.2f));
|
||||
Camera camera = new Camera(new Vector3f(0, 0.1f, 0), player);
|
||||
Camera camera = new FirstPersonCamera(player);
|
||||
|
||||
player.isVisible = false;
|
||||
|
||||
ginger3D = new Ginger();
|
||||
data = new GameData(player, camera, 30);
|
||||
data.handleGuis = false;
|
||||
|
@ -55,7 +58,7 @@ public class Litecraft extends Game
|
|||
|
||||
FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt");
|
||||
ginger3D.setGlobalFont(font);
|
||||
GUIText titleText = ginger3D.registerText("LiteCraft", 3, new Vector2f(0, 0), 1f, true, "PLAYBUTTON");
|
||||
GUIText titleText = ginger3D.registerText("LiteCraft PRE-ALPHA build 1", 3, new Vector2f(0, 0), 1f, true, "PLAYBUTTON");
|
||||
titleText.setBorderWidth(0.5f);
|
||||
|
||||
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));
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.github.hydos.ginger.engine.particle.ParticleMaster;
|
|||
import com.github.hydos.ginger.engine.postprocessing.*;
|
||||
import com.github.hydos.ginger.engine.render.MasterRenderer;
|
||||
import com.github.hydos.ginger.engine.render.tools.MousePicker;
|
||||
import com.github.hydos.ginger.engine.screen.Screen;
|
||||
import com.github.hydos.ginger.engine.utils.Loader;
|
||||
|
||||
public class Ginger
|
||||
|
@ -38,6 +39,11 @@ public class Ginger
|
|||
TextMaster.cleanUp();
|
||||
Loader.cleanUp();
|
||||
}
|
||||
|
||||
public void openScreen(Screen screen)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void postRender()
|
||||
{ Window.swapBuffers(); }
|
||||
|
|
|
@ -13,7 +13,7 @@ public class Camera
|
|||
private Vector3f position = new Vector3f(0, 0, 0);
|
||||
private float pitch, yaw;
|
||||
private float roll;
|
||||
private Player player;
|
||||
public Player player;
|
||||
|
||||
public Camera(Player player)
|
||||
{ this.player = player; }
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
package com.github.hydos.ginger.engine.cameras;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.github.hydos.ginger.engine.io.Window;
|
||||
import com.github.hydos.ginger.engine.elements.objects.Player;
|
||||
import com.github.hydos.ginger.engine.math.vectors.Vector3f;
|
||||
|
||||
public class FirstPersonCamera
|
||||
public class FirstPersonCamera extends Camera
|
||||
{
|
||||
private Vector3f position = new Vector3f(0, 0, 0);
|
||||
private float pitch, yaw;
|
||||
private float roll;
|
||||
|
||||
public FirstPersonCamera()
|
||||
{}
|
||||
|
||||
public FirstPersonCamera(Vector3f vector3f)
|
||||
{ this.position = vector3f; }
|
||||
public FirstPersonCamera(Player player)
|
||||
{
|
||||
super(player);
|
||||
}
|
||||
|
||||
public float getPitch()
|
||||
{ return pitch; }
|
||||
|
@ -31,21 +28,13 @@ public class FirstPersonCamera
|
|||
|
||||
public void move()
|
||||
{
|
||||
if (Window.isKeyDown(GLFW.GLFW_KEY_W))
|
||||
{ position.z -= 0.05f; }
|
||||
if (Window.isKeyDown(GLFW.GLFW_KEY_A))
|
||||
{ position.x -= 0.05f; }
|
||||
if (Window.isKeyDown(GLFW.GLFW_KEY_S))
|
||||
{ position.z -= -0.05f; }
|
||||
if (Window.isKeyDown(GLFW.GLFW_KEY_D))
|
||||
{ position.x += 0.05f; }
|
||||
if (Window.isKeyDown(GLFW.GLFW_KEY_SPACE))
|
||||
{ position.y += 0.05f; }
|
||||
if (Window.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT))
|
||||
{ position.y -= 0.05f; }
|
||||
if (Window.isKeyDown(GLFW.GLFW_KEY_LEFT))
|
||||
{ yaw -= 0.5f; }
|
||||
if (Window.isKeyDown(GLFW.GLFW_KEY_RIGHT))
|
||||
{ yaw += 0.5f; }
|
||||
position.x = player.getPosition().x;
|
||||
position.z = player.getPosition().z;
|
||||
position.y = player.getPosition().y;
|
||||
|
||||
roll = player.getRotX();
|
||||
yaw = -player.getRotY() + 180;
|
||||
pitch = player.getRotZ();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ public class RenderObject
|
|||
private Vector3f position;
|
||||
private float rotX = 0, rotY = 0, rotZ = 0;
|
||||
private Vector3f scale;
|
||||
public boolean isVisible = true;
|
||||
|
||||
public RenderObject(TexturedModel model, Vector3f position, float rotX, float rotY, float rotZ, Vector3f scale)
|
||||
{
|
||||
|
|
|
@ -82,7 +82,7 @@ public class Window
|
|||
|
||||
public static float getFloatTime()
|
||||
{
|
||||
float f = (System.nanoTime() / (float) 1000000000);
|
||||
float f = (System.nanoTime() / (long) 1000000000);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class Window
|
|||
|
||||
public static double getTime()
|
||||
{
|
||||
double f = (double) System.nanoTime() / (double) 1000000000;
|
||||
double f = (double) System.nanoTime() / (long) 1000000000;
|
||||
return f;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,8 +66,11 @@ public class ObjectRenderer extends Renderer
|
|||
List<RenderObject> batch = entities.get(model);
|
||||
for (RenderObject entity : batch)
|
||||
{
|
||||
prepareInstance(entity);
|
||||
GL11.glDrawElements(GL11.GL_TRIANGLES, model.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
|
||||
if(entity.isVisible) {
|
||||
prepareInstance(entity);
|
||||
GL11.glDrawElements(GL11.GL_TRIANGLES, model.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
|
||||
}
|
||||
|
||||
}
|
||||
unbindTexturedModel();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,6 @@ public abstract class Screen
|
|||
{
|
||||
|
||||
public abstract void render();
|
||||
|
||||
public abstract void tick();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue