Just removed two printfs I have mistakelly committed.
[supertux.git] / src / physic.h
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20
21 #ifndef SUPERTUX_PHYSIC_H
22 #define SUPERTUX_PHYSIC_H
23
24 /** This is a very simplistic physics engine handling accelerated and constant
25   * movement along with gravity.
26   */
27 class Physic
28 {
29 public:
30     Physic();
31     ~Physic();
32
33     /** resets all velocities and accelerations to 0 */
34     void reset();
35
36     /** sets velocity to a fixed value */
37     void set_velocity(float vx, float vy);
38
39     /** velocities invertion */
40     void inverse_velocity_x();
41     void inverse_velocity_y();
42
43     float get_velocity_x();
44     float get_velocity_y();
45     
46     /** sets acceleration applied to the object. (Note that gravity is
47      * eventually added to the vertical acceleration)
48      */
49     void set_acceleration(float ax, float ay);
50
51     float get_acceleration_x();
52     float get_acceleration_y();
53
54     /** enables or disables handling of gravity */
55     void enable_gravity(bool gravity_enabled);
56
57     /** applies the physical simulation to given x and y coordinates */
58     void apply(float frame_ratio, float &x, float &y); 
59
60 private:
61     /// horizontal and vertical acceleration
62     float ax, ay;
63     /// horizontal and vertical velocity
64     float vx, vy;
65     /// should we respect gravity in out calculations?
66     bool gravity_enabled;
67 };
68
69 #endif /*SUPERTUX_PHYSIC_H*/