maze is looking good!
This commit is contained in:
parent
c2ad4f64d2
commit
c69e82317b
2
haloo3d
2
haloo3d
@ -1 +1 @@
|
|||||||
Subproject commit a4b465b82d9d4160fbba59f7d61b749dea066a5a
|
Subproject commit eadd683885698be471fd5763b7a266786d6dec41
|
89
maze.c
89
maze.c
@ -303,12 +303,13 @@ typedef struct {
|
|||||||
int *timer;
|
int *timer;
|
||||||
} ecs_syncgrow;
|
} ecs_syncgrow;
|
||||||
|
|
||||||
// A component which has pointers back to global world state.
|
// A billboard for OUR system, which does not look up or down at the target. As
|
||||||
// typedef struct {
|
// such, no matter what the lookat is set to, y is always going to be equal to
|
||||||
// worldstate *state;
|
// the y of the instance, so it appears to be looking "straight"
|
||||||
// } ecs_worldstate;
|
typedef struct {
|
||||||
|
haloo3d_obj_instance *obj;
|
||||||
// #define MAXGROWERS 10
|
struct vec3 *lookat;
|
||||||
|
} ecs_billboard;
|
||||||
|
|
||||||
// A component which holds onto data specifically for world
|
// A component which holds onto data specifically for world
|
||||||
// entities. You can think of it as private data so people
|
// entities. You can think of it as private data so people
|
||||||
@ -325,6 +326,20 @@ typedef struct {
|
|||||||
// p->yaw += m->yawvel;
|
// p->yaw += m->yawvel;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
void sys_billboard(ecs_billboard *bb) {
|
||||||
|
// In our current system, the lookvec is the direction it wants to face, not a
|
||||||
|
// "lookat" point. To lookat something, you simply get the vector pointing
|
||||||
|
// towards it. Since we want them to never be looking up or down, y is luckily
|
||||||
|
// 0.
|
||||||
|
// NOTE: since we look towards the -z dir, we invert z. IDK if that's right
|
||||||
|
// but things spawn looking in the same direction as the camera, so turning it
|
||||||
|
// to face the player would make the texture backwards.
|
||||||
|
bb->obj->lookvec.x = -(bb->lookat->x - bb->obj->pos.x);
|
||||||
|
bb->obj->lookvec.y = 0;
|
||||||
|
bb->obj->lookvec.z = -(bb->lookat->z - bb->obj->pos.z);
|
||||||
|
// Why does inverting the lookvec do nothing??
|
||||||
|
}
|
||||||
|
|
||||||
void sys_syncgrow(ecs_syncgrow *sg) {
|
void sys_syncgrow(ecs_syncgrow *sg) {
|
||||||
// Only perform logic when a timer is running
|
// Only perform logic when a timer is running
|
||||||
if (*sg->timer) {
|
if (*sg->timer) {
|
||||||
@ -396,7 +411,7 @@ void sys_world(ecs_world *w) {
|
|||||||
w->scaletimer--;
|
w->scaletimer--;
|
||||||
if (w->scaletimer == 0) {
|
if (w->scaletimer == 0) {
|
||||||
eprintf("SPINUP COMPLETE, starting gameplay\n");
|
eprintf("SPINUP COMPLETE, starting gameplay\n");
|
||||||
// Start gameplay. We won't know when it's done
|
// w->scaletimer = 1;
|
||||||
w->state->state = WSTATE_GAMEPLAY;
|
w->state->state = WSTATE_GAMEPLAY;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -454,12 +469,12 @@ static void sys_smartai(ecs_smartai *smartai, ecs_placement *p,
|
|||||||
// Move startmarker to in front of player.
|
// Move startmarker to in front of player.
|
||||||
struct vec2i lookdir = dirtovec(smartai->dir);
|
struct vec2i lookdir = dirtovec(smartai->dir);
|
||||||
smartai->startmarker->pos.x = p->pos.x + lookdir.x;
|
smartai->startmarker->pos.x = p->pos.x + lookdir.x;
|
||||||
smartai->startmarker->pos.y = 0.0;
|
// smartai->startmarker->pos.y = 0.0;
|
||||||
smartai->startmarker->pos.z = p->pos.z + lookdir.y;
|
smartai->startmarker->pos.z = p->pos.z + lookdir.y;
|
||||||
vec3_subtract(smartai->startmarker->lookvec.v, p->pos.v,
|
// vec3_subtract(smartai->startmarker->lookvec.v, p->pos.v,
|
||||||
smartai->startmarker->pos.v);
|
// smartai->startmarker->pos.v);
|
||||||
// To not face up or down, always set y = 0;
|
// To not face up or down, always set y = 0;
|
||||||
smartai->startmarker->lookvec.y = 0;
|
// smartai->startmarker->lookvec.y = 0;
|
||||||
// Reset autonav + autorotate
|
// Reset autonav + autorotate
|
||||||
anav->dest = p->pos;
|
anav->dest = p->pos;
|
||||||
anav->timer = 0;
|
anav->timer = 0;
|
||||||
@ -554,7 +569,6 @@ static void sys_smartai(ecs_smartai *smartai, ecs_placement *p,
|
|||||||
|
|
||||||
// Setup ECS system for our game
|
// Setup ECS system for our game
|
||||||
ECS_START(mecs)
|
ECS_START(mecs)
|
||||||
// ECS_COMPONENT(ecs_worldstate);
|
|
||||||
ECS_COMPONENT(ecs_world);
|
ECS_COMPONENT(ecs_world);
|
||||||
ECS_COMPONENT(ecs_autonav);
|
ECS_COMPONENT(ecs_autonav);
|
||||||
ECS_COMPONENT(ecs_autorotate);
|
ECS_COMPONENT(ecs_autorotate);
|
||||||
@ -562,6 +576,7 @@ ECS_COMPONENT(ecs_placement);
|
|||||||
ECS_COMPONENT(ecs_camera);
|
ECS_COMPONENT(ecs_camera);
|
||||||
ECS_COMPONENT(ecs_smartai);
|
ECS_COMPONENT(ecs_smartai);
|
||||||
ECS_COMPONENT(ecs_syncgrow);
|
ECS_COMPONENT(ecs_syncgrow);
|
||||||
|
ECS_COMPONENT(ecs_billboard);
|
||||||
ECS_END(mecs)
|
ECS_END(mecs)
|
||||||
|
|
||||||
// And then a copy of the components here... that sucksssss
|
// And then a copy of the components here... that sucksssss
|
||||||
@ -573,9 +588,11 @@ ECS_CID(ecs_placement, 4);
|
|||||||
ECS_CID(ecs_camera, 5);
|
ECS_CID(ecs_camera, 5);
|
||||||
ECS_CID(ecs_smartai, 6);
|
ECS_CID(ecs_smartai, 6);
|
||||||
ECS_CID(ecs_syncgrow, 7);
|
ECS_CID(ecs_syncgrow, 7);
|
||||||
|
ECS_CID(ecs_billboard, 8);
|
||||||
|
|
||||||
ECS_SYSTEM1(mecs, sys_world, ecs_world);
|
ECS_SYSTEM1(mecs, sys_world, ecs_world);
|
||||||
ECS_SYSTEM1(mecs, sys_syncgrow, ecs_syncgrow);
|
ECS_SYSTEM1(mecs, sys_syncgrow, ecs_syncgrow);
|
||||||
|
ECS_SYSTEM1(mecs, sys_billboard, ecs_billboard);
|
||||||
ECS_SYSTEM2(mecs, sys_autonav, ecs_autonav, ecs_placement);
|
ECS_SYSTEM2(mecs, sys_autonav, ecs_autonav, ecs_placement);
|
||||||
ECS_SYSTEM2(mecs, sys_autorotate, ecs_autorotate, ecs_placement);
|
ECS_SYSTEM2(mecs, sys_autorotate, ecs_autorotate, ecs_placement);
|
||||||
ECS_SYSTEM2(mecs, sys_camera, ecs_camera, ecs_placement);
|
ECS_SYSTEM2(mecs, sys_camera, ecs_camera, ecs_placement);
|
||||||
@ -608,9 +625,47 @@ void init_walltexture(haloo3d_fb *wallt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init_starttexture(haloo3d_fb *startt) {
|
void init_starttexture(haloo3d_fb *startt) {
|
||||||
haloo3d_fb_init_tex(startt, 64, 64);
|
haloo3d_fb_init_tex(startt, 64, 128);
|
||||||
haloo3d_recti rect = {.x1 = 20, .x2 = 44, .y1 = 24, .y2 = 40};
|
haloo3d_recti rect = {.x1 = 4, .x2 = 60, .y1 = 58, .y2 = 71};
|
||||||
haloo3d_apply_rect(startt, &rect, 0xF777, 1);
|
// Create a temporary printing system just to print to this. IDK, maybe I'll
|
||||||
|
// make this betterin the future
|
||||||
|
haloo3d_print_tracker pt;
|
||||||
|
const uint16_t bgcol = 0xF888;
|
||||||
|
char buf[64];
|
||||||
|
uint8_t dither[8];
|
||||||
|
haloo3d_print_initdefault(&pt, buf, sizeof(buf));
|
||||||
|
pt.bcolor = 0; // Full transparency
|
||||||
|
pt.fb = startt;
|
||||||
|
// haloo3d_getdither4x4(0.75, dither);
|
||||||
|
// haloo3d_apply_fillrect(startt, &rect, 0xFAAA, dither);
|
||||||
|
int pbx = rect.x2 - 42;
|
||||||
|
int pby = rect.y1 + 2;
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
int x = -1 + (i % 3);
|
||||||
|
int y = -1 + (i / 3);
|
||||||
|
pt.fcolor = bgcol;
|
||||||
|
pt.x = pbx + x;
|
||||||
|
pt.y = pby + y;
|
||||||
|
haloo3d_print(&pt, "START");
|
||||||
|
}
|
||||||
|
pt.fcolor = 0xF222;
|
||||||
|
pt.x = pbx;
|
||||||
|
pt.y = pby;
|
||||||
|
haloo3d_print(&pt, "START");
|
||||||
|
uint16_t binbows[4] = {0xF6C5, 0xFF63, 0xFFC0, 0xF48D};
|
||||||
|
haloo3d_getdither4x4(1, dither);
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
int x = rect.x1 + 2 + 5 * (i % 2);
|
||||||
|
int y = rect.y1 + 2 + 5 * (i / 2);
|
||||||
|
haloo3d_recti wrect = {.x1 = x, .x2 = x + 4, .y1 = y, .y2 = y + 4};
|
||||||
|
haloo3d_apply_fillrect(startt, &wrect, binbows[i], dither);
|
||||||
|
}
|
||||||
|
haloo3d_apply_rect(startt, &rect, bgcol, 1);
|
||||||
|
rect.x1--;
|
||||||
|
rect.x2++;
|
||||||
|
rect.y1--;
|
||||||
|
rect.y2++;
|
||||||
|
haloo3d_apply_rect(startt, &rect, 0xF222, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_mazeinstances(haloo3d_obj_instance *floori,
|
void init_mazeinstances(haloo3d_obj_instance *floori,
|
||||||
@ -632,6 +687,7 @@ void init_mazeinstances(haloo3d_obj_instance *floori,
|
|||||||
walli->pos.x += MAZESIZE / 2.0 * HSCALE;
|
walli->pos.x += MAZESIZE / 2.0 * HSCALE;
|
||||||
walli->pos.z += MAZESIZE / 2.0 * HSCALE;
|
walli->pos.z += MAZESIZE / 2.0 * HSCALE;
|
||||||
ceili->pos.y = 1;
|
ceili->pos.y = 1;
|
||||||
|
starti->pos.y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() { // int argc, char **argv) {
|
int main() { // int argc, char **argv) {
|
||||||
@ -750,6 +806,8 @@ int main() { // int argc, char **argv) {
|
|||||||
ecs_eid startid = mecs_newentity(&ecs, 0);
|
ecs_eid startid = mecs_newentity(&ecs, 0);
|
||||||
ECS_SETCOMPONENT(&ecs, startid, ecs_syncgrow){
|
ECS_SETCOMPONENT(&ecs, startid, ecs_syncgrow){
|
||||||
.obj = starti, .scale = &eworld->scaleto, .timer = &eworld->scaletimer};
|
.obj = starti, .scale = &eworld->scaleto, .timer = &eworld->scaletimer};
|
||||||
|
ECS_SETCOMPONENT(&ecs, startid, ecs_billboard){.obj = starti,
|
||||||
|
.lookat = &render.camera.pos};
|
||||||
|
|
||||||
// Player is ofc most complicated
|
// Player is ofc most complicated
|
||||||
ecs_eid playerid = mecs_newentity(&ecs, 0);
|
ecs_eid playerid = mecs_newentity(&ecs, 0);
|
||||||
@ -815,6 +873,7 @@ int main() { // int argc, char **argv) {
|
|||||||
sys_autonav_run(&ecs, i);
|
sys_autonav_run(&ecs, i);
|
||||||
sys_autorotate_run(&ecs, i);
|
sys_autorotate_run(&ecs, i);
|
||||||
sys_camera_run(&ecs, i);
|
sys_camera_run(&ecs, i);
|
||||||
|
sys_billboard_run(&ecs, i);
|
||||||
}
|
}
|
||||||
haloo3d_easytimer_end(&logictimer);
|
haloo3d_easytimer_end(&logictimer);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user