Back to shtanton's homepage
summaryrefslogtreecommitdiff
path: root/src/all.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/all.c')
-rw-r--r--src/all.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/all.c b/src/all.c
index 7955b90..15f2558 100644
--- a/src/all.c
+++ b/src/all.c
@@ -139,7 +139,7 @@ static DrawList *render(State *state, UI *ui, Arena *a) {
.h = cellHeight,
.fill = {255, 0, 0, 63},
.border = {255, 0, 0, 255},
- .image = 5,
+ .image = 1,
};
drawList->els[drawList->len++] = (DrawElement) {
@@ -229,6 +229,10 @@ typedef struct {
SDL_Texture *textures[sizeof(images) / sizeof(images[0])];
+#include "../build/music.c"
+
+SDL_AudioStream *stream;
+
int main(int argc, char **argv) {
(void) argc;
(void) argv;
@@ -252,7 +256,7 @@ int main(int argc, char **argv) {
game->state.buttonStates[i] = BUTTON_STATE_IDLE;
}
- SDL_Init(SDL_INIT_VIDEO);
+ SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
SDL_Window *w = SDL_CreateWindow(
"LDJam 57",
game->ui.width,
@@ -282,6 +286,15 @@ int main(int argc, char **argv) {
}
SDL_UpdateTexture(textures[j], NULL, pixels, images[j].width * 4);
}
+
+ SDL_AudioSpec audioSpec = {
+ .format = SDL_AUDIO_S16LE,
+ .channels = 2,
+ .freq = 48000,
+ };
+ stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &audioSpec, NULL, NULL);
+ SDL_PutAudioStreamData(stream, musicBytes, sizeof(musicBytes));
+ SDL_ResumeAudioStreamDevice(stream);
for (;;) {
uint64_t now = SDL_GetTicks();
@@ -351,6 +364,10 @@ int main(int argc, char **argv) {
update(game, now, a);
+ if (SDL_GetAudioStreamQueued(stream) < (int) sizeof(musicBytes) / 8) {
+ SDL_PutAudioStreamData(stream, musicBytes, sizeof(musicBytes));
+ }
+
SDL_RenderPresent(r);
}