diff options
Diffstat (limited to 'sdl/pyramid.c')
-rw-r--r-- | sdl/pyramid.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/sdl/pyramid.c b/sdl/pyramid.c index 1d36870..c7fe00e 100644 --- a/sdl/pyramid.c +++ b/sdl/pyramid.c @@ -119,8 +119,8 @@ static void keys(SDL_keysym *keysym, unsigned int *keys_held, int flag) case SDLK_s: xRot += 5.0f; break; case SDLK_a: yRot -= 5.0f; break; case SDLK_d: yRot += 5.0f; break; - case SDLK_UP: move_forward(&camera, 0.1f); break; - case SDLK_DOWN: move_forward(&camera, -0.1f); break; + case SDLK_UP: move_forward(&camera, 0.5f); break; + case SDLK_DOWN: move_forward(&camera, -0.5f); break; case SDLK_LEFT: rotate_local_y(&camera, 0.1f); break; case SDLK_RIGHT: rotate_local_y(&camera, -0.1f); break; default: break; @@ -138,13 +138,13 @@ static void keys(SDL_keysym *keysym, unsigned int *keys_held, int flag) yRot += 5.0f; if (keys_held[SDLK_UP]) - move_forward(&camera, 0.01f); + move_forward(&camera, 0.05f); if (keys_held[SDLK_DOWN]) - move_forward(&camera, -0.01f); + move_forward(&camera, -0.05f); if (keys_held[SDLK_LEFT]) - rotate_local_y(&camera, 0.01f); + rotate_local_y(&camera, 0.02f); if (keys_held[SDLK_RIGHT]) - rotate_local_y(&camera, -0.01f); + rotate_local_y(&camera, -0.02f); } xRot = (GLfloat) ((const int) xRot % 360); @@ -186,7 +186,8 @@ void processEvents() /* XXX below code has to be placed here */ /* check for keys that are being constantly held */ - if (keys_held[SDLK_w] || keys_held[SDLK_s] || keys_held[SDLK_a] || keys_held[SDLK_d]) + if (keys_held[SDLK_w] || keys_held[SDLK_s] || keys_held[SDLK_a] || keys_held[SDLK_d] || + keys_held[SDLK_UP] || keys_held[SDLK_DOWN] || keys_held[SDLK_LEFT] || keys_held[SDLK_RIGHT]) { flag = !flag; keys(NULL, keys_held, flag); @@ -197,7 +198,7 @@ void processEvents() static void draw_ground(void) { - GLfloat fExtent = 20.0f; + GLfloat fExtent = 10.0f; GLfloat fStep = 0.5f; GLfloat y = -0.4f; GLfloat iLine; @@ -230,8 +231,10 @@ static void render(void) /* save the matrix state and do the rotations */ glPushMatrix(); - + /* apply camera transform, and draw the ground */ apply_camera_transform(&camera); + glColor3ub(255, 0, 255); + draw_ground(); /* move object back and do in place rotation */ glTranslatef(0.0f, 0.2f, -3.5f); @@ -302,9 +305,6 @@ static void render(void) /* restore the matrix state */ glPopMatrix(); - - glColor3ub(255, 0, 255); - draw_ground(); /* buffer swap */ SDL_GL_SwapBuffers(); |