examples

Toy examples in single C files.
git clone git://henryandlizzy.uk/examples
Log | Files | Refs

commit ea51d2f712d3f95513f8c928fb52b6e5f01f9969
parent acad23d153291c4a1836eb285f8d38869eae2ca6
Author: Henry Wilson <henry@henryandlizzy.uk>
Date:   Sun,  3 Apr 2022 21:19:41 +0100

gl-asteroids: Fix flame being controllable after game end

Diffstat:
Msrc/gl-asteroids.cpp | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gl-asteroids.cpp b/src/gl-asteroids.cpp @@ -225,6 +225,7 @@ bool is_pressed(int key) std::vector<entity> rocks; std::vector<entity> bullets; physics s{{}, {}, 0.f, 0.f, .06f}; +bool up = false; void draw_scene(void) { @@ -238,7 +239,7 @@ void draw_scene(void) b.draw(); draw_wrapped(ship, s); - if (is_pressed(GLFW_KEY_UP)) + if (up) draw(flame, s); glfwSwapBuffers(w); @@ -327,7 +328,9 @@ int main(int argc, char* argv[]) else s.ang_mom = 0; - if (is_pressed(GLFW_KEY_UP)) + up = is_pressed(GLFW_KEY_UP); + + if (up) { float sr = sin(s.rot), cr = cos(s.rot); s.vel += coord{sr, cr} * dt;