a-game

2D platformer written from scratch.
Log | Files | Refs | README | LICENSE

commit 0b759003872232ee76a33d8c806d481d5f6816bf
parent a9170c814432efc15aa3a0dbc5517d57ca40501a
Author: Amin Mesbah <dev@aminmesbah.com>
Date:   Mon,  4 Mar 2019 21:31:34 -0800

Use sweet inline compound literals to init vec3s

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);