PoisonIvy::PoisonIvy(const lisp::Lisp& reader)
: BadGuy(reader, "images/creatures/poison_ivy/poison_ivy.sprite")
{
- set_direction = false;
- reader.get("direction", direction);
- if( direction != "auto" && direction != ""){
- set_direction = true;
- initial_direction = str2dir( direction );
- }
}
PoisonIvy::PoisonIvy(const Vector& pos, Direction d)
- : BadGuy(pos, "images/creatures/poison_ivy/poison_ivy.sprite")
+ : BadGuy(pos, d, "images/creatures/poison_ivy/poison_ivy.sprite")
{
- set_direction = true;
- initial_direction = d;
}
void
{
writer.start_list("poisonivy");
- writer.write_string("direction", direction);
writer.write_float("x", start_position.x);
writer.write_float("y", start_position.y);
void
PoisonIvy::activate()
{
- if (set_direction) {dir = initial_direction;}
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
}
return true;
}
-HitResponse
-PoisonIvy::collision_solid(GameObject& , const CollisionHit& hit)
+void
+PoisonIvy::collision_solid(const CollisionHit& hit)
{
- if(fabsf(hit.normal.y) > .5) { // hit floor or roof?
+ if(hit.top || hit.bottom) {
physic.set_velocity_y(0);
- } else { // hit right or left
+ } else if(hit.left || hit.right) {
dir = dir == LEFT ? RIGHT : LEFT;
sprite->set_action(dir == LEFT ? "left" : "right");
physic.set_velocity_x(-physic.get_velocity_x());
}
-
- return CONTINUE;
}
HitResponse
PoisonIvy::collision_badguy(BadGuy& , const CollisionHit& hit)
{
- if(fabsf(hit.normal.x) > .8) { // left or right hit
+ if(hit.left || hit.right) {
dir = dir == LEFT ? RIGHT : LEFT;
sprite->set_action(dir == LEFT ? "left" : "right");
physic.set_velocity_x(-physic.get_velocity_x());