Skip to content

Commit

Permalink
bbox fix when actor was technically removed from level
Browse files Browse the repository at this point in the history
  • Loading branch information
Pomax committed Jul 5, 2012
1 parent 778193e commit b52ecfc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Boundary.pde
Expand Up @@ -127,6 +127,9 @@ class Boundary extends Positionable {
// FIXME: this is not the correct implementation
boolean supports(Positionable thing) {
float[] bbox = thing.getBoundingBox(), nbox = new float[8];

// shortcut on "this thing has already been removed"
if (bbox == null) return false;

// First, translate all coordinates so that they're
// relative to the boundary's (x,y) coordinate.
Expand Down
5 changes: 4 additions & 1 deletion docs/codebase.pde
Expand Up @@ -585,6 +585,9 @@ class Boundary extends Positionable {
// FIXME: this is not the correct implementation
boolean supports(Positionable thing) {
float[] bbox = thing.getBoundingBox(), nbox = new float[8];

// shortcut on "this thing has already been removed"
if (bbox == null) return false;

// First, translate all coordinates so that they're
// relative to the boundary's (x,y) coordinate.
Expand Down Expand Up @@ -674,7 +677,7 @@ class Boundary extends Positionable {
* Useful for debugging
*/
String toString() { return x+","+y+","+xw+","+yh; }
}
}
/**
* Things can listen to boundary collisions for a boundary
*/
Expand Down
5 changes: 4 additions & 1 deletion mario/codebase.pde
Expand Up @@ -585,6 +585,9 @@ class Boundary extends Positionable {
// FIXME: this is not the correct implementation
boolean supports(Positionable thing) {
float[] bbox = thing.getBoundingBox(), nbox = new float[8];

// shortcut on "this thing has already been removed"
if (bbox == null) return false;

// First, translate all coordinates so that they're
// relative to the boundary's (x,y) coordinate.
Expand Down Expand Up @@ -674,7 +677,7 @@ class Boundary extends Positionable {
* Useful for debugging
*/
String toString() { return x+","+y+","+xw+","+yh; }
}
}
/**
* Things can listen to boundary collisions for a boundary
*/
Expand Down
6 changes: 3 additions & 3 deletions mario/mainlayer.pde
Expand Up @@ -72,7 +72,7 @@ class MainLevelLayer extends MarioLayer {
// we set up some trigger regions.
void addTriggers() {
// initial hidden mushroom
addTrigger(new MushroomTrigger(64,370,5,12, 148,375, 2, 0));
addTrigger(new MushroomTrigger(148,370,5,12, 406,375, 2, 0));
// koopas
addTrigger(new KoopaTrigger(412,0,5,height, 350, height-64, -0.2, 0));
addTrigger(new KoopaTrigger(562,0,5,height, 350, height-64, -0.2, 0));
Expand All @@ -84,10 +84,10 @@ class MainLevelLayer extends MarioLayer {
// some tubes for transport
void addTubes() {
// tube transport
addTube(660,height-48, new LayerTeleportTrigger("background layer", 662,height-65,28,1, 304+16,height/0.75-100));
addTube(660,height-48, new LayerTeleportTrigger("background layer", 662,height-64,28,1, 304+16,height/0.75-116));
addTube(804,height-48, null);

addTube(2020,height-48, new LevelTeleportTrigger("Dark Level", 2022,height-65,28,1, 16, height-16));
addTube(2020,height-48, new LevelTeleportTrigger("Dark Level", 2022,height-65,28,1, 16, height-32));
addUpsideDownTube(2020,0);
}
}
6 changes: 2 additions & 4 deletions mario/tubes.pde
Expand Up @@ -2,7 +2,7 @@
* Tube trigger - teleports between locations
*/
class TeleportTrigger extends Trigger {
float popup_speed = -50;
float popup_speed = -40;
float tx, ty;
Boundary lid;
TeleportTrigger(float x, float y, float w, float h, float tx, float ty) {
Expand Down Expand Up @@ -35,7 +35,7 @@ class LayerTeleportTrigger extends TeleportTrigger {
void run(LevelLayer layer, Actor actor, float[] intersection) {
super.run(layer, actor, intersection);
if(actor instanceof Player) {
Player p = (Player) actor;
Player p = (Player) actor;
LevelLayer current = p.layer;
current.removePlayer(p);
LevelLayer next = current.parent.getLevelLayer(layerName);
Expand All @@ -60,8 +60,6 @@ class LevelTeleportTrigger extends TeleportTrigger {
MarioLevel l = (MarioLevel) setActiveScreen(levelName);
MarioLevel a = (MarioLevel) activeScreen;
a.updateMario(p);
a.mario.setPosition(tx,ty);
a.mario.setImpulse(0, popup_speed);
}
}
}
Expand Down

0 comments on commit b52ecfc

Please sign in to comment.