projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix mkdir on win32
[supertux.git]
/
src
/
physic.h
diff --git
a/src/physic.h
b/src/physic.h
index
8e467d7
..
86114eb
100644
(file)
--- a/
src/physic.h
+++ b/
src/physic.h
@@
-17,56
+17,61
@@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
-
#ifndef SUPERTUX_PHYSIC_H
#define SUPERTUX_PHYSIC_H
#ifndef SUPERTUX_PHYSIC_H
#define SUPERTUX_PHYSIC_H
+#include "math/vector.h"
+
+/// Physics engine.
/** This is a very simplistic physics engine handling accelerated and constant
* movement along with gravity.
*/
class Physic
{
public:
/** This is a very simplistic physics engine handling accelerated and constant
* movement along with gravity.
*/
class Physic
{
public:
- Physic();
- ~Physic();
+ Physic();
+ ~Physic();
+
+ /// Resets all velocities and accelerations to 0.
+ void reset();
+
+ /// Sets velocity to a fixed value.
+ void set_velocity(float vx, float vy);
- /** resets all velocities and accelerations to 0 */
-
void reset(
);
+ void set_velocity_x(float vx);
+
void set_velocity_y(float vy
);
- /** sets velocity to a fixed value */
- void set_velocity(float vx, float vy);
+ /// Velocities invertion.
+ void inverse_velocity_x();
+ void inverse_velocity_y();
-
void set_velocity_x(float vx
);
-
void set_velocity_y(float vy
);
+
float get_velocity_x(
);
+
float get_velocity_y(
);
- /** velocities invertion */
- void inverse_velocity_x();
- void inverse_velocity_y();
+ /// Set acceleration.
+ /** Sets acceleration applied to the object. (Note that gravity is
+ * eventually added to the vertical acceleration)
+ */
+ void set_acceleration(float ax, float ay);
- float get_velocity_x();
- float get_velocity_y();
-
- /** sets acceleration applied to the object. (Note that gravity is
- * eventually added to the vertical acceleration)
- */
- void set_acceleration(float ax, float ay);
+ void set_acceleration_x(float ax);
+ void set_acceleration_y(float ay);
-
float get_acceleration_x();
-
float get_acceleration_y();
+ float get_acceleration_x();
+ float get_acceleration_y();
- /** enables or disables handling of gravity */
-
void enable_gravity(bool gravity_enabled);
+ /// Enables or disables handling of gravity.
+ void enable_gravity(bool gravity_enabled);
- /** applies the physical simulation to given x and y coordinates */
- void apply(float frame_ratio, float &x, float &y);
+ Vector get_movement(float elapsed_time);
private:
private:
-
/// horizontal and vertical acceleration
-
float ax, ay;
-
/// horizontal and vertical velocity
-
float vx, vy;
-
/// should we respect gravity in out calculations?
-
bool gravity_enabled;
+ /// horizontal and vertical acceleration
+ float ax, ay;
+ /// horizontal and vertical velocity
+ float vx, vy;
+ /// should we respect gravity in out calculations?
+ bool gravity_enabled;
};
};
-#endif
/*SUPERTUX_PHYSIC_H*/
+#endif