# HG changeset patch # User ekku # Date 1227048763 0 # Node ID f4457e62439a8bf931bef5fb152fa45be0712a91 # Parent cd47406d4cc22e2d12c4705fb06b2eab4e39df88 Fyssaa. diff -r cd47406d4cc2 -r f4457e62439a src/proto2/GameState.hh --- a/src/proto2/GameState.hh Tue Nov 18 22:52:00 2008 +0000 +++ b/src/proto2/GameState.hh Tue Nov 18 22:52:43 2008 +0000 @@ -14,7 +14,7 @@ const float PLAYER_MASS = 10.0; const float PLAYER_MOVE_FORCE = 500.0; const float PLAYER_INITIAL_X = 50.0; -const float PLAYER_INITIAL_Y = 50.0; +const float PLAYER_INITIAL_Y = 40.0; // forward-declare GameState class GameState; diff -r cd47406d4cc2 -r f4457e62439a src/proto2/Physics.cc --- a/src/proto2/Physics.cc Tue Nov 18 22:52:00 2008 +0000 +++ b/src/proto2/Physics.cc Tue Nov 18 22:52:43 2008 +0000 @@ -32,6 +32,15 @@ void PhysicsObject::updatePosition () { + // Check if the player is moving on the ground + /*if (this->velocity.y == 0 && (position.y >= world.dimensions.y - 3)) { + position.x += 50 * velocity.x * (PHYSICS_TICK_MS / 1000.0); + velocity.x = 0; + return; + }*/ + + // If not moving on the ground, apply normal physics + // Calculate gravity's influence on the velocity vector this->velocity += world.gravity * (PHYSICS_TICK_MS / 1000.0); @@ -42,6 +51,7 @@ // Engine::log(DEBUG, "physics.update_position") << "position=" << newPosition << ", velocity=" << velocity; bool collided = false; + if (newPosition.x < 0 || (newPosition.x > world.dimensions.x)) { // CRASH! this->velocity.x *= -0.5; @@ -59,17 +69,21 @@ if (newPosition.y <= 0 || (newPosition.y >= world.dimensions.y)) { this->velocity.y *= -0.3; - if (abs(this->velocity.y) < 0.1) + + + if (abs(this->velocity.y) < 0.1) { this->velocity.y = 0; - - // Friction - if(this->velocity.y == 0) - this->velocity.x = 0; + // Friction + this->velocity.x *= 0.95; + } else { + // Bigger friction + this->velocity.x *= 0.75; + } collided = true; } else { this->position.y = newPosition.y; - } + } if(!collided) { this->position = newPosition; diff -r cd47406d4cc2 -r f4457e62439a src/proto2/SinglePlayer.hh --- a/src/proto2/SinglePlayer.hh Tue Nov 18 22:52:00 2008 +0000 +++ b/src/proto2/SinglePlayer.hh Tue Nov 18 22:52:43 2008 +0000 @@ -5,7 +5,7 @@ class SinglePlayer : public LocalPlayer { public: - SinglePlayer (GameState &state) : LocalPlayer(state, Vector(50.0, 50.0), true) { } + SinglePlayer (GameState &state) : LocalPlayer(state, Vector(PLAYER_INITIAL_X, PLAYER_INITIAL_Y), true) { } }; #endif /* SINGLE_PLAYER_HH */