vrfileman
changeset 4:85e26116ba5a
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 02 Feb 2015 21:11:23 +0200 |
parents | 2cbf85690e03 |
children | d487181ee1d9 |
files | src/app.cc src/user.cc |
diffstat | 2 files changed, 18 insertions(+), 7 deletions(-) [+] |
line diff
1.1 --- a/src/app.cc Sun Feb 01 20:56:16 2015 +0200 1.2 +++ b/src/app.cc Mon Feb 02 21:11:23 2015 +0200 1.3 @@ -9,10 +9,13 @@ 1.4 static User user; 1.5 static float eye_level = 1.6; 1.6 1.7 +static const float walk_speed = 4.0; 1.8 + 1.9 static int win_width, win_height; 1.10 static bool keystate[256]; 1.11 static bool bnstate[16]; 1.12 static int prev_x, prev_y, click_x, click_y; 1.13 +static unsigned int prev_upd; 1.14 1.15 bool app_init() 1.16 { 1.17 @@ -28,11 +31,9 @@ 1.18 1.19 static void update(unsigned int msec) 1.20 { 1.21 - static unsigned int prev_upd; 1.22 float dt = (float)(msec - prev_upd) / 1000.0f; 1.23 prev_upd = msec; 1.24 1.25 - static const float walk_speed = 1.0; 1.26 float fwd = 0.0f, right = 0.0f; 1.27 1.28 if(keystate['w'] || keystate['W']) { 1.29 @@ -94,14 +95,23 @@ 1.30 switch(key) { 1.31 case 27: 1.32 quit(); 1.33 + 1.34 + case 'w': 1.35 + case 'W': 1.36 + case 'd': 1.37 + case 'D': 1.38 + case 's': 1.39 + case 'S': 1.40 + case 'a': 1.41 + case 'A': 1.42 + prev_upd = get_time_msec(); 1.43 + redisplay(); 1.44 } 1.45 } 1.46 1.47 if(key < 256) { 1.48 keystate[key] = pressed; 1.49 } 1.50 - 1.51 - redisplay(); 1.52 } 1.53 1.54 void app_mouse_button(int bn, bool pressed, int x, int y) 1.55 @@ -120,8 +130,8 @@ 1.56 { 1.57 static const float rot_speed = 10.0; 1.58 1.59 - float dx = (x - prev_x) / win_width; 1.60 - float dy = (y - prev_y) / win_height; 1.61 + float dx = (float)(x - prev_x) / (float)win_width; 1.62 + float dy = (float)(y - prev_y) / (float)win_height; 1.63 prev_x = x; 1.64 prev_y = y; 1.65
2.1 --- a/src/user.cc Sun Feb 01 20:56:16 2015 +0200 2.2 +++ b/src/user.cc Mon Feb 02 21:11:23 2015 +0200 2.3 @@ -2,7 +2,7 @@ 2.4 2.5 void PosRot::move(float dfwd, float dright, float dup) 2.6 { 2.7 - Vector3 dir = Vector3(dright, dup, dfwd); 2.8 + Vector3 dir = Vector3(dright, dup, -dfwd); 2.9 dir.transform(rot); 2.10 pos += dir; 2.11 } 2.12 @@ -26,4 +26,5 @@ 2.13 { 2.14 calc_matrix(res); 2.15 *res = res->inverse(); 2.16 + // TODO: optimize 2.17 }