More customization
This commit is contained in:
parent
165dc24bba
commit
9f73d6b1fd
67
maze.c
67
maze.c
@ -15,8 +15,11 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// INteresting flags for performance comparisons
|
// INteresting flags for debugging
|
||||||
#define FASTFILL
|
#define FASTFILL
|
||||||
|
#define NUMMICE 1
|
||||||
|
#define MOUSELOGGING
|
||||||
|
// #define NOWALLS
|
||||||
|
|
||||||
#define WIDTH 480
|
#define WIDTH 480
|
||||||
#define HEIGHT 300
|
#define HEIGHT 300
|
||||||
@ -48,7 +51,7 @@
|
|||||||
#define PRINTMAZE
|
#define PRINTMAZE
|
||||||
// Max amount of flip polys to generate in maze. actual amount can be lower,
|
// Max amount of flip polys to generate in maze. actual amount can be lower,
|
||||||
// but there will always at least be 1
|
// but there will always at least be 1
|
||||||
#define MAXFLIPPOLYS 6
|
#define MAXFLIPPOLYS 5
|
||||||
// Min space between flip polys
|
// Min space between flip polys
|
||||||
#define FLIPPOLYBUFFER 3
|
#define FLIPPOLYBUFFER 3
|
||||||
|
|
||||||
@ -88,7 +91,7 @@ float ditherend = 8;
|
|||||||
float fov = 90.0;
|
float fov = 90.0;
|
||||||
float minlight = 0.15;
|
float minlight = 0.15;
|
||||||
float speed = 1.0;
|
float speed = 1.0;
|
||||||
int fps = 45;
|
int fps = 30;
|
||||||
uint16_t sky = 0xF000;
|
uint16_t sky = 0xF000;
|
||||||
|
|
||||||
struct vec2i dirtovec(uint8_t dir) {
|
struct vec2i dirtovec(uint8_t dir) {
|
||||||
@ -446,10 +449,10 @@ void sys_world(ecs_world *w, mecs **ecs) {
|
|||||||
if (m.x == w->state->start.x && m.y == w->state->start.y) {
|
if (m.x == w->state->start.x && m.y == w->state->start.y) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int yc = m.y - FLIPPOLYBUFFER; yc < m.y + FLIPPOLYBUFFER; yc++) {
|
for (int yc = m.y - FLIPPOLYBUFFER; yc <= m.y + FLIPPOLYBUFFER; yc++) {
|
||||||
if (yc < 0 || yc >= w->state->size)
|
if (yc < 0 || yc >= w->state->size)
|
||||||
continue;
|
continue;
|
||||||
for (int xc = m.x - FLIPPOLYBUFFER; xc < m.x + FLIPPOLYBUFFER; xc++) {
|
for (int xc = m.x - FLIPPOLYBUFFER; xc <= m.x + FLIPPOLYBUFFER; xc++) {
|
||||||
if (xc < 0 || xc >= w->state->size)
|
if (xc < 0 || xc >= w->state->size)
|
||||||
continue;
|
continue;
|
||||||
if (w->state->maze[m.x + m.y * w->state->size] & MAZEFLIP) {
|
if (w->state->maze[m.x + m.y * w->state->size] & MAZEFLIP) {
|
||||||
@ -691,20 +694,26 @@ void sys_mouseai(ecs_mouseai *mouseai, ecs_placement *p, ecs_autonav *anav) {
|
|||||||
anav->dest = p->pos;
|
anav->dest = p->pos;
|
||||||
anav->timer = 0;
|
anav->timer = 0;
|
||||||
mouseai->state = SAI_READY;
|
mouseai->state = SAI_READY;
|
||||||
|
#ifdef MOUSELOGGING
|
||||||
eprintf("MOUSE READY: %f %f, waiting for spinup\n", anav->dest.x,
|
eprintf("MOUSE READY: %f %f, waiting for spinup\n", anav->dest.x,
|
||||||
anav->dest.z);
|
anav->dest.z);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SAI_READY:
|
case SAI_READY:
|
||||||
if (mouseai->ws->state == WSTATE_GAMEPLAY) {
|
if (mouseai->ws->state == WSTATE_GAMEPLAY) {
|
||||||
mouseai->state = SAI_GAMEPLAY;
|
mouseai->state = SAI_GAMEPLAY;
|
||||||
|
#ifdef MOUSELOGGING
|
||||||
eprintf("MOUSE STARTING GAMEPLAY\n");
|
eprintf("MOUSE STARTING GAMEPLAY\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SAI_GAMEPLAY:
|
case SAI_GAMEPLAY:
|
||||||
// Normal gameplay: move through the maze, etc.
|
// Normal gameplay: move through the maze, etc.
|
||||||
if (mouseai->ws->state != WSTATE_GAMEPLAY) {
|
if (mouseai->ws->state != WSTATE_GAMEPLAY) {
|
||||||
|
#ifdef MOUSELOGGING
|
||||||
eprintf("GAMEPLAY OVER, MOUSE RESETTING\n");
|
eprintf("GAMEPLAY OVER, MOUSE RESETTING\n");
|
||||||
|
#endif
|
||||||
mouseai->state = SAI_INIT;
|
mouseai->state = SAI_INIT;
|
||||||
anav->timer = 0; // Stop moving
|
anav->timer = 0; // Stop moving
|
||||||
return;
|
return;
|
||||||
@ -712,8 +721,10 @@ void sys_mouseai(ecs_mouseai *mouseai, ecs_placement *p, ecs_autonav *anav) {
|
|||||||
// Only decide to do things if you're not moving anymore. Movement is the
|
// Only decide to do things if you're not moving anymore. Movement is the
|
||||||
// most important thing
|
// most important thing
|
||||||
if (anav->timer == 0) {
|
if (anav->timer == 0) {
|
||||||
|
#ifdef MOUSELOGGING
|
||||||
eprintf("MOUSEAI DIR: %d POS: (%f, %f)\n", mouseai->dir, p->pos.x,
|
eprintf("MOUSEAI DIR: %d POS: (%f, %f)\n", mouseai->dir, p->pos.x,
|
||||||
p->pos.z);
|
p->pos.z);
|
||||||
|
#endif
|
||||||
// Look left or right randomly. You can affect how "straight" the mouse
|
// Look left or right randomly. You can affect how "straight" the mouse
|
||||||
// moves by increasing the MOUSETURNRAND
|
// moves by increasing the MOUSETURNRAND
|
||||||
uint8_t ndir;
|
uint8_t ndir;
|
||||||
@ -1032,14 +1043,9 @@ int main() { // int argc, char **argv) {
|
|||||||
haloo3d_easyrender_addinstance(&render, starto, startt);
|
haloo3d_easyrender_addinstance(&render, starto, startt);
|
||||||
haloo3d_obj_instance *endi =
|
haloo3d_obj_instance *endi =
|
||||||
haloo3d_easyrender_addinstance(&render, endo, endt);
|
haloo3d_easyrender_addinstance(&render, endo, endt);
|
||||||
haloo3d_obj_instance *mousei =
|
|
||||||
haloo3d_easyrender_addinstance(&render, mouseo, mouset);
|
|
||||||
init_mazeinstances(floori, ceili, walli);
|
init_mazeinstances(floori, ceili, walli);
|
||||||
init_billboard(starti, 1.0);
|
init_billboard(starti, 1.0);
|
||||||
init_billboard(endi, 0.25);
|
init_billboard(endi, 0.25);
|
||||||
init_billboard(mousei, MOUSESCALE);
|
|
||||||
// Mouse should be near the floor
|
|
||||||
mousei->pos.y = MOUSESCALE;
|
|
||||||
eprintf("Setup all static object instances\n");
|
eprintf("Setup all static object instances\n");
|
||||||
|
|
||||||
unigi_type_event event;
|
unigi_type_event event;
|
||||||
@ -1094,7 +1100,11 @@ int main() { // int argc, char **argv) {
|
|||||||
ECS_SETCOMPONENT(&ecs, wallid, ecs_syncgrow){
|
ECS_SETCOMPONENT(&ecs, wallid, ecs_syncgrow){
|
||||||
.obj = walli,
|
.obj = walli,
|
||||||
.scale = &eworld->scaleto,
|
.scale = &eworld->scaleto,
|
||||||
.basescale = 1, // can't set to scale because hscale
|
#ifdef NOWALLS
|
||||||
|
.basescale = 0, // can't set to scale because hscale
|
||||||
|
#else
|
||||||
|
.basescale = 1,
|
||||||
|
#endif
|
||||||
.timer = &eworld->scaletimer};
|
.timer = &eworld->scaletimer};
|
||||||
ecs_eid startid = mecs_newentity(&ecs, 0);
|
ecs_eid startid = mecs_newentity(&ecs, 0);
|
||||||
ECS_SETCOMPONENT(&ecs, startid, ecs_syncgrow){.obj = starti,
|
ECS_SETCOMPONENT(&ecs, startid, ecs_syncgrow){.obj = starti,
|
||||||
@ -1127,20 +1137,27 @@ int main() { // int argc, char **argv) {
|
|||||||
.upsidedown = 0,
|
.upsidedown = 0,
|
||||||
.startmarker = starti};
|
.startmarker = starti};
|
||||||
|
|
||||||
ecs_eid mouseid = mecs_newentity(&ecs, 0);
|
for (int i = 0; i < NUMMICE; i++) {
|
||||||
eprintf("Mouse eid: %d\n", mouseid);
|
haloo3d_obj_instance *mousei =
|
||||||
ECS_SETCOMPONENT(&ecs, mouseid, ecs_placement){.pos = mousei->pos,
|
haloo3d_easyrender_addinstance(&render, mouseo, mouset);
|
||||||
.rot = {.x = 0, .y = 0}};
|
init_billboard(mousei, MOUSESCALE);
|
||||||
ECS_SETCOMPONENT(&ecs, mouseid, ecs_autonav){.timer = 0};
|
// Mouse should be near the floor
|
||||||
ECS_SETCOMPONENT(&ecs, mouseid, ecs_object) mousei;
|
mousei->pos.y = MOUSESCALE;
|
||||||
ECS_SETCOMPONENT(&ecs, mouseid, ecs_mouseai){.state = SAI_INIT,
|
ecs_eid mouseid = mecs_newentity(&ecs, 0);
|
||||||
.ws = &wstate};
|
eprintf("Mouse eid: %d\n", mouseid);
|
||||||
ECS_SETCOMPONENT(&ecs, mouseid, ecs_billboard){.obj = mousei,
|
ECS_SETCOMPONENT(&ecs, mouseid, ecs_placement){.pos = mousei->pos,
|
||||||
.lookat = &render.camera.pos};
|
.rot = {.x = 0, .y = 0}};
|
||||||
ECS_SETCOMPONENT(&ecs, mouseid, ecs_syncgrow){.obj = mousei,
|
ECS_SETCOMPONENT(&ecs, mouseid, ecs_autonav){.timer = 0};
|
||||||
.scale = &eworld->scaleto,
|
ECS_SETCOMPONENT(&ecs, mouseid, ecs_object) mousei;
|
||||||
.basescale = mousei->scale.x,
|
ECS_SETCOMPONENT(&ecs, mouseid, ecs_mouseai){.state = SAI_INIT,
|
||||||
.timer = &eworld->scaletimer};
|
.ws = &wstate};
|
||||||
|
ECS_SETCOMPONENT(&ecs, mouseid, ecs_billboard){
|
||||||
|
.obj = mousei, .lookat = &render.camera.pos};
|
||||||
|
ECS_SETCOMPONENT(&ecs, mouseid, ecs_syncgrow){.obj = mousei,
|
||||||
|
.scale = &eworld->scaleto,
|
||||||
|
.basescale = mousei->scale.x,
|
||||||
|
.timer = &eworld->scaletimer};
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Actual rendering
|
// Actual rendering
|
||||||
|
Loading…
Reference in New Issue
Block a user