Merge remote-tracking branch 'origin'

This commit is contained in:
2025-10-06 19:32:12 +01:00
65 changed files with 316 additions and 84 deletions

View File

@@ -78,6 +78,8 @@ int main(int argc, char **argv)
game->draw.arena = arena;
G_ImagesLoad(game);
//D_FontLoad(&game->draw, S("ubuntu"), 60);
G_PipelinesLoad(game);
G_AudioLoad(game);
@@ -86,7 +88,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, 48);
camera->p = V3F(0, 0, 16);
camera->fov = 60.0f;
@@ -95,10 +97,9 @@ int main(int argc, char **argv)
game->draw.camera = camera;
World *world = M_ArenaPush(arena, World);
//LoadWorld(arena, world);
LoadWorld(arena, world);
game->world = world;
world->arena = arena;
//world->navMesh = &TestNavMesh;
world->random = Random_Seed(29237489723847);
world->npcCount = 127;
for(U32 i = 0; i < world->npcCount; i++) {
@@ -125,17 +126,19 @@ int main(int argc, char **argv)
badman->waitTime = 0;
badman->maxWaitTime = 2;
badman->poiCount = 2;
badman->shootoutTimer = 1.5;
badman->agroRadius = 600.0;
badman->bullets = 6;
badman->shootDelay = 1;
badman->accuracyRange = 0.25;
badman->reloadTime = 2.5;
badman->reloadTimer = 0;
badman->pointsOfInterest[0] = 937;
badman->pointsOfInterest[1] = 12;
world->npcPOI[0] = 100;
world->player.world = world;
world->player.pos.x = 0;
world->player.pos.y = 0;
world->player.bulletsLoaded = PLAYER_BULLET_COUNT;
world->player.reloadTimer = 0;
world->player.currentArea = WORLD_AREA_OUTSIDE;
world->map = map;
PlayerInit(game, &world->player);
world->tileTypes = M_ArenaPush(arena, World_Tile, .count=WORLD_TILE_TYPE_MAX);
world->tileTypes[0].rotation=0;
@@ -223,13 +226,6 @@ int main(int argc, char **argv)
game->editor.mode = G_EDITOR_MODE_TILE;
game->editor.currentLevel = WORLD_AREA_OUTSIDE;
D_Animation animation;
{
U32 id = D_ImageHandle(&game->draw, S("npc_front_base_white"));
D_AnimationInit(&animation, id, 1, 4, 1.0f / 20.0f);
}
bool running = true;
const int width = 1280;
@@ -244,6 +240,13 @@ int main(int argc, char **argv)
{
running = false;
}
else if (e.type == SDL_EVENT_KEY_DOWN) {
Player *player = &game->world->player;
switch (e.key.key) {
case SDLK_R: { PlayerInit(game, player); } break;
}
}
V3f projection = G_CameraUnproject(&game->camera, V2f_Clip(
V2F(e.button.x, e.button.y),
V2F((F32) width, (F32) height)
@@ -258,8 +261,8 @@ int main(int argc, char **argv)
if(e.type==SDL_EVENT_MOUSE_BUTTON_DOWN && e.button.button == SDL_BUTTON_LEFT) {
switch(game->editor.mode){
case G_EDITOR_MODE_TILE: {
F32 tilex = (S32)(game->editor.cursor.x+TILE_SIZE/2);
F32 tiley = (S32)(game->editor.cursor.y+TILE_SIZE/2);
F32 tilex = (F32) (S32)(game->editor.cursor.x+TILE_SIZE/2);
F32 tiley = (F32) (S32)(game->editor.cursor.y+TILE_SIZE/2);
game->world->map[(S32)tilex + (S32)tiley * 96] = game->editor.currentAsset;
break;
}
@@ -276,7 +279,7 @@ int main(int argc, char **argv)
}
}
} else if(e.type==SDL_EVENT_MOUSE_BUTTON_UP && e.button.button == SDL_BUTTON_LEFT && game->editor.mode == G_EDITOR_MODE_HITBOX) {
// Add 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(
@@ -346,10 +349,10 @@ int main(int argc, char **argv)
if(!game->editor.enabled) {
UpdateWorld(1.0f / 60.0f, game->world);
game->camera.p.x = game->world->player.pos.x;
game->camera.p.y = game->world->player.pos.y;
}
D_AnimationUpdate(&animation, 1.0f / 250.0f);
game->camera.p.x = game->world->player.collision.pos.x;
game->camera.p.y = game->world->player.collision.pos.y;
}
int w, h;
SDL_GetWindowSizeInPixels(window, &w, &h);
@@ -389,13 +392,12 @@ int main(int argc, char **argv)
RenderWorld(game->world, &game->draw);
R2f aframe = D_AnimationFrame(&animation);
D_Rect(&game->draw, 0, 0, .texture = animation.id, .uv = aframe, .flags = D_RECT_UV_ASPECT);
//D_Text(&game->draw, game->draw.fonts, S("Small Test"), 0, 0);
if(game->editor.enabled) {
G_Editor editor = game->editor;
F32 tilex = floor(editor.cursor.x+TILE_SIZE/2);
F32 tiley = floor(editor.cursor.y+TILE_SIZE/2);
F32 tilex = cast(F32) floor(editor.cursor.x+TILE_SIZE/2);
F32 tiley = cast(F32) floor(editor.cursor.y+TILE_SIZE/2);
switch(game->editor.mode) {
case G_EDITOR_MODE_TILE: {
World_Tile asset = game->world->tileTypes[editor.currentAsset];
@@ -408,7 +410,7 @@ int main(int argc, char **argv)
break;
}
case G_EDITOR_MODE_HITBOX: {
for(int i = 0; i < game->world->hitboxCount; i++) {
for(U32 i = 0; i < game->world->hitboxCount; i++) {
V2f centre = AABB_Centre(game->world->hitboxes[i]);
D_Rect(
&game->draw,