Skip to content
Snippets Groups Projects
Commit e3075244 authored by iaminadequate's avatar iaminadequate
Browse files

mege for collision fix

parent 3d1b7208
Branches
No related tags found
No related merge requests found
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
class mapObj : public gameObj { class mapObj : public gameObj {
public: public:
GLint id; GLint id;
glm::vec2 pos; glm::vec3 pos;
glm::vec2 size; glm::vec2 size;
bool visible; bool visible;
// Longass constructor. // Longass constructor.
mapObj(){} mapObj(){}
mapObj(int i, glm::vec2 p, glm::vec2 s) :gameObj() { id = 0; pos = p; size = s; visible = true; } mapObj(int i, glm::vec3 p, glm::vec2 s) :gameObj() { id = 0; pos = p; size = s; visible = true; }
mapObj(GLenum primitive_mode, int numVertices, const GLfloat* vertices, const GLfloat* normal, const GLfloat* tex, texture* texProg, shader* shaProg, GLenum fill_mode, int i, glm::vec2 p, glm::vec2 s) : gameObj( primitive_mode, numVertices, vertices, normal, tex, texProg, shaProg, fill_mode) { id = i; pos = p; size = s; visible = true; } mapObj(GLenum primitive_mode, int numVertices, const GLfloat* vertices, const GLfloat* normal, const GLfloat* tex, texture* texProg, shader* shaProg, GLenum fill_mode, int i, glm::vec3 p, glm::vec2 s) : gameObj( primitive_mode, numVertices, vertices, normal, tex, texProg, shaProg, fill_mode) { id = i; pos = p; size = s; visible = true; }
}; };
......
...@@ -42,7 +42,7 @@ vec3 PointLight( ...@@ -42,7 +42,7 @@ vec3 PointLight(
// Attenuation Intensity reduction when traveling through space. // Attenuation Intensity reduction when traveling through space.
float distance = length(position - vec3(model * vert_position)); float distance = length(position - vec3(model * vert_position));
float attenuation = 1.0 / (constant + linear * distance + quadratic * distance * distance + EPSILON); float attenuation = 1 / (constant + linear * distance + quadratic * distance * distance + EPSILON);
return (ambient + diffuse + specular) * attenuation; return (ambient + diffuse + specular) * attenuation;
} }
......
...@@ -25,12 +25,16 @@ void levelLoader::loadLevel(const char* levelFilePath) { ...@@ -25,12 +25,16 @@ void levelLoader::loadLevel(const char* levelFilePath) {
while (lvlFile[i] == ' ' || lvlFile[i] == '\n')i++; while (lvlFile[i] == ' ' || lvlFile[i] == '\n')i++;
float lex = -size.x / 2.f * xsize; float bex = -size.y / 2.f * ysize; float lex = -size.x / 2.f * xsize; float bex = -size.y / 2.f * ysize;
float xAdd = float(k) * size.x + size.x / 2.f; float yAdd = float(j) * size.y + size.y / 2.f; float xAdd = float(k) * size.x + size.x / 2.f; float yAdd = float(j) * size.y + size.y / 2.f;
glm::vec2 pos = glm::vec2(lex + xAdd, bex + yAdd); glm::vec3 pos = glm::vec3(lex + xAdd, 0, bex + yAdd);
glm::vec3 posF = glm::vec3(lex + xAdd, -1, bex + yAdd);
glm::vec3 posC = glm::vec3(lex + xAdd, 1, bex + yAdd);
switch (lvlFile[i]) switch (lvlFile[i])
{ {
case '0': //if the read_entire_file read a 0 here, dont do anything as the path does not need an object case '0': //if the read_entire_file read a 0 here, dont do anything as the path does not need an object
floorObjects.push_back({ GL_TRIANGLES, 36, vertices, normal, uvCoordinates, texProgPellet, shaProg, GL_FILL, 0, pos, size }); //we give these objects the id of 1 floorObjects.push_back({ GL_TRIANGLES, 36, vertices, normal, uvCoordinates, texProgPellet, shaProg, GL_FILL, 0, pos, size }); //we give these objects the id of 1
mapObjects.push_back({ GL_TRIANGLES, 36, vertices, normal, uvCoordinates, texProgBrick, shaProg, GL_FILL, 1, posF, size });
mapObjects.push_back({ GL_TRIANGLES, 36, vertices, normal, uvCoordinates, texProgBrick, shaProg, GL_FILL, 1, posC, size });
break; break;
case '1': //if the read_entire_file read a 1 here, make a new object for a wall case '1': //if the read_entire_file read a 1 here, make a new object for a wall
mapObjects.push_back({ GL_TRIANGLES, 36, vertices, normal, uvCoordinates, texProgBrick, shaProg, GL_FILL, 1, pos, size }); //we give these objects the id of 1 mapObjects.push_back({ GL_TRIANGLES, 36, vertices, normal, uvCoordinates, texProgBrick, shaProg, GL_FILL, 1, pos, size }); //we give these objects the id of 1
......
...@@ -23,7 +23,7 @@ void renderer::loadMap(std::vector<mapObj> mapObjects, pacman pacman){ ...@@ -23,7 +23,7 @@ void renderer::loadMap(std::vector<mapObj> mapObjects, pacman pacman){
* Prepare changes that are to be applied to the UNIFORM shader variables * Prepare changes that are to be applied to the UNIFORM shader variables
*/ */
glm::mat4 proj = glm::perspective(3.14f / 3.0f, (GLfloat)1024 / (GLfloat)768, 0.1f, -10.0f); glm::mat4 proj = glm::perspective(3.14f / 3.0f, (GLfloat)1024 / (GLfloat)768, 0.1f, -10.0f);
glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(iter->pos.x * 18, 0, iter->pos.y * 18)); glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(iter->pos.x * 18, iter->pos.y, iter->pos.z * 18));
//glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(view * model))); // Might get some use out of this one in the future //glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(view * model))); // Might get some use out of this one in the future
/* /*
...@@ -66,7 +66,7 @@ void renderer::updatePellet(std::vector<mapObj> pelletObj, pacman pacman){ ...@@ -66,7 +66,7 @@ void renderer::updatePellet(std::vector<mapObj> pelletObj, pacman pacman){
*/ */
glm::mat4 proj = glm::perspective(3.14f / 3.0f, (GLfloat)1024 / (GLfloat)768, 0.1f, -10.0f); glm::mat4 proj = glm::perspective(3.14f / 3.0f, (GLfloat)1024 / (GLfloat)768, 0.1f, -10.0f);
glm::mat4 modelCanvas = glm::mat4(1.0f); glm::mat4 modelCanvas = glm::mat4(1.0f);
glm::mat4 model = glm::translate(modelCanvas, glm::vec3(iter->pos.x * 18, -0.2f, iter->pos.y * 18)) * glm::scale(modelCanvas, glm::vec3(0.05f, 0.05f, 0.05f)); glm::mat4 model = glm::translate(modelCanvas, glm::vec3(iter->pos.x * 18, -0.2f, iter->pos.z * 18)) * glm::scale(modelCanvas, glm::vec3(0.05f, 0.05f, 0.05f));
//glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(view * model))); // Might get some use out of this one in the future //glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(view * model))); // Might get some use out of this one in the future
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment