#include "audio/sound_manager.hpp"
#include "audio/sound_source.hpp"
-class BadGuy : public MovingSprite, public Serializable
+class BadGuy : public MovingSprite, protected UsesPhysic, public Serializable
{
public:
BadGuy(const Vector& pos, const std::string& sprite_name, int layer = LAYER_OBJECTS);
*/
Player* get_nearest_player();
- Physic physic;
-
/// is the enemy activated
bool activated;
/**
#include "sprite/sprite.hpp"
#include "player_status.hpp"
-class Bullet : public MovingObject
+class Bullet : public MovingObject, private UsesPhysic
{
public:
Bullet(const Vector& pos, float xm, int dir, BonusType type);
private:
int life_count;
- Physic physic;
std::auto_ptr<Sprite> sprite;
BonusType type;
};
#include "video/drawing_context.hpp"
#include "physic.hpp"
-class FallingCoin : public GameObject
+class FallingCoin : public GameObject, private UsesPhysic
{
public:
FallingCoin(const Vector& start_position, const int x_vel);
private:
Vector pos;
Sprite* sprite;
- Physic physic;
};
#endif
#include "moving_object.hpp"
#include "sprite/sprite.hpp"
-#include "physic.hpp"
#include "player_status.hpp"
class Flower : public MovingObject
#include "video/surface.hpp"
#include "timer.hpp"
-#include "physic.hpp"
#include "game_object.hpp"
#include "moving_object.hpp"
#include "serializable.hpp"
#include "physic.hpp"
#include "direction.hpp"
-class GrowUp : public MovingSprite
+class GrowUp : public MovingSprite, private UsesPhysic
{
public:
GrowUp(Direction direction = RIGHT);
virtual void update(float elapsed_time);
virtual void collision_solid(const CollisionHit& hit);
virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
-
-private:
- Physic physic;
};
#endif
#include "physic.hpp"
#include "direction.hpp"
-class OneUp : public MovingSprite
+class OneUp : public MovingSprite, private UsesPhysic
{
public:
OneUp(const Vector& pos, Direction direction = RIGHT);
virtual void update(float elapsed_time);
virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
-
-private:
- Physic physic;
};
#endif
extern TuxBodyParts* fire_tux;
extern TuxBodyParts* ice_tux;
-class Player : public MovingObject, public Scripting::Player, public ScriptInterface
+class Player : public MovingObject, public UsesPhysic, public Scripting::Player, public ScriptInterface
{
public:
enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING };
Timer growing_timer;
Timer idle_timer;
Timer backflip_timer;
- Physic physic;
public:
Player(PlayerStatus* player_status, const std::string& name);
#include "collision_hit.hpp"
#include "physic.hpp"
-class PowerUp : public MovingSprite
+class PowerUp : public MovingSprite, private UsesPhysic
{
public:
PowerUp(const lisp::Lisp& lisp);
virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
private:
- Physic physic;
std::string script;
bool no_physics;
};
class Sprite;
-class Rock : public MovingSprite, public Portable, public Serializable
+class Rock : public MovingSprite, public Portable, protected UsesPhysic, public Serializable
{
public:
Rock(const lisp::Lisp& reader);
protected:
bool on_ground;
bool grabbed;
- Physic physic;
Vector last_movement;
};
#include "script_interface.hpp"
#include "scripting/scripted_object.hpp"
-class ScriptedObject : public MovingSprite, public Scripting::ScriptedObject,
- public ScriptInterface
+class ScriptedObject : public MovingSprite, public UsesPhysic,
+ public Scripting::ScriptedObject, public ScriptInterface
{
public:
ScriptedObject(const lisp::Lisp& lisp);
bool visible;
bool new_vel_set;
Vector new_vel;
- Physic physic;
};
#endif
class Player;
/** A tile that starts falling down if tux stands to long on it */
-class SkullTile : public MovingSprite
+class SkullTile : public MovingSprite, private UsesPhysic
{
public:
SkullTile(const lisp::Lisp& lisp);
void draw(DrawingContext& context);
private:
- Physic physic;
Timer timer;
bool hit;
bool falling;
#include "physic.hpp"
#include "direction.hpp"
-class Star : public MovingSprite
+class Star : public MovingSprite, private UsesPhysic
{
public:
Star(const Vector& pos, Direction direction = RIGHT);
virtual void update(float elapsed_time);
virtual void collision_solid(const CollisionHit& hit);
virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
-
-private:
- Physic physic;
};
#endif
#include "moving_sprite.hpp"
#include "lisp/lisp.hpp"
#include "object/rock.hpp"
-#include "physic.hpp"
/**
* Jumping on a trampolin makes tux jump higher.
/**
* A block that disintegrates when stood on
*/
-class UnstableTile : public MovingSprite
+class UnstableTile : public MovingSprite, public UsesPhysic
{
public:
UnstableTile(const lisp::Lisp& lisp);
STATE_DISINTEGRATING /**< disintegrating, no longer solid */
};
State state;
-
- Physic physic;
};
#endif
/**
* A block that can be destroyed by Bullet hits
*/
-class WeakBlock : public MovingSprite
+class WeakBlock : public MovingSprite, public UsesPhysic
{
public:
WeakBlock(const lisp::Lisp& lisp);
STATE_DISINTEGRATING /**< crumbling to dust, no longer solid */
};
State state;
-
- Physic physic;
};
#endif
float gravity;
};
+class UsesPhysic
+{
+public:
+ Physic physic;
+ friend class Sector;
+};
+
#endif
Sector::Sector(Level* parent)
: level(parent), currentmusic(LEVEL_MUSIC),
- ambient_light( 1.0f, 1.0f, 1.0f, 1.0f ), gravity(10), player(0), camera(0)
+ ambient_light( 1.0f, 1.0f, 1.0f, 1.0f ), gravity(1000.0), player(0), camera(0)
{
add_object(new Player(player_status, "Tux"));
add_object(new DisplayEffect("Effect"));
this->player = player;
}
+ UsesPhysic *physic_object = dynamic_cast<UsesPhysic *>(object);
+ if(physic_object)
+ {
+ physic_object->physic.set_gravity(gravity);
+ }
+
+
if(_current == this) {
try_expose(object);
}