diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-05-29 13:20:04 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-05-29 13:20:04 +0200 |
commit | dec532e0574dfc900d4693e78cf5a9b4c35be204 (patch) | |
tree | b5748cadeecce33227a1441d99559346ab09a0e1 | |
parent | 214e2599599d5132234a28ff6852dc2d0eeb8d21 (diff) |
Somewhat fixed gravitation and jumping.
-rw-r--r-- | scene.cpp | 13 | ||||
-rw-r--r-- | scene.h | 1 |
2 files changed, 10 insertions, 4 deletions
@@ -20,6 +20,7 @@ Scene::Scene() { normals = false; render_terrain = true; gravity = true; + flying = true; last_node = NULL; @@ -185,7 +186,10 @@ void Scene::events() { render_terrain = !render_terrain; break; case SDLK_SPACE: - yvel = .05; + if(!flying) { + yvel = .02; + flying = true; + } break; case SDLK_h: gravity = !gravity; @@ -335,13 +339,14 @@ void Scene::render() { if(gravity) { float y = node->get_height(pos.x, pos.z); if(pos.y > y && !keystate[SDLK_e]) - yvel -= 9.81 * steps / 85000; - if(yvel < -.5) - yvel = -.5; + yvel -= 9.81 / 200000. * steps; + if(yvel < -.1) + yvel = -.1; pos.y += yvel * steps; if(pos.y < y) { pos.y = y; yvel = 0; + flying = false; } } move_str = (boost::format("%s n: %.2f,%.2f c: %d,%d %dx%d") @@ -29,6 +29,7 @@ class Scene { bool render_terrain; bool gravity; bool dialog; + bool flying; Terrain::Node *last_node; |