Fix hero avatar moving with camera

This commit is contained in:
Doyle Thai 2016-07-16 21:08:30 +10:00
parent 2d9fded235
commit 6da8eff9b1
2 changed files with 15 additions and 7 deletions

View File

@ -578,16 +578,15 @@ void worldTraveller_gameUpdateAndRender(GameState *state, const f32 dt)
V2(10.0f, (renderer->size.h * 0.5f) - (0.5f * heroAvatarSize.h));
RenderTex heroRenderTex = {hero->tex, heroAvatarTexRect};
renderer_rect(renderer, cameraBounds, heroAvatarP, heroAvatarSize, 0,
heroRenderTex, V4(1, 1, 1, 1));
renderer_staticRect(renderer, heroAvatarP, heroAvatarSize, 0, heroRenderTex,
V4(1, 1, 1, 1));
v4 color = V4(0, 0, 1.0f, 1);
char *heroAvatarStr = "HP: 100/100";
f32 strLenInPixels =
CAST(f32)(font->maxSize.w * common_strlen(heroAvatarStr));
v2 strPos = V2(heroAvatarP.x, heroAvatarP.y - (0.5f * heroAvatarSize.h));
renderer_staticString(&state->renderer, font, heroAvatarStr, strPos, 0,
color);
V4(0, 0, 1, 1));
#ifdef DENGINE_DEBUG
/* Render debug info stack */

View File

@ -27,10 +27,18 @@ typedef struct RenderQuad
// TODO(doyle): Clean up lines
// Renderer::~Renderer() { glDeleteVertexArrays(1, &this->quadVAO); }
void renderer_rect(Renderer *const renderer, v4 cameraBounds, v2 pos, v2 size,
f32 rotate, RenderTex renderTex, v4 color);
inline void renderer_staticRect(Renderer *const renderer, v2 pos, v2 size,
f32 rotate, RenderTex renderTex, v4 color)
{
v4 staticCameraBounds = math_getRect(V2(0, 0), renderer->size);
renderer_rect(renderer, staticCameraBounds, pos, size, rotate, renderTex,
color);
}
void renderer_string(Renderer *const renderer, v4 cameraBounds,
Font *const font, const char *const string, v2 pos,
f32 rotate, v4 color);
@ -39,8 +47,9 @@ inline void renderer_staticString(Renderer *const renderer, Font *const font,
const char *const string, v2 pos, f32 rotate,
v4 color)
{
renderer_string(renderer, V4(0, renderer->size.h, renderer->size.w, 0),
font, string, pos, rotate, color);
v4 staticCameraBounds = math_getRect(V2(0, 0), renderer->size);
renderer_string(renderer, staticCameraBounds, font, string, pos, rotate,
color);
}
void renderer_entity(Renderer *renderer, v4 cameraBounds, Entity *entity,