Adjust hud postion to the new scale

This commit is contained in:
s473577 2024-02-03 21:50:55 +01:00
parent 1f09c40bb5
commit 61170baa47
2 changed files with 20 additions and 25 deletions

View File

@ -85,7 +85,7 @@ private:
void shoot(float time) {
Spaceship* spaceship = Spaceship::getInstance();
glm::vec3 bulletDirection = glm::normalize(spaceship->spaceshipPos - glm::vec3(modelMatrix[3]));
//bulletDirection += glm::linearRand(glm::vec3(-0.01f), glm::vec3(0.1f)); // Modyfikacja kierunku o losowy szum
this->bullets.push_back(Bullet::createSimpleBullet(bulletDirection, this->modelMatrix[3], time));
this->lastShootTime = time;
}

View File

@ -98,10 +98,10 @@ void renderHUD() {
glUseProgram(programSpriteBar);
glDisable(GL_DEPTH_TEST);
glm::mat4 spaceshipModelMatrix = spaceship->calculateModelMatrix();
glm::mat4 healthBarPosition = glm::translate(spaceshipModelMatrix, glm::vec3(12.0f, -9.0f, 0.0f));
glm::mat4 healthBarPosition = glm::translate(spaceshipModelMatrix, glm::vec3(36.0f, -34.0f, 0.0f));
spriteRenderer->DrawHUDBar(
glm::vec3(0.0f, 1.0f, 0.0f),
glm::scale(healthBarPosition, glm::vec3(9.0f, 1.1f, 1.0f)),
glm::scale(healthBarPosition, glm::vec3(26.0f, 4.f, 1.0f)),
spaceship->currentHP / spaceship->maxHP,
programSpriteBar);
glEnable(GL_DEPTH_TEST);
@ -198,44 +198,40 @@ void renderScene(GLFWwindow* window)
texture::spaceshipTexture,
spaceship->roughness, spaceship->metallic, programTex
);
<<<<<<< HEAD
<<<<<<< HEAD
//Core::SetActiveTexture(texture::earthTexture, "textureSampler", programTex, 0);
drawObjectPBRTexture(models::sphereContext, glm::translate(glm::vec3(10.f, 0, 0)) * glm::scale(glm::vec3(1.0f)), texture::earthTexture, 0.3, 0.0, programTex);
//glm::translate(pointlightPos) * glm::scale(glm::vec3(1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(10.f, 0, 0)) *
Core::SetActiveTexture(texture::earthTexture, "textureSampler", programTex, 0);
drawObjectPBRTexture(models::sphereContext, glm::translate(pointlightPos) * glm::scale(glm::vec3(1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(10.f, 0, 0)) * glm::scale(glm::vec3(0.3f)), texture::earthTexture, 0.3, 0.0, programTex);
glUseProgram(programSprite);
for (const auto& enemy : enemies) {
if (enemy->isAlive()) {
spriteRenderer->DrawSprite(texture::spriteTexture, enemy->modelMatrix, programSprite);
}
//glUseProgram(programSprite);
//for (const auto& enemy : enemies) {
// if (enemy->isAlive()) {
// spriteRenderer->DrawSprite(texture::spriteTexture, enemy->modelMatrix, programSprite);
// }
}
glUseProgram(program);
for (const auto& enemy : enemies) {
if (enemy->isAlive()) {
enemy->attack(spaceship->spaceshipPos, glfwGetTime());
enemy->renderBullets(glfwGetTime(), program);
}
//}
//glUseProgram(program);
//for (const auto& enemy : enemies) {
// if (enemy->isAlive()) {
// enemy->attack(spaceship->spaceshipPos, glfwGetTime());
// enemy->renderBullets(glfwGetTime(), program, gameEntities);
// }
}
//}
glm::vec3 cameraSide = glm::normalize(glm::cross(spaceship->cameraDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide, spaceship->cameraDir));
glm::mat4 viewMatrix = Core::createViewMatrix(spaceship->cameraPos, spaceship->cameraDir, cameraUp);
spaceship->renderParticles(programParticle, viewMatrix, Core::createPerspectiveMatrix(), time);
=======
=======
renderHUD();
>>>>>>> 9586849 (Add collision detection and taking dmg)
renderEnemies();
//drawObjectPBR(sphereContext, glm::translate(pointlightPos) * glm::scale(glm::vec3(1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(10.f, 0, 0)) * glm::scale(glm::vec3(0.3f)), glm::vec3(0.2, 0.7, 0.3), 0.3, 0.0, program);
>>>>>>> 6ccdec5 (Add drawing health bars for enemies)
glUseProgram(0);
glfwSwapBuffers(window);
@ -319,12 +315,11 @@ void init(GLFWwindow* window)
programTest = gameUtils->shaderLoader->CreateProgram("shaders/test.vert", "shaders/test.frag");
programSun = gameUtils->shaderLoader->CreateProgram("shaders/shader_8_sun.vert", "shaders/shader_8_sun.frag");
programCubemap = gameUtils->shaderLoader->CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
<<<<<<< HEAD
programTex = gameUtils->shaderLoader->CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
=======
programSprite = gameUtils->shaderLoader->CreateProgram("shaders/shader_sprite.vert", "shaders/shader_sprite.frag");
programSpriteBar = gameUtils->shaderLoader->CreateProgram("shaders/shader_sprite_bar.vert", "shaders/shader_sprite_bar.frag");
>>>>>>> 6ccdec5 (Add drawing health bars for enemies)
programSprite = gameUtils->shaderLoader->CreateProgram("shaders/shader_sprite.vert", "shaders/shader_sprite.frag");