better timeline + turn lv1 on its head in 1 block
This commit is contained in:
parent
930a97b738
commit
2094618c01
|
@ -21,6 +21,7 @@ set(SOURCES
|
|||
src/game.c
|
||||
src/geometry.c
|
||||
src/item.c
|
||||
src/level.c
|
||||
src/main.c
|
||||
src/map.c
|
||||
src/menu.c
|
||||
|
@ -51,7 +52,8 @@ set(ASSETS
|
|||
assets-cg/menu_arrows.png
|
||||
# HUD
|
||||
assets-cg/hud.png
|
||||
assets-cg/hud_event.png
|
||||
assets-cg/hud_delay.png
|
||||
assets-cg/hud_flag.png
|
||||
assets-cg/hud_life.png
|
||||
assets-cg/hud_stars.png
|
||||
assets-cg/hud_window.png
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 162 B |
Binary file not shown.
Before Width: | Height: | Size: 305 B |
Binary file not shown.
After Width: | Height: | Size: 177 B |
|
@ -7,8 +7,8 @@
|
|||
2,2,2,2,7,7,8,8,2,2,2,15,7,8,8,15,7,8,7,2,2,2,2,2,
|
||||
2,2,7,16,3,3,5,3,16,2,15,4,4,4,4,4,4,3,3,8,7,2,2,2,
|
||||
2,2,3,3,5,3,3,3,3,8,5,4,4,4,2,16,3,5,6,5,3,16,2,2,
|
||||
2,2,5,3,3,3,3,5,3,3,5,5,4,7,8,3,5,6,3,6,5,3,2,2,
|
||||
2,2,3,3,16,8,16,3,3,3,5,5,5,5,5,3,6,3,3,3,6,3,2,2,
|
||||
2,2,5,3,3,3,3,5,3,3,5,5,4,7,2,3,5,6,3,6,5,3,2,2,
|
||||
2,2,3,3,16,8,16,3,3,3,5,5,5,5,7,3,6,3,3,3,6,3,2,2,
|
||||
2,2,3,5,3,6,3,3,5,2,2,5,4,5,5,3,5,6,3,6,5,3,2,2,
|
||||
2,2,2,3,6,3,6,3,2,2,7,7,4,5,2,2,3,5,6,5,3,2,2,2,
|
||||
2,2,2,3,5,6,3,3,15,8,4,4,4,4,2,2,2,3,3,3,2,2,2,2,
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#include "level.h"
|
||||
|
||||
int level_wave_count(level_t const *lv)
|
||||
{
|
||||
int wave_count = 0;
|
||||
|
||||
for(int i = 0; i < lv->event_count; i++)
|
||||
wave_count += (lv->events[i].type == LEVEL_EVENT_WAVE);
|
||||
|
||||
return wave_count;
|
||||
}
|
|
@ -74,6 +74,9 @@ typedef struct {
|
|||
|
||||
} level_t;
|
||||
|
||||
/* Get the number of waves in a level */
|
||||
int level_wave_count(level_t const *lv);
|
||||
|
||||
/* List of levels */
|
||||
extern level_t level_lv1;
|
||||
extern level_t level_lv2;
|
||||
|
|
94
src/render.c
94
src/render.c
|
@ -297,19 +297,27 @@ static void render_entities(game_t const *g, camera_t const *camera,
|
|||
free(rendering_order);
|
||||
}
|
||||
|
||||
static void render_info_wave(int x0, int y0, level_event_t const *event, int w)
|
||||
static int render_info_delay(int x, int y, level_event_t const *event)
|
||||
{
|
||||
extern bopti_image_t img_hud_delay;
|
||||
dimage(x, y, &img_hud_delay);
|
||||
return img_hud_delay.width;
|
||||
}
|
||||
|
||||
static int render_info_wave(int x, int y, level_event_t const *event,
|
||||
uint8_t *wave_left)
|
||||
{
|
||||
level_wave_t const *wave = event->wave;
|
||||
|
||||
int x = x0 + 5;
|
||||
int y = y0 + 8;
|
||||
int x0 = x;
|
||||
y += 4;
|
||||
|
||||
for(int i = 0; i < wave->entry_count; i++) {
|
||||
enemy_t const *enemy = enemy_data(wave->entries[i].identity);
|
||||
int amount = wave->entries[i].amount;
|
||||
int amount_total = wave->entries[i].amount;
|
||||
int amount = wave_left ? wave_left[i] : amount_total;
|
||||
|
||||
int text_w;
|
||||
font_damage_size(amount, &text_w, NULL);
|
||||
font_damage_size(amount_total, &text_w, NULL);
|
||||
|
||||
anim_frame_t *frame = enemy->anim_idle->start[0];
|
||||
dsubimage(x, y - frame->h / 2, frame->sheet,
|
||||
|
@ -319,50 +327,58 @@ static void render_info_wave(int x0, int y0, level_event_t const *event, int w)
|
|||
|
||||
x += frame->w - 6 + text_w;
|
||||
}
|
||||
|
||||
return x-x0;
|
||||
}
|
||||
|
||||
static void render_info_item(int x, int y, level_event_t const *event, int w)
|
||||
static int render_info_item(int x, int y, level_event_t const *event)
|
||||
{
|
||||
dprint(x, y+3, C_WHITE, "Item");
|
||||
int w;
|
||||
dsize("Item", NULL, &w, NULL);
|
||||
|
||||
dprint(x, y, C_WHITE, "Item");
|
||||
return w;
|
||||
}
|
||||
|
||||
static void render_info_bg(int x, int y, int w)
|
||||
static void render_info(int x, int y, game_t const *g)
|
||||
{
|
||||
extern bopti_image_t img_hud_event;
|
||||
int h = img_hud_event.height;
|
||||
if(!g->level)
|
||||
return;
|
||||
|
||||
dsubimage(x, y, &img_hud_event, 0, 0, 8, h, DIMAGE_NONE);
|
||||
x += 8; w -= 8;
|
||||
int intro_w;
|
||||
char str[32];
|
||||
snprintf(str, 32, "Wave %d", level_wave_count(g->level));
|
||||
dsize(str, NULL, &intro_w, NULL);
|
||||
snprintf(str, 32, "Wave %d", g->wave_number);
|
||||
dtext(x+8, y-1, C_WHITE, str);
|
||||
x += intro_w + 20;
|
||||
|
||||
while(w >= 24) {
|
||||
dsubimage(x, y, &img_hud_event, 8, 0, 16, h, DIMAGE_NONE);
|
||||
x += 16; w -= 16;
|
||||
}
|
||||
int sep_w;
|
||||
dsize(">", NULL, &sep_w, NULL);
|
||||
|
||||
dsubimage(x, y, &img_hud_event, 32-w, 0, w, h, DIMAGE_NONE);
|
||||
}
|
||||
for(int i = g->event; i <= g->level->event_count && x <= DWIDTH; i++) {
|
||||
if(i == g->level->event_count) {
|
||||
extern bopti_image_t img_hud_flag;
|
||||
dimage(x+1, y, &img_hud_flag);
|
||||
|
||||
static void render_info(int y, game_t const *g)
|
||||
{
|
||||
int const PX_PER_SECOND = 12;
|
||||
|
||||
int x = fround(-g->time_total * PX_PER_SECOND);
|
||||
|
||||
for(int i = 0; i < g->level->event_count && x <= DWIDTH; i++) {
|
||||
level_event_t const *event = &g->level->events[i];
|
||||
int w = fround(event->duration * PX_PER_SECOND);
|
||||
|
||||
if(i > g->event && x + w > 0) {
|
||||
if(event->type != LEVEL_EVENT_DELAY)
|
||||
render_info_bg(x, y, w);
|
||||
|
||||
if(event->type == LEVEL_EVENT_WAVE)
|
||||
render_info_wave(x, y, event, w);
|
||||
if(event->type == LEVEL_EVENT_ITEM)
|
||||
render_info_item(x, y, event, w);
|
||||
// TODO: If victory reached, write "Victory!"
|
||||
break;
|
||||
}
|
||||
|
||||
x += w;
|
||||
level_event_t const *event = &g->level->events[i];
|
||||
|
||||
if(event->type == LEVEL_EVENT_DELAY)
|
||||
x += render_info_delay(x, y, event);
|
||||
if(event->type == LEVEL_EVENT_WAVE) {
|
||||
uint8_t *wave_left = (i == g->event) ? g->wave_left : NULL;
|
||||
x += render_info_wave(x, y, event, wave_left);
|
||||
}
|
||||
if(event->type == LEVEL_EVENT_ITEM)
|
||||
x += render_info_item(x, y, event);
|
||||
|
||||
x += 12;
|
||||
dprint(x, y, C_WHITE, ">");
|
||||
x += sep_w + 12;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,7 +475,7 @@ void render_game(game_t const *g, bool show_hitboxes)
|
|||
int HEADER_Y = cubic(-15, 2, gui_time, MAX_GUI_TIME);
|
||||
|
||||
/* Render wave information */
|
||||
render_info(HEADER_Y, g);
|
||||
render_info(0, HEADER_Y, g);
|
||||
|
||||
/* Render HUD */
|
||||
extern bopti_image_t img_hud;
|
||||
|
|
Loading…
Reference in New Issue