Merge remote-tracking branch 'origin'
This commit is contained in:
62
code/first.c
62
code/first.c
@@ -26,15 +26,12 @@
|
||||
#include "game/impl/bandit.c"
|
||||
#include "game/testnavmesh.h"
|
||||
|
||||
const int width = 1280;
|
||||
const int height = 720;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)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;
|
||||
@@ -47,6 +44,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;
|
||||
@@ -54,11 +75,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;
|
||||
|
||||
@@ -115,10 +137,20 @@ int main(int argc, char **argv)
|
||||
world->player.currentArea = 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));
|
||||
|
||||
const int width = 1280;
|
||||
const int height = 720;
|
||||
|
||||
while (running)
|
||||
{
|
||||
SDL_Event e;
|
||||
@@ -130,13 +162,14 @@ int main(int argc, char **argv)
|
||||
}
|
||||
V3f projection = G_CameraUnproject(&game->camera, V2f_Clip(
|
||||
V2F(e.button.x, e.button.y),
|
||||
V2F(width, height)
|
||||
V2F((F32) width, (F32) height)
|
||||
));
|
||||
game->world->mouseProjected = V2F(projection.x, projection.y);
|
||||
ProcessEvents(&e, game->world);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -176,10 +209,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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user