commit 76401de43d3ec54c3a4f9635f1da340611496782
parent d4d0d98cea7a7f26e02da1cfa40935fd7fd3415b
Author: Henry Wilson <henry@henryandlizzy.uk>
Date: Wed, 11 May 2022 22:52:19 +0100
gl-asteroids: Draw ammo counter
Diffstat:
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/gl-asteroids.cpp b/src/gl-asteroids.cpp
@@ -336,6 +336,7 @@ physics ship_phys{{}, {}, 0.f, 0.f, .06f};
bool up = false;
int lives = 3;
+unsigned ammo = 10;
void draw_scene(float t)
{
@@ -369,6 +370,12 @@ void draw_scene(float t)
for (int i = 0; i < lives-1; ++i)
draw(ship, {{.9f, -.9f + i * .15f}, {}, 0.f, 0.f, .04f});
+ glBegin(GL_LINES);
+ glColor({.0,.4,.0});
+ glCoord({-.95f, -.9f});
+ glCoord({-.95f, ammo * .09f - .9f});
+ glEnd();
+
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glfwSwapBuffers(w);
@@ -388,7 +395,6 @@ visual const& random_rock_visual(void)
int main(int argc, char* argv[])
{
signed score = 0;
- unsigned ammo = 10;
float firerate = 2, bullet_speed = 1;
std::uniform_real_distribution<float> dis_p(-1,1);
@@ -465,7 +471,8 @@ int main(int argc, char* argv[])
powerup_time += 15;
int dir = dis_d(gen);
auto scale = .03f;
- coord p = {dis_p(gen) / 2 - .5f, -1 - scale};
+ static std::uniform_real_distribution<float> pos(-.9,.9);
+ coord p = {pos(gen) / 2 - .5f, -1 - scale};
coord v = {0, .3f};
if (dir & 1)
v.x = -v.x, p.x = -p.x;