… | |
… | |
22 | |
22 | |
23 | /**********************************************************************/ |
23 | /**********************************************************************/ |
24 | |
24 | |
25 | view camera; |
25 | view camera; |
26 | vec3 camera_velocity; |
26 | vec3 camera_velocity; |
|
|
27 | int camera_velocity_factor = 10; |
27 | |
28 | |
28 | void |
29 | void |
29 | HotKey_ToggleFullScreen (void) |
30 | HotKey_ToggleFullScreen (void) |
30 | { |
31 | { |
31 | SDL_Surface *screen; |
32 | SDL_Surface *screen; |
… | |
… | |
91 | printf ("focus\n"); |
92 | printf ("focus\n"); |
92 | break; |
93 | break; |
93 | |
94 | |
94 | #define VELOCITY 10 |
95 | #define VELOCITY 10 |
95 | case SDL_KEYDOWN: |
96 | case SDL_KEYDOWN: |
96 | if (event->key.keysym.sym == SDLK_UP) camera_velocity.z -= VELOCITY; |
97 | if (event->key.keysym.sym == SDLK_UP) camera_velocity.z--; |
97 | if (event->key.keysym.sym == SDLK_DOWN) camera_velocity.z += VELOCITY; |
98 | if (event->key.keysym.sym == SDLK_DOWN) camera_velocity.z++; |
98 | if (event->key.keysym.sym == SDLK_LEFT) camera_velocity.x -= VELOCITY; |
99 | if (event->key.keysym.sym == SDLK_LEFT) camera_velocity.x--; |
99 | if (event->key.keysym.sym == SDLK_RIGHT) camera_velocity.x += VELOCITY; |
100 | if (event->key.keysym.sym == SDLK_RIGHT) camera_velocity.x++; |
|
|
101 | if (event->key.keysym.sym == SDLK_a) camera_velocity.y--; |
|
|
102 | if (event->key.keysym.sym == SDLK_s) camera_velocity.y++; |
|
|
103 | if (event->key.keysym.sym == SDLK_v) camera_velocity_factor *= 1.5; |
|
|
104 | if (event->key.keysym.sym == SDLK_b) camera_velocity_factor /= 1.5; |
100 | |
105 | |
101 | if (event->key.keysym.sym == SDLK_ESCAPE) |
106 | if (event->key.keysym.sym == SDLK_ESCAPE) |
102 | done = 1; |
107 | done = 1; |
103 | |
108 | |
104 | if ((event->key.keysym.sym == SDLK_g) && |
109 | if ((event->key.keysym.sym == SDLK_g) && |
… | |
… | |
114 | HotKey_ToggleFullScreen (); |
119 | HotKey_ToggleFullScreen (); |
115 | |
120 | |
116 | break; |
121 | break; |
117 | |
122 | |
118 | case SDL_KEYUP: |
123 | case SDL_KEYUP: |
119 | if (event->key.keysym.sym == SDLK_UP) camera_velocity.z += VELOCITY; |
124 | if (event->key.keysym.sym == SDLK_UP) camera_velocity.z++; |
120 | if (event->key.keysym.sym == SDLK_DOWN) camera_velocity.z -= VELOCITY; |
125 | if (event->key.keysym.sym == SDLK_DOWN) camera_velocity.z--; |
121 | if (event->key.keysym.sym == SDLK_LEFT) camera_velocity.x += VELOCITY; |
126 | if (event->key.keysym.sym == SDLK_LEFT) camera_velocity.x++; |
122 | if (event->key.keysym.sym == SDLK_RIGHT) camera_velocity.x -= VELOCITY; |
127 | if (event->key.keysym.sym == SDLK_RIGHT) camera_velocity.x--; |
|
|
128 | if (event->key.keysym.sym == SDLK_a) camera_velocity.y++; |
|
|
129 | if (event->key.keysym.sym == SDLK_s) camera_velocity.y--; |
123 | break; |
130 | break; |
124 | |
131 | |
125 | case SDL_QUIT: |
132 | case SDL_QUIT: |
126 | done = 1; |
133 | done = 1; |
127 | break; |
134 | break; |
… | |
… | |
372 | char *sdl_error; |
379 | char *sdl_error; |
373 | SDL_Event event; |
380 | SDL_Event event; |
374 | |
381 | |
375 | glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
382 | glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
376 | |
383 | |
377 | camera.p.x += camera_velocity.x * timer.diff; |
384 | camera.p.x += (camera_velocity_factor * camera_velocity.x) * timer.diff; |
378 | camera.p.y += camera_velocity.y * timer.diff; |
385 | camera.p.y += (camera_velocity_factor * camera_velocity.y) * timer.diff; |
379 | camera.p.z += camera_velocity.z * timer.diff; |
386 | camera.p.z += (camera_velocity_factor * camera_velocity.z) * timer.diff; |
380 | |
387 | |
381 | GLfloat lightp[4]; |
388 | GLfloat lightp[4]; |
382 | lightp[0] = camera.p.x; |
389 | lightp[0] = camera.p.x; |
383 | lightp[1] = camera.p.y; |
390 | lightp[1] = camera.p.y; |
384 | lightp[2] = camera.p.z; |
391 | lightp[2] = camera.p.z; |