# HG changeset patch # User John Tsiombikas # Date 1422904283 -7200 # Node ID 85e26116ba5a9b268c6909a976db8c29b3f66338 # Parent 2cbf85690e0323220f777e4bc2cbb31297bf5698 foo diff -r 2cbf85690e03 -r 85e26116ba5a src/app.cc --- a/src/app.cc Sun Feb 01 20:56:16 2015 +0200 +++ b/src/app.cc Mon Feb 02 21:11:23 2015 +0200 @@ -9,10 +9,13 @@ static User user; static float eye_level = 1.6; +static const float walk_speed = 4.0; + static int win_width, win_height; static bool keystate[256]; static bool bnstate[16]; static int prev_x, prev_y, click_x, click_y; +static unsigned int prev_upd; bool app_init() { @@ -28,11 +31,9 @@ static void update(unsigned int msec) { - static unsigned int prev_upd; float dt = (float)(msec - prev_upd) / 1000.0f; prev_upd = msec; - static const float walk_speed = 1.0; float fwd = 0.0f, right = 0.0f; if(keystate['w'] || keystate['W']) { @@ -94,14 +95,23 @@ switch(key) { case 27: quit(); + + case 'w': + case 'W': + case 'd': + case 'D': + case 's': + case 'S': + case 'a': + case 'A': + prev_upd = get_time_msec(); + redisplay(); } } if(key < 256) { keystate[key] = pressed; } - - redisplay(); } void app_mouse_button(int bn, bool pressed, int x, int y) @@ -120,8 +130,8 @@ { static const float rot_speed = 10.0; - float dx = (x - prev_x) / win_width; - float dy = (y - prev_y) / win_height; + float dx = (float)(x - prev_x) / (float)win_width; + float dy = (float)(y - prev_y) / (float)win_height; prev_x = x; prev_y = y; diff -r 2cbf85690e03 -r 85e26116ba5a src/user.cc --- a/src/user.cc Sun Feb 01 20:56:16 2015 +0200 +++ b/src/user.cc Mon Feb 02 21:11:23 2015 +0200 @@ -2,7 +2,7 @@ void PosRot::move(float dfwd, float dright, float dup) { - Vector3 dir = Vector3(dright, dup, dfwd); + Vector3 dir = Vector3(dright, dup, -dfwd); dir.transform(rot); pos += dir; } @@ -26,4 +26,5 @@ { calc_matrix(res); *res = res->inverse(); + // TODO: optimize }