From 36afad72b6c66d4619372892f589a4131afed638 Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Sun, 25 Jun 2006 13:32:44 +0000 Subject: [PATCH] Switched y coordinate of Physics class to be like all other y coordinates in SuperTux: positive y is down SVN-Revision: 3741 --- src/badguy/angrystone.cpp | 4 ++-- src/badguy/bouncing_snowball.cpp | 2 +- src/badguy/fish.cpp | 6 +++--- src/badguy/flyingsnowball.cpp | 2 +- src/badguy/jumpy.cpp | 2 +- src/badguy/kugelblitz.cpp | 2 +- src/badguy/nolok_01.cpp | 2 +- src/badguy/skullyhop.cpp | 6 +++--- src/badguy/snail.cpp | 2 +- src/badguy/spidermite.cpp | 2 +- src/badguy/totem.cpp | 4 ++-- src/badguy/yeti.cpp | 6 +++--- src/badguy/zeekling.cpp | 4 ++-- src/object/bullet.cpp | 4 ++-- src/object/falling_coin.cpp | 2 +- src/object/oneup.cpp | 2 +- src/object/player.cpp | 32 ++++++++++++++++---------------- src/object/scripted_object.cpp | 2 +- src/object/star.cpp | 4 ++-- src/physic.cpp | 16 ++++++++-------- 20 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/badguy/angrystone.cpp b/src/badguy/angrystone.cpp index 906112d5c..010230c19 100644 --- a/src/badguy/angrystone.cpp +++ b/src/badguy/angrystone.cpp @@ -107,10 +107,10 @@ AngryStone::active_update(float elapsed_time) { if ((dx > -playerWidth) && (dx < badguyWidth)) { if (dy > 0) { attackDirection.x = 0; - attackDirection.y = -1; + attackDirection.y = 1; } else { attackDirection.x = 0; - attackDirection.y = 1; + attackDirection.y = -1; } if ((attackDirection.x != oldWallDirection.x) || (attackDirection.y != oldWallDirection.y)) { sprite->set_action("charging"); diff --git a/src/badguy/bouncing_snowball.cpp b/src/badguy/bouncing_snowball.cpp index 76df35af0..5601bfb12 100644 --- a/src/badguy/bouncing_snowball.cpp +++ b/src/badguy/bouncing_snowball.cpp @@ -21,7 +21,7 @@ #include "bouncing_snowball.hpp" -static const float JUMPSPEED = 450; +static const float JUMPSPEED = -450; static const float WALKSPEED = 80; BouncingSnowball::BouncingSnowball(const lisp::Lisp& reader) diff --git a/src/badguy/fish.cpp b/src/badguy/fish.cpp index 850d0a6f2..4c6817a44 100644 --- a/src/badguy/fish.cpp +++ b/src/badguy/fish.cpp @@ -24,7 +24,7 @@ #include "object/tilemap.hpp" #include "log.hpp" -static const float FISH_JUMP_POWER = 600; +static const float FISH_JUMP_POWER = -600; static const float FISH_WAIT_TIME = 1; Fish::Fish(const lisp::Lisp& reader) @@ -84,7 +84,7 @@ Fish::hit(const CollisionHit& chit) void Fish::collision_tile(uint32_t tile_attributes) { - if ((tile_attributes & Tile::WATER) && (physic.get_velocity_y() <= 0)) { + if ((tile_attributes & Tile::WATER) && (physic.get_velocity_y() >= 0)) { // initialize stop position if uninitialized if (stop_y == 0) stop_y = get_pos().y + get_bbox().get_height(); @@ -109,7 +109,7 @@ Fish::active_update(float elapsed_time) } // set sprite - sprite->set_action(physic.get_velocity_y() > 0 ? "normal" : "down"); + sprite->set_action(physic.get_velocity_y() < 0 ? "normal" : "down"); // we can't afford flying out of the tilemap, 'cause the engine would remove us. if ((get_pos().y - 31.8) < 0) // too high, let us fall diff --git a/src/badguy/flyingsnowball.cpp b/src/badguy/flyingsnowball.cpp index 4c3acdbe4..59b10f321 100644 --- a/src/badguy/flyingsnowball.cpp +++ b/src/badguy/flyingsnowball.cpp @@ -26,7 +26,7 @@ #include "object/sprite_particle.hpp" static const float FLYTIME = 1.0; -static const float FLYSPEED = 100.0; +static const float FLYSPEED = -100.0; namespace { const float PUFF_PROBABILITY = 0.1; /**< chanche of puffs being spawned in the current cycle */ diff --git a/src/badguy/jumpy.cpp b/src/badguy/jumpy.cpp index d6e71fea8..02ceeb1bb 100644 --- a/src/badguy/jumpy.cpp +++ b/src/badguy/jumpy.cpp @@ -21,7 +21,7 @@ #include "jumpy.hpp" -static const float JUMPSPEED=600; +static const float JUMPSPEED=-600; static const float JUMPY_MID_TOLERANCE=4; static const float JUMPY_LOW_TOLERANCE=2; diff --git a/src/badguy/kugelblitz.cpp b/src/badguy/kugelblitz.cpp index 697678dd0..f8ecf1703 100644 --- a/src/badguy/kugelblitz.cpp +++ b/src/badguy/kugelblitz.cpp @@ -54,7 +54,7 @@ Kugelblitz::write(lisp::Writer& writer) void Kugelblitz::activate() { - physic.set_velocity_y(-300); + physic.set_velocity_y(300); physic.set_velocity_x(-20); //fall a little to the left direction = 1; dying = false; diff --git a/src/badguy/nolok_01.cpp b/src/badguy/nolok_01.cpp index f03a31fb6..b1e7c777d 100644 --- a/src/badguy/nolok_01.cpp +++ b/src/badguy/nolok_01.cpp @@ -74,7 +74,7 @@ Nolok_01::active_update(float elapsed_time) case WALKING: { sprite->set_action("jump"); - physic.set_velocity_y(700); + physic.set_velocity_y(-700); action = JUMPING; action_timer.start(JUMP_TIME); break; diff --git a/src/badguy/skullyhop.cpp b/src/badguy/skullyhop.cpp index 9282d29ea..fb12d7519 100644 --- a/src/badguy/skullyhop.cpp +++ b/src/badguy/skullyhop.cpp @@ -23,7 +23,7 @@ #include "random_generator.hpp" namespace { - const float VERTICAL_SPEED = 450; /**< y-speed when jumping */ + const float VERTICAL_SPEED = -450; /**< y-speed when jumping */ const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */ const float MIN_RECOVER_TIME = 0.1; /**< minimum time to stand still before starting a (new) jump */ const float MAX_RECOVER_TIME = 1.0; /**< maximum time to stand still before starting a (new) jump */ @@ -99,12 +99,12 @@ SkullyHop::collision_solid(GameObject& , const CollisionHit& hit) if(state != JUMPING) return CONTINUE; // check if we hit the floor while falling - if ((hit.normal.y < 0) && (physic.get_velocity_y() < 0)) { + if ((hit.normal.y < 0) && (physic.get_velocity_y() > 0)) { set_state(STANDING); } // check if we hit the roof while climbing - if ((hit.normal.y > 0) && (physic.get_velocity_y() > 0)) { + if ((hit.normal.y > 0) && (physic.get_velocity_y() < 0)) { physic.set_velocity_y(0); } diff --git a/src/badguy/snail.cpp b/src/badguy/snail.cpp index 39664feab..c2da55673 100644 --- a/src/badguy/snail.cpp +++ b/src/badguy/snail.cpp @@ -26,7 +26,7 @@ namespace { const float WALKSPEED = 80; const float KICKSPEED = 500; const int MAXSQUISHES = 10; - const float KICKSPEED_Y = 500; /**< y-velocity gained when kicked */ + const float KICKSPEED_Y = -500; /**< y-velocity gained when kicked */ } Snail::Snail(const lisp::Lisp& reader) diff --git a/src/badguy/spidermite.cpp b/src/badguy/spidermite.cpp index c98598493..41ccb2e34 100644 --- a/src/badguy/spidermite.cpp +++ b/src/badguy/spidermite.cpp @@ -23,7 +23,7 @@ #include "spidermite.hpp" static const float FLYTIME = 1.2; -static const float FLYSPEED = 100.0; +static const float FLYSPEED = -100.0; SpiderMite::SpiderMite(const lisp::Lisp& reader) : BadGuy(reader, "images/creatures/spidermite/spidermite.sprite") diff --git a/src/badguy/totem.cpp b/src/badguy/totem.cpp index 7ec6693cb..825ed8143 100644 --- a/src/badguy/totem.cpp +++ b/src/badguy/totem.cpp @@ -24,8 +24,8 @@ #include "log.hpp" static const float WALKSPEED = 100; -static const float JUMP_ON_SPEED_Y = 400; -static const float JUMP_OFF_SPEED_Y = 500; +static const float JUMP_ON_SPEED_Y = -400; +static const float JUMP_OFF_SPEED_Y = -500; Totem::Totem(const lisp::Lisp& reader) : BadGuy(reader, "images/creatures/totem/totem.sprite") diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index c8c717dc3..9f6924540 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -32,14 +32,14 @@ namespace { const float JUMP_DOWN_VX = 250; /**< horizontal speed while jumping off the dais */ - const float JUMP_DOWN_VY = 250; /**< vertical speed while jumping off the dais */ + const float JUMP_DOWN_VY = -250; /**< vertical speed while jumping off the dais */ const float RUN_VX = 350; /**< horizontal speed while running */ const float JUMP_UP_VX = 350; /**< horizontal speed while jumping on the dais */ - const float JUMP_UP_VY = 800; /**< vertical speed while jumping on the dais */ + const float JUMP_UP_VY = -800; /**< vertical speed while jumping on the dais */ - const float STOMP_VY = 250; /** vertical speed while stomping on the dais */ + const float STOMP_VY = -250; /** vertical speed while stomping on the dais */ const float LEFT_STAND_X = 16; /**< x-coordinate of left dais' end position */ const float RIGHT_STAND_X = 800-60-16; /**< x-coordinate of right dais' end position */ diff --git a/src/badguy/zeekling.cpp b/src/badguy/zeekling.cpp index 65abb0c24..5e30d2052 100644 --- a/src/badguy/zeekling.cpp +++ b/src/badguy/zeekling.cpp @@ -98,7 +98,7 @@ Zeekling::onBumpVertical() { } else if (state == DIVING) { state = CLIMBING; - physic.set_velocity_y(speed); + physic.set_velocity_y(-speed); sprite->set_action(dir == LEFT ? "left" : "right"); } else if (state == CLIMBING) { @@ -168,7 +168,7 @@ Zeekling::active_update(float elapsed_time) { if (state == FLYING) { if (should_we_dive()) { state = DIVING; - physic.set_velocity_y(-2*fabsf(physic.get_velocity_x())); + physic.set_velocity_y(2*fabsf(physic.get_velocity_x())); sprite->set_action(dir == LEFT ? "diving-left" : "diving-right"); } return; diff --git a/src/object/bullet.cpp b/src/object/bullet.cpp index 40d9a5e4c..a8b7cef9d 100644 --- a/src/object/bullet.cpp +++ b/src/object/bullet.cpp @@ -39,7 +39,7 @@ Bullet::Bullet(const Vector& pos, float xm, int dir, int kind_) float speed = dir == RIGHT ? BULLET_XM : -BULLET_XM; physic.set_velocity_x(speed + xm); - physic.set_velocity_y(-BULLET_STARTING_YM); + physic.set_velocity_y(BULLET_STARTING_YM); if (kind == ICE_BULLET) { life_count = 6; //ice-bullets get "extra lives" for bumping off walls @@ -59,7 +59,7 @@ Bullet::update(float elapsed_time) { if(kind == FIRE_BULLET) { // @not completely framerate independant :-/ - physic.set_velocity_y(physic.get_velocity_y() - 50 * elapsed_time); + physic.set_velocity_y(physic.get_velocity_y() + 50 * elapsed_time); } if(physic.get_velocity_y() > 900) physic.set_velocity_y(900); diff --git a/src/object/falling_coin.cpp b/src/object/falling_coin.cpp index 4066d2bd3..8e091a5d3 100644 --- a/src/object/falling_coin.cpp +++ b/src/object/falling_coin.cpp @@ -29,7 +29,7 @@ FallingCoin::FallingCoin(const Vector& start_position, const int vel_x) { pos = start_position; sprite = sprite_manager->create("images/objects/coin/coin.sprite"); - physic.set_velocity_y(800); + physic.set_velocity_y(-800); physic.set_velocity_x(vel_x); } diff --git a/src/object/oneup.cpp b/src/object/oneup.cpp index d449daf76..3b45a63f3 100644 --- a/src/object/oneup.cpp +++ b/src/object/oneup.cpp @@ -29,7 +29,7 @@ OneUp::OneUp(const Vector& pos) : MovingSprite(pos, "images/powerups/1up/1up.sprite", LAYER_FLOATINGOBJECTS, COLGROUP_TOUCHABLE) { - physic.set_velocity(100, 400); + physic.set_velocity(100, -400); } void diff --git a/src/object/player.cpp b/src/object/player.cpp index ce9bc9de4..66f4291ab 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -342,7 +342,7 @@ Player::handle_horizontal_input() if (floor_normal.y != 0) { if ((floor_normal.x * vx) > 0) { // we overdo it a little, just to be on the safe side - vy = vx * (floor_normal.x / floor_normal.y) * 2; + vy = -vx * (floor_normal.x / floor_normal.y) * 2; } } } @@ -377,17 +377,17 @@ Player::handle_vertical_input() if(controller->pressed(Controller::JUMP) && can_jump && on_ground()) { if (duck) { if (physic.get_velocity_x() != 0) // only jump a little bit when running ducked - physic.set_velocity_y(300); + physic.set_velocity_y(-300); else { //do a backflip backflipping = true; - physic.set_velocity_y(580); + physic.set_velocity_y(-580); backflip_timer.start(0.15); } } else if (fabs(physic.get_velocity_x()) > MAX_WALK_XM) // jump higher if we are running - physic.set_velocity_y(580); + physic.set_velocity_y(-580); else - physic.set_velocity_y(520); + physic.set_velocity_y(-520); //bbox.move(Vector(0, -1)); jumping = true; @@ -397,7 +397,7 @@ Player::handle_vertical_input() else sound_manager->play("sounds/jump.wav"); } else if(!controller->hold(Controller::JUMP)) { // Let go of jump key - if (!backflipping && jumping && physic.get_velocity_y() > 0) { + if (!backflipping && jumping && physic.get_velocity_y() < 0) { jumping = false; physic.set_velocity_y(0); } @@ -430,7 +430,7 @@ Player::handle_vertical_input() Vector(base.x + 1, base.y + base.height), false) || Sector::current()->trybreakbrick( Vector(base.x + base.width - 1, base.y + base.height), false)) { - physic.set_velocity_y(2); + physic.set_velocity_y(-2); butt_jump = true; } @@ -564,10 +564,10 @@ Player::handle_input_ghost() vx += MAX_RUN_XM * 2; } if ((controller->hold(Controller::UP)) || (controller->hold(Controller::JUMP))) { - vy += MAX_RUN_XM * 2; + vy -= MAX_RUN_XM * 2; } if (controller->hold(Controller::DOWN)) { - vy -= MAX_RUN_XM * 2; + vy += MAX_RUN_XM * 2; } if (controller->hold(Controller::ACTION)) { set_ghost_mode(false); @@ -828,7 +828,7 @@ Player::collision(GameObject& other, const CollisionHit& hit) */ if(hit.normal.y < 0) { // landed on floor? - if(physic.get_velocity_y() < 0) + if(physic.get_velocity_y() > 0) physic.set_velocity_y(0); on_ground_flag = true; @@ -848,16 +848,16 @@ Player::collision(GameObject& other, const CollisionHit& hit) Platform* platform = dynamic_cast (&other); if(platform != NULL) { if(platform->get_speed().y > 0) - physic.set_velocity_y(-platform->get_speed().y); + physic.set_velocity_y(platform->get_speed().y); //physic.set_velocity_x(platform->get_speed().x); } } else if(hit.normal.y > 0) { // bumped against the roof - physic.set_velocity_y(.1); + physic.set_velocity_y(-.1); // hack platform so that we are not glued to it from below Platform* platform = dynamic_cast (&other); if(platform != NULL) { - physic.set_velocity_y(-platform->get_speed().y); + physic.set_velocity_y(platform->get_speed().y); } } @@ -951,7 +951,7 @@ Player::kill(bool completely) } physic.enable_gravity(true); physic.set_acceleration(0, 0); - physic.set_velocity(0, 700); + physic.set_velocity(0, -700); player_status->coins -= 25; set_bonus(NO_BONUS); dying = true; @@ -1042,9 +1042,9 @@ void Player::bounce(BadGuy& ) { if(controller->hold(Controller::JUMP)) - physic.set_velocity_y(520); + physic.set_velocity_y(-520); else - physic.set_velocity_y(300); + physic.set_velocity_y(-300); } //Scripting Functions Below diff --git a/src/object/scripted_object.cpp b/src/object/scripted_object.cpp index 69f15ca2a..d525022d2 100644 --- a/src/object/scripted_object.cpp +++ b/src/object/scripted_object.cpp @@ -173,7 +173,7 @@ ScriptedObject::collision(GameObject& other, const CollisionHit& hit) if(other.get_flags() & FLAG_SOLID) { if(hit.normal.y < 0) { // landed on floor - if(physic.get_velocity_y() < 0) + if(physic.get_velocity_y() > 0) physic.set_velocity_y(0); } else if(hit.normal.y > 0) { // bumped against roof physic.set_velocity_y(.1); diff --git a/src/object/star.cpp b/src/object/star.cpp index 39724b8d7..e6ef93461 100644 --- a/src/object/star.cpp +++ b/src/object/star.cpp @@ -26,9 +26,9 @@ #include "sprite/sprite_manager.hpp" #include "video/drawing_context.hpp" -static const float INITIALJUMP = 400; +static const float INITIALJUMP = -400; static const float SPEED = 150; -static const float JUMPSPEED = 300; +static const float JUMPSPEED = -300; Star::Star(const Vector& pos) : MovingSprite(pos, "images/powerups/star/star.sprite", LAYER_OBJECTS, COLGROUP_MOVING) diff --git a/src/physic.cpp b/src/physic.cpp index 753d3cbf6..518ce8349 100644 --- a/src/physic.cpp +++ b/src/physic.cpp @@ -47,14 +47,14 @@ Physic::set_velocity_x(float nvx) void Physic::set_velocity_y(float nvy) { - vy = -nvy; + vy = nvy; } void Physic::set_velocity(float nvx, float nvy) { vx = nvx; - vy = -nvy; + vy = nvy; } void @@ -83,13 +83,13 @@ Physic::get_velocity_x() const float Physic::get_velocity_y() const { - return -vy; + return vy; } Vector Physic::get_velocity() const { - return Vector(vx, -vy); + return Vector(vx, vy); } void @@ -101,14 +101,14 @@ Physic::set_acceleration_x(float nax) void Physic::set_acceleration_y(float nay) { - ay = -nay; + ay = nay; } void Physic::set_acceleration(float nax, float nay) { ax = nax; - ay = -nay; + ay = nay; } float @@ -120,13 +120,13 @@ Physic::get_acceleration_x() const float Physic::get_acceleration_y() const { - return -ay; + return ay; } Vector Physic::get_acceleration() const { - return Vector(ax, -ay); + return Vector(ax, ay); } void -- 2.11.0