Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Basic rendering and WASD controls complete! Need to finish tile rende…
…ring.
- Loading branch information
Showing
13 changed files
with
149 additions
and
46 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#version 330 core | ||
|
||
layout (location = 0) out vec4 color; | ||
|
||
in DATA | ||
{ | ||
vec2 tc; | ||
} fs_in; | ||
|
||
uniform sampler2D tex; | ||
|
||
void main() | ||
{ | ||
color = texture(tex, fs_in.tc); | ||
if (color.w < 1.0) | ||
discard; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#version 330 core | ||
|
||
layout (location = 0) in vec4 position; | ||
layout (location = 1) in vec2 tc; | ||
|
||
uniform mat4 pr_matrix; | ||
uniform mat4 vw_matrix = mat4(1.0); | ||
uniform mat4 ml_matrix = mat4(1.0); | ||
|
||
out DATA | ||
{ | ||
vec2 tc; | ||
} vs_out; | ||
|
||
void main() | ||
{ | ||
gl_Position = pr_matrix * vw_matrix * ml_matrix * position; | ||
vs_out.tc = tc; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ out DATA | |
{ | ||
vec2 tc; | ||
vec3 position; | ||
} | ||
} vs_out; | ||
|
||
void main() | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package game.entity; | ||
|
||
import static org.lwjgl.glfw.GLFW.*; | ||
import org.lwjgl.glfw.GLFW; | ||
|
||
import game.graphics.Shader; | ||
import game.graphics.Texture; | ||
import game.graphics.VertexArray; | ||
import game.input.Input; | ||
import game.math.Matrix4f; | ||
import game.math.Vector3f; | ||
|
||
public class Player { | ||
|
||
private float SIZE = 1.0f; | ||
private VertexArray mesh; | ||
private Texture texture; | ||
|
||
private Vector3f position = new Vector3f(); | ||
|
||
public Player() { | ||
float[] vertices = new float[] { | ||
-SIZE / 2.0f, -SIZE / 2.0f, 0.2f, | ||
-SIZE / 2.0f, SIZE / 2.0f, 0.2f, | ||
SIZE / 2.0f, SIZE / 2.0f, 0.2f, | ||
SIZE / 2.0f, -SIZE / 2.0f, 0.2f, | ||
}; | ||
|
||
byte[] indices = new byte[] { | ||
0, 1, 2, | ||
2, 3, 0 | ||
}; | ||
|
||
float[] tcs = new float[] { | ||
0, 1, | ||
0, 0, | ||
1, 0, | ||
1, 1 | ||
}; | ||
|
||
mesh = new VertexArray(vertices, indices, tcs); | ||
// TODO: More color options? | ||
texture = new Texture("res/playerBlue.png"); | ||
} | ||
|
||
public void update() { | ||
if (Input.keys[GLFW.GLFW_KEY_UP]) | ||
position.y += 0.1f; | ||
if (Input.keys[GLFW.GLFW_KEY_DOWN]) | ||
position.y -= 0.1f; | ||
if (Input.keys[GLFW.GLFW_KEY_LEFT]) | ||
position.x -= 0.1f; | ||
if (Input.keys[GLFW.GLFW_KEY_RIGHT]) | ||
position.x += 0.1f; | ||
|
||
System.out.println("At (" + position.x + ", " + position.y + ")"); | ||
} | ||
|
||
public void render() { | ||
Shader.PLAYER.enable(); | ||
Shader.PLAYER.setUniformMat4f("ml_matrix", Matrix4f.translate(position)); | ||
texture.bind(); | ||
mesh.render(); | ||
Shader.PLAYER.disable(); | ||
} | ||
|
||
public float getY() { | ||
return position.y; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters