GameObjects

Began to add GameObjects, starting with the player.
This commit is contained in:
onTheZero
2025-08-13 00:59:03 -04:00
parent 237272c17b
commit 4bf6b02255
37 changed files with 2640 additions and 222 deletions

View File

@@ -153,6 +153,43 @@ public:
}
}
void render(glm::mat4 view, glm::mat4 projection, glm::vec3 lightPos, float deltaTime, int amountOfCubes)
{
shader.use();
shader.setMat4("projection", projection);
shader.setMat4("view", view);
int i = 0;
for (Cube& cube : cubes)
{
if (i >= amountOfCubes)
{
break;
}
//std::cout << "Cube position: (" << cube.getColor().x << "," << cube.getColor().y << "," << cube.getColor().z << ")" << std::endl;
cube.setRotation(cube.getRotation() + (glm::vec3(5.0f, 10.0f, 20.0f)) * deltaTime);
glm::mat4 model = cube.getModelMatrix();
glm::vec3 color = cube.getColor();
shader.setMat4("model", model);
shader.setVec3("objectColor", color);
shader.setVec3("lightColor", 1.0f, 1.0f, 1.0f);
shader.setVec3("lightPos", lightPos);
glBindVertexArray(VAO);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDrawArrays(GL_TRIANGLES, 0, 36);
//glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0);
//shader.setVec3("objectColor", 0.0f, 0.0f, 0.0f);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
//glDrawArrays(GL_TRIANGLES, 0, 36);
//glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
i++;
}
}
std::list<Cube> getCubes()
{
return cubes;