AngryStone::AngryStone(const lisp::Lisp& reader)
: BadGuy(reader, "images/creatures/angrystone/angrystone.sprite"), state(IDLE)
{
+ physic.set_velocity_x(0);
+ physic.set_velocity_y(0);
+ physic.enable_gravity(true);
+ sprite->set_action("idle");
}
void
}
void
-AngryStone::activate()
-{
- physic.set_velocity_x(0);
- physic.set_velocity_y(0);
- physic.enable_gravity(true);
- sprite->set_action("idle");
-}
-
-void
AngryStone::collision_solid(const CollisionHit& hit)
{
// TODO
public:
AngryStone(const lisp::Lisp& reader);
- void activate();
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <config.h>
-
#include "badguy.hpp"
#include "object/camera.hpp"
#include "object/tilemap.hpp"
#include "random_generator.hpp"
static const float SQUISH_TIME = 2;
+
static const float X_OFFSCREEN_DISTANCE = 1600;
static const float Y_OFFSCREEN_DISTANCE = 1200;
BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name, int layer)
- : MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), countMe(true),
+ : MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), countMe(true), is_initialized(false),
dir(LEFT), start_dir(AUTO), frozen(false), ignited(false),
- state(STATE_INIT), on_ground_flag(false)
+ state(STATE_INIT), on_ground_flag(false), colgroup_active(COLGROUP_MOVING)
{
start_position = bbox.p1;
sound_manager->preload("sounds/squish.wav");
sound_manager->preload("sounds/fall.wav");
+
+ dir = (start_dir == AUTO) ? LEFT : start_dir;
}
BadGuy::BadGuy(const Vector& pos, Direction direction, const std::string& sprite_name, int layer)
- : MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), countMe(true),
+ : MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), countMe(true), is_initialized(false),
dir(direction), start_dir(direction), frozen(false), ignited(false),
- state(STATE_INIT), on_ground_flag(false)
+ state(STATE_INIT), on_ground_flag(false), colgroup_active(COLGROUP_MOVING)
{
start_position = bbox.p1;
sound_manager->preload("sounds/squish.wav");
sound_manager->preload("sounds/fall.wav");
+
+ dir = (start_dir == AUTO) ? LEFT : start_dir;
}
BadGuy::BadGuy(const lisp::Lisp& reader, const std::string& sprite_name, int layer)
- : MovingSprite(reader, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(LEFT), start_dir(AUTO), frozen(false), ignited(false), state(STATE_INIT), on_ground_flag(false)
+ : MovingSprite(reader, sprite_name, layer, COLGROUP_DISABLED), countMe(true), is_initialized(false), dir(LEFT), start_dir(AUTO), frozen(false), ignited(false), state(STATE_INIT), on_ground_flag(false), colgroup_active(COLGROUP_MOVING)
{
start_position = bbox.p1;
sound_manager->preload("sounds/squish.wav");
sound_manager->preload("sounds/fall.wav");
+
+ dir = (start_dir == AUTO) ? LEFT : start_dir;
}
void
remove_me();
return;
}
- if(is_offscreen()) {
+ if ((state != STATE_INACTIVE) && is_offscreen()) {
if (state == STATE_ACTIVE) deactivate();
set_state(STATE_INACTIVE);
}
}
void
+BadGuy::initialize()
+{
+}
+
+void
BadGuy::activate()
{
}
state_timer.start(SQUISH_TIME);
break;
case STATE_ACTIVE:
- set_group(COLGROUP_MOVING);
- bbox.set_pos(start_position);
+ set_group(colgroup_active);
+ //bbox.set_pos(start_position);
break;
case STATE_INACTIVE:
// was the badguy dead anyway?
bool
BadGuy::is_offscreen()
{
- float scroll_x = Sector::current()->camera->get_translation().x;
- float scroll_y = Sector::current()->camera->get_translation().y;
-
- if(bbox.p2.x < scroll_x - X_OFFSCREEN_DISTANCE
- || bbox.p1.x > scroll_x + X_OFFSCREEN_DISTANCE + SCREEN_WIDTH
- || bbox.p2.y < scroll_y - Y_OFFSCREEN_DISTANCE
- || bbox.p1.y > scroll_y + Y_OFFSCREEN_DISTANCE + SCREEN_HEIGHT)
- return true;
-
- return false;
+ Player* player = get_nearest_player();
+ if (!player) return false;
+ Vector dist = player->get_bbox().get_middle() - get_bbox().get_middle();
+ if ((dist.x <= X_OFFSCREEN_DISTANCE+32) && (dist.y <= Y_OFFSCREEN_DISTANCE+32)) {
+ return false;
+ }
+ return true;
}
void
BadGuy::try_activate()
{
- float scroll_x = Sector::current()->camera->get_translation().x;
- float scroll_y = Sector::current()->camera->get_translation().y;
-
- /* Activate badguys if they're just around the screen to avoid
- * the effect of having badguys suddenly popping up from nowhere.
- */
- //Badguy left of screen
- if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE &&
- start_position.x < scroll_x - bbox.get_width() &&
- start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE &&
- start_position.y < scroll_y + SCREEN_HEIGHT + Y_OFFSCREEN_DISTANCE) {
- if (start_dir != AUTO) dir = start_dir; else dir = RIGHT;
- set_state(STATE_ACTIVE);
- activate();
- //Badguy right of screen
- } else if (start_position.x > scroll_x + SCREEN_WIDTH &&
- start_position.x < scroll_x + SCREEN_WIDTH + X_OFFSCREEN_DISTANCE &&
- start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE &&
- start_position.y < scroll_y + SCREEN_HEIGHT + Y_OFFSCREEN_DISTANCE) {
- if (start_dir != AUTO) dir = start_dir; else dir = LEFT;
+ // In SuperTux 0.1.x, Badguys were activated when Tux<->Badguy center distance was approx. <= ~668px
+ // This doesn't work for wide-screen monitors which give us a virt. res. of approx. 1066px x 600px
+ Player* player = get_nearest_player();
+ if (!player) return;
+ Vector dist = player->get_bbox().get_middle() - get_bbox().get_middle();
+ if ((fabsf(dist.x) <= X_OFFSCREEN_DISTANCE) && (fabsf(dist.y) <= Y_OFFSCREEN_DISTANCE)) {
set_state(STATE_ACTIVE);
- activate();
- //Badguy over or under screen
- } else if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE &&
- start_position.x < scroll_x + SCREEN_WIDTH + X_OFFSCREEN_DISTANCE &&
- ((start_position.y > scroll_y + SCREEN_HEIGHT &&
- start_position.y < scroll_y + SCREEN_HEIGHT + Y_OFFSCREEN_DISTANCE) ||
- (start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE &&
- start_position.y < scroll_y - bbox.get_height() ))) {
- if (start_dir != AUTO) dir = start_dir;
- else{
- // if nearest player is to our right, start facing right
- Player* player = get_nearest_player();
- if (player && (player->get_bbox().p1.x > get_bbox().p2.x)) {
- dir = RIGHT;
- } else {
- dir = LEFT;
- }
- }
- set_state(STATE_ACTIVE);
- activate();
- } else if(state == STATE_INIT
- && start_position.x > scroll_x - X_OFFSCREEN_DISTANCE
- && start_position.x < scroll_x + X_OFFSCREEN_DISTANCE + SCREEN_WIDTH
- && start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE
- && start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE + SCREEN_HEIGHT ) {
- if (start_dir != AUTO) {
- dir = start_dir;
- } else {
- // if nearest player is to our right, start facing right
- Player* player = get_nearest_player();
- if (player && (player->get_bbox().p1.x > get_bbox().p2.x)) {
- dir = RIGHT;
- } else {
- dir = LEFT;
+ if (!is_initialized) {
+
+ // if starting direction was set to AUTO, this is our chance to re-orient the badguy
+ if (start_dir == AUTO) {
+ Player* player = get_nearest_player();
+ if (player && (player->get_bbox().p1.x > get_bbox().p2.x)) {
+ dir = RIGHT;
+ } else {
+ dir = LEFT;
+ }
}
+
+ initialize();
+ is_initialized = true;
}
- set_state(STATE_ACTIVE);
activate();
}
}
void
BadGuy::unfreeze()
{
- set_group(COLGROUP_MOVING);
+ set_group(colgroup_active);
frozen = false;
}
{
return ignited;
}
+
+void
+BadGuy::set_colgroup_active(CollisionGroup group)
+{
+ this->colgroup_active = group;
+ if (state == STATE_ACTIVE) set_group(group);
+}
+
/** called each frame when the badguy is not activated. */
virtual void inactive_update(float elapsed_time);
+ bool is_initialized; /**< true if initialize() has already been called */
+ /** called immediately before the first call to initialize */
+ virtual void initialize();
/**
* called when the badguy has been activated. (As a side effect the dir
* variable might have been changed so that it faces towards the player.
*/
Player* get_nearest_player();
- /// is the enemy activated
- bool activated;
/**
* initial position of the enemy. Also the position where enemy respawns when
* after being deactivated.
*/
bool is_active();
+ void set_colgroup_active(CollisionGroup group); /**< changes colgroup_active. Also calls set_group when badguy is in STATE_ACTIVE */
+
private:
void try_activate();
Timer state_timer;
bool on_ground_flag; /**< true if we touched something solid from above and update_on_ground_flag was called last frame */
Vector floor_normal; /**< floor normal stored the last time when update_on_ground_flag was called and we touched something solid from above */
+ CollisionGroup colgroup_active; /**< CollisionGroup the badguy should be in while active */
};
}
void
-BouncingSnowball::activate()
+BouncingSnowball::initialize()
{
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
BouncingSnowball(const lisp::Lisp& reader);
BouncingSnowball(const Vector& pos, Direction d);
- void activate();
+ void initialize();
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
}
void
-Dart::activate()
+Dart::initialize()
{
physic.set_velocity_x(dir == LEFT ? -::SPEED : ::SPEED);
sprite->set_action(dir == LEFT ? "flying-left" : "flying-right");
+}
+void
+Dart::activate()
+{
sound_source.reset(sound_manager->create_sound_source(SOUNDFILE));
sound_source->set_position(get_pos());
sound_source->set_looping(true);
Dart(const Dart& dart);
~Dart();
+ void initialize();
void activate();
void deactivate();
void write(lisp::Writer& writer);
countMe = false;
sound_manager->preload("sounds/dartfire.wav");
if (start_dir == AUTO) log_warning << "Setting a DartTrap's direction to AUTO is no good idea" << std::endl;
+ state = IDLE;
+ set_colgroup_active(COLGROUP_DISABLED);
+ if (initial_delay == 0) initial_delay = 0.1f;
}
void
}
void
-DartTrap::activate()
+DartTrap::initialize()
{
- state = IDLE;
sprite->set_action(dir == LEFT ? "idle-left" : "idle-right");
- set_group(COLGROUP_DISABLED);
+}
- if (initial_delay == 0) initial_delay = 0.1f;
+void
+DartTrap::activate()
+{
fire_timer.start(initial_delay);
}
public:
DartTrap(const lisp::Lisp& reader);
+ void initialize();
void activate();
void write(lisp::Writer& writer);
void active_update(float elapsed_time);
void
Dispenser::activate()
{
- if(frozen)
- return;
- if (badguy == "mrrocket") {
- sprite->set_action(dir == LEFT ? "working-left" : "working-right");
- }
dispense_timer.start(cycle, true);
launch_badguy();
}
Fish::start_waiting()
{
waiting.start(FISH_WAIT_TIME);
- set_group(COLGROUP_DISABLED);
+ set_colgroup_active(COLGROUP_DISABLED);
physic.enable_gravity(false);
physic.set_velocity_y(0);
}
{
physic.set_velocity_y(FISH_JUMP_POWER);
physic.enable_gravity(true);
- set_group(COLGROUP_MOVING);
+ set_colgroup_active(COLGROUP_MOVING);
}
void
start_position.y + sin(angle) * radius));
countMe = false;
sound_manager->preload(SOUNDFILE);
+
+ set_colgroup_active(COLGROUP_TOUCHABLE);
}
void
void
Flame::activate()
{
- set_group(COLGROUP_TOUCHABLE);
-
sound_source.reset(sound_manager->create_sound_source(SOUNDFILE));
sound_source->set_position(get_pos());
sound_source->set_looping(true);
}
void
-FlyingSnowBall::activate()
+FlyingSnowBall::initialize()
{
sprite->set_action(dir == LEFT ? "left" : "right");
mode = FLY_UP;
physic.set_velocity_y(FLYSPEED);
timer.start(FLYTIME/2);
+}
+
+void
+FlyingSnowBall::activate()
+{
puff_timer.start(systemRandom.randf(PUFF_INTERVAL_MIN, PUFF_INTERVAL_MAX));
}
FlyingSnowBall(const lisp::Lisp& reader);
FlyingSnowBall(const Vector& pos);
+ void initialize();
void activate();
void write(lisp::Writer& writer);
void active_update(float elapsed_time);
treecolor(0), suck_lantern(0)
{
glow_sprite.reset(sprite_manager->create("images/creatures/ghosttree/ghosttree-glow.sprite"));
+ set_colgroup_active(COLGROUP_TOUCHABLE);
}
GhostTree::~GhostTree()
willowisp_timer.start(1.0f, true);
colorchange_timer.start(13, true);
root_timer.start(5, true);
- set_group(COLGROUP_TOUCHABLE);
}
void
void
Igel::be_normal()
{
- activate();
+ initialize();
}
void
}
void
-Kugelblitz::activate()
+Kugelblitz::initialize()
{
physic.set_velocity_y(300);
physic.set_velocity_x(-20); //fall a little to the left
public:
Kugelblitz(const lisp::Lisp& reader);
- void activate();
+ void initialize();
HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit);
void collision_solid(const CollisionHit& hit);
HitResponse collision_player(Player& player, const CollisionHit& hit);
switch (new_state) {
case PRE_THROWING:
sprite->set_action("idle");
- set_group(COLGROUP_DISABLED);
+ set_colgroup_active(COLGROUP_DISABLED);
timer.start(IDLE_TIME);
break;
case THROWING:
sprite->set_action("idle");
- set_group(COLGROUP_DISABLED);
+ set_colgroup_active(COLGROUP_DISABLED);
timer.start(THROW_TIME);
throw_timer.start(THROW_INTERVAL);
break;
case POST_THROWING:
sprite->set_action("idle");
- set_group(COLGROUP_DISABLED);
+ set_colgroup_active(COLGROUP_DISABLED);
timer.start(IDLE_TIME);
break;
case PEEKING:
sprite->set_action("peeking", 1);
- set_group(COLGROUP_STATIC);
+ set_colgroup_active(COLGROUP_STATIC);
break;
case DEAD:
sprite->set_action("idle");
- set_group(COLGROUP_DISABLED);
+ set_colgroup_active(COLGROUP_DISABLED);
break;
}
}
void
-MoleRock::activate()
+MoleRock::initialize()
{
physic.set_velocity(initial_velocity);
sprite->set_action("default");
MoleRock(const MoleRock& mole_rock);
~MoleRock();
- void activate();
+ void initialize();
void deactivate();
void write(lisp::Writer& writer);
movement = pos - get_pos();
this->dir = dir;
sprite->set_action(dir == LEFT ? "iced-left" : "iced-right");
- set_group(COLGROUP_DISABLED);
+ set_colgroup_active(COLGROUP_DISABLED);
grabbed = true;
}
MrBomb::ungrab(MovingObject& , Direction dir)
{
this->dir = dir;
- set_group(COLGROUP_MOVING);
+ set_colgroup_active(COLGROUP_MOVING);
grabbed = false;
}
}
void
-MrIceBlock::activate()
+MrIceBlock::initialize()
{
- WalkingBadguy::activate();
+ WalkingBadguy::initialize();
set_state(ICESTATE_NORMAL);
}
switch(state) {
case ICESTATE_NORMAL:
- WalkingBadguy::activate();
+ WalkingBadguy::initialize();
break;
case ICESTATE_FLAT:
if(dir == UP) {
this->dir = dir;
sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
set_state(ICESTATE_GRABBED);
- set_group(COLGROUP_DISABLED);
+ set_colgroup_active(COLGROUP_DISABLED);
}
void
{
this->dir = dir;
set_state(dir == UP ? ICESTATE_FLAT : ICESTATE_KICKED);
- set_group(COLGROUP_MOVING);
+ set_colgroup_active(COLGROUP_MOVING);
}
bool
MrIceBlock(const lisp::Lisp& reader);
MrIceBlock(const Vector& pos, Direction d);
- void activate();
+ void initialize();
void write(lisp::Writer& writer);
HitResponse collision(GameObject& object, const CollisionHit& hit);
void collision_solid(const CollisionHit& hit);
}
void
-MrRocket::activate()
+MrRocket::initialize()
{
physic.set_velocity_x(dir == LEFT ? -SPEED : SPEED);
physic.enable_gravity(false);
MrRocket(const lisp::Lisp& reader);
MrRocket(const Vector& pos, Direction d);
- void activate();
+ void initialize();
void active_update(float elapsed_time);
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
}
void
-Plant::activate()
+Plant::initialize()
{
//FIXME: turns sspiky around for debugging
dir = dir == LEFT ? RIGHT : LEFT;
public:
Plant(const lisp::Lisp& reader);
- void activate();
+ void initialize();
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
base_sprite->set_action("appearing", 1);
base_sprite->set_animation_loops(1); // TODO: necessary because set_action ignores loops for default action
physic.enable_gravity(false);
+ set_colgroup_active(COLGROUP_TOUCHABLE);
}
Root::~Root()
}
void
-Root::activate()
-{
- set_group(COLGROUP_TOUCHABLE);
-}
-
-void
Root::deactivate()
{
remove_me();
Root(const Vector& pos);
~Root();
- void activate();
void deactivate();
void active_update(float elapsed_time);
virtual void draw(DrawingContext& context);
}
void
-SkullyHop::activate()
+SkullyHop::initialize()
{
// initial state is JUMPING, because we might start airborne
state = JUMPING;
SkullyHop(const lisp::Lisp& reader);
SkullyHop(const Vector& pos, Direction d);
- void activate();
+ void initialize();
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
}
void
-Snail::activate()
+Snail::initialize()
{
- WalkingBadguy::activate();
+ WalkingBadguy::initialize();
be_normal();
}
if (state == STATE_NORMAL) return;
state = STATE_NORMAL;
- WalkingBadguy::activate();
+ WalkingBadguy::initialize();
}
void
Snail(const lisp::Lisp& reader);
Snail(const Vector& pos, Direction d);
- void activate();
+ void initialize();
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
}
void
-SpiderMite::activate()
+SpiderMite::initialize()
{
sprite->set_action(dir == LEFT ? "left" : "right");
mode = FLY_UP;
SpiderMite(const lisp::Lisp& reader);
SpiderMite(const Vector& pos);
- void activate();
+ void initialize();
void write(lisp::Writer& writer);
void active_update(float elapsed_time);
void collision_solid(const CollisionHit& hit);
}
void
-SSpiky::activate()
+SSpiky::initialize()
{
state = SSPIKY_SLEEPING;
physic.set_velocity_x(0);
if(sprite->animation_done()) {
// start walking
state = SSPIKY_WALKING;
- WalkingBadguy::activate();
+ WalkingBadguy::initialize();
}
BadGuy::active_update(elapsed_time);
public:
SSpiky(const lisp::Lisp& reader);
- void activate();
+ void initialize();
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
Stalactite::squish()
{
state = STALACTITE_SQUISHED;
- set_group(COLGROUP_MOVING_ONLY_STATIC);
+ set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC);
sprite->set_action("squished");
if(!timer.started())
timer.start(SQUISH_TIME);
}
void
-Stumpy::activate()
+Stumpy::initialize()
{
switch (mystate) {
case STATE_INVINCIBLE:
physic.set_velocity_x(0);
break;
case STATE_NORMAL:
- WalkingBadguy::activate();
+ WalkingBadguy::initialize();
break;
}
}
case STATE_INVINCIBLE:
if (invincible_timer.check()) {
mystate = STATE_NORMAL;
- WalkingBadguy::activate();
+ WalkingBadguy::initialize();
}
BadGuy::active_update(elapsed_time);
break;
Stumpy(const lisp::Lisp& reader);
Stumpy(const Vector& pos, Direction d);
- void activate();
+ void initialize();
void active_update(float elapsed_time);
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
}
void
-Toad::activate()
+Toad::initialize()
{
// initial state is JUMPING, because we might start airborne
state = JUMPING;
Toad(const lisp::Lisp& reader);
Toad(const Vector& pos, Direction d);
- void activate();
+ void initialize();
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
}
void
-Totem::activate()
+Totem::initialize()
{
if (!carried_by) {
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
if (on_ground() && might_fall())
{
dir = (dir == LEFT ? RIGHT : LEFT);
- activate();
+ initialize();
}
Sector* s = Sector::current();
// If we are hit from the direction we are facing: turn around
if (hit.left && (dir == LEFT)) {
dir = RIGHT;
- activate();
+ initialize();
}
if (hit.right && (dir == RIGHT)) {
dir = LEFT;
- activate();
+ initialize();
}
}
// If we are hit from the direction we are facing: turn around
if(hit.left && (dir == LEFT)) {
dir = RIGHT;
- activate();
+ initialize();
}
if(hit.right && (dir == RIGHT)) {
dir = LEFT;
- activate();
+ initialize();
}
return CONTINUE;
target->carrying = this;
this->carried_by = target;
- this->activate();
+ this->initialize();
bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
sound_manager->play( LAND_ON_TOTEM_SOUND , get_pos());
this->carried_by = 0;
- this->activate();
+ this->initialize();
bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
Totem(const Totem& totem);
~Totem();
- void activate();
+ void initialize();
void active_update(float elapsed_time);
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
this->angle = 0;
this->speed = speed;
start_position = tree->get_pos() + treepos_delta;
+
+ set_colgroup_active(COLGROUP_MOVING);
}
TreeWillOWisp::~TreeWillOWisp()
sound_source->set_gain(2.0);
sound_source->set_reference_distance(32);
sound_source->play();
-
- set_group(COLGROUP_MOVING);
}
void
{
mystate = STATE_VANISHING;
sprite->set_action("vanishing", 1);
- set_group(COLGROUP_DISABLED);
+ set_colgroup_active(COLGROUP_DISABLED);
}
void
}
void
-WalkingBadguy::activate()
+WalkingBadguy::initialize()
{
if(frozen)
return;
WalkingBadguy::unfreeze()
{
BadGuy::unfreeze();
- WalkingBadguy::activate();
+ WalkingBadguy::initialize();
}
WalkingBadguy(const Vector& pos, Direction direction, const std::string& sprite_name, const std::string& walk_left_action, const std::string& walk_right_action, int layer = LAYER_OBJECTS);
WalkingBadguy(const lisp::Lisp& reader, const std::string& sprite_name, const std::string& walk_left_action, const std::string& walk_right_action, int layer = LAYER_OBJECTS);
- void activate();
+ void initialize();
void write(lisp::Writer& writer);
void active_update(float elapsed_time);
void collision_solid(const CollisionHit& hit);
countMe = false;
sound_manager->preload(SOUNDFILE);
sound_manager->preload("sounds/warp.wav");
+
+ sprite->set_action("idle");
}
void
void
WillOWisp::activate()
{
- sprite->set_action("idle");
-
sound_source.reset(sound_manager->create_sound_source(SOUNDFILE));
sound_source->set_position(get_pos());
sound_source->set_looping(true);
{
mystate = STATE_VANISHING;
sprite->set_action("vanishing", 1);
- set_group(COLGROUP_DISABLED);
+ set_colgroup_active(COLGROUP_DISABLED);
}
bool
}
void
-Yeti::activate()
+Yeti::initialize()
{
dir = RIGHT;
jump_down();
state = SQUISHED;
state_timer.start(SQUISH_TIME);
- set_group(COLGROUP_MOVING_ONLY_STATIC);
+ set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC);
sprite->set_action("dead");
if (countMe) Sector::current()->get_level()->stats.badguys++;
void draw(DrawingContext& context);
void write(lisp::Writer& writer);
- void activate();
+ void initialize();
void active_update(float elapsed_time);
void collision_solid(const CollisionHit& hit);
bool collision_squished(GameObject& object);
: BadGuy(reader, "images/creatures/zeekling/zeekling.sprite"), last_player(0)
{
state = FLYING;
+ speed = systemRandom.rand(130, 171);
+ physic.enable_gravity(false);
}
Zeekling::Zeekling(const Vector& pos, Direction d)
: BadGuy(pos, d, "images/creatures/zeekling/zeekling.sprite"), last_player(0)
{
state = FLYING;
+ speed = systemRandom.rand(130, 171);
+ physic.enable_gravity(false);
}
void
}
void
-Zeekling::activate()
+Zeekling::initialize()
{
- speed = systemRandom.rand(130, 171);
physic.set_velocity_x(dir == LEFT ? -speed : speed);
- physic.enable_gravity(false);
sprite->set_action(dir == LEFT ? "left" : "right");
}
Zeekling(const lisp::Lisp& reader);
Zeekling(const Vector& pos, Direction d);
- void activate();
+ void initialize();
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
void active_update(float elapsed_time);