X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fapp.cc;h=065e5810ec8ff084a0fb45146d422fdfcb084937;hp=96b3f86229e2106fd14c98162e6504b06c78a542;hb=458f4c5972fc6b0ba43ea42c3b8d5c211d8f3f3d;hpb=c64bd959ffb4034cb288780f13a351b00fb22ca0 diff --git a/src/app.cc b/src/app.cc index 96b3f86..065e581 100644 --- a/src/app.cc +++ b/src/app.cc @@ -24,7 +24,7 @@ static Vec3 cam_pos; static float floor_y; // last floor height static float user_eye_height = 165; -static float walk_speed = 400.0f; +static float walk_speed = 300.0f; static bool show_walk_mesh, noclip = false; static int prev_mx, prev_my; @@ -250,6 +250,15 @@ void app_keyboard(int key, bool pressed) app_quit(); break; + case 'f': + app_toggle_fullscreen(); + break; + + case '`': + app_toggle_grab_mouse(); + show_message("mouse %s", app_is_mouse_grabbed() ? "grabbed" : "released"); + break; + case 'w': if(mod & MOD_CTRL) { show_walk_mesh = !show_walk_mesh; @@ -288,6 +297,21 @@ void app_mouse_button(int bn, bool pressed, int x, int y) bnstate[bn] = pressed; } +static inline void mouse_look(int dx, int dy) +{ + cam_theta += dx * 0.5; + cam_phi += dy * 0.5; + + if(cam_phi < -90) cam_phi = -90; + if(cam_phi > 90) cam_phi = 90; +} + +static void mouse_zoom(int dx, int dy) +{ + cam_dist += dy * 0.1; + if(cam_dist < 0.0) cam_dist = 0.0; +} + void app_mouse_motion(int x, int y) { int dx = x - prev_mx; @@ -297,20 +321,19 @@ void app_mouse_motion(int x, int y) if(!dx && !dy) return; - app_mouse_delta(dx, dy); + if(bnstate[0]) { + mouse_look(dx, dy); + } + if(bnstate[2]) { + mouse_zoom(dx, dy); + } } void app_mouse_delta(int dx, int dy) { - if(bnstate[0]) { - cam_theta += dx * 0.5; - cam_phi += dy * 0.5; - - if(cam_phi < -90) cam_phi = -90; - if(cam_phi > 90) cam_phi = 90; - } if(bnstate[2]) { - cam_dist += dy * 0.1; - if(cam_dist < 0.0) cam_dist = 0.0; + mouse_zoom(dx, dy); + } else { + mouse_look(dx, dy); } }