render: display actual level map, also some bugfixes
This commit is contained in:
parent
1556c37340
commit
a534ccddbe
|
@ -28,7 +28,8 @@ void level_update(level_t *level)
|
|||
|
||||
void level_advance(level_t *level)
|
||||
{
|
||||
level->section_buffer.erase(level->section_buffer.begin());
|
||||
if(level->section_buffer.size())
|
||||
level->section_buffer.erase(level->section_buffer.begin());
|
||||
}
|
||||
|
||||
void level_display(level_t *level)
|
||||
|
|
54
src/main.cpp
54
src/main.cpp
|
@ -45,6 +45,7 @@ int main(void)
|
|||
bool game_run = true;
|
||||
while(game_run) {
|
||||
while(!need_frame) sleep();
|
||||
need_frame = 0;
|
||||
|
||||
num dt = 1.0 / 30;
|
||||
t += dt;
|
||||
|
@ -69,17 +70,27 @@ int main(void)
|
|||
|
||||
for(int depth = RENDER_SECTION_DISTANCE - 1; depth >= 0; depth--) {
|
||||
num z = depth * RENDER_SECTION_LENGTH - level_z;
|
||||
struct section *s = &level.section_buffer[depth];
|
||||
|
||||
for(int i = 0; i < PLATFORM_COUNT; i++) {
|
||||
int gray = ((i + depth + sections_passed) % PLATFORM_COUNT)
|
||||
* 31 / PLATFORM_COUNT;
|
||||
int color = C_RGB(gray, gray, gray);
|
||||
/* Set this to get the full tunnel test */
|
||||
constexpr bool full_tunnel = false;
|
||||
int color = C_WHITE;
|
||||
|
||||
if(full_tunnel) {
|
||||
int gray = ((i + depth + sections_passed) % PLATFORM_COUNT)
|
||||
* 31 / PLATFORM_COUNT;
|
||||
color = C_RGB(gray, gray, gray);
|
||||
}
|
||||
else {
|
||||
if(s->platforms[i].type != PLATFORM_WHITE) continue;
|
||||
}
|
||||
|
||||
struct prect p = render_platform_position(i, z);
|
||||
/* Near plane clipping */
|
||||
if(p.fl.z <= num(0.1)) continue;
|
||||
if(p.nl.z <= num(0.1)) p.nl.z = num(0.1);
|
||||
if(p.nr.z <= num(0.1)) p.nr.z = num(0.1);
|
||||
if(p.fl.z <= num(0.2)) continue;
|
||||
if(p.nl.z <= num(0.2)) p.nl.z = num(0.2);
|
||||
if(p.nr.z <= num(0.2)) p.nr.z = num(0.2);
|
||||
camera_project_prect(&camera, &p, screen_size);
|
||||
|
||||
render_triangle(&p.nl, &p.fr, &p.fl, color);
|
||||
|
@ -89,14 +100,17 @@ int main(void)
|
|||
prof_leave_norec(perf_comp);
|
||||
azrp_update();
|
||||
|
||||
drect(0, DHEIGHT-20, DWIDTH-1, DHEIGHT-1, C_WHITE);
|
||||
dprint(4, 209, C_BLACK, "render:%4d+%4dus comp:%4dus(%02d FPS)",
|
||||
prof_time(azrp_perf_render) - prof_time(azrp_perf_r61524),
|
||||
prof_time(azrp_perf_r61524),
|
||||
prof_time(perf_comp),
|
||||
last_frame_us ? 1000000 / last_frame_us : 0,
|
||||
(float)level_z);
|
||||
r61524_display(gint_vram, DHEIGHT-20, 20, R61524_DMA_WAIT);
|
||||
static bool show_footer = false;
|
||||
if(show_footer) {
|
||||
drect(0, DHEIGHT-20, DWIDTH-1, DHEIGHT-1, C_WHITE);
|
||||
dprint(4, 209, C_BLACK, "render:%4d+%4dus comp:%4dus FPS:%02d",
|
||||
prof_time(azrp_perf_render) - prof_time(azrp_perf_r61524),
|
||||
prof_time(azrp_perf_r61524),
|
||||
prof_time(perf_comp),
|
||||
last_frame_us ? 1000000 / last_frame_us : 0);
|
||||
r61524_display(gint_vram, DHEIGHT-20, 20, R61524_DMA_WAIT);
|
||||
}
|
||||
show_footer = !show_footer;
|
||||
|
||||
//---
|
||||
// Input
|
||||
|
@ -109,12 +123,18 @@ int main(void)
|
|||
|
||||
if(ev.key == KEY_EXIT || ev.key == KEY_MENU)
|
||||
game_run = false;
|
||||
if(ev.key == KEY_F1)
|
||||
if(ev.key == KEY_F1) {
|
||||
level = level_create(1);
|
||||
if(ev.key == KEY_F2)
|
||||
level_update(&level);
|
||||
}
|
||||
if(ev.key == KEY_F2) {
|
||||
level = level_create(2);
|
||||
if(ev.key == KEY_F3)
|
||||
level_update(&level);
|
||||
}
|
||||
if(ev.key == KEY_F3) {
|
||||
level = level_create(3);
|
||||
level_update(&level);
|
||||
}
|
||||
}
|
||||
|
||||
if(!game_run) break;
|
||||
|
|
Loading…
Reference in New Issue