1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-18 11:19:59 +00:00

touch-based rug movement in android

This commit is contained in:
Zeno Rogue 2018-02-03 20:04:19 +01:00
parent e5f1670702
commit d3d6eec424
3 changed files with 16 additions and 12 deletions

View File

@ -5473,7 +5473,7 @@ void gamescreen(int _darken) {
}
else {
if(andmode != 0) displayabutton(-1, +1, XLAT("MOVE"), andmode == 0 ? BTON : BTOFF);
displayabutton(+1, +1, XLAT(andmode == 1 ? "BACK" : "DRAG"), andmode == 1 ? BTON : BTOFF);
displayabutton(+1, +1, rug::rugged ? "RUG" : XLAT(andmode == 1 ? "BACK" : "DRAG"), andmode == 1 ? BTON : BTOFF);
}
displayabutton(-1, -1, XLAT("INFO"), andmode == 12 ? BTON : BTOFF);
displayabutton(+1, -1, XLAT("MENU"), andmode == 3 ? BTON : BTOFF);

View File

@ -751,10 +751,17 @@ void mobile_draw(MOBPAR_FORMAL) {
#endif
if(clicked && lclicked && andmode == 1 && (cmode & sm::NORMAL)) {
if(!mouseout2() && mouseoh[2] < 50 && mouseh[2] < 50) {
if(!mouseout2() && mouseoh[2] < 50 && mouseh[2] < 50 && !rug::rugged) {
panning(mouseoh, mouseh);
}
}
static int lticks_rug;
if(andmode == 1 && !inmenu && rug::rugged && clicked)
rug::move_forward((ticks - lticks_rug) / 2500);
lticks_rug = ticks;
if(andmode == 1 && lclicked && !clicked && !inmenu && mouseover)
performMarkCommand(mouseover);

17
rug.cpp
View File

@ -1315,6 +1315,11 @@ void apply_rotation(const transmatrix& t) {
for(auto p: points) p->flat = t * p->flat;
}
void move_forward(ld distance) {
if(rug_perspective) push_all_points(2, -distance);
else model_distance /= exp(distance);
}
bool handlekeys(int sym, int uni) {
if(uni == '4') {
#if CAP_ODS
@ -1344,16 +1349,8 @@ bool handlekeys(int sym, int uni) {
return true;
}
#if !CAP_SDL
else if(uni == SDLK_PAGEUP || uni == '[') {
if(rug_perspective) push_all_points(2, -.1);
else model_distance /= exp(.1);
return true;
}
else if(uni == SDLK_PAGEDOWN || uni == ']') {
if(rug_perspective) push_all_points(2, +.1);
else model_distance *= exp(.1);
return true;
}
else if(uni == SDLK_PAGEUP || uni == '[') move_forward(.1);
else if(uni == SDLK_PAGEDOWN || uni == ']') move_forward(-.1);
#endif
else return false;
}