game_keys_scroll option

This commit is contained in:
Zeno Rogue 2022-08-05 19:20:25 +02:00
parent 1da912a0a2
commit 3184aea2be
2 changed files with 47 additions and 9 deletions

View File

@ -646,6 +646,9 @@ EX void initConfig() {
param_b(resizable, "resizable", true)
-> editable("resizable window", 'r');
param_b(no_find_player, "no_find_player");
param_b(game_keys_scroll, "game_keys_scroll");
param_b(arb::apeirogon_consistent_coloring, "apeirogon_consistent_coloring", true)
-> editable("apeirogon_consistent_coloring", 'c');
param_b(arb::apeirogon_hide_grid_edges, "apeirogon_hide_grid_edges", true)

View File

@ -356,14 +356,22 @@ EX void full_forward_camera(ld t) {
}
}
EX void full_strafe_camera(ld t) {
EX void full_cstrafe_camera(int dir, ld t) {
if(GDIM == 3) {
shift_view(ctangent(0, t * camera_speed));
shift_view(ctangent(dir, t * camera_speed));
didsomething = true;
playermoved = false;
}
}
EX void full_strafe_camera(ld t) { full_cstrafe_camera(0, t); }
EX void full_ystrafe_camera(ld t) {
if(walking::on) walking::eye_level += t;
else full_cstrafe_camera(1, t);
}
EX ld third_person_rotation = 0;
EX void full_rotate_camera(int dir, ld val) {
@ -512,7 +520,7 @@ EX void handleKeyNormal(int sym, int uni) {
if(handleTune(sym, uni)) return;
#endif
if(!(uni >= 'A' && uni <= 'Z') && DEFAULTCONTROL) {
if(!(uni >= 'A' && uni <= 'Z') && DEFAULTCONTROL && !game_keys_scroll) {
for(int i=0; i<8; i++)
if(among(sym, keys_vi[i], keys_wasd[i], keys_numpad[i]))
movepckeydir(i);
@ -535,7 +543,7 @@ EX void handleKeyNormal(int sym, int uni) {
}
#endif
if(DEFAULTCONTROL) {
if(DEFAULTCONTROL && !game_keys_scroll) {
if(sym == '.' || sym == 's') movepcto(-1, 1);
if((sym == SDLK_DELETE || sym == SDLK_KP_PERIOD || sym == 'g') && uni != 'G' && uni != 'G'-64)
movepcto(MD_DROP, 1);
@ -550,7 +558,7 @@ EX void handleKeyNormal(int sym, int uni) {
}
}
if(sym == SDLK_KP5 && DEFAULTCONTROL) movepcto(-1, 1);
if(sym == SDLK_KP5 && DEFAULTCONTROL && !game_keys_scroll) movepcto(-1, 1);
if(sym == SDLK_F5) {
#if CAP_DAILY
@ -580,7 +588,7 @@ EX void handleKeyNormal(int sym, int uni) {
if(uni == 'o' && DEFAULTNOR(sym)) get_o_key().second();
#if CAP_INV
if(uni == 'i' && DEFAULTNOR(sym) && inv::on)
if(uni == 'i' && DEFAULTNOR(sym) && inv::on && !game_keys_scroll)
pushScreen(inv::show);
#endif
@ -689,13 +697,16 @@ EX void resize_screen_to(int x, int y) {
int lastframe;
EX int sc_ticks;
EX int sc_ticks, sc_ticks2;
EX bool mouseaiming(bool shmupon) {
return
(GDIM == 3 && !shmupon) || (rug::rugged && (lctrlclick ^ rug::mouse_control_rug));
}
/* visualization only -- the HyperRogue movement keys should move the camera */
EX bool game_keys_scroll;
EX void mainloopiter() {
GLWRAP;
DEBB(DF_GRAPH, ("main loop\n"));
@ -907,7 +918,10 @@ EX void mainloopiter() {
lastticks = ticks;
#if CAP_SDL2
const Uint8 *keystate = SDL_GetKeyboardState(NULL);
rug::using_rugview urv;
auto& lastticks = sc_ticks;
ld t = (ticks - lastticks) * shiftmul / 1000.;
lastticks = ticks;
if(keystate[SDL_SCANCODE_END] && GDIM == 3 && DEFAULTNOR(SDL_SCANCODE_END)) full_forward_camera(-t);
if(keystate[SDL_SCANCODE_HOME] && GDIM == 3 && DEFAULTNOR(SDL_SCANCODE_HOME)) full_forward_camera(t);
@ -919,7 +933,6 @@ EX void mainloopiter() {
if(keystate[SDL_SCANCODE_PAGEDOWN] && DEFAULTNOR(SDL_SCANCODE_PAGEDOWN)) full_rotate_view(-t * 180 / M_PI, -t);
#else
Uint8 *keystate = SDL_GetKeyState(NULL);
if(keystate[SDLK_END] && GDIM == 3 && DEFAULTNOR(SDLK_END)) full_forward_camera(-t);
if(keystate[SDLK_HOME] && GDIM == 3 && DEFAULTNOR(SDLK_HOME)) full_forward_camera(t);
@ -933,6 +946,28 @@ EX void mainloopiter() {
}
else sc_ticks = ticks;
if(game_keys_scroll && !shmup::on && (cmode & sm::NORMAL)) {
rug::using_rugview urv;
auto& lastticks = sc_ticks2;
ld t = (ticks - lastticks) * shiftmul / 1000.;
lastticks = ticks;
println(hlog, "t = ", t);
if(keystate['d'] && DEFAULTNOR('d')) full_rotate_camera(0, -t);
if(keystate['a'] && DEFAULTNOR('a')) full_rotate_camera(0, t);
if(keystate['w'] && DEFAULTNOR('w')) full_rotate_camera(1, t);
if(keystate['s'] && DEFAULTNOR('s')) full_rotate_camera(1, -t);
if(keystate['q'] && DEFAULTNOR('q')) full_rotate_view(t * 180 / M_PI, t);
if(keystate['e'] && DEFAULTNOR('e')) full_rotate_view(-t * 180 / M_PI, -t);
if(keystate['i'] && GDIM == 3 && DEFAULTNOR('i')) full_forward_camera(-t);
if(keystate['k'] && GDIM == 3 && DEFAULTNOR('k')) full_forward_camera(t);
if(keystate['l'] && GDIM == 3 && DEFAULTNOR('l')) full_strafe_camera(-t);
if(keystate['j'] && GDIM == 3 && DEFAULTNOR('j')) full_strafe_camera(t);
if(keystate['h'] && GDIM == 3 && DEFAULTNOR('h')) full_ystrafe_camera(-t);
if(keystate['y'] && GDIM == 3 && DEFAULTNOR('y')) full_ystrafe_camera(t);
}
#if CAP_VR
vrhr::vr_control();
#endif