Maze supports runtime value manip
This commit is contained in:
parent
a4f0540210
commit
a5b905ab43
2
haloo3d
2
haloo3d
@ -1 +1 @@
|
||||
Subproject commit 775397220d63a5f92ad1ad16c0409c515ce13c30
|
||||
Subproject commit d7b2d938cd5b53a65c5bdd78f62c1a7160c576e6
|
53
maze.c
53
maze.c
@ -1,4 +1,5 @@
|
||||
#include "haloo3d/haloo3d.h"
|
||||
#include "haloo3d/haloo3dex_console.h"
|
||||
#include "haloo3d/haloo3dex_easy.h"
|
||||
#include "haloo3d/haloo3dex_gen.h"
|
||||
// #include "haloo3d/haloo3dex_img.h"
|
||||
@ -8,26 +9,21 @@
|
||||
#include "unigi/unigi.headers/src/main.h"
|
||||
#include "unigi/unigi.platform.sdl1/src/main.c"
|
||||
|
||||
#include "keys.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// Performance options
|
||||
#define DOLIGHTING
|
||||
// #define FASTTRIS
|
||||
#define DITHERSTART -1
|
||||
#define DITHEREND 8
|
||||
#define TARGETFPS 30
|
||||
#define SECPERFRAME (1.0 / TARGETFPS)
|
||||
// #define SECPERFRAME (1.0 / TARGETFPS)
|
||||
|
||||
#define WIDTH 320
|
||||
#define HEIGHT 200
|
||||
#define SWIDTH WIDTH * 3
|
||||
#define SHEIGHT HEIGHT * 3
|
||||
#define ASPECT ((float)WIDTH / HEIGHT)
|
||||
#define FOV 90.0
|
||||
#define NEARCLIP 0.01
|
||||
#define FARCLIP 100.0
|
||||
#define LIGHTANG -MPI / 4.0
|
||||
#define MINLIGHT 0.25
|
||||
#define AVGWEIGHT 0.85
|
||||
|
||||
// Game options
|
||||
@ -109,9 +105,20 @@ void gen_maze(haloo3d_obj *mazewalls, int size) {
|
||||
|
||||
int main() { // int argc, char **argv) {
|
||||
|
||||
// Store all the values users can change at the beginning
|
||||
float ditherstart = -1;
|
||||
float ditherend = 8;
|
||||
float fov = 90.0;
|
||||
float minlight = 0.25;
|
||||
int fps = 30;
|
||||
uint16_t sky = 0xF000;
|
||||
|
||||
haloo3d_easystore storage;
|
||||
haloo3d_easystore_init(&storage);
|
||||
|
||||
haloo3d_debugconsole dc;
|
||||
haloo3d_debugconsole_init(&dc);
|
||||
|
||||
haloo3d_fb screen;
|
||||
haloo3d_fb_init(&screen, SWIDTH, SHEIGHT);
|
||||
haloo3d_recti texrect = {.x1 = 0, .y1 = 0, .x2 = WIDTH, .y2 = HEIGHT};
|
||||
@ -119,13 +126,18 @@ int main() { // int argc, char **argv) {
|
||||
|
||||
haloo3d_easyrender render;
|
||||
haloo3d_easyrender_init(&render, WIDTH, HEIGHT);
|
||||
haloo3d_perspective(render.perspective, FOV, ASPECT, NEARCLIP, FARCLIP);
|
||||
render.camera.pos.y = 0.5;
|
||||
#ifdef FASTTRIS
|
||||
render.trifunc = H3D_EASYRENDER_FASTFUNC;
|
||||
#endif
|
||||
// render.trifunc = H3D_EASYRENDER_FASTFUNC;
|
||||
eprintf("Initialized renderer\n");
|
||||
|
||||
haloo3d_debugconsole_set(&dc, "render/fps.i", &fps);
|
||||
haloo3d_debugconsole_set(&dc, "render/fov.f", &fov);
|
||||
haloo3d_debugconsole_set(&dc, "render/trifunc.f", &render.trifunc);
|
||||
haloo3d_debugconsole_set(&dc, "render/ditherstart.f", &ditherstart);
|
||||
haloo3d_debugconsole_set(&dc, "render/ditherend.f", &ditherend);
|
||||
haloo3d_debugconsole_set(&dc, "render/sky.u16x", &sky);
|
||||
haloo3d_debugconsole_set(&dc, "render/fasttris.i", &sky);
|
||||
|
||||
render.tprint.fb = &screen;
|
||||
|
||||
haloo3d_easytimer frametimer, sdltimer;
|
||||
@ -212,8 +224,9 @@ int main() { // int argc, char **argv) {
|
||||
while (1) {
|
||||
haloo3d_easytimer_start(&frametimer);
|
||||
render.camera.yaw += 0.008;
|
||||
haloo3d_perspective(render.perspective, fov, ASPECT, NEARCLIP, FARCLIP);
|
||||
haloo3d_easyrender_beginframe(&render);
|
||||
haloo3d_fb_clear(&render.window, 0xF000);
|
||||
haloo3d_fb_clear(&render.window, sky);
|
||||
|
||||
walli->scale.y = fabs(sin(3 * render.camera.yaw));
|
||||
// render.camera.up.x = sin(render.camera.yaw);
|
||||
@ -223,7 +236,15 @@ int main() { // int argc, char **argv) {
|
||||
|
||||
unigi_event_get(&event);
|
||||
if (event.type == unigi_enum_event_input_keyboard) {
|
||||
exit(0);
|
||||
if (event.data.input_keyboard.down) {
|
||||
switch (event.data.input_keyboard.button) {
|
||||
case KEY_SPACE:
|
||||
haloo3d_debugconsole_beginprompt(&dc);
|
||||
break;
|
||||
default:
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
totaldrawn = 0;
|
||||
@ -238,7 +259,7 @@ int main() { // int argc, char **argv) {
|
||||
// Iterate over object faces
|
||||
for (int fi = 0; fi < object->model->numfaces; fi++) {
|
||||
totaldrawn += haloo3d_easyrender_renderface(
|
||||
&render, object, fi, DITHERSTART, DITHEREND, MINLIGHT);
|
||||
&render, object, fi, ditherstart, ditherend, minlight);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +281,7 @@ int main() { // int argc, char **argv) {
|
||||
|
||||
haloo3d_easytimer_end(&frametimer);
|
||||
|
||||
float waittime = SECPERFRAME - frametimer.last;
|
||||
float waittime = (1.0 / fps) - frametimer.last;
|
||||
if (waittime > 0) {
|
||||
unigi_time_sleep(waittime * unigi_time_clocks_per_s);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user