summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/main.cpp b/main.cpp
index 36ddb10..9f3bf15 100644
--- a/main.cpp
+++ b/main.cpp
@@ -198,14 +198,14 @@ int main(int argc, char **argv) {
grid = !grid;
break;
case SDLK_KP_PLUS:
- delete qt;
- qt = new Quadtree(hm->w, hm->h, heightmap, ++level);
+ case SDLK_PLUS:
+ qt->create_nodes(++level);
level = qt->levels;
break;
case SDLK_KP_MINUS:
+ case SDLK_MINUS:
if(level > 0) {
- delete qt;
- qt = new Quadtree(hm->w, hm->h, heightmap, --level);
+ qt->create_nodes(--level);
}
break;
case SDLK_SPACE:
@@ -278,21 +278,19 @@ int main(int argc, char **argv) {
scene.move(forward, right, steps*(keystate[SDLK_LSHIFT]?10:1));
std::string move_str;
- {
- Quadtree::QuadNode *node = qt->find(scene.pos.x, scene.pos.z);
- if(node) {
- float y = node->get_height(scene.pos.x, scene.pos.z);
- if(scene.pos.y > y && !keystate[SDLK_e])
- scene.yvel -= 9.81 * steps / 85000;
- if(scene.yvel < -.5)
- scene.yvel = -.5;
- scene.pos.y += scene.yvel * steps;
- if(scene.pos.y < y) {
- scene.pos.y = y;
- scene.yvel = 0;
- }
- move_str = (boost::format("%s %.2f,%.2f %dx%d") % scene.pos.str() % node->x % node->y % node->width % node->height).str();
+ Quadtree::QuadNode *node = qt->find(scene.pos.x, scene.pos.z);
+ if(node) {
+ float y = node->get_height(scene.pos.x, scene.pos.z);
+ if(scene.pos.y > y && !keystate[SDLK_e])
+ scene.yvel -= 9.81 * steps / 85000;
+ if(scene.yvel < -.5)
+ scene.yvel = -.5;
+ scene.pos.y += scene.yvel * steps;
+ if(scene.pos.y < y) {
+ scene.pos.y = y;
+ scene.yvel = 0;
}
+ move_str = (boost::format("%s %.2f,%.2f %dx%d %d") % scene.pos.str() % node->x % node->y % node->width % node->height % node->level).str();
}
scene.lookat();