Skip to content
Permalink
65699eab6c
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
73 lines (59 sloc) 1.38 KB
package game.level.tiles;
import game.graphics.Shader;
import game.graphics.Texture;
import game.graphics.VertexArray;
import game.math.Matrix4f;
import game.math.Vector3f;
public abstract class Tile {
protected Vector3f position = new Vector3f();
protected boolean isWall;
protected static final float SIZE = 1.0f;
protected Texture texture;
protected Matrix4f ml_matrix;
protected static VertexArray mesh;
private static float[] vertices;
private static float[] tcs;
private static byte[] indices;
public static void create() {
vertices = new float[] {
-SIZE / 2.0f, -SIZE / 2.0f, 0.1f,
-SIZE / 2.0f, SIZE / 2.0f, 0.1f,
SIZE / 2.0f, SIZE / 2.0f, 0.1f,
SIZE / 2.0f, -SIZE / 2.0f, 0.1f,
};
indices = new byte[] {
0, 1, 2,
2, 3, 0
};
tcs = new float[] {
0, 1,
0, 0,
1, 0,
1, 1
};
mesh = new VertexArray(vertices, indices, tcs);
}
public void render() {
Shader.TILE.enable();
Shader.TILE.setUniformMat4f("vw_matrix", Matrix4f.translate(position));
texture.bind();
mesh.bind();
Shader.TILE.setUniformMat4f("ml_matrix", ml_matrix);
mesh.draw();
texture.unbind();
mesh.unbind();
}
public abstract void update();
public float getSize() {
return SIZE;
}
public float getX() {
return position.x;
}
public float getY() {
return position.y;
}
public boolean isWall() {
return isWall;
}
}