fix logo bounce, adjust music a bit
This commit is contained in:
parent
17dd2a23a3
commit
272e0bc615
7 changed files with 50 additions and 36 deletions
|
|
@ -76,10 +76,18 @@
|
||||||
:logo (do
|
:logo (do
|
||||||
(set logo-x (+ logo-x (* logo-dx dt)))
|
(set logo-x (+ logo-x (* logo-dx dt)))
|
||||||
(set logo-y (+ logo-y (* logo-dy dt)))
|
(set logo-y (+ logo-y (* logo-dy dt)))
|
||||||
(when (or (< logo-x 0) (> logo-x 512))
|
(when (< logo-x 0)
|
||||||
(set logo-dx (- logo-dx)))
|
(set logo-x 0)
|
||||||
(when (or (< logo-y 0) (> logo-y 296))
|
(set logo-dx (math.abs logo-dx)))
|
||||||
(set logo-dy (- logo-dy))))
|
(when (> logo-x 512)
|
||||||
|
(set logo-x 512)
|
||||||
|
(set logo-dx (- (math.abs logo-dx))))
|
||||||
|
(when (< logo-y 0)
|
||||||
|
(set logo-y 0)
|
||||||
|
(set logo-dy (math.abs logo-dy)))
|
||||||
|
(when (> logo-y 296)
|
||||||
|
(set logo-y 296)
|
||||||
|
(set logo-dy (- (math.abs logo-dy)))))
|
||||||
:worldgen (worldgen.update dt))
|
:worldgen (worldgen.update dt))
|
||||||
|
|
||||||
(music.update dt)
|
(music.update dt)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,27 @@
|
||||||
|
;; ============================================================================
|
||||||
|
;; Theme in A minor
|
||||||
|
;; Key: Am | Tempo: 95 BPM | Time: 4/4
|
||||||
|
;; ============================================================================
|
||||||
|
;;
|
||||||
|
;; Melody (Triangle, A4 range):
|
||||||
|
;; Bar 1: A4~ .C5 | E5 D5 | C5 A4 | G4 A4 |
|
||||||
|
;; Bar 2: A4~ .C5 | E5 G5 | F5 E5 | D5~~~~ |
|
||||||
|
;; Bar 3: D5~ .E5 | F5 D5 | C5 A4 | G4 A4 |
|
||||||
|
;; Bar 4: C5~ .D5 | E5 C5 | A4 G4 | A4~~~~ |
|
||||||
|
;;
|
||||||
|
;; Bass (Triangle, A2 range, octave jumps):
|
||||||
|
;; | A2 A2 A3 A2 | A2 A3 A2 A3 | C3 C3 C4 C3 | C3 C4 C3 C4 |
|
||||||
|
;; | D3 D3 D4 D3 | D3 D4 D3 D4 | A2 A2 A3 A2 | A2 A3 E3 A2 |
|
||||||
|
;;
|
||||||
|
;; Legend: ~ = held note, . = sixteenth rest before
|
||||||
|
;; ============================================================================
|
||||||
|
|
||||||
(local pxl8 (require :pxl8))
|
(local pxl8 (require :pxl8))
|
||||||
|
|
||||||
(var time 0)
|
(var time 0)
|
||||||
(var step 0)
|
(var step 0)
|
||||||
(var ctx nil)
|
(var ctx nil)
|
||||||
(var melody-params nil)
|
(var melody-params nil)
|
||||||
(var harmony-params nil)
|
|
||||||
(var bass-params nil)
|
(var bass-params nil)
|
||||||
(var playing false)
|
(var playing false)
|
||||||
|
|
||||||
|
|
@ -13,7 +30,7 @@
|
||||||
(local sixteenth (/ beat 4))
|
(local sixteenth (/ beat 4))
|
||||||
(local eighth (/ beat 2))
|
(local eighth (/ beat 2))
|
||||||
(local quarter beat)
|
(local quarter beat)
|
||||||
(local whole (* 4 beat))
|
(local _whole (* 4 beat))
|
||||||
|
|
||||||
(local melody [[69 eighth] [0 sixteenth] [72 sixteenth]
|
(local melody [[69 eighth] [0 sixteenth] [72 sixteenth]
|
||||||
[76 eighth] [74 eighth]
|
[76 eighth] [74 eighth]
|
||||||
|
|
@ -35,11 +52,6 @@
|
||||||
[69 eighth] [67 eighth]
|
[69 eighth] [67 eighth]
|
||||||
[69 quarter]])
|
[69 quarter]])
|
||||||
|
|
||||||
(local harmony [[57 whole] ; A3
|
|
||||||
[60 whole] ; C4
|
|
||||||
[62 whole] ; D4
|
|
||||||
[57 whole]]) ; A3
|
|
||||||
|
|
||||||
(local bass [[45 eighth] [45 eighth] [57 eighth] [45 eighth]
|
(local bass [[45 eighth] [45 eighth] [57 eighth] [45 eighth]
|
||||||
[45 eighth] [57 eighth] [45 eighth] [57 eighth]
|
[45 eighth] [57 eighth] [45 eighth] [57 eighth]
|
||||||
[48 eighth] [48 eighth] [60 eighth] [48 eighth]
|
[48 eighth] [48 eighth] [60 eighth] [48 eighth]
|
||||||
|
|
@ -53,6 +65,14 @@
|
||||||
|
|
||||||
(fn init []
|
(fn init []
|
||||||
(set ctx (pxl8.sfx_context_create))
|
(set ctx (pxl8.sfx_context_create))
|
||||||
|
|
||||||
|
(local reverb (pxl8.sfx_reverb_create
|
||||||
|
{:room 0.5 :damping 0.4 :mix 0.35}))
|
||||||
|
(local compressor (pxl8.sfx_compressor_create
|
||||||
|
{:threshold -18 :ratio 6 :attack 3 :release 100}))
|
||||||
|
(pxl8.sfx_context_append_node ctx reverb)
|
||||||
|
(pxl8.sfx_context_append_node ctx compressor)
|
||||||
|
|
||||||
(pxl8.sfx_mixer_attach ctx)
|
(pxl8.sfx_mixer_attach ctx)
|
||||||
|
|
||||||
(set melody-params (pxl8.sfx_voice_params
|
(set melody-params (pxl8.sfx_voice_params
|
||||||
|
|
@ -60,21 +80,14 @@
|
||||||
:attack 0.02 :decay 0.15 :sustain 0.5 :release 0.15
|
:attack 0.02 :decay 0.15 :sustain 0.5 :release 0.15
|
||||||
:filter_type pxl8.SFX_FILTER_LOWPASS
|
:filter_type pxl8.SFX_FILTER_LOWPASS
|
||||||
:filter_cutoff 4000 :filter_resonance 0.0
|
:filter_cutoff 4000 :filter_resonance 0.0
|
||||||
:fx_send 0.0}))
|
:fx_send 0.4}))
|
||||||
|
|
||||||
(set harmony-params (pxl8.sfx_voice_params
|
|
||||||
{:waveform pxl8.SFX_WAVE_TRIANGLE
|
|
||||||
:attack 0.05 :decay 0.2 :sustain 0.3 :release 0.2
|
|
||||||
:filter_type pxl8.SFX_FILTER_LOWPASS
|
|
||||||
:filter_cutoff 2500 :filter_resonance 0.0
|
|
||||||
:fx_send 0.0}))
|
|
||||||
|
|
||||||
(set bass-params (pxl8.sfx_voice_params
|
(set bass-params (pxl8.sfx_voice_params
|
||||||
{:waveform pxl8.SFX_WAVE_TRIANGLE
|
{:waveform pxl8.SFX_WAVE_TRIANGLE
|
||||||
:attack 0.015 :decay 0.1 :sustain 0.7 :release 0.1
|
:attack 0.015 :decay 0.1 :sustain 0.7 :release 0.1
|
||||||
:filter_type pxl8.SFX_FILTER_LOWPASS
|
:filter_type pxl8.SFX_FILTER_LOWPASS
|
||||||
:filter_cutoff 1200 :filter_resonance 0.0
|
:filter_cutoff 1800 :filter_resonance 0.0
|
||||||
:fx_send 0.0})))
|
:fx_send 0.15})))
|
||||||
|
|
||||||
(fn start []
|
(fn start []
|
||||||
(set playing true)
|
(set playing true)
|
||||||
|
|
@ -98,13 +111,6 @@
|
||||||
(when (> melody-note 0)
|
(when (> melody-note 0)
|
||||||
(pxl8.sfx_play_note ctx melody-note melody-params 0.45 melody-dur))
|
(pxl8.sfx_play_note ctx melody-note melody-params 0.45 melody-dur))
|
||||||
|
|
||||||
(local bar (math.floor (/ step 32)))
|
|
||||||
(local harmony-idx (+ 1 (% bar (length harmony))))
|
|
||||||
(local harmony-entry (. harmony harmony-idx))
|
|
||||||
(local harmony-note (. harmony-entry 1))
|
|
||||||
(when (= (% step 32) 0)
|
|
||||||
(pxl8.sfx_play_note ctx harmony-note harmony-params 0.25 whole))
|
|
||||||
|
|
||||||
(local bass-step (math.floor (/ step 2)))
|
(local bass-step (math.floor (/ step 2)))
|
||||||
(local bass-idx (+ 1 (% bass-step (length bass))))
|
(local bass-idx (+ 1 (% bass-step (length bass))))
|
||||||
(local bass-entry (. bass bass-idx))
|
(local bass-entry (. bass bass-idx))
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@ function anim.play(a)
|
||||||
C.pxl8_anim_play(a)
|
C.pxl8_anim_play(a)
|
||||||
end
|
end
|
||||||
|
|
||||||
function anim.render_sprite(a, x, y, w, h)
|
function anim.render_sprite(a, x, y, w, h, flip_x, flip_y)
|
||||||
C.pxl8_anim_render_sprite(a, core.gfx, x, y, w, h)
|
C.pxl8_anim_render_sprite(a, core.gfx, x, y, w, h, flip_x or false, flip_y or false)
|
||||||
end
|
end
|
||||||
|
|
||||||
function anim.reset(a)
|
function anim.reset(a)
|
||||||
|
|
|
||||||
|
|
@ -284,11 +284,11 @@ void pxl8_anim_play(pxl8_anim* anim) {
|
||||||
anim->playing = true;
|
anim->playing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pxl8_anim_render_sprite(const pxl8_anim* anim, pxl8_gfx* gfx, i32 x, i32 y, i32 w, i32 h) {
|
void pxl8_anim_render_sprite(const pxl8_anim* anim, pxl8_gfx* gfx, i32 x, i32 y, i32 w, i32 h, bool flip_x, bool flip_y) {
|
||||||
if (!anim || !gfx) return;
|
if (!anim || !gfx) return;
|
||||||
|
|
||||||
u32 sprite_id = pxl8_anim_get_current_frame_id(anim);
|
u32 sprite_id = pxl8_anim_get_current_frame_id(anim);
|
||||||
pxl8_sprite(gfx, sprite_id, x, y, w, h);
|
pxl8_sprite(gfx, sprite_id, x, y, w, h, flip_x, flip_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pxl8_anim_reset(pxl8_anim* anim) {
|
void pxl8_anim_reset(pxl8_anim* anim) {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ bool pxl8_anim_is_complete(const pxl8_anim* anim);
|
||||||
bool pxl8_anim_is_playing(const pxl8_anim* anim);
|
bool pxl8_anim_is_playing(const pxl8_anim* anim);
|
||||||
void pxl8_anim_pause(pxl8_anim* anim);
|
void pxl8_anim_pause(pxl8_anim* anim);
|
||||||
void pxl8_anim_play(pxl8_anim* anim);
|
void pxl8_anim_play(pxl8_anim* anim);
|
||||||
void pxl8_anim_render_sprite(const pxl8_anim* anim, pxl8_gfx* gfx, i32 x, i32 y, i32 w, i32 h);
|
void pxl8_anim_render_sprite(const pxl8_anim* anim, pxl8_gfx* gfx, i32 x, i32 y, i32 w, i32 h, bool flip_x, bool flip_y);
|
||||||
void pxl8_anim_reset(pxl8_anim* anim);
|
void pxl8_anim_reset(pxl8_anim* anim);
|
||||||
void pxl8_anim_set_frame(pxl8_anim* anim, u16 frame);
|
void pxl8_anim_set_frame(pxl8_anim* anim, u16 frame);
|
||||||
void pxl8_anim_set_loop(pxl8_anim* anim, bool loop);
|
void pxl8_anim_set_loop(pxl8_anim* anim, bool loop);
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ static const char* pxl8_ffi_cdefs =
|
||||||
"bool pxl8_anim_is_playing(const pxl8_anim* anim);\n"
|
"bool pxl8_anim_is_playing(const pxl8_anim* anim);\n"
|
||||||
"void pxl8_anim_pause(pxl8_anim* anim);\n"
|
"void pxl8_anim_pause(pxl8_anim* anim);\n"
|
||||||
"void pxl8_anim_play(pxl8_anim* anim);\n"
|
"void pxl8_anim_play(pxl8_anim* anim);\n"
|
||||||
"void pxl8_anim_render_sprite(const pxl8_anim* anim, pxl8_gfx* gfx, i32 x, i32 y, i32 w, i32 h);\n"
|
"void pxl8_anim_render_sprite(const pxl8_anim* anim, pxl8_gfx* gfx, i32 x, i32 y, i32 w, i32 h, bool flip_x, bool flip_y);\n"
|
||||||
"void pxl8_anim_reset(pxl8_anim* anim);\n"
|
"void pxl8_anim_reset(pxl8_anim* anim);\n"
|
||||||
"void pxl8_anim_set_frame(pxl8_anim* anim, u16 frame);\n"
|
"void pxl8_anim_set_frame(pxl8_anim* anim, u16 frame);\n"
|
||||||
"void pxl8_anim_set_loop(pxl8_anim* anim, bool loop);\n"
|
"void pxl8_anim_set_loop(pxl8_anim* anim, bool loop);\n"
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
#define PXL8_SFX_BUFFER_SIZE 1024
|
#define PXL8_SFX_BUFFER_SIZE 1024
|
||||||
#define PXL8_SFX_MAX_CONTEXTS 8
|
#define PXL8_SFX_MAX_CONTEXTS 8
|
||||||
#define PXL8_SFX_MAX_DELAY_SAMPLES 44100
|
#define PXL8_SFX_MAX_DELAY_SAMPLES 48000
|
||||||
#define PXL8_SFX_MAX_VOICES 16
|
#define PXL8_SFX_MAX_VOICES 16
|
||||||
#define PXL8_SFX_SAMPLE_RATE 44100
|
#define PXL8_SFX_SAMPLE_RATE 48000
|
||||||
|
|
||||||
typedef struct pxl8_sfx_context pxl8_sfx_context;
|
typedef struct pxl8_sfx_context pxl8_sfx_context;
|
||||||
typedef struct pxl8_sfx_mixer pxl8_sfx_mixer;
|
typedef struct pxl8_sfx_mixer pxl8_sfx_mixer;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue