a-game

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

commit 1e6a4a57d58e889fc68898b0586d781d4e1720e9
parent 1f894f9b1b1cfe19b91b8293257db05d7ae02522
Author: amin <dev@aminmesbah.com>
Date:   Tue,  5 Mar 2019 05:31:33 +0000

Use sweet inline compound literals to init vec3s

FossilOrigin-Name: a698d8a2e9ac6990d7ff5ac5e21fc4e928fc913ea464e13f58f935316cd9dd10
Diffstat:
Msrc/game.c | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/game.c b/src/game.c @@ -222,8 +222,8 @@ void game_update_and_render(struct GameState *game_state, f32 dt, v2u framebuffe { u32 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_scale(model, glmth_v3_init(size, size, 1.0f)); + model = glmth_translate(model, (v3) {start + (size * x), start + (size * y), 0.0f}); + model = glmth_scale(model, (v3) {size, size, 1.0f}); shader_setm4(&game_state->star_shader, "model", &model); v3 color; @@ -256,7 +256,7 @@ void game_update_and_render(struct GameState *game_state, f32 dt, v2u framebuffe m4 projection = glmth_m4_init_id(); projection = glmth_projection_ortho(0.0f, screen_width, screen_height, 0.0f, -1.0f, 1.0f); shader_setm4(&game_state->star_shader, "projection", &projection); - v3 color = glmth_v3_init(1.0f, 1.0f, 1.0f); + v3 color = (v3) {1.0f, 1.0f, 1.0f}; shader_setv3(&game_state->star_shader, "color", &color); glBindVertexArray(game_state->star_vao_id); @@ -267,12 +267,12 @@ void game_update_and_render(struct GameState *game_state, f32 dt, v2u framebuffe // render triangle { m4 model = glmth_m4_init_id(); - model = glmth_translate(model, glmth_v3_init(screen_width / 2.0f, screen_height / 2.0f, 0.0f)); - model = glmth_translate(model, glmth_v3_init(100.0f * cosf(dt), 100.0f * sinf(dt), 0.0f)); + model = glmth_translate(model, (v3) {screen_width / 2.0f, screen_height / 2.0f, 0.0f}); + model = glmth_translate(model, (v3) {100.0f * cosf(dt), 100.0f * sinf(dt), 0.0f}); model = glmth_rotate_z(model, -dt); - model = glmth_scale(model, glmth_v3_init(10.0f, 10.0f, 10.0f)); + model = glmth_scale(model, (v3) {10.0f, 10.0f, 10.0f}); f32 scale_factor = fabs(1.0f * sinf(dt)); - model = glmth_scale(model, glmth_v3_init(scale_factor, scale_factor, scale_factor)); + model = glmth_scale(model, (v3) {scale_factor, scale_factor, scale_factor}); shader_use(&game_state->triangle_shader); shader_setm4(&game_state->triangle_shader, "model", &model);