1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-22 17:37:39 +00:00

3d:: mouse aiming

This commit is contained in:
?
2019-02-26 02:35:30 +01:00
committed by Zeno Rogue
parent 3cf1236a0a
commit 71f02d5dc2
4 changed files with 53 additions and 2 deletions

View File

@@ -492,6 +492,10 @@ void resize_screen_to(int x, int y) {
setvideomode();
}
bool mousepan, oldmousepan;
ld mouseaim_x, mouseaim_y;
ld mouseaim_sensitivity = 0.01;
void mainloopiter() {
DEBB(DF_GRAPH, (debugfile,"main loop\n"));
@@ -524,6 +528,22 @@ void mainloopiter() {
cwtV = gmatrix[cwt.at] * ddspin(cwt.at, cwt.spin);
if(cwt.mirrored) playerV = playerV * Mirror;
}
mousepan = normal && DIM == 3;
if(mousepan != oldmousepan) {
oldmousepan = mousepan;
if(mousepan) {
SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_ShowCursor(SDL_DISABLE);
mouseaim_x = mouseaim_y = 0;
}
else {
SDL_WM_GrabInput( SDL_GRAB_OFF );
SDL_ShowCursor(SDL_ENABLE);
SDL_WarpMouse(vid.xres/2, vid.yres/2);
mouseaim_x = mouseaim_y = 0;
}
}
#if ISWEB
timetowait = 0;
@@ -581,6 +601,11 @@ void mainloopiter() {
SDL_Event ev;
DEBB(DF_GRAPH, (debugfile,"polling for events\n"));
if(DIM == 3 && !shmup::on && !rug::rugged) {
View = cspin(0, 2, -mouseaim_x) * cspin(1, 2, -mouseaim_y) * View;
mouseaim_x = mouseaim_y = 0;
}
if(smooth_scrolling && !shmup::on && !rug::rugged) {
static int lastticks;
ld t = (ticks - lastticks) * shiftmul / 1000.;
@@ -796,6 +821,13 @@ void handle_event(SDL_Event& ev) {
mousex = ev.motion.x;
mousey = ev.motion.y;
if(mousepan) {
mousex = vid.xres/2;
mousey = vid.yres/2;
mouseaim_x += ev.motion.xrel * mouseaim_sensitivity;
mouseaim_y += ev.motion.yrel * mouseaim_sensitivity;
}
need_mouseh = true;
if(holdmouse && getcstat == '-') sym = uni = getcstat, fix_mouseh();