(mode "normal")
)
+ (spawnpoint (name "main") (x 950) (y 400))
(background
(image "ghostforest.jpg")
(speed 1.000000)
)
- (poisonivy (x 987) (y 440))
- (poisonivy (x 873) (y 438))
+ (poisonivy (x 800) (y 440))
+ (poisonivy (x 100) (y 438))
(kugelblitz (x 519) (y 32))
+ (kugelblitz (x 700) (y 32))
(kugelblitz (x 1100) (y 169))
)
)
#include "object/tilemap.hpp"
#include "tile.hpp"
+#define LIFETIME 5
+#define MOVETIME 0.75
+#define BASE_SPEED 200
+#define RAND_SPEED 150
+
Kugelblitz::Kugelblitz(const lisp::Lisp& reader)
: groundhit_pos_set(false)
{
physic.set_velocity_y(-300);
physic.set_velocity_x(-20); //fall a little to the left
direction = 1;
+ dying = false;
}
HitResponse
Kugelblitz::collision_solid(GameObject& other, const CollisionHit& chit)
{
+ //TODO: Explode when Tux is hit
return hit(chit);
}
}
sprite->set_action("flying");
physic.set_velocity_y(0);
- movement_timer.start(1500);
+ //Set random initial speed and direction
+ if ((rand() % 2) == 1) direction = 1; else direction = -1;
+ int speed = (BASE_SPEED + (rand() % RAND_SPEED)) * direction;
+ physic.set_velocity_x(speed);
+ movement_timer.start(MOVETIME);
+ lifetime.start(LIFETIME);
} else if(chit.normal.y < .5) { // bumped on roof
physic.set_velocity_y(0);
void
Kugelblitz::active_update(float elapsed_time)
{
- if (groundhit_pos_set) {
- if (movement_timer.check()) {
- //std::cout << "IM HERE" << std::endl;
- //FIXME: Find out why the program never gets here
- if (direction == 1) direction = -1; else direction = 1;
- int speed = (300 + (rand() % 300)) * direction;
- physic.set_velocity_x(speed);
- movement_timer.start(1500);
+ if (lifetime.check()) {
+ if (!dying) {
+ sprite->set_action("pop");
+ lifetime.start(0.2);
+ dying = true;
}
+ else remove_me();
}
- if (Sector::current()->solids->get_tile_at(get_pos())->getAttributes() == 16) {
- //HIT WATER
+ else {
+ if (groundhit_pos_set) {
+ if (movement_timer.check()) {
+ if (direction == 1) direction = -1; else direction = 1;
+ int speed = (BASE_SPEED + (rand() % RAND_SPEED)) * direction;
+ physic.set_velocity_x(speed);
+ movement_timer.start(MOVETIME);
+ }
+ }
+ if (Sector::current()->solids->get_tile_at(get_pos())->getAttributes() == 16) {
+ //HIT WATER
+ }
}
BadGuy::active_update(elapsed_time);
}
+void
+Kugelblitz::kill_fall()
+{
+}
+
IMPLEMENT_FACTORY(Kugelblitz, "kugelblitz")