Add menu option for screen shake

This commit is contained in:
Dominic Szablewski
2025-04-18 09:22:56 +02:00
parent ec887204b5
commit fca01a0900
5 changed files with 12 additions and 3 deletions

View File

@@ -258,7 +258,6 @@ PRs Welcome.
Some things from the original game are not yet implemented in this rewrite. This includes
- screen shake effect
- game-end animations, formerly `Spline.cpp` (the end messages are just shown over the attract mode cameras)
- reverb for sfx and music when there's more than 4 track faces (tunnels and such)
- some more? grep the source for `TODO` and `FIXME`

View File

@@ -181,8 +181,9 @@ void camera_set_shake(camera_t *camera, float duration) {
void camera_update_shake(camera_t *camera) {
if (camera->shake_timer > 0.0f) {
camera->shake.x = (-(rand_float(0.0f, camera->shake_timer)) + (camera->shake_timer * 0.5f));
camera->shake.y = (-(rand_float(0.0f, camera->shake_timer)) + (camera->shake_timer * 0.5f));
float s = 0.25 * save.screen_shake * camera->shake_timer;
camera->shake.x = rand_float(-s, s);
camera->shake.y = rand_float(-s, s);
camera->shake_timer -= system_tick();
}
else {

View File

@@ -397,6 +397,7 @@ save_t save = {
.sfx_volume = 0.6,
.music_volume = 0.5,
.internal_roll = 0.6,
.screen_shake = 0.5,
.ui_scale = 0,
.show_fps = false,
.fullscreen = false,

View File

@@ -246,6 +246,7 @@ typedef struct {
bool fullscreen;
int screen_res;
int post_effect;
float screen_shake;
uint32_t has_rapier_class;
uint32_t has_bonus_circuts;

View File

@@ -294,11 +294,17 @@ static void toggle_post(menu_t *menu, int data) {
save.is_dirty = true;
}
static void toggle_screen_shake(menu_t *menu, int data) {
save.screen_shake = (float)data * 0.5;
save.is_dirty = true;
}
static const char *opts_off_on[] = {"OFF", "ON"};
static const char *opts_roll[] = {"0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"};
static const char *opts_ui_sizes[] = {"AUTO", "1X", "2X", "3X", "4X"};
static const char *opts_res[] = {"NATIVE", "240P", "480P"};
static const char *opts_post[] = {"NONE", "CRT EFFECT"};
static const char *opts_screen_shake[] = {"DISABLED", "REDUCED", "FULL"};
static void page_options_video_init(menu_t *menu) {
menu_page_t *page = menu_push(menu, "VIDEO OPTIONS", NULL);
@@ -313,6 +319,7 @@ static void page_options_video_init(menu_t *menu) {
menu_page_add_toggle(page, save.fullscreen, "FULLSCREEN", opts_off_on, len(opts_off_on), toggle_fullscreen);
#endif
menu_page_add_toggle(page, save.internal_roll * 10, "INTERNAL VIEW ROLL", opts_roll, len(opts_roll), toggle_internal_roll);
menu_page_add_toggle(page, save.screen_shake * 2, "SCREEN SHAKE", opts_screen_shake, len(opts_screen_shake), toggle_screen_shake);
menu_page_add_toggle(page, save.ui_scale, "UI SCALE", opts_ui_sizes, len(opts_ui_sizes), toggle_ui_scale);
menu_page_add_toggle(page, save.show_fps, "SHOW FPS", opts_off_on, len(opts_off_on), toggle_show_fps);
menu_page_add_toggle(page, save.screen_res, "SCREEN RESOLUTION", opts_res, len(opts_res), toggle_res);