first commit

This commit is contained in:
josua 2020-05-05 22:04:33 +10:00
commit c85083fc92
85 changed files with 2299 additions and 0 deletions

8
.classpath Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/LWJGL_Lightweight"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/mainloop.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RoboticsAndGameDesignMazeGame</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

BIN
bin/maze_game/Main.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,32 @@
################################
# #
# #
# #
# #
# #
# #
# #
# #
# &&&&& &&& &&& &&& #
# & & & & & & & #
# & & & &&& & && #
# & & & & & & & #
# & & & & & &&& &&& #
# #
# #
# &&& &&& &&&&& &&& #
# & & & & & & & #
# & & &&& & & & && #
# & & & & & & & & #
# &&& & & & & & &&& #
# #
# #
# #
# #
# #
# #
# #
# #
# #
#! 1#
################################

View File

@ -0,0 +1,32 @@
################
#&&&& &#
#&&&& #
###### ##### #
###### ##### &#
## @ # &&#
########## #& ### ### # &&#
# # #& # @ # # #
# ###### # #& # #3# # # #
# # # #& # # # # #&& #
###### # # #& # #2# # #&& #
# # # # #& # # # # #&& #
# # # # # #& # # # # #
#&&# # # # #& ##### # # #
#&&# #4#3# #& # # &&#
#### ###### ## #### # &&#
# # #########&& # #
# #### # # #&& ##
# # ##### ##### #########
# &&# #### @ @ #
# &&# # &# ##### #### ####
# # # @ && #
# # #5###### ############# #
#&& # ### @ # # #
#&& # # #### ### # # # # & #
# # ##### @ # # # # & #
# # ## ### # # #
## ########## 2##############
# & & ###### #
# #
# #&&&&&&# #&&&&&&# #
################################

View File

@ -0,0 +1,32 @@
#######
# #
# ### #
# # # #
# # #1#
# # ###
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
### #
#1 #
#####

View File

@ -0,0 +1,32 @@
#######
# #
# ### #
# # # #
# # #1#
# # # #
######### ### #
# @ #
# ###### ### #
### # # #&& #
#1# # # # #
# # # # #####
# # # # #
# # # #
###### # #
# #
# #
# #
# #
# #
### #
#1 #
#####

View File

@ -0,0 +1,32 @@
################################
################################
################ #######
########## #####
######### ####
###### ####
#### ####
#### ###
### ###
## ###
## ###
## ###
# ### ####### ####### ###
# #1#&# #&# # ###
# ### ### ### ### ### ##### ##
# @ @ @ @ @ # ##
# ### &&& &&& &&& &&& &&& # ##
# # &&& &&& &&& &&& &&& # ##
# ### &&& &&& &&& &&& &&& # #
# # @ @ @ @ @ # #
# # # &&& &&& &&& &&& ##### #
# # # &&& &&& &&& &&& # #
# # # &&& &&& &&& &&& ##### #
# # @ @ @ @ @ # #
# ### &&& ### &&& ### &&& # #
# # &&& # # &&& # # &&& # #
# # &&& # # &&& # # &&& # #
#&&&&# #&# #&# #&55#
#&&&&#######&#######&#######&&&#
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#
################################

View File

@ -0,0 +1,32 @@
################################
#### ###########################
### ###########################
##&&&&##########################
##&&&&##########################
##&&&&&#########################
###&&###########################
######### ###################
#### ########
## ########## ####
## #&&&&&####### ######### ##
## ###&######### ######### #
## ############## ########## #
## ############### ######### #
## ############### ####### #
### ###############&&&&&##### #
#### ##########&&&&##### #
#####&&&## 6######&&###### #
############################# #
#&&### ##### ##
#& # ########## #####
#& ###1# ######&&&&&&######
#& ##### #######&&########
#& #### ##################
#& #&&&&&&&&&###################
#& ##&&&&&&&####################
#& ####&&####################44#
## ####&## ############# #
# ##### # # ########### #
# # ####&### ## #
# ######## ## #
##&&&&&&##########&&&&&&###&&&&#

View File

@ -0,0 +1,35 @@
###################################
# #
# #
# #
# #
# ### # # ### # # # # ### #
# # # # # # ## # ## # #
# # ### ### # # # # ### #
# # # # # # # ## ## # #
# # # # # # # # # # ### #
# #
# ### ### ### #
# # # # # # #
# ## # # ### #
# # # # ## #
# # ### # # #
# #
# ### # ### # # ### # # ### #
# # # # # # # # # ## # # #
# ### # ### ### # # # # # # #
# # # # # # # # ## # # #
# # ### # # # ### # # ### #
# #
# #
# #
# #
# #
# ! #
# #
# #
# #
# #
# #
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#
###################################

View File

View File

View File

View File

@ -0,0 +1,9 @@
#version 330
in vec3 color;
out vec4 FragColor;
void main()
{
FragColor = vec4(color, 0);
}

View File

@ -0,0 +1,16 @@
#version 330
layout (location = 0) in vec2 aPos;
layout (location = 1) in vec3 aColor;
out vec3 color;
uniform vec2 pos;
uniform ivec2 maze;
void main()
{
vec2 cPos = (aPos + pos) / maze;
gl_Position = vec4(cPos * 2 - 1, 0, 1);
color = aColor;
}

View File

@ -0,0 +1,9 @@
#version 330
in vec3 color;
out vec4 FragColor;
void main()
{
FragColor = vec4(color, 0);
}

View File

@ -0,0 +1,12 @@
#version 330
layout (location = 0) in vec2 aPos;
layout (location = 1) in vec3 aColor;
out vec3 color;
void main()
{
gl_Position = vec4(aPos.x * 2 - 1, aPos.y * 2 - 1, 0, 1);
color = aColor;
}

34
src/maze_game/Main.java Normal file
View File

@ -0,0 +1,34 @@
package maze_game;
import maze_game.entity.EntityPlayer;
import maze_game.graphics.GameWindow;
import maze_game.helpers.ResourceLoader;
import maze_game.helpers.vec.Vec2d;
import maze_game.init.Entities;
import maze_game.init.Mazes;
import maze_game.mainloop.MainloopHandler;
import maze_game.maze.Maze;
import maze_game.maze.MazeDrawer;
public class Main
{
public static GameWindow window;
public static MainloopHandler ml_handler;
public static EntityPlayer player;
public static Maze maze;
public static void main(String[] args)
{
maze = Mazes.MAZE[0];
window = new GameWindow();
ml_handler = new MainloopHandler();
player = new EntityPlayer();
player.pos = maze.player_pos.copy();
Entities.entities.add(player);
ml_handler.mainloop.start();
}
}

View File

@ -0,0 +1,64 @@
package maze_game.entity;
import org.lwjgl.opengl.GL33;
import maze_game.Main;
import maze_game.graphics.GraphicsShader;
import maze_game.helpers.vec.Vec2d;
import maze_game.helpers.vec.Vec3d;
import maze_game.models.Model;
public class Entity
{
public static int glsl_pos;
public Vec2d pos;
private Model model;
public Entity(Model model) {
this.pos = new Vec2d(0, 0);
this.model = model;
}
public void render()
{
// Bind the vertex array
model.bind();
// Set entity position and render
GL33.glUniform2f(glsl_pos, (float)pos.x, (float)pos.y);
GL33.glDrawArrays(GL33.GL_TRIANGLES, 0, model.s);
}
public void move(Vec2d pos)
{
pos = this.pos.add(pos);
// Teleport
while(Main.maze.collision(pos, 3))
{
if(pos.x > this.pos.x) {
pos.x += 1;
}
if(pos.x < this.pos.x) {
pos.x -= 1;
}
if(pos.y > this.pos.y) {
pos.y += 1;
}
if(pos.y < this.pos.y) {
pos.y -= 1;
}
}
// Wall collisions
if(!Main.maze.collision(this.pos.x, pos.y, 1)) {
this.pos.y = pos.y;
} if(!Main.maze.collision(pos.x, this.pos.y, 1)) {
this.pos.x = pos.x;
}
}
}

View File

@ -0,0 +1,49 @@
package maze_game.entity;
import static org.lwjgl.opengl.GL20.glGetUniformLocation;
import static org.lwjgl.opengl.GL20.glUniform2i;
import maze_game.Main;
import maze_game.helpers.vec.Vec2d;
import maze_game.init.Mazes;
import maze_game.init.Models;
public class EntityPlayer extends Entity
{
public EntityPlayer() {
super(Models.MODEL_PLAYER);
}
@Override
public void move(Vec2d pos) {
pos = pos.add(this.pos);
// Level teleportation
for(int i=0;i<10;i++) {
if(Main.maze.collision(pos, i + 4)) {
Main.maze = Mazes.MAZE[i];
if(Main.maze.player_pos != null)
{
pos = Main.maze.player_pos.copy();
Main.window.entity_shader.use();
int glsl_maze_size = glGetUniformLocation(Main.window.entity_shader.program, "maze");
glUniform2i(glsl_maze_size, Main.maze.width, Main.maze.height);
}
}
}
pos = pos.subtract(this.pos);
super.move(pos);
// Death
if(Main.maze.collision(this.pos, 2)) {
Main.maze = Mazes.MAZE[0];
this.pos = Main.maze.player_pos.copy();
return;
}
}
}

View File

@ -0,0 +1,118 @@
package maze_game.graphics;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_FLOAT;
import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_INT;
import static org.lwjgl.opengl.GL11.glClear;
import static org.lwjgl.opengl.GL11.glClearColor;
import static org.lwjgl.opengl.GL11.glDrawElements;
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
import static org.lwjgl.opengl.GL20.glUniform4f;
import static org.lwjgl.opengl.GL20.glUseProgram;
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
import static org.lwjgl.opengl.GL30.glBindVertexArray;
import static org.lwjgl.opengl.GL33.*;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL;
import maze_game.Main;
import maze_game.entity.Entity;
import maze_game.helpers.ResourceLoader;
import maze_game.init.Entities;
import maze_game.input.InputKeyboard;
import maze_game.mainloop.FpsCounter;
import maze_game.maze.Maze;
import maze_game.maze.MazeDrawer;
public class GameWindow
{
public GraphicsShader maze_shader;
public GraphicsShader entity_shader;
public long window;
public GameWindow()
{
if(!glfwInit()) {
throw new RuntimeException("GLFW intialization failed");
}
// Setup OpenGL with the core profile
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_FALSE);
window = glfwCreateWindow(800, 600, "Maze Game", 0, 0);
if(window == 0) {
glfwTerminate();
throw new RuntimeException("GLFW window initialization failed");
}
glfwSetKeyCallback(window, InputKeyboard.INPUT_KEYBOARD);
glfwMakeContextCurrent(window);
glfwShowWindow(window);
GL.createCapabilities();
glViewport(0, 0, 800, 600);
// Load and compile the shader
maze_shader = new GraphicsShader("environment");
entity_shader = new GraphicsShader("entity");
maze_shader.use();
Entity.glsl_pos = glGetUniformLocation(entity_shader.program, "pos");
entity_shader.use();
int glsl_maze_size = glGetUniformLocation(entity_shader.program, "maze");
glUniform2i(glsl_maze_size, Main.maze.width, Main.maze.height);
}
public void render()
{
int w[] = {0};
int h[] = {0};
glfwGetFramebufferSize(window, w, h);
double w_r = (double)w[0] / (double)h[0];
double m_r = (double)Main.maze.width / (double)Main.maze.height;
int o_x = 0;
int o_y = 0;
if(w_r < m_r) {
o_y = (int)(h[0] * w_r / m_r) - h[0];
}
if(w_r > m_r) {
o_x = (int)(w[0] / w_r * m_r) - w[0];
}
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(-o_x/2, -o_y/2, w[0] + o_x, h[0] + o_y);
maze_shader.use();
Main.maze.bind();
glDrawArrays(GL_TRIANGLES, 0, Main.maze.s / 5);
entity_shader.use();
for(Entity entity : Entities.entities) {
entity.render();
}
glfwSwapBuffers(window);
glfwPollEvents();
FpsCounter.fps += 1;
}
}

View File

@ -0,0 +1,25 @@
package maze_game.graphics;
import mainloop.task.IMainloopTask;
import maze_game.Main;
public class GraphicsHandler implements IMainloopTask
{
public static int mspf = 1000 / 60;
@Override
public boolean MainLoopDelay(long millis) {
return millis > mspf;
}
@Override
public boolean MainLoopRepeat() {
return true;
}
@Override
public void MainLoopUpdate() {
Main.window.render();
}
}

View File

@ -0,0 +1,34 @@
package maze_game.graphics;
import org.lwjgl.opengl.GL33;
import maze_game.helpers.ResourceLoader;
public class GraphicsShader
{
public int program;
public GraphicsShader(String id) {
program = ResourceLoader.loadShader(id);
}
public void use() {
GL33.glUseProgram(program);
}
public void setInt(int v) {
GL33.glUniform1i(program, v);
}
public void setFloat(float v) {
GL33.glUniform1f(program, v);
}
public void setIntv(int[] v) {
GL33.glUniform1iv(program, v);
}
public void setFloatv(float[] v) {
GL33.glUniform1fv(program, v);
}
}

View File

@ -0,0 +1,112 @@
package maze_game.helpers;
import maze_game.helpers.vec.Vec2d;
import maze_game.helpers.vec.Vec3d;
public class MathHelpers
{
public static final double FallSpeed = 0.00098;
public static double squared(double x) {
return x*x;
}
public static double pow(int c, double x)
{
double res = 1;
for(int i=0;i<c;i++) {
res *= x;
}
return res;
}
public static double distance3d(double x1, double y1, double z1, double x2, double y2, double z2) {
return Math.sqrt( squared(x2 - x1) + squared(y2 - y1) + squared(z2 - z1) );
}
public static double distance2d(double x1, double y1, double x2, double y2) {
return Math.sqrt( squared(x2 - x1) + squared(y2 - y1) );
}
public static double map(double x, double in_min, double in_max, double out_min, double out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
public static Vec2d moveTowards2(double amount, double angle) {
return new Vec2d(Math.sin(angle) * amount, Math.cos(angle) * amount);
}
public static Vec3d moveTowards3(double amount, Vec2d angles)
{
// Create some varibles
Vec3d points = new Vec3d(0, 0, 0);
double m;
points.z = Math.sin(angles.y) * amount;
m = Math.cos(angles.y);
points.x = Math.sin(angles.x) * m * amount;
m = Math.cos(angles.x) * m;
points.y = m * amount;
return points;
}
public static double mod(double a, double b) {
return (((a % b) + b) % b);
}
public static int mod(int a, int b) {
return (((a % b) + b) % b);
}
public static int floor(double a)
{
if((int)a == a) {
return (int) a;
}
else if(a < 0) {
return (int)(a - 1);
}
else {
return (int)a;
}
}
public static double positive(double a) {
if(a < 0) return -a;
else return a;
}
public static int positive(int a) {
if(a < 0) return -a;
else return a;
}
public static Vec2d rotate2(Vec2d pos, double angle)
{
// Calculate 2 sin and cos values
double s = Math.sin(angle);
double c = Math.cos(angle);
// Return and calculate the new positions
return new Vec2d(
pos.x * c - pos.y * s,
pos.x * s + pos.y * c);
}
public static double biggest(double a, double b)
{
if(a > b) return a;
else return b;
}
public static double smallest(double a, double b)
{
if(a < b) return a;
else return b;
}
}

View File

@ -0,0 +1,86 @@
package maze_game.helpers;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.lwjgl.PointerBuffer;
import org.lwjgl.glfw.GLFW;
import static org.lwjgl.opengl.GL33.*;
public class ResourceLoader
{
public static byte[] loadResource(String name)
{
try
{
InputStream in = ResourceLoader.class.getResourceAsStream(name);
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte buffer[] = new byte[1024];
int size = 0;
while((size = in.read(buffer)) != -1) {
out.write(buffer, 0, size);
}
return out.toByteArray();
}
catch(IOException e) {
e.printStackTrace();
return new byte[0];
}
}
public static int loadShader(String name)
{
int vsh = glCreateShader(GL_VERTEX_SHADER);
int fsh = glCreateShader(GL_FRAGMENT_SHADER);
byte[] vsh_source = loadResource("/resources/shader/" + name + ".vsh");
byte[] fsh_source = loadResource("/resources/shader/" + name + ".fsh");
StringBuilder vsh_sb = new StringBuilder(new String(vsh_source));
StringBuilder fsh_sb = new StringBuilder(new String(fsh_source));
glShaderSource(vsh, vsh_sb);
glShaderSource(fsh, fsh_sb);
glCompileShader(vsh);
glCompileShader(fsh);
int vsh_success[] = new int[1];
int fsh_success[] = new int[1];
glGetShaderiv(vsh, GL_COMPILE_STATUS, vsh_success);
glGetShaderiv(fsh, GL_COMPILE_STATUS, fsh_success);
if(vsh_success[0] == 0) {
System.err.println("ERROR:SHADER:VERTEX:" + name + ":" + glGetShaderInfoLog(vsh));
System.exit(1);
}
if(fsh_success[0] == 0) {
System.err.println("ERROR:SHADER:FRAGMENT:" + name + ":" + glGetShaderInfoLog(fsh));
System.exit(1);
}
int program = glCreateProgram();
glAttachShader(program, vsh);
glAttachShader(program, fsh);
glLinkProgram(program);
int success[] = {0};
glGetProgramiv(program, GL_LINK_STATUS, success);
if(success[0] == 0) {
System.err.println("ERROR:PROGRAM:LINKING:" + name + ":" + glGetProgramInfoLog(program));
System.exit(1);
}
glDeleteShader(vsh);
glDeleteShader(fsh);
return program;
}
}

View File

@ -0,0 +1,17 @@
package maze_game.helpers.range;
public class Range2i
{
public int mx;
public int my;
public Range2i(int mx, int my)
{
this.mx = mx;
this.my = my;
}
public int maxValue() {
return mx * my;
}
}

View File

@ -0,0 +1,19 @@
package maze_game.helpers.range;
public class Range3i
{
public int mx;
public int my;
public int mz;
public Range3i(int mx, int my, int mz)
{
this.mx = mx;
this.my = my;
this.mz = mz;
}
public int maxValue() {
return mx * my * mz;
}
}

View File

@ -0,0 +1,21 @@
package maze_game.helpers.range;
public class Range4i
{
public int mx;
public int my;
public int mz;
public int mm;
public Range4i(int mx, int my, int mz, int mm)
{
this.mx = mx;
this.my = my;
this.mz = mz;
this.mm = mm;
}
public int maxValue() {
return mx * my * mz * mm;
}
}

View File

@ -0,0 +1,74 @@
package maze_game.helpers.vec;
import maze_game.helpers.MathHelpers;
public class Vec2d
{
public double x;
public double y;
public Vec2d(double x, double y)
{
this.x = x;
this.y = y;
}
public double distance(Vec2d other) {
return MathHelpers.distance2d(x, y, other.x, other.y);
}
public static double distance(Vec2d v1, Vec2d v2) {
return v1.distance(v2);
}
public boolean equal(Vec2d other) {
return x == other.x && y == other.y;
}
public Vec2d add(Vec2d other) {
return new Vec2d(this.x + other.x, this.y + other.y);
}
public Vec2d subtract(Vec2d other) {
return new Vec2d(this.x - other.x, this.y - other.y);
}
public Vec2d multiply(Vec2d other) {
return new Vec2d(this.x * other.x, this.y * other.y);
}
public Vec2d divide(Vec2d other) {
return new Vec2d(this.x / other.x, this.y / other.y);
}
public Vec2d add(double v) {
return new Vec2d(this.x + v, this.y + v);
}
public Vec2d subtract(double v) {
return new Vec2d(this.x - v, this.y - v);
}
public Vec2d multiply(double v) {
return new Vec2d(this.x * v, this.y * v);
}
public Vec2d divide(double v) {
return new Vec2d(this.x / v, this.y / v);
}
public Vec2d copy() {
return new Vec2d(x, y);
}
public double squareDistance(Vec2d other)
{
double dx = MathHelpers.positive(other.x - x);
double dy = MathHelpers.positive(other.y - y);
return MathHelpers.biggest(dx, dy);
}
public Vec2i toInt() {
return new Vec2i(MathHelpers.floor(x), MathHelpers.floor(y));
}
}

View File

@ -0,0 +1,100 @@
package maze_game.helpers.vec;
import maze_game.helpers.MathHelpers;
import maze_game.helpers.range.Range2i;
public class Vec2i
{
public int x;
public int y;
public Vec2i(int x, int y)
{
this.x = x;
this.y = y;
}
public double distance(Vec2i other) {
return MathHelpers.distance2d(x, y, other.x, other.y);
}
public static double distance(Vec2i v1, Vec2i v2) {
return v1.distance(v2);
}
public int getId(Range2i range)
{
int x = MathHelpers.mod(this.x, range.mx);
int y = MathHelpers.mod(this.y, range.my);
int id = 0;
int m = 1;
id += x;
m = range.mx;
id += y*m;
return id;
}
public static Vec2i fromId(Range2i range, int id)
{
int x = MathHelpers.mod(id, range.mx);
id -= x;
id /= range.mx;
int y = MathHelpers.mod(id, range.my);
return new Vec2i(x, y);
}
public boolean equal(Vec2i other) {
return x == other.x && y == other.y;
}
public Vec2i add(Vec2i other) {
return new Vec2i(this.x + other.x, this.y + other.y);
}
public Vec2i subtract(Vec2i other) {
return new Vec2i(this.x - other.x, this.y - other.y);
}
public Vec2i multiply(Vec2i other) {
return new Vec2i(this.x * other.x, this.y * other.y);
}
public Vec2i divide(Vec2i other) {
return new Vec2i(this.x / other.x, this.y / other.y);
}
public Vec2i add(int v) {
return new Vec2i(this.x + v, this.y + v);
}
public Vec2i subtract(int v) {
return new Vec2i(this.x - v, this.y - v);
}
public Vec2i multiply(int v) {
return new Vec2i(this.x * v, this.y * v);
}
public Vec2i divide(int v) {
return new Vec2i(this.x / v, this.y / v);
}
public Vec2i copy() {
return new Vec2i(x, y);
}
public double squareDistance(Vec2i other)
{
int dx = MathHelpers.positive(other.x - x);
int dy = MathHelpers.positive(other.y - y);
return MathHelpers.biggest(dx, dy);
}
public Vec2d toDouble() {
return new Vec2d(x, y);
}
}

View File

@ -0,0 +1,80 @@
package maze_game.helpers.vec;
import maze_game.helpers.MathHelpers;
public class Vec3d
{
public double x;
public double y;
public double z;
public Vec3d(double x, double y, double z)
{
this.x = x;
this.y = y;
this.z = z;
}
public double distance(Vec3d other) {
return MathHelpers.distance3d(x, y, z, other.x, other.y, other.z);
}
public static double distance(Vec3d v1, Vec3d v2) {
return v1.distance(v2);
}
public boolean equal(Vec3d other) {
return x == other.x && y == other.y && z == other.z;
}
public Vec3d add(Vec3d other) {
return new Vec3d(this.x + other.x, this.y + other.y, this.z + other.z);
}
public Vec3d subtract(Vec3d other) {
return new Vec3d(this.x - other.x, this.y - other.y, this.z - other.z);
}
public Vec3d multiply(Vec3d other) {
return new Vec3d(this.x * other.x, this.y * other.y, this.z * other.z);
}
public Vec3d divide(Vec3d other) {
return new Vec3d(this.x / other.x, this.y / other.y, this.z / other.z);
}
public Vec3d add(double v) {
return new Vec3d(this.x + v, this.y + v, this.z + v);
}
public Vec3d subtract(double v) {
return new Vec3d(this.x - v, this.y - v, this.z - v);
}
public Vec3d multiply(double v) {
return new Vec3d(this.x * v, this.y * v, this.z * v);
}
public Vec3d divide(double v) {
return new Vec3d(this.x / v, this.y / v, this.z / v);
}
public Vec3d copy() {
return new Vec3d(x, y, z);
}
public double squareDistance(Vec3d other)
{
double dx = MathHelpers.positive(other.x - x);
double dy = MathHelpers.positive(other.y - y);
double dz = MathHelpers.positive(other.z - z);
if(dx > dy) return dx;
if(dy > dz) return dy;
else return dz;
}
public Vec3i toInt() {
return new Vec3i(MathHelpers.floor(x), MathHelpers.floor(y), MathHelpers.floor(z));
}
}

View File

@ -0,0 +1,112 @@
package maze_game.helpers.vec;
import maze_game.helpers.MathHelpers;
import maze_game.helpers.range.Range3i;
public class Vec3i
{
public int x;
public int y;
public int z;
public Vec3i(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
public double distance(Vec3i other) {
return MathHelpers.distance3d(x, y, z, other.x, other.y, other.z);
}
public static double distance(Vec3i v1, Vec3i v2) {
return v1.distance(v2);
}
public int getId(Range3i range)
{
int x = MathHelpers.mod(this.x, range.mx);
int y = MathHelpers.mod(this.y, range.my);
int z = MathHelpers.mod(this.z, range.mz);
int id = 0;
int m = 1;
id += x;
m = range.mx;
id += y*m;
m *= range.my;
id += z*m;
return id;
}
public static Vec3i fromId(Range3i range, int id)
{
int x = MathHelpers.mod(id, range.mx);
id -= x;
id /= range.mx;
int y = MathHelpers.mod(id, range.my);
id -= y;
id /= range.my;
int z = MathHelpers.mod(id, range.mz);
return new Vec3i(x, y, z);
}
public boolean equal(Vec3i other) {
return x == other.x && y == other.y && z == other.z;
}
public Vec3i add(Vec3i other) {
return new Vec3i(this.x + other.x, this.y + other.y, this.z + other.z);
}
public Vec3i subtract(Vec3i other) {
return new Vec3i(this.x - other.x, this.y - other.y, this.z - other.z);
}
public Vec3i multiply(Vec3i other) {
return new Vec3i(this.x * other.x, this.y * other.y, this.z * other.z);
}
public Vec3i divide(Vec3i other) {
return new Vec3i(this.x / other.x, this.y / other.y, this.z / other.z);
}
public Vec3i add(int v) {
return new Vec3i(this.x + v, this.y + v, this.z + v);
}
public Vec3i subtract(int v) {
return new Vec3i(this.x - v, this.y - v, this.z - v);
}
public Vec3i multiply(int v) {
return new Vec3i(this.x * v, this.y * v, this.z * v);
}
public Vec3i divide(int v) {
return new Vec3i(this.x / v, this.y / v, this.z / v);
}
public Vec3i copy() {
return new Vec3i(x, y, z);
}
public int squareDistance(Vec3i other)
{
int dx = MathHelpers.positive(other.x - x);
int dy = MathHelpers.positive(other.y - y);
int dz = MathHelpers.positive(other.z - z);
if(dx > dy) return dx;
if(dy > dz) return dy;
else return dz;
}
public Vec3d toDouble() {
return new Vec3d(x, y, z);
}
}

View File

@ -0,0 +1,88 @@
package maze_game.helpers.vec;
import maze_game.helpers.MathHelpers;
public class Vec4d
{
public double x;
public double y;
public double z;
public double m;
public Vec4d(double x, double y, double z, double m)
{
this.x = x;
this.y = y;
this.z = z;
this.m = m;
}
public double distance(Vec4d other) {
return Math.sqrt(
MathHelpers.squared(this.x - other.x) +
MathHelpers.squared(this.y - other.y) +
MathHelpers.squared(this.z - other.z) +
MathHelpers.squared(this.m - other.m));
}
public static double distance(Vec4d v1, Vec4d v2) {
return v1.distance(v2);
}
public boolean equal(Vec4d other) {
return x == other.x && y == other.y && z == other.z && m == other.m;
}
public Vec4d add(Vec4d other) {
return new Vec4d(this.x + other.x, this.y + other.y, this.z + other.z, this.m + other.m);
}
public Vec4d subtract(Vec4d other) {
return new Vec4d(this.x - other.x, this.y - other.y, this.z - other.z, this.m - other.m);
}
public Vec4d multiply(Vec4d other) {
return new Vec4d(this.x * other.x, this.y * other.y, this.z * other.z, this.m * other.m);
}
public Vec4d divide(Vec4d other) {
return new Vec4d(this.x / other.x, this.y / other.y, this.z / other.z, this.m / other.m);
}
public Vec4d add(double v) {
return new Vec4d(this.x + v, this.y + v, this.z + v, this.m + v);
}
public Vec4d subtract(double v) {
return new Vec4d(this.x - v, this.y - v, this.z - v, this.m - v);
}
public Vec4d multiply(double v) {
return new Vec4d(this.x * v, this.y * v, this.z * v, this.m * v);
}
public Vec4d divide(double v) {
return new Vec4d(this.x / v, this.y / v, this.z / v, this.m / v);
}
public Vec4d copy() {
return new Vec4d(x, y, z, m);
}
public double squareDistance(Vec4d other)
{
double dx = MathHelpers.positive(other.x - x);
double dy = MathHelpers.positive(other.y - y);
double dz = MathHelpers.positive(other.z - z);
double dm = MathHelpers.positive(other.m - m);
if(dx > dy) return dx;
if(dy > dz) return dy;
if(dz > dm) return dz;
else return dm;
}
public Vec4i toInt() {
return new Vec4i(MathHelpers.floor(x), MathHelpers.floor(y), MathHelpers.floor(z), MathHelpers.floor(m));
}
}

View File

@ -0,0 +1,125 @@
package maze_game.helpers.vec;
import maze_game.helpers.MathHelpers;
import maze_game.helpers.range.Range4i;
public class Vec4i {
public int x;
public int y;
public int z;
public int m;
public Vec4i(int x, int y, int z, int m)
{
this.x = x;
this.y = y;
this.z = z;
this.m = m;
}
public double distance(Vec4i other) {
return Math.sqrt(
MathHelpers.squared(this.x - other.x) +
MathHelpers.squared(this.y - other.y) +
MathHelpers.squared(this.z - other.z) +
MathHelpers.squared(this.m - other.m));
}
public static double distance(Vec4i v1, Vec4i v2) {
return v1.distance(v2);
}
public int getId(Range4i range)
{
int x = MathHelpers.mod(this.x, range.mx);
int y = MathHelpers.mod(this.y, range.my);
int z = MathHelpers.mod(this.z, range.mz);
int m = MathHelpers.mod(this.m, range.mm);
int id = 0;
int mu = 1;
id += x;
mu = range.mx;
id += y*mu;
mu *= range.my;
id += z*mu;
mu *= range.mz;
id += m*mu;
return id;
}
public static Vec4i fromId(Range4i range, int id)
{
int x = MathHelpers.mod(id, range.mx);
id -= x;
id /= range.mx;
int y = MathHelpers.mod(id, range.my);
id -= y;
id /= range.my;
int z = MathHelpers.mod(id, range.mz);
id -= z;
id /= range.mz;
int m = MathHelpers.mod(id, range.mm);
return new Vec4i(x, y, z, m);
}
public boolean equal(Vec4i other) {
return x == other.x && y == other.y && z == other.z;
}
public Vec4i add(Vec4i other) {
return new Vec4i(this.x + other.x, this.y + other.y, this.z + other.z, this.m + other.m);
}
public Vec4i subtract(Vec4i other) {
return new Vec4i(this.x - other.x, this.y - other.y, this.z - other.z, this.m - other.m);
}
public Vec4i multiply(Vec4i other) {
return new Vec4i(this.x * other.x, this.y * other.y, this.z * other.z, this.m * other.m);
}
public Vec4i divide(Vec4i other) {
return new Vec4i(this.x / other.x, this.y / other.y, this.z / other.z, this.m / other.m);
}
public Vec4i add(int v) {
return new Vec4i(this.x + v, this.y + v, this.z + v, this.m + v);
}
public Vec4i subtract(int v) {
return new Vec4i(this.x - v, this.y - v, this.z - v, this.m - v);
}
public Vec4i multiply(int v) {
return new Vec4i(this.x * v, this.y * v, this.z * v, this.m * v);
}
public Vec4i divide(int v) {
return new Vec4i(this.x / v, this.y / v, this.z / v, this.m / v);
}
public Vec4i copy() {
return new Vec4i(x, y, z, m);
}
public int squareDistance(Vec4i other)
{
int dx = MathHelpers.positive(other.x - x);
int dy = MathHelpers.positive(other.y - y);
int dz = MathHelpers.positive(other.z - z);
int dm = MathHelpers.positive(other.m - m);
if(dx > dy) return dx;
if(dy > dz) return dy;
if(dz > dm) return dz;
else return dm;
}
public Vec4d toDouble() {
return new Vec4d(x, y, z, m);
}
}

View File

@ -0,0 +1,12 @@
package maze_game.init;
import java.util.ArrayList;
import maze_game.Main;
import maze_game.entity.Entity;
import maze_game.helpers.vec.Vec3d;
public class Entities
{
public static ArrayList<Entity> entities = new ArrayList<Entity>();
}

View File

@ -0,0 +1,20 @@
package maze_game.init;
import maze_game.maze.Maze;
import maze_game.maze.MazeDrawer;
public class Mazes
{
public static final Maze[] MAZE = {
MazeDrawer.loadMazeF("maze0"),
MazeDrawer.loadMazeF("maze1"),
MazeDrawer.loadMazeF("maze2"),
MazeDrawer.loadMazeF("maze3"),
MazeDrawer.loadMazeF("maze4"),
MazeDrawer.loadMazeF("maze5"),
MazeDrawer.loadMazeF("maze6"),
MazeDrawer.loadMazeF("maze7"),
MazeDrawer.loadMazeF("maze8"),
MazeDrawer.loadMazeF("maze9"),
};
}

View File

@ -0,0 +1,9 @@
package maze_game.init;
import maze_game.models.Model;
import maze_game.models.ModelPlayer;
public class Models
{
public static final Model MODEL_PLAYER = new ModelPlayer();
}

View File

@ -0,0 +1,78 @@
package maze_game.input;
import org.lwjgl.glfw.GLFWKeyCallbackI;
import static org.lwjgl.glfw.GLFW.*;
import mainloop.task.IMainloopTask;
import maze_game.Main;
import maze_game.helpers.MathHelpers;
import maze_game.helpers.vec.Vec2d;
public class InputKeyboard implements GLFWKeyCallbackI, IMainloopTask
{
public static final InputKeyboard INPUT_KEYBOARD = new InputKeyboard();
boolean key_w = false;
boolean key_a = false;
boolean key_s = false;
boolean key_d = false;
@Override
public boolean MainLoopDelay(long millis) {
return millis > 1;
}
@Override
public boolean MainLoopRepeat() {
return true;
}
@Override
public void MainLoopUpdate()
{
Vec2d direction = new Vec2d(0, 0);
if(key_w) {
direction.y += 1;
}
if(key_a) {
direction.x -= 1;
}
if(key_s) {
direction.y -= 1;
}
if(key_d) {
direction.x += 1;
}
if(direction.x != 0 || direction.y != 0) {
double angle = Math.atan2(direction.x, direction.y);
Main.player.move(MathHelpers.moveTowards2(0.01, angle));
}
}
public void invoke(long window, int key, int scancode, int action, int mods)
{
boolean pressed = ! ( action == GLFW_RELEASE );
if(key == GLFW_KEY_W) {
key_w = pressed;
}
if(key == GLFW_KEY_A) {
key_a = pressed;
}
if(key == GLFW_KEY_S) {
key_s = pressed;
}
if(key == GLFW_KEY_D) {
key_d = pressed;
}
}
}

View File

@ -0,0 +1,25 @@
package maze_game.mainloop;
import mainloop.task.IMainloopTask;
import maze_game.graphics.GraphicsHandler;
public class FpsCounter implements IMainloopTask
{
public static int fps = 0;
@Override
public boolean MainLoopDelay(long millis) {
return millis > 1000;
}
@Override
public boolean MainLoopRepeat() {
return true;
}
@Override
public void MainLoopUpdate() {
System.out.println("FPS: " + fps + ", " + 1000 / GraphicsHandler.mspf);
fps = 0;
}
}

View File

@ -0,0 +1,70 @@
package maze_game.mainloop;
import org.lwjgl.glfw.GLFW;
import mainloop.event.IMainloopEvent;
import mainloop.manager.MainloopManager;
import mainloop.task.IMainloopTask;
import maze_game.Main;
import maze_game.graphics.GraphicsHandler;
import maze_game.input.InputKeyboard;
public class MainloopHandler implements IMainloopTask, IMainloopEvent
{
public MainloopManager mainloop;
public MainloopHandler()
{
mainloop = new MainloopManager(this);
mainloop.register(this);
mainloop.register(new GraphicsHandler());
mainloop.register(new FpsCounter());
mainloop.register(InputKeyboard.INPUT_KEYBOARD);
}
@Override
public void onClose() {
System.out.println("Mainloop closed");
}
@Override
public void onEarly() {
GraphicsHandler.mspf -= 1;
if(GraphicsHandler.mspf < 1) {
GraphicsHandler.mspf = 1;
}
}
@Override
public void onLate() {
GraphicsHandler.mspf += 1;
if(GraphicsHandler.mspf > 1000) {
GraphicsHandler.mspf = 1000;
}
}
@Override
public void onStart() {
}
@Override
public boolean MainLoopDelay(long millis) {
return millis > 10;
}
@Override
public boolean MainLoopRepeat() {
return true;
}
@Override
public void MainLoopUpdate() {
GLFW.glfwPollEvents();
if(GLFW.glfwWindowShouldClose(Main.window.window)) {
mainloop.stop();
}
}
}

View File

@ -0,0 +1,82 @@
package maze_game.maze;
import static org.lwjgl.opengl.GL11.GL_FLOAT;
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
import org.lwjgl.opengl.GL33;
import maze_game.helpers.MathHelpers;
import maze_game.helpers.vec.Vec2d;
import maze_game.helpers.vec.Vec2i;
public class Maze
{
public int width;
public int height;
public int[] maze;
public Vec2d player_pos;
private int vao = -1;
public int s;
public void bind() {
if(vao == -1) {
this.init();
}
GL33.glBindVertexArray(vao);
}
public void init()
{
float[] verticies = MazeDrawer.drawMazeVerticies(maze, width, height);
int vao = GL33.glGenVertexArrays();
int vbo = GL33.glGenBuffers();
GL33.glBindVertexArray(vao);
GL33.glBindBuffer(GL33.GL_ARRAY_BUFFER, vbo);
GL33.glBufferData(GL33.GL_ARRAY_BUFFER, verticies, GL33.GL_STATIC_DRAW);
glVertexAttribPointer(0, 2, GL_FLOAT, false, Float.BYTES * 5, 0);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 3, GL_FLOAT, false, Float.BYTES * 5, 2 * Float.BYTES);
glEnableVertexAttribArray(1);
this.vao = vao;
this.s = verticies.length;
}
public boolean collision(Vec2d pos, int tile) {
return this.collision(pos.x, pos.y, tile);
}
public boolean collision(double px, double py, int tile)
{
double c = 0.01;
int x1 = MathHelpers.floor(px + c) + 0;
int y1 = MathHelpers.floor(py + c) + 0;
int x2 = MathHelpers.floor(px - c) + 1;
int y2 = MathHelpers.floor(py - c) + 1;
if(
x1 < 0 || y1 < 0 || x1 >= width || y1 >= height ||
x2 < 0 || y2 < 0 || x2 >= width || y2 >= height
) {
return false;
}
if(
maze[y1 * width + x1] == tile ||
maze[y2 * width + x1] == tile ||
maze[y2 * width + x2] == tile ||
maze[y1 * width + x2] == tile
) {
return true;
}
return false;
}
}

View File

@ -0,0 +1,203 @@
package maze_game.maze;
import static org.lwjgl.opengl.GL11.GL_FLOAT;
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
import org.lwjgl.opengl.GL33;
import maze_game.helpers.ResourceLoader;
import maze_game.helpers.vec.Vec2d;
public class MazeDrawer
{
public static Maze loadMazeF(String filename) {
return loadMaze(new String(ResourceLoader.loadResource("/resources/maze/" + filename + ".txt")));
}
public static Maze loadMaze(String data)
{
String[] rows = data.split("\n");
int width = 0;
int height = 0;
for(String row : rows)
{
int l = row.length();
if(l == 0) {
continue;
}
if(l > width) {
width = l;
}
height += 1;
}
Vec2d player_pos = null;
int maze[] = new int[width * height];
int it = 0;
for(int r=rows.length-1;r>=0;r-=1)
{
String row = rows[r];
for(int i=0;i<row.length();i++)
{
char c = row.charAt(i);
switch(c)
{
case ' ': {
maze[it] = 0;
break;
}
case '@': {
maze[it] = 3;
break;
}
case '&': {
maze[it] = 2;
break;
}
case '#': {
maze[it] = 1;
break;
}
case '!': {
maze[it] = 0;
player_pos = new Vec2d(i, rows.length - r - 1);
}
default: {
maze[it] = 0;
break;
}
}
for(char n : "1234567890".toCharArray()) {
if(c == n) {
char ca[] = {c};
maze[it] = Integer.parseInt(new String(ca)) + 4;
}
}
it += 1;
}
}
Maze maze2 = new Maze();
maze2.maze = maze;
maze2.player_pos = player_pos;
maze2.width = width;
maze2.height = height;
return maze2;
}
public static float[] getMazeColor(int m)
{
float color[] = {0, 0, 0};
// Wall
if(m == 1) {
color[0] = 0.4f;
color[1] = 0.39f;
color[2] = 0.4f;
}
// Goal
if(m > 3 && m < 14) {
color[0] = 0.61f;
color[1] = 0.64f;
color[2] = 0.3f;
}
// Teleport
if(m == 3) {
color[0] = 0.2f;
color[1] = 0.39f;
color[2] = 0.17f;
}
// Lava
if(m == 2) {
color[0] = 0.82f;
color[1] = 0.23f;
color[2] = 0.1f;
}
return color;
}
public static float[] drawMazePositions(Maze maze) {
return drawMazePositions(maze.maze, maze.width, maze.height);
}
public static float[] drawMazeVerticies(Maze maze) {
return drawMazeVerticies(maze.maze, maze.width, maze.height);
}
public static float[] drawMazePositions(int[] maze, int width, int height)
{
float[] colors = new float[maze.length * 3];
for(int x=0;x<width;x++) {
for(int y=0;y<height;y++)
{
int p = y * width + x;
float[] c = getMazeColor(maze[p]);
float[] color = {
c[0], c[1], c[2],
};
for(int i=0;i<color.length;i++) {
colors[i + p * 3] = color[i];
}
}
}
return colors;
}
public static float[] drawMazeVerticies(int[] maze, int width, int height)
{
float verticies[] = new float[maze.length * 30];
float w = (float)width;
float h = (float)height;
for(int x=0;x<width;x++) {
for(int y=0;y<height;y++)
{
int p = y * width + x;
float[] c = getMazeColor(maze[p]);
float v[] = {
(x+0)/w, (y+0)/h, c[0], c[1], c[2],
(x+1)/w, (y+0)/h, c[0], c[1], c[2],
(x+1)/w, (y+1)/h, c[0], c[1], c[2],
(x+0)/w, (y+0)/h, c[0], c[1], c[2],
(x+0)/w, (y+1)/h, c[0], c[1], c[2],
(x+1)/w, (y+1)/h, c[0], c[1], c[2],
};
for(int i=0;i<v.length;i++) {
verticies[i + p * 30] = v[i];
}
}
}
return verticies;
}
}

View File

@ -0,0 +1,40 @@
package maze_game.models;
import org.lwjgl.opengl.GL33;
public class Model
{
public int s;
int vao;
int vbo;
public Model()
{
float[] verticies = getVerticies();
s = verticies.length / 5;
vao = GL33.glGenVertexArrays();
vbo = GL33.glGenBuffers();
GL33.glBindVertexArray(vao);
GL33.glBindBuffer(GL33.GL_ARRAY_BUFFER, vbo);
GL33.glBufferData(GL33.GL_ARRAY_BUFFER, verticies, GL33.GL_STATIC_DRAW);
GL33.glVertexAttribPointer(0, 2, GL33.GL_FLOAT, false, Float.BYTES * 5, 0);
GL33.glEnableVertexAttribArray(0);
GL33.glVertexAttribPointer(1, 3, GL33.GL_FLOAT, false, Float.BYTES * 5, 2 * Float.BYTES);
GL33.glEnableVertexAttribArray(1);
}
protected float[] getVerticies() {
return null;
}
public void bind() {
GL33.glBindVertexArray(vao);
}
}

View File

@ -0,0 +1,20 @@
package maze_game.models;
public class ModelPlayer extends Model
{
@Override
protected float[] getVerticies()
{
float[] v = {
0, 0, 0.2f, 0.3f, 0.5f,
1, 0, 0.2f, 0.3f, 0.5f,
1, 1, 0.2f, 0.3f, 0.5f,
0, 0, 0.2f, 0.3f, 0.5f,
0, 1, 0.2f, 0.3f, 0.5f,
1, 1, 0.2f, 0.3f, 0.5f,
};
return v;
}
}

View File

@ -0,0 +1,32 @@
################################
# #
# #
# #
# #
# #
# #
# #
# #
# &&&&& &&& &&& &&& #
# & & & & & & & #
# & & & &&& & && #
# & & & & & & & #
# & & & & & &&& &&& #
# #
# #
# &&& &&& &&&&& &&& #
# & & & & & & & #
# & & &&& & & & && #
# & & & & & & & & #
# &&& & & & & & &&& #
# #
# #
# #
# #
# #
# #
# #
# #
# #
#! 1#
################################

View File

@ -0,0 +1,32 @@
################
#&&&& &#
#&&&& #
###### ##### #
###### ##### &#
## @ # &&#
########## #& ### ### # &&#
# # #& # @ # # #
# ###### # #& # #3# # # #
# # # #& # # # # #&& #
###### # # #& # #2# # #&& #
# # # # #& # # # # #&& #
# # # # # #& # # # # #
#&&# # # # #& ##### # # #
#&&# #4#3# #& # # &&#
#### ###### ## #### # &&#
# # #########&& # #
# #### # # #&& ##
# # ##### ##### #########
# &&# #### @ @ #
# &&# # &# ##### #### ####
# # # @ && #
# # #5###### ############# #
#&& # ### @ # # #
#&& # # #### ### # # # # & #
# # ##### @ # # # # & #
# # ## ### # # #
## ########## 2##############
# & & ###### #
# #
# #&&&&&&# #&&&&&&# #
################################

View File

@ -0,0 +1,32 @@
#######
# #
# ### #
# # # #
# # #1#
# # ###
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
### #
#1 #
#####

View File

@ -0,0 +1,32 @@
#######
# #
# ### #
# # # #
# # #1#
# # # #
######### ### #
# @ #
# ###### ### #
### # # #&& #
#1# # # # #
# # # # #####
# # # # #
# # # #
###### # #
# #
# #
# #
# #
# #
### #
#1 #
#####

View File

@ -0,0 +1,32 @@
################################
################################
################ #######
########## #####
######### ####
###### ####
#### ####
#### ###
### ###
## ###
## ###
## ###
# ### ####### ####### ###
# #1#&# #&# # ###
# ### ### ### ### ### ##### ##
# @ @ @ @ @ # ##
# ### &&& &&& &&& &&& &&& # ##
# # &&& &&& &&& &&& &&& # ##
# ### &&& &&& &&& &&& &&& # #
# # @ @ @ @ @ # #
# # # &&& &&& &&& &&& ##### #
# # # &&& &&& &&& &&& # #
# # # &&& &&& &&& &&& ##### #
# # @ @ @ @ @ # #
# ### &&& ### &&& ### &&& # #
# # &&& # # &&& # # &&& # #
# # &&& # # &&& # # &&& # #
#&&&&# #&# #&# #&55#
#&&&&#######&#######&#######&&&#
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#
################################

View File

@ -0,0 +1,32 @@
################################
#### ###########################
### ###########################
##&&&&##########################
##&&&&##########################
##&&&&&#########################
###&&###########################
######### ###################
#### ########
## ########## ####
## #&&&&&####### ######### ##
## ###&######### ######### #
## ############## ########## #
## ############### ######### #
## ############### ####### #
### ###############&&&&&##### #
#### ##########&&&&##### #
#####&&&## 6######&&###### #
############################# #
#&&### ##### ##
#& # ########## #####
#& ###1# ######&&&&&&######
#& ##### #######&&########
#& #### ##################
#& #&&&&&&&&&###################
#& ##&&&&&&&####################
#& ####&&####################44#
## ####&## ############# #
# ##### # # ########### #
# # ####&### ## #
# ######## ## #
##&&&&&&##########&&&&&&###&&&&#

View File

@ -0,0 +1,35 @@
###################################
# #
# #
# #
# #
# ### # # ### # # # # ### #
# # # # # # ## # ## # #
# # ### ### # # # # ### #
# # # # # # # ## ## # #
# # # # # # # # # # ### #
# #
# ### ### ### #
# # # # # # #
# ## # # ### #
# # # # ## #
# # ### # # #
# #
# ### # ### # # ### # # ### #
# # # # # # # # # ## # # #
# ### # ### ### # # # # # # #
# # # # # # # # ## # # #
# # ### # # # ### # # ### #
# #
# #
# #
# #
# #
# ! #
# #
# #
# #
# #
# #
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#
###################################

View File

View File

View File

View File

@ -0,0 +1,9 @@
#version 330
in vec3 color;
out vec4 FragColor;
void main()
{
FragColor = vec4(color, 0);
}

View File

@ -0,0 +1,16 @@
#version 330
layout (location = 0) in vec2 aPos;
layout (location = 1) in vec3 aColor;
out vec3 color;
uniform vec2 pos;
uniform ivec2 maze;
void main()
{
vec2 cPos = (aPos + pos) / maze;
gl_Position = vec4(cPos * 2 - 1, 0, 1);
color = aColor;
}

View File

@ -0,0 +1,9 @@
#version 330
in vec3 color;
out vec4 FragColor;
void main()
{
FragColor = vec4(color, 0);
}

View File

@ -0,0 +1,12 @@
#version 330
layout (location = 0) in vec2 aPos;
layout (location = 1) in vec3 aColor;
out vec3 color;
void main()
{
gl_Position = vec4(aPos.x * 2 - 1, aPos.y * 2 - 1, 0, 1);
color = aColor;
}