X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fphysic.hpp;h=f8e807dab26fcb5cfe0fc6f45d422aaecc232756;hb=1142f65fdd5ccc3309a3da31fb1a0e7d5d0829fe;hp=eee2156120fe9857432c240e2dd2468af9496ea1;hpb=5b7f9214cb929399f1a855ef5807018a9447d510;p=supertux.git diff --git a/src/physic.hpp b/src/physic.hpp index eee215612..f8e807dab 100644 --- a/src/physic.hpp +++ b/src/physic.hpp @@ -1,7 +1,8 @@ // $Id$ -// +// // SuperTux // Copyright (C) 2004 Tobias Glaesser +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -12,7 +13,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA @@ -37,16 +38,18 @@ public: /// Sets velocity to a fixed value. void set_velocity(float vx, float vy); + void set_velocity(const Vector& vector); void set_velocity_x(float vx); void set_velocity_y(float vy); - /// Velocities invertion. + /// Velocity inversion. void inverse_velocity_x(); void inverse_velocity_y(); - float get_velocity_x(); - float get_velocity_y(); + Vector get_velocity() const; + float get_velocity_x() const; + float get_velocity_y() const; /// Set acceleration. /** Sets acceleration applied to the object. (Note that gravity is @@ -57,11 +60,19 @@ public: void set_acceleration_x(float ax); void set_acceleration_y(float ay); - float get_acceleration_x(); - float get_acceleration_y(); + Vector get_acceleration() const; + float get_acceleration_x() const; + float get_acceleration_y() const; /// Enables or disables handling of gravity. void enable_gravity(bool gravity_enabled); + bool gravity_enabled() const; + + /// Set gravity to apply to object when enabled + void set_gravity(float gravity); + + /// Get gravity to apply to object when enabled + float get_gravity() const; Vector get_movement(float elapsed_time); @@ -70,8 +81,17 @@ private: float ax, ay; /// horizontal and vertical velocity float vx, vy; - /// should we respect gravity in out calculations? - bool gravity_enabled; + /// should we respect gravity in our calculations? + bool gravity_enabled_flag; + /// current gravity (multiplied by 100) to apply to object, if enabled + float gravity; +}; + +class UsesPhysic +{ +public: + Physic physic; + friend class Sector; }; #endif