From 8ac9e0e139b1f523c333ed2c33b81291f54def09 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Wed, 15 Aug 2018 02:56:19 +0300 Subject: [PATCH] panning --- src/gamescr.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gamescr.cc b/src/gamescr.cc index 06b0429..3eec738 100644 --- a/src/gamescr.cc +++ b/src/gamescr.cc @@ -89,6 +89,8 @@ static void remove_particle(Particle *p); static Particle *alloc_particle(); void free_particle(Particle *p); +static bool pause; + static float grid[GRID_SIZE * GRID_SIZE]; static Particle *grid_part[GRID_SIZE * GRID_SIZE]; static Texture *grid_tex; @@ -107,9 +109,10 @@ static QuadMesh field_mesh; static Mesh *pmesh; static unsigned int particle_sdr; +static Vec2 cam_pos; static float cam_theta; static float cam_dist = 100.0f; -static Vec2 *targ_pos; +static Vec2 *targ_pos = &cam_pos; static Mat4 view_matrix, proj_matrix; static bool wireframe; @@ -177,6 +180,8 @@ void GameScreen::destroy() static void simstep() { + if(pause) return; + // move existing particles Particle *p = plist; while(p) { @@ -452,6 +457,10 @@ void GameScreen::keyboard(int key, bool pressed) wireframe = !wireframe; break; + case ' ': + pause = !pause; + break; + default: break; } @@ -473,6 +482,13 @@ void GameScreen::mmotion(int x, int y) prev_x = x; prev_y = y; + if(game_bnstate(0)) { + float pan_speed = pow(cam_dist, 1.5) * 0.00035; // magic + Vec2 dir = rotate(Vec2(dx, dy) * pan_speed, deg_to_rad(cam_theta)); + cam_pos.x -= dir.x; + cam_pos.y -= dir.y; + } + if(game_bnstate(2)) { cam_theta += dx * 0.5; } -- 1.7.10.4