#define TRAMPOLINE_FRAMES 4
Sprite *img_trampoline[TRAMPOLINE_FRAMES];
-void load_trampoline_gfx()
+void load_object_gfx()
{
for (int i = 0; i < TRAMPOLINE_FRAMES; i++)
{
{
base.x = x;
base.y = y;
+
+ base.height = 32;
}
void
Trampoline::action(double frame_ratio)
{
(void) frame_ratio;
+ physic.apply(frame_ratio, base.x, base.y);
// TODO:
// If HELD
// - move with tux
#include "texture.h"
#include "timer.h"
#include "scene.h"
+#include "physic.h"
enum ObjectType { OBJ_NONE, OBJ_BADGUY, OBJ_TRAMPOLINE };
: x(0), y(0), type(OBJ_NONE), type_specific() {};
};
-struct TrampolineData
-{
- int power;
-};
-
-
/* Bounciness of distros: */
#define NO_BOUNCE 0
#define BOUNCE 1
std::string type() { return "FloatingScore"; };
};
+
+/* Trampoline */
+struct TrampolineData
+{
+ int power;
+};
+
class Trampoline : public GameObject
{
public:
Trampoline(ObjectData<TrampolineData> data)
{
- base.x = data.x;
- base.y = data.y;
-
power = data.type_specific.power;
- }
+
+ init(data.x, data.y);
+ };
+
+ Physic physic;
private:
int power;
};
-void load_trampoline_gfx();
+
+void load_object_gfx();
#endif
/* Upgrades: */
load_special_gfx();
- /* Trampoline */
- load_trampoline_gfx();
+ /* Objects */
+ load_object_gfx();
/* Distros: */
img_distro[0] = new Surface(datadir + "/images/tilesets/coin1.png",
#include "level.h"
#include "tile.h"
#include "resources.h"
+#include "gameobjs.h"
Surface* img_distro[4];
for (std::vector< ObjectData<TrampolineData> >::iterator i = level->trampoline_data.begin();
i != level->trampoline_data.end();
++i)
- {puts("fo");
+ {
add_object<Trampoline, ObjectData<TrampolineData> >(*i);
}
}
for (BadGuys::iterator i = bad_guys.begin(); i != bad_guys.end(); ++i)
(*i)->action(frame_ratio);
+ for (Trampolines::iterator i = trampolines.begin(); i != trampolines.end(); ++i)
+ (*i)->action(frame_ratio);
+
/* update particle systems */
std::vector<ParticleSystem*>::iterator p;
for(p = particle_systems.begin(); p != particle_systems.end(); ++p)
World::add_object(U data)
{
T* tobject = new T(data);
- trampolines.push_back(tobject);
+
+ if (data.type == OBJ_TRAMPOLINE)
+ trampolines.push_back(tobject);
return tobject;
}