Added animations

Added new assets for the player
Added lookups for assets
Initial sound testing
Re-enabled temp world drawing
This commit is contained in:
2025-10-06 00:52:16 +01:00
parent 3eb8683ce3
commit c721839dfa
30 changed files with 210 additions and 20 deletions

View File

@@ -32,7 +32,7 @@ int main(int argc, char **argv)
(void)argc;
(void)argv;
if (!SDL_Init(SDL_INIT_VIDEO))
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO))
{
printf("[Error] :: Failed to initialise SDL3 (%s)\n", SDL_GetError());
return 1;
@@ -45,6 +45,30 @@ int main(int argc, char **argv)
return 1;
}
SDL_AudioStream *austream;
Str8 audio_data;
M_TempScope(0, 0) {
SDL_AudioSpec spec;
spec.format = SDL_AUDIO_S16LE;
spec.channels = 2;
spec.freq = 44100;
austream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, 0, 0);
if (!austream) {
printf("Failed to open audio stream (%s)\n", SDL_GetError());
}
Str8 exec = FS_SystemPath(temp.arena, FS_SYSTEM_PATH_EXE);
Str8 path = Sf(temp.arena, "%.*s/assets/outside_ambience.wav", Sv(exec));
SDL_AudioSpec wav_spec;
U32 count;
SDL_LoadWAV((const char *) path.data, &wav_spec, &audio_data.data, &count);
audio_data.count = count;
}
Vk_Setup(window);
G_State *game = 0;
@@ -52,11 +76,12 @@ int main(int argc, char **argv)
M_Arena *arena = M_ArenaAlloc(GB(64), .initial = MB(4));
game = M_ArenaPush(arena, G_State);
game->arena = arena;
game->arena = arena;
game->draw.arena = arena;
G_ImagesLoad(game);
G_PipelinesLoad(game);
G_AudioLoad(game);
G_Camera *camera = &game->camera;
@@ -113,6 +138,13 @@ int main(int argc, char **argv)
world->player.reloadTimer = 0;
}
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;
printf("%zu size in bytes\n", sizeof(TestNavMesh));
@@ -131,6 +163,7 @@ int main(int argc, char **argv)
}
UpdateWorld(1.0f / 60.0f, game->world);
D_AnimationUpdate(&animation, 1.0f / 250.0f);
game->camera.p.x = game->world->player.pos.x;
game->camera.p.y = game->world->player.pos.y;
@@ -170,10 +203,15 @@ int main(int argc, char **argv)
D_Begin(&game->draw, frame, D_MAX_RECTS);
RenderWorld(game->world, &game->draw);
D_Rect(&game->draw, 0.0f, 0.0f, .texture = 1);
D_Rect(&game->draw, -8.0f, 0.0f, .texture = 2, .scale = 2.0f);
D_Rect(&game->draw, 6.0f, 0.0f, .texture = 3);
//RenderWorld(game->world, &game->draw);
// D_Rect(&game->draw, 0.0f, 0.0f, .texture = D_ImageHandle(&game->draw, S("saloon_ext")), .scale = 4.0f);
// D_Rect(&game->draw, -8.0f, 0.0f, .texture = 2, .scale = 2.0f);
// D_Rect(&game->draw, 6.0f, 0.0f, .texture = 3);
G_WorldDraw(game, game->world);
R2f aframe = D_AnimationFrame(&animation);
D_Rect(&game->draw, 0, 0, .texture = animation.id, .uv = aframe, .flags = D_RECT_UV_ASPECT);
D_End(&game->draw, frame);