Merge branch 'main' of yibble.dev:bulmanator/ld58

This commit is contained in:
2025-10-07 14:09:59 +01:00
9 changed files with 187 additions and 52 deletions

View File

@@ -60,7 +60,7 @@ int main(int argc, char **argv)
G_AudioLoad(game);
Audio_Context *audio = M_ArenaPush(game->arena, Audio_Context);
Audio_Init(game->arena, audio, 0.15f);
Audio_Init(game->arena, audio, 0.0f); // disabled audio
U32 bgm = Audio_Play(audio, 0);
U32 saloon_music = Audio_Play(audio, 1);
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
camera->x = V3F(1, 0, 0);
camera->y = V3F(0, 1, 0);
camera->z = V3F(0, 0, 1);
camera->p = V3F(0, 0, 16);
camera->p = V3F(0, 0, 48);
camera->fov = 60.0f;
@@ -101,7 +101,7 @@ int main(int argc, char **argv)
npc1->mode = NPC_ACTION_WAITING;
npc1->currentArea = WORLD_AREA_OUTSIDE;
npc1->waitTime = 0;
npc1->maxWaitTime = 5;
npc1->maxWaitTime = 1;
npc1->currentNavNode = 0;
}
@@ -163,9 +163,9 @@ int main(int argc, char **argv)
world->propTypes = M_ArenaPush(arena, World_PropType, .count=WORLD_PROP_TYPE_MAX);
world->propTypes[0].tag=S("rug0");
world->propTypes[0].scale=1;
world->propTypes[0].scale=3;
world->propTypes[1].tag=S("rug1");
world->propTypes[1].scale=1;
world->propTypes[1].scale=3;
world->propTypes[2].tag=S("skull");
world->propTypes[2].scale=1;
world->propTypes[3].tag = S("table");
@@ -173,17 +173,17 @@ int main(int argc, char **argv)
world->propTypes[4].tag = S("barrel");
world->propTypes[4].scale=1;
world->propTypes[5].tag = S("can");
world->propTypes[5].scale=1;
world->propTypes[5].scale=0.5;
world->propTypes[6].tag = S("candle");
world->propTypes[6].scale=1;
world->propTypes[6].scale=0.5;
world->propTypes[7].tag = S("clock");
world->propTypes[7].scale=1;
world->propTypes[7].scale=1.5;
world->propTypes[8].tag = S("log_pile");
world->propTypes[8].scale=1;
world->propTypes[9].tag = S("nightstand");
world->propTypes[9].scale=1;
world->propTypes[10].tag = S("pool_table");
world->propTypes[10].scale=2;
world->propTypes[10].scale=3;
world->propTypes[11].tag = S("saloon_ext");
world->propTypes[11].scale=6.875f;
world->propTypes[12].tag = S("saloon_int");
@@ -191,7 +191,7 @@ int main(int argc, char **argv)
world->propTypes[13].tag = S("house");
world->propTypes[13].scale=6.875f;
world->propTypes[14].tag = S("house_int");
world->propTypes[14].scale=6.875f;
world->propTypes[14].scale=12.875f;
world->propTypes[15].tag=S("tile_detail_0");
world->propTypes[15].scale=1;
world->propTypes[16].tag = S("tile_detail_1");
@@ -208,12 +208,15 @@ int main(int argc, char **argv)
world->propTypes[21].scale=1;
world->propCount = 0;
world->props = M_ArenaPush(arena, World_Prop, .count=WORLD_PROP_MAX);
world->hitboxes = M_ArenaPush(arena, AABB, .count=WORLD_HITBOX_MAX);
world->hitboxes = M_ArenaPush(arena, World_Hitbox, .count=WORLD_HITBOX_MAX);
world->portals = M_ArenaPush(arena, World_Portal, .count=64);
world->portalCount=0;
GenerateNavMesh(arena, world);
}
game->editor.enabled = false;
game->editor.enabled = true;
game->editor.mode = G_EDITOR_MODE_TILE;
game->editor.currentLevel = WORLD_AREA_OUTSIDE;
game->editor.selectedNode = 0;
bool running = true;
@@ -263,20 +266,33 @@ int main(int argc, char **argv)
break;
}
case G_EDITOR_MODE_HITBOX: {
case G_EDITOR_MODE_PORTAL: {
game->editor.dragStart = game->editor.cursor;
break;
}
}
} else if(e.type==SDL_EVENT_MOUSE_BUTTON_UP && e.button.button == SDL_BUTTON_LEFT && game->editor.mode == G_EDITOR_MODE_HITBOX) {
}} else if(e.type==SDL_EVENT_MOUSE_BUTTON_UP && e.button.button == SDL_BUTTON_LEFT && game->editor.mode == G_EDITOR_MODE_HITBOX) {
// Add hitbox
V2f topLeft = V2F(Min(game->editor.cursor.x, game->editor.dragStart.x), Min(game->editor.cursor.y, game->editor.dragStart.y));
game->world->hitboxes[game->world->hitboxCount].pos = topLeft;
game->world->hitboxes[game->world->hitboxCount].size = V2F(
game->world->hitboxes[game->world->hitboxCount].box.pos = topLeft;
game->world->hitboxes[game->world->hitboxCount].box.size = V2F(
Abs(game->editor.cursor.x-game->editor.dragStart.x),
Abs(game->editor.cursor.y-game->editor.dragStart.y)
);
game->world->hitboxes[game->world->hitboxCount].area = game->editor.currentAsset;
game->world->hitboxCount++;
GenerateNavMesh(game->arena, game->world);
} else if(e.type==SDL_EVENT_MOUSE_BUTTON_UP && e.button.button == SDL_BUTTON_LEFT && game->editor.mode == G_EDITOR_MODE_PORTAL) {
// Add portal
V2f topLeft = V2F(Min(game->editor.cursor.x, game->editor.dragStart.x), Min(game->editor.cursor.y, game->editor.dragStart.y));
game->world->portals[game->world->portalCount].box.pos = topLeft;
game->world->portals[game->world->portalCount].box.size = V2F(
Abs(game->editor.cursor.x-game->editor.dragStart.x),
Abs(game->editor.cursor.y-game->editor.dragStart.y)
);
game->world->portals[game->world->portalCount].area = game->editor.currentAsset;
game->world->portalCount++;
GenerateNavMesh(game->arena, game->world);
}
}
@@ -288,10 +304,12 @@ int main(int argc, char **argv)
}
case SDLK_RIGHT: {
game->editor.currentAsset = Min(game->editor.currentAsset+1, 64);
printf("editing with %d\n", game->editor.currentAsset);
break;
}
case SDLK_LEFT: {
game->editor.currentAsset = Max(game->editor.currentAsset-1, 0);
printf("editing with %d\n", game->editor.currentAsset);
break;
}
case SDLK_A: {
@@ -320,6 +338,16 @@ int main(int argc, char **argv)
game->world->player.currentArea--;
break;
}
case SDLK_E: {
game->editor.selectedNode++;
printf("selected %d\n", game->editor.selectedNode);
break;
}
case SDLK_Q: {
game->editor.selectedNode--;
printf("selected %d\n", game->editor.selectedNode);
break;
}
case SDLK_SPACE: {
game->editor.mode = (game->editor.mode + 1) % 4;
printf("EDITOR MODE %d\n", game->editor.mode);
@@ -329,6 +357,7 @@ int main(int argc, char **argv)
switch(game->editor.mode) {
case G_EDITOR_MODE_PROP: {game->world->propCount--;}
case G_EDITOR_MODE_HITBOX: {game->world->hitboxCount--;}
case G_EDITOR_MODE_PORTAL: {game->world->portalCount--;}
}
break;
}
@@ -387,7 +416,39 @@ int main(int argc, char **argv)
G_Editor editor = game->editor;
F32 tilex = cast(F32) floor(editor.cursor.x+TILE_SIZE/2);
F32 tiley = cast(F32) floor(editor.cursor.y+TILE_SIZE/2);
for (U32 i = 0; i < game->world->navMesh->nodeCount; i++) {
NavNode n = game->world->navMesh->nodes[i];
D_Rect(
&game->draw,
n.pos.x,
n.pos.y,
.texture = 0,
.scale = 0.2f,
);
}
for (U32 i = 0; i < game->world->navMesh->nodeCount; i++) {
NavNode n = game->world->navMesh->nodes[i];
if(i == editor.selectedNode) {
D_Rect(
&game->draw,
n.pos.x,
n.pos.y,
.texture = 0,
.scale = 0.2f,
.c = V4F(100, 255, 0, 100),
);
for(int j = 0; j < n.connectionCount; j++) {
D_Rect(
&game->draw,
game->world->navMesh->nodes[n.connections[j].NodeIndex].pos.x,
game->world->navMesh->nodes[n.connections[j].NodeIndex].pos.y,
.texture = 0,
.scale = 0.2f,
.c = V4F(0, 100, 0, 100),
);
}
}
}
switch(game->editor.mode) {
case G_EDITOR_MODE_TILE: {
World_Tile asset = game->world->tileTypes[editor.currentAsset];
@@ -401,22 +462,36 @@ int main(int argc, char **argv)
}
case G_EDITOR_MODE_HITBOX: {
for(U32 i = 0; i < game->world->hitboxCount; i++) {
V2f centre = AABB_Centre(game->world->hitboxes[i]);
if(game->world->player.currentArea == game->world->hitboxes[i].area) {
V2f centre = AABB_Centre(game->world->hitboxes[i].box);
D_Rect(
&game->draw,
centre.x,
centre.y,
.texture=0,
.dim=game->world->hitboxes[i].box.size,
.flags=D_RECT_IGNORE_ASPECT,
.c=V4F(100,0,0,0.7f),
);
}
}
break;
}
case G_EDITOR_MODE_PORTAL: {
for(U32 i = 0; i < game->world->portalCount; i++) {
V2f centre = AABB_Centre(game->world->portals[i].box);
D_Rect(
&game->draw,
centre.x,
centre.y,
.texture=0,
.dim=game->world->hitboxes[i].size,
.dim=game->world->portals[i].box.size,
.flags=D_RECT_IGNORE_ASPECT,
.c=V4F(100,0,0,0.7f),
.c=V4F(0,0,100,0.7f),
);
}
break;
}
case G_EDITOR_MODE_POI: {
break;
}
}
}
D_End(&game->draw, frame);