diff --git a/audio/sfx_toggle_button.wav b/audio/sfx_toggle_button.wav new file mode 100644 index 0000000..cf637f1 Binary files /dev/null and b/audio/sfx_toggle_button.wav differ diff --git a/graphics/bg_w0_s0_0.bmp b/graphics/bg_w0_s0_0.bmp index a5098b3..1f74904 100644 Binary files a/graphics/bg_w0_s0_0.bmp and b/graphics/bg_w0_s0_0.bmp differ diff --git a/graphics/spr_hover_button.bmp b/graphics/spr_hover_button.bmp index 1b1513d..20afe2d 100644 Binary files a/graphics/spr_hover_button.bmp and b/graphics/spr_hover_button.bmp differ diff --git a/graphics_source/bg_w0_s0_0.tmx b/graphics_source/bg_w0_s0_0.tmx index a9c6c39..41b4936 100644 --- a/graphics_source/bg_w0_s0_0.tmx +++ b/graphics_source/bg_w0_s0_0.tmx @@ -1,5 +1,5 @@ - + @@ -96,41 +96,41 @@ 729,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 728,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 727,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -726,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -725,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -724,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +721,722,723,724,725,726,727,728,729,730,721,722,723,724,725,726,727,728,729,730,721,722,723,724,725,726,727,728,729,730,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +722,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 723,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -722,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -721,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +724,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +725,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +726,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +727,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +728,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +729,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +730,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +721,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 722,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -721,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -730,731,731,731,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -729,731,731,731,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -728,731,731,731,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -727,731,731,731,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -726,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -725,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +726,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +727,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +728,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +729,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -730,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -729,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,81,81,81,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -728,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -727,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -726,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -725,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -724,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +723,731,731,731,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +728,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,81,81,81,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +729,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +730,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +721,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +722,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 723,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -722,723,724,725,726,727,728,729,730,721,722,723,724,725,726,727,728,729,730,721,722,723,724,725,726,727,728,729,730,721,722,723,724,725,726,727,728,729,730,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +724,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +725,723,724,725,726,727,728,729,730,721,722,723,724,725,726,727,728,729,730,721,722,723,724,725,726,727,728,729,730,721,722,723,724,725,726,727,728,729,730,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 @@ -270,10 +270,19 @@ - - - - + + + + + + + + + + + + + diff --git a/graphics_source/spr_hover_button.aseprite b/graphics_source/spr_hover_button.aseprite index 9abcfed..4e1767f 100644 Binary files a/graphics_source/spr_hover_button.aseprite and b/graphics_source/spr_hover_button.aseprite differ diff --git a/include/game_entity_Door.h b/include/game_entity_Door.h index 229c78e..f3fe8dd 100644 --- a/include/game_entity_Door.h +++ b/include/game_entity_Door.h @@ -16,7 +16,7 @@ class Door final : public IOpenableEntity * * @param textNumber number which is shown above the door. */ - Door(bn::fixed_point position, bool isOpened, int textNumber); + Door(bn::fixed_point position, bool isOpenedByDefault, int textNumber); Door(Door&& other) = delete; Door& operator=(Door&& other) = delete; @@ -29,11 +29,18 @@ class Door final : public IOpenableEntity void Update() final; - void InitDoorOpenAction(); - void InitDoorCloseAction(); + /** + * @brief Toggle opened (also animates door) + * + * @return `true` if the door is opened + */ + [[maybe_unused]] bool ToggleOpened() final; private: bn::optional> action_; + + void InitDoorOpenAction_(); + void InitDoorCloseAction_(); }; } // namespace sym::game::entity diff --git a/include/game_entity_HoverButton.h b/include/game_entity_HoverButton.h index 2256d54..8ce4338 100644 --- a/include/game_entity_HoverButton.h +++ b/include/game_entity_HoverButton.h @@ -24,11 +24,21 @@ class HoverButton final : public IButtonEntity void Update() final; - void InitButtonOnAction(); - void InitButtonOffAction(); + [[nodiscard]] bool CanButtonBeToggled() final; + /** + * @brief Toggles button (and also animates it) + * + * `CanButtonBeToggled()` needs to be checked first before using this function. + * + * @return `true` if button is on + */ + [[maybe_unused]] bool ToggleButtonOn() final; private: bn::optional> action_; + + void InitButtonOnAction_(); + void InitButtonOffAction_(); }; } // namespace sym::game::entity diff --git a/include/game_entity_IButtonEntity.h b/include/game_entity_IButtonEntity.h index 6ec1883..1c36c94 100644 --- a/include/game_entity_IButtonEntity.h +++ b/include/game_entity_IButtonEntity.h @@ -20,8 +20,16 @@ class IButtonEntity : public INumberTextEntity IButtonEntity(const IButtonEntity& other) = delete; IButtonEntity& operator=(const IButtonEntity& other) = delete; - bool GetButtonOn() const; - void SetButtonOn(bool isButtonOn); + [[nodiscard]] bool GetButtonOn() const; + // void SetButtonOn(bool isButtonOn); + [[nodiscard]] virtual bool CanButtonBeToggled() = 0; + /** + * @brief `CanButtonBeToggled()` needs to be checked first before using this function. + * `IButtonEntity::ToggleButtonOn()` must be called somewhere in the Button implementation. + * + * @return `true` if button is on + */ + [[maybe_unused]] virtual bool ToggleButtonOn() = 0; private: bool isButtonOn_; diff --git a/include/game_entity_INumberTextEntity.h b/include/game_entity_INumberTextEntity.h index 774b237..38ea240 100644 --- a/include/game_entity_INumberTextEntity.h +++ b/include/game_entity_INumberTextEntity.h @@ -24,7 +24,7 @@ class INumberTextEntity : public IEntity void SetCamera(const bn::camera_ptr& camera); -private: +protected: bn::optional numberSprite_; int textNumber_; bn::fixed_point relativeNumberTextPosition_; diff --git a/include/game_entity_IOpenableEntity.h b/include/game_entity_IOpenableEntity.h index 85c0ed8..57d5956 100644 --- a/include/game_entity_IOpenableEntity.h +++ b/include/game_entity_IOpenableEntity.h @@ -11,20 +11,29 @@ class IOpenableEntity : public INumberTextEntity virtual ~IOpenableEntity() = 0; IOpenableEntity(bn::fixed_point position, bn::fixed_rect relativeInteractRange, int textNumber, - bn::fixed_point relativeNumberTextPosition, bool isOpened, + bn::fixed_point relativeNumberTextPosition, bool isOpenedByDefault, const bn::sprite_item* spriteItem = nullptr); - IOpenableEntity(IOpenableEntity&& other); - IOpenableEntity& operator=(IOpenableEntity&& other); + IOpenableEntity(IOpenableEntity&& other) = delete; + IOpenableEntity& operator=(IOpenableEntity&& other) = delete; IOpenableEntity(const IOpenableEntity& other) = delete; IOpenableEntity& operator=(const IOpenableEntity& other) = delete; - bool GetOpened() const; - void SetOpened(bool); - [[maybe_unused]] bool ToggleOpened(); + void AllocateGraphicResource(int z_order) override; -private: + [[nodiscard]] bool GetOpened() const; + // void SetOpened(bool); + + /** + * @brief `IOpenableEntity::ToggleOpened()` must be called somewhere in the Openable implementation. + * + * @return `true` if it is opened + */ + [[maybe_unused]] virtual bool ToggleOpened() = 0; + +protected: + const bool isOpenedByDefault_; bool isOpened_; }; diff --git a/include/game_entity_Player.h b/include/game_entity_Player.h index b16399a..296f27d 100644 --- a/include/game_entity_Player.h +++ b/include/game_entity_Player.h @@ -2,7 +2,6 @@ #include "game_entity_IGravityEntity.h" -#include #include namespace sym::game::entity @@ -30,15 +29,15 @@ class Player final : public IGravityEntity void InitMergeStartAction(); void InitMergeEndAction(); -private: - static constexpr bn::fixed_rect RELATIVE_INTERACT_RANGE = {{0, 0}, {32, 32}}; - static constexpr bn::fixed_rect RELATIVE_PHYSICS_COLLIDER = {{0, 0}, {26, 26}}; - static constexpr bool IS_GRAVITY_ENABLED_BY_DEFAULT = true; - static constexpr bn::fixed GRAVITY_SCALE = 1; - - static constexpr int IDLE_ACTION_WAIT_UPDATE = 30; - static constexpr int OTHER_ACTIONS_WAIT_UPDATE = 10; + [[nodiscard]] bn::fixed_rect GetLeftSymbolPickupRange() const; + [[nodiscard]] bn::fixed_rect GetRightSymbolPickupRange() const; + [[nodiscard]] bn::fixed_rect GetLeftButtonInteractRange() const; + [[nodiscard]] bn::fixed_rect GetRightButtonInteractRange() const; + [[nodiscard]] bn::fixed_point GetLeftSymbolPosition() const; + [[nodiscard]] bn::fixed_point GetRightSymbolPosition() const; + [[nodiscard]] bn::fixed_point GetMergeSymbolPosition() const; +private: bn::optional> action2_; bn::optional> action3_; /** @@ -49,6 +48,12 @@ class Player final : public IGravityEntity */ int additionalWaitUpdateCount = -1; + /** + * @brief Updates action. + * + * @return `true` if action is done, otherwise `false` + */ + bool UpdateAction_(); void DestroyActions_(); }; diff --git a/include/game_entity_PressureButton.h b/include/game_entity_PressureButton.h index 3d35aab..9741e52 100644 --- a/include/game_entity_PressureButton.h +++ b/include/game_entity_PressureButton.h @@ -24,11 +24,21 @@ class PressureButton final : public IButtonEntity void Update() final; - void InitButtonOnAction(); - void InitButtonOffAction(); + [[nodiscard]] bool CanButtonBeToggled() final; + /** + * @brief Toggles button (and also animates it) + * + * `CanButtonBeToggled()` needs to be checked first before using this function. + * + * @return `true` if button is on + */ + [[maybe_unused]] bool ToggleButtonOn() final; private: bn::optional> action_; + + void InitButtonOnAction_(); + void InitButtonOffAction_(); }; } // namespace sym::game::entity diff --git a/include/game_entity_Shutter.h b/include/game_entity_Shutter.h index 2f2db8a..18cd785 100644 --- a/include/game_entity_Shutter.h +++ b/include/game_entity_Shutter.h @@ -16,7 +16,7 @@ class Shutter final : public IOpenableEntity * * @param textNumber number which is shown above the Shutter. */ - Shutter(bn::fixed_point position, bool isOpened, int textNumber); + Shutter(bn::fixed_point position, bool isOpenedByDefault, int textNumber); Shutter(Shutter&& other) = delete; Shutter& operator=(Shutter&& other) = delete; @@ -29,11 +29,18 @@ class Shutter final : public IOpenableEntity void Update() final; - void InitShutterOpenAction(); - void InitShutterCloseAction(); + /** + * @brief Toggle opened (also animates shutter) + * + * @return `true` if the shutter is opened + */ + [[maybe_unused]] bool ToggleOpened() final; private: bn::optional> action_; + + void InitShutterOpenAction_(); + void InitShutterCloseAction_(); }; } // namespace sym::game::entity diff --git a/include/game_system_ButtonInteraction.h b/include/game_system_ButtonInteraction.h new file mode 100644 index 0000000..86f833c --- /dev/null +++ b/include/game_system_ButtonInteraction.h @@ -0,0 +1,31 @@ +#pragma once + +#include "game_system_ISystem.h" + +namespace sym::game::system +{ + +class ButtonInteraction final : public ISystem +{ +public: + ButtonInteraction(scene::GameState& state); + + void Update() final; + +private: + static constexpr int KEYPRESS_LASTING_UPDATE_COUNT = 5; + int lKeyLastingCount = -1; + int rKeyLastingCount = -1; + + void HoverButtonPlayerInteract_(); + void HoverButtonThrownSymbolInteract_(); + + void UpdateKeyLastingCount_(); + bool IsLKeyPressLasts_() const; + bool IsRKeyPressLasts_() const; + void ResetLKeyPress_(); + void ResetRKeyPress_(); + void ToggleOpenedHoverButtonAssociatedOpenables_(int hoverButtonIdx); +}; + +} // namespace sym::game::system diff --git a/include/game_system_ISystem.h b/include/game_system_ISystem.h new file mode 100644 index 0000000..2351bcd --- /dev/null +++ b/include/game_system_ISystem.h @@ -0,0 +1,22 @@ +#pragma once + +#include "scene_GameState.h" + +namespace sym::game::system +{ + +class ISystem +{ +public: + virtual ~ISystem() = default; + ISystem(scene::GameState& state) : state_(state) + { + } + + virtual void Update() = 0; + +protected: + scene::GameState& state_; +}; + +} // namespace sym::game::system diff --git a/include/game_system_PlayerMovement.h b/include/game_system_PlayerMovement.h new file mode 100644 index 0000000..36ce6ff --- /dev/null +++ b/include/game_system_PlayerMovement.h @@ -0,0 +1,18 @@ +#pragma once + +#include "game_system_ISystem.h" + +namespace sym::game::system +{ + +class PlayerMovement final : public ISystem +{ +public: + PlayerMovement(scene::GameState& state); + + void Update() final; + +private: +}; + +} // namespace sym::game::system diff --git a/include/scene_Game.h b/include/scene_Game.h index 3c39cd9..c54e808 100644 --- a/include/scene_Game.h +++ b/include/scene_Game.h @@ -2,34 +2,18 @@ #include "scene_IScene.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "effect_Transition.h" -#include "game_Status.h" -#include "game_entity_Door.h" -#include "game_entity_HoverButton.h" -#include "game_entity_Player.h" -#include "game_entity_PressureButton.h" -#include "game_entity_Shutter.h" -#include "game_entity_Symbol.h" -#include "game_stage_Id.h" -#include "game_stage_StageInfo.h" +#include "game_system_ButtonInteraction.h" +#include "game_system_PlayerMovement.h" +#include "scene_GameState.h" namespace sym::scene { +using namespace game; class Game final : public IScene { public: - Game(game::Status& status); + Game(scene::Param& sceneParam); ~Game(); [[nodiscard]] bn::optional Update() final; @@ -38,36 +22,15 @@ class Game final : public IScene static constexpr int FADE_IN_UPDATE_COUNT = 30; static constexpr int FADE_OUT_UPDATE_COUNT = 30; - static constexpr int ZONE_MAX_COUNT = 8; - static constexpr int STAGE_SYMBOL_MAX_COUNT = 16; - static constexpr int ZONE_HOVER_BUTTON_MAX_COUNT = 4; - static constexpr int ZONE_PRESSURE_BUTTON_MAX_COUNT = 4; - static constexpr int ZONE_DOOR_MAX_COUNT = 4; - static constexpr int ZONE_SHUTTER_MAX_COUNT = 4; - - game::Status& status_; - const game::stage::StageInfo& stageInfo_; - - effect::Transition fadeIn_; - effect::Transition fadeOut_; - - int currentZoneIdx_; - bn::affine_bg_ptr currentMapBg_; - - bn::camera_ptr camera_; - bn::fixed_rect zoneBoundary_; - - // Movable entities. - game::entity::Player player_; - bn::vector, ZONE_MAX_COUNT> symbolsOfZones_; - bn::array, 2> symbolsInHands_; + /** + * @brief All member variables reside in here. + * to easily pass states by reference into Systems. + * + */ + GameState state_; - // Fixed entities. - bn::vector, ZONE_MAX_COUNT> doorsOfZones_; - bn::vector, ZONE_MAX_COUNT> shuttersOfZones_; - bn::vector, ZONE_MAX_COUNT> hoverButtonsOfZones_; - bn::vector, ZONE_MAX_COUNT> - pressureButtonsOfZones_; + system::PlayerMovement playerMovement_; + system::ButtonInteraction buttonInteraction_; void SetCurrentZone_(int zoneIdx); }; diff --git a/include/scene_GameState.h b/include/scene_GameState.h new file mode 100644 index 0000000..a2b3f73 --- /dev/null +++ b/include/scene_GameState.h @@ -0,0 +1,65 @@ +#pragma once + +#include +#include +#include + +#include "effect_Transition.h" +#include "game_entity_Door.h" +#include "game_entity_HoverButton.h" +#include "game_entity_Player.h" +#include "game_entity_PressureButton.h" +#include "game_entity_Shutter.h" +#include "game_stage_StageInfo.h" +#include "scene_Param.h" + +namespace sym::scene +{ + +namespace +{ + +constexpr int ZONE_MAX_COUNT = 8; +constexpr int STAGE_SYMBOL_MAX_COUNT = 16; +constexpr int ZONE_HOVER_BUTTON_MAX_COUNT = 8; +constexpr int ZONE_PRESSURE_BUTTON_MAX_COUNT = 8; +constexpr int ZONE_DOOR_MAX_COUNT = 8; +constexpr int ZONE_SHUTTER_MAX_COUNT = 8; + +} // namespace + +/** + * @brief All scene::Game member variables reside in here. + * to easily pass states by reference into Systems. + * + */ +struct GameState +{ + scene::Param& sceneParam_; + const game::stage::StageInfo& stageInfo; + + effect::Transition fadeIn; + effect::Transition fadeOut; + + int currentZoneIdx; + bn::affine_bg_ptr currentMapBg; + + bn::camera_ptr camera; + bn::fixed_rect zoneBoundary; + + // Movable entities. + game::entity::Player player; + bn::vector, ZONE_MAX_COUNT> symbolsOfZones; + bn::array, 2> symbolsInHands; + + // Fixed entities. + bn::vector, ZONE_MAX_COUNT> doorsOfZones; + bn::vector, ZONE_MAX_COUNT> shuttersOfZones; + bn::vector, ZONE_MAX_COUNT> hoverButtonsOfZones; + bn::vector, ZONE_MAX_COUNT> + pressureButtonsOfZones; + + bool isMenuPopup; +}; + +} // namespace sym::scene diff --git a/include/scene_IScene.h b/include/scene_IScene.h index 100b407..ea92891 100644 --- a/include/scene_IScene.h +++ b/include/scene_IScene.h @@ -2,6 +2,7 @@ #include +#include "scene_Param.h" #include "scene_Type.h" namespace sym::scene @@ -11,10 +12,14 @@ class IScene { public: virtual ~IScene() = default; + IScene(scene::Param& sceneParam) : sceneParam_(sceneParam) + { + } + [[nodiscard]] virtual bn::optional Update() = 0; protected: - IScene() = default; + scene::Param& sceneParam_; }; } // namespace sym::scene diff --git a/include/game_Status.h b/include/scene_Param.h similarity index 82% rename from include/game_Status.h rename to include/scene_Param.h index 6ad7b41..ae53da0 100644 --- a/include/game_Status.h +++ b/include/scene_Param.h @@ -2,10 +2,10 @@ #include "game_stage_Id.h" -namespace sym::game +namespace sym::scene { -class Status +class Param { public: void SetCurrentStage(game::stage::Id stage) @@ -21,4 +21,4 @@ class Status game::stage::Id currentStage_; }; -} // namespace sym::game +} // namespace sym::scene diff --git a/include/scene_Splash.h b/include/scene_Splash.h index aaef73c..cdad617 100644 --- a/include/scene_Splash.h +++ b/include/scene_Splash.h @@ -14,7 +14,7 @@ namespace sym::scene class Splash final : public IScene { public: - Splash(); + Splash(scene::Param& sceneParam); ~Splash(); [[nodiscard]] bn::optional Update() final; diff --git a/include/scene_Title.h b/include/scene_Title.h index b287ae2..42d71d5 100644 --- a/include/scene_Title.h +++ b/include/scene_Title.h @@ -20,7 +20,7 @@ namespace sym::scene class Title final : public IScene { public: - Title(); + Title(scene::Param& sceneParam); ~Title(); [[nodiscard]] bn::optional Update() final; diff --git a/license/sfx_toggle_button.txt b/license/sfx_toggle_button.txt new file mode 100644 index 0000000..c062f90 --- /dev/null +++ b/license/sfx_toggle_button.txt @@ -0,0 +1,4 @@ +Sound name : button +Made by : Leszek_Szary +Link : https://freesound.org/people/Leszek_Szary/sounds/171521/ +License : CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/) diff --git a/src/game_entity_Door.cpp b/src/game_entity_Door.cpp index 72628a6..7b61e3b 100644 --- a/src/game_entity_Door.cpp +++ b/src/game_entity_Door.cpp @@ -28,8 +28,8 @@ constexpr int CLOSED_GRAPHICS_INDEX = 0; } // namespace -Door::Door(bn::fixed_point position, bool isOpened, int textNumber) - : IOpenableEntity(position, RELATIVE_INTERACT_RANGE, textNumber, RELATIVE_NUMBER_TEXT_POS, isOpened, +Door::Door(bn::fixed_point position, bool isOpenedByDefault, int textNumber) + : IOpenableEntity(position, RELATIVE_INTERACT_RANGE, textNumber, RELATIVE_NUMBER_TEXT_POS, isOpenedByDefault, &bn::sprite_items::spr_door) { } @@ -54,14 +54,25 @@ void Door::Update() action_->update(); } -void Door::InitDoorOpenAction() +bool Door::ToggleOpened() +{ + const bool isOpenedBefore = GetOpened(); + IOpenableEntity::ToggleOpened(); + if (isOpenedBefore) + InitDoorCloseAction_(); + else + InitDoorOpenAction_(); + return !isOpenedBefore; +} + +void Door::InitDoorOpenAction_() { BN_ASSERT(sprite_, "Door action cannot be init without allocating graphics!"); action_ = bn::create_sprite_animate_action_once(*sprite_, WAIT_UPDATES, bn::sprite_items::spr_door.tiles_item(), 0, 1, 2, 3); } -void Door::InitDoorCloseAction() +void Door::InitDoorCloseAction_() { BN_ASSERT(sprite_, "Door action cannot be init without allocating graphics!"); action_ = bn::create_sprite_animate_action_once(*sprite_, WAIT_UPDATES, bn::sprite_items::spr_door.tiles_item(), 3, diff --git a/src/game_entity_HoverButton.cpp b/src/game_entity_HoverButton.cpp index f1e4aa4..3dd34ae 100644 --- a/src/game_entity_HoverButton.cpp +++ b/src/game_entity_HoverButton.cpp @@ -52,14 +52,30 @@ void HoverButton::Update() action_->update(); } -void HoverButton::InitButtonOnAction() +bool HoverButton::CanButtonBeToggled() +{ + return !action_ || action_->done(); +} + +bool HoverButton::ToggleButtonOn() +{ + const bool isButtonOnBefore = GetButtonOn(); + IButtonEntity::ToggleButtonOn(); + if (isButtonOnBefore) + InitButtonOffAction_(); + else + InitButtonOnAction_(); + return !isButtonOnBefore; +} + +void HoverButton::InitButtonOnAction_() { BN_ASSERT(sprite_, "HoverButton action cannot be init without allocating graphics!"); action_ = bn::create_sprite_animate_action_once(*sprite_, WAIT_UPDATES, bn::sprite_items::spr_hover_button.tiles_item(), 2, 3); } -void HoverButton::InitButtonOffAction() +void HoverButton::InitButtonOffAction_() { BN_ASSERT(sprite_, "HoverButton action cannot be init without allocating graphics!"); action_ = bn::create_sprite_animate_action_once(*sprite_, WAIT_UPDATES, diff --git a/src/game_entity_IButtonEntity.cpp b/src/game_entity_IButtonEntity.cpp index 0b336ed..71b526f 100644 --- a/src/game_entity_IButtonEntity.cpp +++ b/src/game_entity_IButtonEntity.cpp @@ -1,5 +1,7 @@ #include "game_entity_IButtonEntity.h" +#include + namespace sym::game::entity { @@ -30,9 +32,15 @@ bool IButtonEntity::GetButtonOn() const return isButtonOn_; } -void IButtonEntity::SetButtonOn(bool isButtonOn) +// void IButtonEntity::SetButtonOn(bool isButtonOn) +// { +// isButtonOn_ = isButtonOn; +// } + +bool IButtonEntity::ToggleButtonOn() { - isButtonOn_ = isButtonOn; + BN_ASSERT(CanButtonBeToggled(), "Button can't be toggled when action is not done"); + return isButtonOn_ = !isButtonOn_; } } // namespace sym::game::entity diff --git a/src/game_entity_IOpenableEntity.cpp b/src/game_entity_IOpenableEntity.cpp index 9c2a171..361dbfd 100644 --- a/src/game_entity_IOpenableEntity.cpp +++ b/src/game_entity_IOpenableEntity.cpp @@ -6,23 +6,21 @@ namespace sym::game::entity IOpenableEntity::~IOpenableEntity() = default; IOpenableEntity::IOpenableEntity(bn::fixed_point position, bn::fixed_rect relativeInteractRange, int textNumber, - bn::fixed_point relativeNumberTextPosition, bool isOpened, + bn::fixed_point relativeNumberTextPosition, bool isOpenedByDefault, const bn::sprite_item* spriteItem) : INumberTextEntity(position, relativeInteractRange, textNumber, relativeNumberTextPosition, spriteItem), - isOpened_(isOpened) + isOpenedByDefault_(isOpenedByDefault), isOpened_(isOpenedByDefault) { } -IOpenableEntity::IOpenableEntity(IOpenableEntity&& other) - : INumberTextEntity(bn::move(other)), isOpened_(other.isOpened_) +void IOpenableEntity::AllocateGraphicResource(int z_order) { -} - -IOpenableEntity& IOpenableEntity::operator=(IOpenableEntity&& other) -{ - INumberTextEntity::operator=(bn::move(other)); - isOpened_ = other.isOpened_; - return *this; + INumberTextEntity::AllocateGraphicResource(z_order); + if (isOpenedByDefault_) + { + numberSprite_->set_horizontal_flip(true); + numberSprite_->set_vertical_flip(true); + } } bool IOpenableEntity::GetOpened() const @@ -30,10 +28,10 @@ bool IOpenableEntity::GetOpened() const return isOpened_; } -void IOpenableEntity::SetOpened(bool isOpened) -{ - isOpened_ = isOpened; -} +// void IOpenableEntity::SetOpened(bool isOpened) +// { +// isOpened_ = isOpened; +// } bool IOpenableEntity::ToggleOpened() { diff --git a/src/game_entity_Player.cpp b/src/game_entity_Player.cpp index 42a7304..b61a646 100644 --- a/src/game_entity_Player.cpp +++ b/src/game_entity_Player.cpp @@ -4,10 +4,39 @@ #include #include "bn_sprite_items_spr_ingame_protagonist_star.h" +#include "helper_rect.h" namespace sym::game::entity { +namespace +{ + +constexpr int SPRITE_WIDTH = bn::sprite_items::spr_ingame_protagonist_star.shape_size().width(); +constexpr int SPRITE_HEIGHT = bn::sprite_items::spr_ingame_protagonist_star.shape_size().height(); + +constexpr bn::fixed_rect RELATIVE_INTERACT_RANGE = {{0, 0}, {32, 32}}; +constexpr bn::fixed_rect RELATIVE_LEFT_SYMBOL_PICKUP_RANGE = + helper::rect::MakeFixedRectByTopLeftAndSize({0 - SPRITE_WIDTH / 2, 0 - SPRITE_HEIGHT / 2}, {23, 32}); +constexpr bn::fixed_rect RELATIVE_RIGHT_SYMBOL_PICKUP_RANGE = + helper::rect::MakeFixedRectByTopLeftAndSize({9 - SPRITE_WIDTH / 2, 0 - SPRITE_HEIGHT / 2}, {23, 32}); +constexpr bn::fixed_rect RELATIVE_LEFT_BUTTON_INTERACT_RANGE = + helper::rect::MakeFixedRectByTopLeftAndSize({2 - SPRITE_WIDTH / 2, 9 - SPRITE_HEIGHT / 2}, {9, 11}); +constexpr bn::fixed_rect RELATIVE_RIGHT_BUTTON_INTERACT_RANGE = + helper::rect::MakeFixedRectByTopLeftAndSize({21 - SPRITE_WIDTH / 2, 9 - SPRITE_HEIGHT / 2}, {9, 11}); +constexpr bn::fixed_point RELATIVE_LEFT_SYMBOL_POS = {-12, 2.5}; +constexpr bn::fixed_point RELATIVE_RIGHT_SYMBOL_POS = {12, 2.5}; +constexpr bn::fixed_point RELATIVE_MERGE_SYMBOL_POS = {0, -21}; + +constexpr bn::fixed_rect RELATIVE_PHYSICS_COLLIDER = {{0, 0}, {26, 26}}; +constexpr bool IS_GRAVITY_ENABLED_BY_DEFAULT = true; +constexpr bn::fixed GRAVITY_SCALE = 1; + +constexpr int IDLE_ACTION_WAIT_UPDATE = 30; +constexpr int OTHER_ACTIONS_WAIT_UPDATE = 10; + +} // namespace + Player::Player(bn::fixed_point position) : IGravityEntity(position, RELATIVE_INTERACT_RANGE, RELATIVE_PHYSICS_COLLIDER, IS_GRAVITY_ENABLED_BY_DEFAULT, GRAVITY_SCALE, &bn::sprite_items::spr_ingame_protagonist_star) @@ -24,23 +53,7 @@ void Player::Update() { IGravityEntity::Update(); - bool isActionDone = true; - if (action2_) - { - if (!action2_->done()) - { - action2_->update(); - isActionDone = false; - } - } - else if (action3_) - { - if (!action3_->done()) - { - action3_->update(); - isActionDone = false; - } - } + bool isActionDone = UpdateAction_(); if (isActionDone && additionalWaitUpdateCount >= 0) { @@ -101,6 +114,67 @@ void Player::InitMergeEndAction() additionalWaitUpdateCount = OTHER_ACTIONS_WAIT_UPDATE; } +bn::fixed_rect Player::GetLeftSymbolPickupRange() const +{ + using helper::rect::operator+; + return position_ + RELATIVE_LEFT_SYMBOL_PICKUP_RANGE; +} + +bn::fixed_rect Player::GetRightSymbolPickupRange() const +{ + using helper::rect::operator+; + return position_ + RELATIVE_RIGHT_SYMBOL_PICKUP_RANGE; +} + +bn::fixed_rect Player::GetLeftButtonInteractRange() const +{ + using helper::rect::operator+; + return position_ + RELATIVE_LEFT_BUTTON_INTERACT_RANGE; +} + +bn::fixed_rect Player::GetRightButtonInteractRange() const +{ + using helper::rect::operator+; + return position_ + RELATIVE_RIGHT_BUTTON_INTERACT_RANGE; +} + +bn::fixed_point Player::GetLeftSymbolPosition() const +{ + return position_ + RELATIVE_LEFT_SYMBOL_POS; +} + +bn::fixed_point Player::GetRightSymbolPosition() const +{ + return position_ + RELATIVE_RIGHT_SYMBOL_POS; +} + +bn::fixed_point Player::GetMergeSymbolPosition() const +{ + return position_ + RELATIVE_MERGE_SYMBOL_POS; +} + +bool Player::UpdateAction_() +{ + bool isActionDone = true; + if (action2_) + { + if (!action2_->done()) + { + action2_->update(); + isActionDone = false; + } + } + else if (action3_) + { + if (!action3_->done()) + { + action3_->update(); + isActionDone = false; + } + } + return isActionDone; +} + void Player::DestroyActions_() { additionalWaitUpdateCount = -1; diff --git a/src/game_entity_PressureButton.cpp b/src/game_entity_PressureButton.cpp index 2f545e2..89b4abb 100644 --- a/src/game_entity_PressureButton.cpp +++ b/src/game_entity_PressureButton.cpp @@ -52,14 +52,30 @@ void PressureButton::Update() action_->update(); } -void PressureButton::InitButtonOnAction() +bool PressureButton::CanButtonBeToggled() +{ + return !action_ || action_->done(); +} + +bool PressureButton::ToggleButtonOn() +{ + const bool isButtonOnBefore = GetButtonOn(); + IButtonEntity::ToggleButtonOn(); + if (isButtonOnBefore) + InitButtonOffAction_(); + else + InitButtonOnAction_(); + return !isButtonOnBefore; +} + +void PressureButton::InitButtonOnAction_() { BN_ASSERT(sprite_, "PressureButton action cannot be init without allocating graphics!"); action_ = bn::create_sprite_animate_action_once(*sprite_, WAIT_UPDATES, bn::sprite_items::spr_pressure_button.tiles_item(), 1, 2); } -void PressureButton::InitButtonOffAction() +void PressureButton::InitButtonOffAction_() { BN_ASSERT(sprite_, "PressureButton action cannot be init without allocating graphics!"); action_ = bn::create_sprite_animate_action_once(*sprite_, WAIT_UPDATES, diff --git a/src/game_entity_Shutter.cpp b/src/game_entity_Shutter.cpp index 58e42a9..de2022b 100644 --- a/src/game_entity_Shutter.cpp +++ b/src/game_entity_Shutter.cpp @@ -28,8 +28,8 @@ constexpr int CLOSED_GRAPHICS_INDEX = 0; } // namespace -Shutter::Shutter(bn::fixed_point position, bool isOpened, int textNumber) - : IOpenableEntity(position, RELATIVE_INTERACT_RANGE, textNumber, RELATIVE_NUMBER_TEXT_POS, isOpened, +Shutter::Shutter(bn::fixed_point position, bool isOpenedByDefault, int textNumber) + : IOpenableEntity(position, RELATIVE_INTERACT_RANGE, textNumber, RELATIVE_NUMBER_TEXT_POS, isOpenedByDefault, &bn::sprite_items::spr_shutter) { } @@ -54,14 +54,25 @@ void Shutter::Update() action_->update(); } -void Shutter::InitShutterOpenAction() +bool Shutter::ToggleOpened() +{ + const bool isOpenedBefore = GetOpened(); + IOpenableEntity::ToggleOpened(); + if (isOpenedBefore) + InitShutterCloseAction_(); + else + InitShutterOpenAction_(); + return !isOpenedBefore; +} + +void Shutter::InitShutterOpenAction_() { BN_ASSERT(sprite_, "Shutter action cannot be init without allocating graphics!"); action_ = bn::create_sprite_animate_action_once(*sprite_, WAIT_UPDATES, bn::sprite_items::spr_shutter.tiles_item(), 0, 1, 2, 3); } -void Shutter::InitShutterCloseAction() +void Shutter::InitShutterCloseAction_() { BN_ASSERT(sprite_, "Shutter action cannot be init without allocating graphics!"); action_ = bn::create_sprite_animate_action_once(*sprite_, WAIT_UPDATES, bn::sprite_items::spr_shutter.tiles_item(), diff --git a/src/game_stage_W0_S0.cpp b/src/game_stage_W0_S0.cpp index a73d3b1..efaed75 100644 --- a/src/game_stage_W0_S0.cpp +++ b/src/game_stage_W0_S0.cpp @@ -25,19 +25,28 @@ constexpr ZoneInfo::SymbolInfo Z0_symbolInfos_[] = { }; constexpr ZoneInfo::DoorInfo Z0_doorInfos_[] = { - {{115 - MAP_DIMENSIONS[0].width() / 2, 857 - MAP_DIMENSIONS[0].height() / 2}, false, -1, -1, 1}, + {{87 - MAP_DIMENSIONS[0].width() / 2, 849 - MAP_DIMENSIONS[0].height() / 2}, false, -1, -1, 1}, + {{55 - MAP_DIMENSIONS[0].width() / 2, 849 - MAP_DIMENSIONS[0].height() / 2}, true, -1, -1, 1}, + {{87 - MAP_DIMENSIONS[0].width() / 2, 792 - MAP_DIMENSIONS[0].height() / 2}, false, -1, -1, 2}, + {{55 - MAP_DIMENSIONS[0].width() / 2, 792 - MAP_DIMENSIONS[0].height() / 2}, true, -1, -1, 2}, }; constexpr ZoneInfo::ShutterInfo Z0_shutterInfos_[] = { - {{256 - MAP_DIMENSIONS[0].width() / 2, 792 - MAP_DIMENSIONS[0].height() / 2}, false, 2}, + {{256 - MAP_DIMENSIONS[0].width() / 2, 792 - MAP_DIMENSIONS[0].height() / 2}, false, 0}, + {{135 - MAP_DIMENSIONS[0].width() / 2, 849 - MAP_DIMENSIONS[0].height() / 2}, false, 1}, + {{119 - MAP_DIMENSIONS[0].width() / 2, 849 - MAP_DIMENSIONS[0].height() / 2}, true, 1}, + {{135 - MAP_DIMENSIONS[0].width() / 2, 792 - MAP_DIMENSIONS[0].height() / 2}, false, 2}, + {{119 - MAP_DIMENSIONS[0].width() / 2, 792 - MAP_DIMENSIONS[0].height() / 2}, true, 2}, }; constexpr ZoneInfo::ButtonInfo Z0_hoverButtonInfos_[] = { - {{92 - MAP_DIMENSIONS[0].width() / 2, 962 - MAP_DIMENSIONS[0].height() / 2}, false, 1}, + {{92 - MAP_DIMENSIONS[0].width() / 2, 962 - MAP_DIMENSIONS[0].height() / 2}, false, 0}, + {{167 - MAP_DIMENSIONS[0].width() / 2, 849 - MAP_DIMENSIONS[0].height() / 2}, false, 1}, + {{167 - MAP_DIMENSIONS[0].width() / 2, 792 - MAP_DIMENSIONS[0].height() / 2}, false, 2}, }; constexpr ZoneInfo::ButtonInfo Z0_pressureButtonInfos_[] = { - {{136 - MAP_DIMENSIONS[0].width() / 2, 984 - MAP_DIMENSIONS[0].height() / 2}, false, 2}, + {{136 - MAP_DIMENSIONS[0].width() / 2, 984 - MAP_DIMENSIONS[0].height() / 2}, false, 3}, }; constexpr ZoneInfo::EntranceInfo Z0_entranceInfos_[] = { diff --git a/src/game_system_ButtonInteraction.cpp b/src/game_system_ButtonInteraction.cpp new file mode 100644 index 0000000..5318b9b --- /dev/null +++ b/src/game_system_ButtonInteraction.cpp @@ -0,0 +1,121 @@ +#include "game_system_ButtonInteraction.h" + +#include +#include + +#include "bn_sound_items.h" + +namespace sym::game::system +{ + +ButtonInteraction::ButtonInteraction(scene::GameState& state) : ISystem(state) +{ +} + +void ButtonInteraction::Update() +{ + UpdateKeyLastingCount_(); + + HoverButtonPlayerInteract_(); + HoverButtonThrownSymbolInteract_(); +} + +void ButtonInteraction::HoverButtonPlayerInteract_() +{ + if (IsLKeyPressLasts_()) + { + const bn::fixed_rect leftHand = state_.player.GetLeftButtonInteractRange(); + + for (int i = 0; i < state_.hoverButtonsOfZones[state_.currentZoneIdx].size(); ++i) + { + auto& hoverButton = state_.hoverButtonsOfZones[state_.currentZoneIdx][i]; + if (!hoverButton.CanButtonBeToggled()) + continue; + + if (leftHand.intersects(hoverButton.GetInteractRange())) + { + hoverButton.ToggleButtonOn(); + ToggleOpenedHoverButtonAssociatedOpenables_(i); + bn::sound_items::sfx_toggle_button.play(); + ResetLKeyPress_(); + break; + } + } + } + + if (IsRKeyPressLasts_()) + { + const bn::fixed_rect rightHand = state_.player.GetRightButtonInteractRange(); + for (int i = 0; i < state_.hoverButtonsOfZones[state_.currentZoneIdx].size(); ++i) + { + auto& hoverButton = state_.hoverButtonsOfZones[state_.currentZoneIdx][i]; + if (!hoverButton.CanButtonBeToggled()) + continue; + + if (rightHand.intersects(hoverButton.GetInteractRange())) + { + hoverButton.ToggleButtonOn(); + ToggleOpenedHoverButtonAssociatedOpenables_(i); + bn::sound_items::sfx_toggle_button.play(); + ResetRKeyPress_(); + break; + } + } + } +} + +void ButtonInteraction::HoverButtonThrownSymbolInteract_() +{ + // TODO +} + +void ButtonInteraction::UpdateKeyLastingCount_() +{ + if (lKeyLastingCount >= 0) + --lKeyLastingCount; + if (rKeyLastingCount >= 0) + --rKeyLastingCount; + if (bn::keypad::l_pressed()) + lKeyLastingCount = KEYPRESS_LASTING_UPDATE_COUNT; + if (bn::keypad::r_pressed()) + rKeyLastingCount = KEYPRESS_LASTING_UPDATE_COUNT; +} + +bool ButtonInteraction::IsLKeyPressLasts_() const +{ + return lKeyLastingCount >= 0; +} + +bool ButtonInteraction::IsRKeyPressLasts_() const +{ + return rKeyLastingCount >= 0; +} + +void ButtonInteraction::ResetLKeyPress_() +{ + lKeyLastingCount = -1; +} + +void ButtonInteraction::ResetRKeyPress_() +{ + rKeyLastingCount = -1; +} + +void ButtonInteraction::ToggleOpenedHoverButtonAssociatedOpenables_(int hoverButtonIdx) +{ + const auto& zoneInfo = state_.stageInfo.zoneInfos[state_.currentZoneIdx]; + const int hoverButtonTextNum = zoneInfo.hoverButtons[hoverButtonIdx].textSpriteNumber; + + for (int i = 0; i < state_.doorsOfZones[state_.currentZoneIdx].size(); ++i) + { + if (hoverButtonTextNum == zoneInfo.doors[i].textSpriteNumber) + state_.doorsOfZones[state_.currentZoneIdx][i].ToggleOpened(); + } + for (int i = 0; i < state_.shuttersOfZones[state_.currentZoneIdx].size(); ++i) + { + if (hoverButtonTextNum == zoneInfo.shutters[i].textSpriteNumber) + state_.shuttersOfZones[state_.currentZoneIdx][i].ToggleOpened(); + } +} + +} // namespace sym::game::system diff --git a/src/game_system_PlayerMovement.cpp b/src/game_system_PlayerMovement.cpp new file mode 100644 index 0000000..7b73b4a --- /dev/null +++ b/src/game_system_PlayerMovement.cpp @@ -0,0 +1,33 @@ +#include "game_system_PlayerMovement.h" + +#include + +namespace sym::game::system +{ + +PlayerMovement::PlayerMovement(scene::GameState& state) : ISystem(state) +{ +} + +void PlayerMovement::Update() +{ + // Move player + if (bn::keypad::up_held()) + { + state_.player.SetY(state_.player.GetY() - 3); + } + else if (bn::keypad::down_held()) + { + state_.player.SetY(state_.player.GetY() + 3); + } + if (bn::keypad::left_held()) + { + state_.player.SetX(state_.player.GetX() - 3); + } + else if (bn::keypad::right_held()) + { + state_.player.SetX(state_.player.GetX() + 3); + } +} + +} // namespace sym::game::system diff --git a/src/main.cpp b/src/main.cpp index 99c9484..6a3a441 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,11 +20,10 @@ #include "global.h" #include "scene_Game.h" +#include "scene_Param.h" #include "scene_Splash.h" #include "scene_Title.h" -#include "game_Status.h" - using namespace sym; int main() @@ -33,10 +32,10 @@ int main() sym::global::setting::Init(); bn::bg_palettes::set_transparent_color(constant::TRANSPARENT_BG_COLOR); - game::Status status; + scene::Param sceneParam; // Test // bn::unique_ptr scene(new scene::Splash); - bn::unique_ptr scene(new scene::Game(status)); + bn::unique_ptr scene(new scene::Game(sceneParam)); bn::optional nextScene; #ifndef NDEBUG @@ -104,11 +103,11 @@ int main() { case scene::Type::SPLASH: scene.reset(); - scene.reset(new scene::Splash); + scene.reset(new scene::Splash(sceneParam)); break; case scene::Type::TITLE: scene.reset(); - scene.reset(new scene::Title); + scene.reset(new scene::Title(sceneParam)); break; // TODO: Add other scenes // case SceneType::GAME: diff --git a/src/scene_Game.cpp b/src/scene_Game.cpp index df5a214..8f25f9d 100644 --- a/src/scene_Game.cpp +++ b/src/scene_Game.cpp @@ -43,85 +43,100 @@ constexpr int BUTTON_Z_ORDER = 5; using namespace effect; -Game::Game(game::Status& status) - : status_(status), stageInfo_(GetStageInfo(status.GetCurrentStage())), - fadeIn_(Transition::Types::FADE | Transition::Types::BG_MOSAIC | effect::Transition::Types::SPRITE_MOSAIC, - Transition::Direction::IN, FADE_IN_UPDATE_COUNT), - fadeOut_(Transition::Types::FADE | Transition::Types::BG_MOSAIC | effect::Transition::Types::SPRITE_MOSAIC, - Transition::Direction::OUT, FADE_OUT_UPDATE_COUNT), - currentMapBg_(stageInfo_.zoneInfos[0].mapBg.create_bg({0, 0})), camera_(bn::camera_ptr::create(0, 0)), - player_({0, 0}) +Game::Game(scene::Param& sceneParam) + : IScene(sceneParam), + state_{ + sceneParam, + GetStageInfo(sceneParam.GetCurrentStage()), + {Transition::Types::FADE | Transition::Types::BG_MOSAIC | effect::Transition::Types::SPRITE_MOSAIC, + Transition::Direction::IN, FADE_IN_UPDATE_COUNT}, + {Transition::Types::FADE | Transition::Types::BG_MOSAIC | effect::Transition::Types::SPRITE_MOSAIC, + Transition::Direction::OUT, FADE_OUT_UPDATE_COUNT}, + 0, + state_.stageInfo.zoneInfos[0].mapBg.create_bg({0, 0}), + bn::camera_ptr::create(0, 0), + helper::tilemap::ConvertIndexRectToPositionRect( + state_.stageInfo.zoneInfos[state_.currentZoneIdx].zoneBoundary), + bn::fixed_point{0, 0}, + {}, + {}, + {}, + {}, + {}, + {}, + true, + }, + playerMovement_(state_), buttonInteraction_(state_) { - currentZoneIdx_ = 0; - currentMapBg_.set_wrapping_enabled(false); - currentMapBg_.set_camera(camera_); - zoneBoundary_ = helper::tilemap::ConvertIndexRectToPositionRect(stageInfo_.zoneInfos[currentZoneIdx_].zoneBoundary); + state_.currentMapBg.set_wrapping_enabled(false); + state_.currentMapBg.set_camera(state_.camera); // Resize vectors according to zone count - const int zoneCount = stageInfo_.zoneInfos.size(); - symbolsOfZones_.resize(zoneCount); - doorsOfZones_.resize(zoneCount); - hoverButtonsOfZones_.resize(zoneCount); - pressureButtonsOfZones_.resize(zoneCount); - shuttersOfZones_.resize(zoneCount); + const int zoneCount = state_.stageInfo.zoneInfos.size(); + state_.symbolsOfZones.resize(zoneCount); + state_.doorsOfZones.resize(zoneCount); + state_.hoverButtonsOfZones.resize(zoneCount); + state_.pressureButtonsOfZones.resize(zoneCount); + state_.shuttersOfZones.resize(zoneCount); // Initialize player and camera - const bn::fixed_point& playerPosition = stageInfo_.zoneInfos[0].entrances[0].position; - player_.SetPosition(playerPosition); - camera_.set_position(playerPosition); + const bn::fixed_point& playerPosition = state_.stageInfo.zoneInfos[0].entrances[0].position; + state_.player.SetPosition(playerPosition); + state_.camera.set_position(playerPosition); // Load and initialize Entities in zones using ZoneInfo for (int i = 0; i < zoneCount; ++i) { - const auto& zoneInfo = stageInfo_.zoneInfos[i]; + const auto& zoneInfo = state_.stageInfo.zoneInfos[i]; for (const auto& symbolInfo : zoneInfo.symbols) - symbolsOfZones_[i].emplace_front(symbolInfo.position, symbolInfo.symbolType); + state_.symbolsOfZones[i].emplace_front(symbolInfo.position, symbolInfo.symbolType); for (const auto& doorInfo : zoneInfo.doors) - doorsOfZones_[i].emplace_back(doorInfo.position, doorInfo.isOpenedByDefault, doorInfo.textSpriteNumber); + state_.doorsOfZones[i].emplace_back(doorInfo.position, doorInfo.isOpenedByDefault, + doorInfo.textSpriteNumber); for (const auto& shutterInfo : zoneInfo.shutters) - shuttersOfZones_[i].emplace_back(shutterInfo.position, shutterInfo.isOpenedByDefault, - shutterInfo.textSpriteNumber); + state_.shuttersOfZones[i].emplace_back(shutterInfo.position, shutterInfo.isOpenedByDefault, + shutterInfo.textSpriteNumber); for (const auto& hoverButtonInfo : zoneInfo.hoverButtons) - hoverButtonsOfZones_[i].emplace_back(hoverButtonInfo.position, hoverButtonInfo.textSpriteNumber, - hoverButtonInfo.isOnByDefault); + state_.hoverButtonsOfZones[i].emplace_back(hoverButtonInfo.position, hoverButtonInfo.textSpriteNumber, + hoverButtonInfo.isOnByDefault); for (const auto& pressureButtonInfo : zoneInfo.pressureButtons) - pressureButtonsOfZones_[i].emplace_back(pressureButtonInfo.position, pressureButtonInfo.textSpriteNumber, - pressureButtonInfo.isOnByDefault); + state_.pressureButtonsOfZones[i].emplace_back( + pressureButtonInfo.position, pressureButtonInfo.textSpriteNumber, pressureButtonInfo.isOnByDefault); } // Allocate all graphics within current zone - player_.AllocateGraphicResource(PLAYER_Z_ORDER); - player_.SetCamera(camera_); - for (auto& symbol : symbolsOfZones_[currentZoneIdx_]) + state_.player.AllocateGraphicResource(PLAYER_Z_ORDER); + state_.player.SetCamera(state_.camera); + for (auto& symbol : state_.symbolsOfZones[state_.currentZoneIdx]) { symbol.AllocateGraphicResource(SYMBOL_Z_ORDER); - symbol.SetCamera(camera_); + symbol.SetCamera(state_.camera); } - for (auto& door : doorsOfZones_[currentZoneIdx_]) + for (auto& door : state_.doorsOfZones[state_.currentZoneIdx]) { door.AllocateGraphicResource(DOOR_Z_ORDER); - door.SetCamera(camera_); + door.SetCamera(state_.camera); } - for (auto& shutter : shuttersOfZones_[currentZoneIdx_]) + for (auto& shutter : state_.shuttersOfZones[state_.currentZoneIdx]) { shutter.AllocateGraphicResource(DOOR_Z_ORDER); - shutter.SetCamera(camera_); + shutter.SetCamera(state_.camera); } - for (auto& hoverButton : hoverButtonsOfZones_[currentZoneIdx_]) + for (auto& hoverButton : state_.hoverButtonsOfZones[state_.currentZoneIdx]) { hoverButton.AllocateGraphicResource(BUTTON_Z_ORDER); - hoverButton.SetCamera(camera_); + hoverButton.SetCamera(state_.camera); } - for (auto& pressureButton : pressureButtonsOfZones_[currentZoneIdx_]) + for (auto& pressureButton : state_.pressureButtonsOfZones[state_.currentZoneIdx]) { pressureButton.AllocateGraphicResource(BUTTON_Z_ORDER); - pressureButton.SetCamera(camera_); + pressureButton.SetCamera(state_.camera); } // Initialize Idle action - player_.InitIdleAction(); + state_.player.InitIdleAction(); } Game::~Game() @@ -132,47 +147,35 @@ Game::~Game() bn::optional Game::Update() { // TODO - - // Move player - if (bn::keypad::up_held()) - { - player_.SetY(player_.GetY() - 3); - } - else if (bn::keypad::down_held()) - { - player_.SetY(player_.GetY() + 3); - } - if (bn::keypad::left_held()) - { - player_.SetX(player_.GetX() - 3); - } - else if (bn::keypad::right_held()) - { - player_.SetX(player_.GetX() + 3); - } + playerMovement_.Update(); + buttonInteraction_.Update(); // Update sprite graphics - player_.Update(); - for (auto& symbol : symbolsOfZones_[currentZoneIdx_]) + state_.player.Update(); + for (auto& symbol : state_.symbolsOfZones[state_.currentZoneIdx]) symbol.Update(); - for (auto& door : doorsOfZones_[currentZoneIdx_]) + for (auto& door : state_.doorsOfZones[state_.currentZoneIdx]) door.Update(); - // for (auto& shutter : shuttersOfZones_[currentZoneIdx_]) - // shutter.Update(); + for (auto& shutter : state_.shuttersOfZones[state_.currentZoneIdx]) + shutter.Update(); + for (auto& hoverButton : state_.hoverButtonsOfZones[state_.currentZoneIdx]) + hoverButton.Update(); + for (auto& pressureButton : state_.pressureButtonsOfZones[state_.currentZoneIdx]) + pressureButton.Update(); // Move camera (follows player) - camera_.set_position(player_.GetPosition()); - helper::tilemap::SnapCameraToZoneBoundary(camera_, zoneBoundary_); + state_.camera.set_position(state_.player.GetPosition()); + helper::tilemap::SnapCameraToZoneBoundary(state_.camera, state_.zoneBoundary); return bn::nullopt; } void Game::SetCurrentZone_(int zoneIdx) { - BN_ASSERT(0 <= zoneIdx && zoneIdx < stageInfo_.zoneInfos.size(), "Zone index out of range!"); + BN_ASSERT(0 <= zoneIdx && zoneIdx < state_.stageInfo.zoneInfos.size(), "Zone index out of range!"); - currentMapBg_ = stageInfo_.zoneInfos[zoneIdx].mapBg.create_bg({0, 0}); - currentMapBg_.set_wrapping_enabled(false); + state_.currentMapBg = state_.stageInfo.zoneInfos[zoneIdx].mapBg.create_bg({0, 0}); + state_.currentMapBg.set_wrapping_enabled(false); } } // namespace sym::scene diff --git a/src/scene_Splash.cpp b/src/scene_Splash.cpp index b266dbf..9b6fef6 100644 --- a/src/scene_Splash.cpp +++ b/src/scene_Splash.cpp @@ -12,8 +12,9 @@ namespace sym::scene { -Splash::Splash() - : bgs_{bn::regular_bg_items::bg_splash1.create_bg(0, 0), bn::regular_bg_items::bg_splash2.create_bg(0, 0)}, +Splash::Splash(scene::Param& sceneParam) + : IScene(sceneParam), bgs_{bn::regular_bg_items::bg_splash1.create_bg(0, 0), + bn::regular_bg_items::bg_splash2.create_bg(0, 0)}, fadeIn_(effect::Transition::Types::TRANSPARENCY, effect::Transition::Direction::IN, FADE_IN_UPDATE_COUNT), fadeOut_(effect::Transition::Types::TRANSPARENCY, effect::Transition::Direction::OUT, FADE_OUT_UPDATE_COUNT) { diff --git a/src/scene_Title.cpp b/src/scene_Title.cpp index a681fb0..5d317fc 100644 --- a/src/scene_Title.cpp +++ b/src/scene_Title.cpp @@ -16,9 +16,9 @@ namespace sym::scene { -Title::Title() - : cursor_{bn::sprite_items::spr_cursor_star.create_sprite(0, 0), - bn::sprite_items::spr_cursor_star.create_sprite(0, 0)}, +Title::Title(scene::Param& sceneParam) + : IScene(sceneParam), cursor_{bn::sprite_items::spr_cursor_star.create_sprite(0, 0), + bn::sprite_items::spr_cursor_star.create_sprite(0, 0)}, bg_(bn::regular_bg_items::bg_title.create_bg(0, 0)), fadeIn_(effect::Transition::Types::FADE | effect::Transition::Types::SPRITE_MOSAIC | effect::Transition::Types::BG_MOSAIC,