Skip to content

Commit

Permalink
music viz anim
Browse files Browse the repository at this point in the history
  • Loading branch information
redthing1 committed Jul 16, 2021
1 parent 1335001 commit f974aba
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
3 changes: 3 additions & 0 deletions demo/DuskDemo/asset/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ atl_logo_0.img.bin: atl_logo_0.png
atl_thred_0.img.bin: atl_thred_0.png
grit "$<" $(GRIT_FLAGS) -Mh 8 -Mw 8 -o "$@"

atl_mus_0.img.bin: atl_mus_0.png
grit "$<" $(GRIT_FLAGS) -Mh 8 -Mw 8 -o "$@"

$(ATLS_PNG): $(ATLS_OUT)
@true

Expand Down
Binary file added demo/DuskDemo/asset/img/mus/musviz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 22 additions & 2 deletions demo/DuskDemo/src/scenes/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "soundbank.h"

mm_sound_effect boom;
Sprite* vizspr;
Anim vz_anim1;

void audio_start() {
dusk_init_graphics_mode0();
Expand All @@ -31,6 +33,19 @@ void audio_start() {
boom.volume = 255;
boom.panning = 255;

// load sprite atlas
dusk_sprites_init();
SpriteAtlas atlas = dusk_load_atlas("atl_mus");
dusk_sprites_upload_atlas(&atlas);

vizspr = dusk_sprites_make(0, 64, 64,
(Sprite){
.x = SCREEN_WIDTH / 2 - 32,
.y = SCREEN_HEIGHT / 2 - 32,
.tid = 0,
});
vz_anim1 = MAKE_ANIM(0, 16);

// init text engine
REG_DISPCNT |= DCNT_BG1;
tte_init_chr4c(1, BG_CBB(0) | BG_SBB(31), 0, 0x0201, CLR_GRAY, NULL, NULL);
Expand All @@ -41,15 +56,20 @@ void audio_start() {
}

void audio_update() {
dusk_frame(); // video frame
mmFrame(); // audio frame
dusk_frame(); // video frame
mmFrame(); // audio frame

dusk_sprites_anim_play(vizspr, &vz_anim1);

int a_press = key_is_down(KEY_A);

if (a_press) {
// play sfx
mmEffectEx(&boom);
}

// update sprites
dusk_sprites_update();
}

void audio_end() {
Expand Down
6 changes: 3 additions & 3 deletions demo/DuskDemo/src/scenes/thred.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "tonc.h"

Sprite* thred;
Anim anim1;
Anim th_anim1;

void thred_start() {
dusk_init_graphics_mode0();
Expand All @@ -21,7 +21,7 @@ void thred_start() {
.page = 0,
});

anim1 = MAKE_ANIM(0, 16);
th_anim1 = MAKE_ANIM(0, 16);

// ----------

Expand All @@ -36,7 +36,7 @@ void thred_start() {
void thred_update() {
dusk_frame();

dusk_sprites_anim_play(thred, &anim1);
dusk_sprites_anim_play(thred, &th_anim1);

// update sprites
dusk_sprites_update();
Expand Down

0 comments on commit f974aba

Please sign in to comment.