a-game

2D platformer written from scratch.
git clone git://git.amin.space/a-game.git
Log | Files | Refs | README | LICENSE

commit 66a432812e55acc8c8c941f18af82f6cafb0f853
parent 0932526a570609afc69439f7ffb61bf805a88a7d
Author: amin <dev@aminmesbah.com>
Date:   Tue,  5 Mar 2019 01:48:50 +0000

Align the tile map to the upper left corner

FossilOrigin-Name: 3a8aca41c25f801f2d3cb5be4c757c3963551f1c9aee64c8f52f4447b02017fc
Diffstat:
Msrc/game.c | 20++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/game.c b/src/game.c @@ -245,15 +245,24 @@ void game_update_and_render(struct GameState *game_state, float dt, v2u framebuf { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, }, }; - uint32_t start = 25; - float size = fabsf(100 * sinf(dt)); + float size; + if (screen_width < screen_height) + { + size = ((float)screen_width) / 16.0f; + } + else + { + size = ((float)screen_height) / 9.0f; + } + + float start = size / 2.0f; for (size_t y = 0; y < 9; y++) { for (size_t x = 0; x < 16; x++) { uint32_t tile_id = tile_map[y][x]; m4 model = glmth_m4_init_id(); - model = glmth_translate(model, glmth_v3_init(start + (size * x), start + (size * y), 0.0f)); + model = glmth_translate(model, glmth_v3_init(start + ((size + 1.0f) * x), start + ((size + 1.0f) * y), 0.0f)); model = glmth_scale(model, glmth_v3_init(size, size, 1.0f)); shader_setm4(&game_state->star_shader, "model", &model); @@ -264,12 +273,11 @@ void game_update_and_render(struct GameState *game_state, float dt, v2u framebuf } else { - color = glmth_v3_init(1.0f, 0.0f, 0.0f); + //color = glmth_v3_init(1.0f, 0.0f, 0.0f); } shader_setv3(&game_state->star_shader, "color", &color); - m4 projection = glmth_m4_init_id(); - projection = glmth_projection_ortho(0.0f, screen_width, screen_height, 0.0f, -1.0f, 1.0f); + m4 projection = glmth_projection_ortho(0.0f, screen_width, screen_height, 0.0f, -1.0f, 0.0f); shader_setm4(&game_state->star_shader, "projection", &projection); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);