Create text module for displaying messages
This commit is contained in:
50
game.c
50
game.c
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "input.h"
|
||||
#include "renderer.h"
|
||||
#include "text.h"
|
||||
#include "rng.h"
|
||||
|
||||
#include <assert.h>
|
||||
@@ -51,10 +52,7 @@
|
||||
#define MAX_SHAPES_PER_ENTITY 2
|
||||
#define MAX_COLLISIONS 128U
|
||||
|
||||
#define GAME_OVER_WIDTH 24
|
||||
#define GAME_OVER_HEIGHT 8
|
||||
#define GAME_OVER_SCALE 0.025
|
||||
#define GAME_OVER_COUNTER_MASK (1 << 6)
|
||||
#define COUNTER_MASK (1 << 6)
|
||||
|
||||
#define NELEMS(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
|
||||
@@ -103,40 +101,6 @@ static const vec2_t fire_verts[] = {
|
||||
};
|
||||
static const vec2_t shot_verts[] = { { 0.0, -0.02 }, { 0.0, 0.02 } };
|
||||
|
||||
static const vec2_t game_over_verts[][MAX_VERTS] = {
|
||||
// G
|
||||
{ { -10, 4 }, { -12, 4 }, { -12, -4 }, { -10, -4 }, { -10, 0 } },
|
||||
// A
|
||||
{ { -9, -4 }, { -8, 4 }, { -7, -4 } },
|
||||
{ { -8.75, -2 }, { -7.25, -2 } },
|
||||
// M
|
||||
{ { -6, -4 }, { -6, 4 }, { -5, -4 }, { -4, 4 }, { -4, -4 } },
|
||||
// E
|
||||
{ { -1, 4 }, { -3, 4 }, { -3, -4 }, { -1, -4 } },
|
||||
{ { -3, 0 }, { -2, 0 } },
|
||||
// O
|
||||
{ { 1, 4 }, { 1, -4 }, { 3, -4 }, { 3, 4 }, { 1, 4 } },
|
||||
// V
|
||||
{ { 4, 4 }, { 5, -4 }, { 6, 4 } },
|
||||
// E
|
||||
{ { 9, 4 }, { 7, 4 }, { 7, -4 }, { 9, -4 } },
|
||||
{ { 7, 0 }, { 8, 0 } },
|
||||
// R
|
||||
{ { 10, -4 }, { 10, 4 }, { 12, 4 }, { 12, -2 }, { 10, -2 }, { 12, -4 } },
|
||||
};
|
||||
static const unsigned game_over_lens[NELEMS(game_over_verts)] = {
|
||||
5, 3, 2, 5, 4, 2, 5, 3, 4, 2, 6,
|
||||
};
|
||||
static const mat3_t game_over_transform = {
|
||||
{ GAME_OVER_SCALE, 0, 0 },
|
||||
{ 0, GAME_OVER_SCALE, 0 },
|
||||
{ 0, 0, 1 },
|
||||
};
|
||||
static const vec2_t game_over_bg = {
|
||||
.x = (GAME_OVER_WIDTH + 2) * GAME_OVER_SCALE,
|
||||
.y = (GAME_OVER_HEIGHT + 2) * GAME_OVER_SCALE,
|
||||
};
|
||||
|
||||
static entity_t entities[MAX_ENTITIES];
|
||||
static mat3_t transforms[MAX_ENTITIES];
|
||||
static shape_t shapes[MAX_SHAPES];
|
||||
@@ -530,12 +494,6 @@ void game_draw()
|
||||
shapes[i].connect);
|
||||
}
|
||||
|
||||
if (dead && !(counter & GAME_OVER_COUNTER_MASK)) {
|
||||
renderer_clear_rect((vec2_t) { 0, 0 }, game_over_bg);
|
||||
for (unsigned i = 0; i < NELEMS(game_over_verts); ++i) {
|
||||
renderer_draw(
|
||||
game_over_verts[i], game_over_lens[i], game_over_transform,
|
||||
false);
|
||||
}
|
||||
}
|
||||
if (dead && !(counter & COUNTER_MASK))
|
||||
text_draw("GAME OVER");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user