#include "badguy/flame.h"
#include "badguy/mriceblock.h"
#include "badguy/mrbomb.h"
+#include "badguy/dispenser.h"
#include "trigger/sequence_trigger.h"
#include "trigger/secretarea_trigger.h"
return new MrIceBlock(reader);
} else if(name == "mrbomb") {
return new MrBomb(reader);
+ } else if(name == "dispenser") {
+ return new Dispenser(reader);
}
#if 0
else if(badguykind_from_string(name) != BAD_INVALID) {
CollisionHit temphit, hit;
Rectangle dest = object->get_bbox();
dest.move(object->movement);
- hit.depth = -1;
+ hit.time = -1; // represents an invalid value
for(int x = starttilex; x*32 < max_x; ++x) {
for(int y = starttiley; y*32 < max_y; ++y) {
const Tile* tile = solids->get_tile(x, y);
if(Collision::rectangle_aatriangle(temphit, dest, object->movement,
triangle)) {
- if(temphit.depth > hit.depth)
+ if(temphit.time > hit.time)
hit = temphit;
}
} else { // normal rectangular tile
Rectangle rect(x*32, y*32, (x+1)*32, (y+1)*32);
if(Collision::rectangle_rectangle(temphit, dest,
object->movement, rect)) {
- if(temphit.depth > hit.depth)
+ if(temphit.time > hit.time)
hit = temphit;
}
}
}
// did we collide at all?
- if(hit.depth < 0)
+ if(hit.time < 0)
return;
// call collision function
return;
}
// move out of collision and try again
- object->movement += hit.normal * (hit.depth + .001);
+ object->movement += hit.normal * (hit.depth + .05);
collision_tilemap(object, depth+1);
}
Vector movement = object1->get_movement() - object2->get_movement();
if(Collision::rectangle_rectangle(hit, dest1, movement, dest2)) {
HitResponse response1 = object1->collision(*object2, hit);
- Vector hitnormal1 = hit.normal;
hit.normal *= -1;
HitResponse response2 = object2->collision(*object1, hit);
if(response1 == ABORT_MOVE)
object1->movement = Vector(0, 0);
if(response2 == CONTINUE)
- object2->movement += hit.normal * (hit.depth + .1);
+ object2->movement += hit.normal * (hit.depth + .05);
} else if(response2 != CONTINUE) {
if(response2 == ABORT_MOVE)
object2->movement = Vector(0, 0);
if(response1 == CONTINUE)
- object1->movement += hitnormal1 * (hit.depth + .1);
+ object1->movement += -hit.normal * (hit.depth + .05);
} else {
- object1->movement += hitnormal1 * (hit.depth/2 + 1);
- object2->movement += hit.normal * (hit.depth/2 + 1);
+ object1->movement += -hit.normal * (hit.depth/2 + .05);
+ object2->movement += hit.normal * (hit.depth/2 + .05);
}
}
}