bullet time and basic UI
This commit is contained in:
parent
fdde4809d3
commit
65b23e83f2
|
@ -46,6 +46,7 @@ set(ASSETS
|
|||
# HUD
|
||||
assets-cg/hud.png
|
||||
assets-cg/hud_life.png
|
||||
assets-cg/hud_window.png
|
||||
assets-cg/hud_xp.png
|
||||
assets-cg/skillicons.png
|
||||
assets-cg/font_hud.png
|
||||
|
|
|
@ -7,6 +7,8 @@ hud.png:
|
|||
profile: p4
|
||||
hud_life.png:
|
||||
profile: p4
|
||||
hud_window.png:
|
||||
profile: p4
|
||||
hud_xp.png:
|
||||
profile: p4
|
||||
skillicons.png:
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 405 B |
31
src/main.c
31
src/main.c
|
@ -33,17 +33,11 @@
|
|||
|
||||
int main_menu(void)
|
||||
{
|
||||
entity_t *e = enemy_make(ENEMY_SLIME_1);
|
||||
|
||||
while(1) {
|
||||
dclear(C_BLACK);
|
||||
dprint(1, 1, C_WHITE, "Rogue Life");
|
||||
dprint(1, 15, C_WHITE, "[1] Cavern");
|
||||
dprint(1, 29, C_WHITE, "[2] Lab");
|
||||
|
||||
fighter_t *f = getcomp(e, fighter);
|
||||
dprint(1, 43, C_WHITE, "HP:%d ATK:%d MAG:%d DEF:%d",
|
||||
f->HP_max, f->ATK, f->MAG, f->DEF);
|
||||
dupdate();
|
||||
|
||||
int key = getkey().key;
|
||||
|
@ -168,6 +162,8 @@ int main(void)
|
|||
timer_start(timer_id);
|
||||
|
||||
bool stop = false;
|
||||
bool menu_stats_open = false;
|
||||
bool menu_inventory_open = false;
|
||||
|
||||
prof_t perf_render, perf_simul;
|
||||
uint32_t time_render=0, time_simul=0;
|
||||
|
@ -177,9 +173,12 @@ int main(void)
|
|||
frame_tick = 0;
|
||||
|
||||
bool attack = false;
|
||||
bool bullet_time = menu_stats_open || menu_inventory_open;
|
||||
|
||||
/* This assumes the frame is not late; can do better with libprof */
|
||||
fixed_t dt = fix(1) / FRAME_RATE;
|
||||
if(bullet_time)
|
||||
dt >>= 3;
|
||||
if(debug.paused)
|
||||
dt = 0;
|
||||
|
||||
|
@ -188,6 +187,19 @@ int main(void)
|
|||
|
||||
render_game(&game, debug.show_hitboxes);
|
||||
|
||||
if(menu_stats_open) {
|
||||
render_window(48, 24, 300, 154);
|
||||
extern font_t font_rogue;
|
||||
font_t const *old_font = dfont(&font_rogue);
|
||||
dprint(54, 40, C_WHITE, "Player");
|
||||
dprint(54, 55, C_WHITE, "HP:%d ATK:%d MAG:%d DEF:%d",
|
||||
player_f->HP_max, player_f->ATK, player_f->MAG, player_f->DEF);
|
||||
dfont(old_font);
|
||||
}
|
||||
else if(menu_inventory_open) {
|
||||
render_window(48, 24, 300, 154);
|
||||
}
|
||||
|
||||
/* kmalloc_arena_t *_uram = kmalloc_get_arena("_uram");
|
||||
kmalloc_gint_stats_t *_uram_stats = kmalloc_get_gint_stats(_uram);
|
||||
dprint(1, 15, C_WHITE, "Memory: %d", _uram_stats->used_memory); */
|
||||
|
@ -387,8 +399,15 @@ int main(void)
|
|||
if(ev.key == KEY_MINUS)
|
||||
camera_zoom(c, c->zoom - 1);
|
||||
#endif
|
||||
|
||||
if(ev.key == KEY_SHIFT)
|
||||
attack = true;
|
||||
|
||||
/* Menus */
|
||||
if(ev.key == KEY_F5 && !keydown(KEY_VARS))
|
||||
menu_inventory_open = !menu_inventory_open;
|
||||
if(ev.key == KEY_F6 && !keydown(KEY_VARS) && !keydown(KEY_ALPHA))
|
||||
menu_stats_open = !menu_stats_open;
|
||||
}
|
||||
|
||||
/* Camera movement */
|
||||
|
|
41
src/render.c
41
src/render.c
|
@ -301,6 +301,47 @@ static void render_wave_info(game_t const *g)
|
|||
dtext_opt(x-2, y, C_WHITE, C_NONE, DTEXT_RIGHT, DTEXT_MIDDLE, "Next:");
|
||||
}
|
||||
|
||||
void render_window(int x, int y, int w, int h)
|
||||
{
|
||||
extern bopti_image_t img_hud_window;
|
||||
w = max(w, 40);
|
||||
h = max(h, 22);
|
||||
int slices = w / 20 - 2;
|
||||
w = (slices + 2) * 20;
|
||||
|
||||
/* Shaded background */
|
||||
int x0=x, x1=x+w-2;
|
||||
x0 = (x0 + (x0 & 1)) >> 1;
|
||||
x1 = (x1 + (x1 & 1)) >> 1;
|
||||
uint32_t *vram = (void *)gint_vram + (DWIDTH*2) * (y+9);
|
||||
|
||||
for(int vy = 0; vy <= h-18; vy++) {
|
||||
for(int vx = x0; vx <= x1; vx++) {
|
||||
vram[vx] = (vram[vx] & 0xf7def7de) >> 1;
|
||||
vram[vx] = (vram[vx] & 0xf7def7de) >> 1;
|
||||
}
|
||||
vram += DWIDTH / 2;
|
||||
}
|
||||
|
||||
/* Top section */
|
||||
dsubimage(x, y, &img_hud_window, 0, 0, 20, 11, DIMAGE_NONE);
|
||||
for(int i = 0; i < slices; i++)
|
||||
dsubimage(x+20*(i+1), y, &img_hud_window, 20, 0, 20, 11, DIMAGE_NONE);
|
||||
dsubimage(x+w-20, y, &img_hud_window, 40, 0, 20, 11, DIMAGE_NONE);
|
||||
|
||||
/* Vertical bars */
|
||||
int color = RGB24(0x66686f);
|
||||
dline(x, y+10, x, y+h-11, color);
|
||||
dline(x+w-1, y+10, x+w-1, y+h-11, color);
|
||||
|
||||
/* Bottom section */
|
||||
dsubimage(x, y+h-11, &img_hud_window, 0, 11, 20, 11, DIMAGE_NONE);
|
||||
for(int i = 0; i < slices; i++)
|
||||
dsubimage(x+20*(i+1), y+h-11, &img_hud_window, 20, 11, 20, 11,
|
||||
DIMAGE_NONE);
|
||||
dsubimage(x+w-20, y+h-11, &img_hud_window, 40, 11, 20, 11, DIMAGE_NONE);
|
||||
}
|
||||
|
||||
void render_game(game_t const *g, bool show_hitboxes)
|
||||
{
|
||||
camera_t const *camera = &g->camera;
|
||||
|
|
|
@ -56,6 +56,9 @@ fixed_t camera_ppu(camera_t const *c);
|
|||
// Rendering
|
||||
//---
|
||||
|
||||
/* Render window overlay. */
|
||||
void render_window(int x, int y, int w, int h);
|
||||
|
||||
/* Render game full-screen. */
|
||||
struct game;
|
||||
void render_game(struct game const *g, bool show_hitboxes);
|
||||
|
|
Loading…
Reference in New Issue