From b52ecfccb26d625665fa3782d87827f5f4b28ab0 Mon Sep 17 00:00:00 2001 From: Mike Kamermans Date: Thu, 5 Jul 2012 14:12:19 -0400 Subject: [PATCH] bbox fix when actor was technically removed from level --- Boundary.pde | 3 +++ docs/codebase.pde | 5 ++++- mario/codebase.pde | 5 ++++- mario/mainlayer.pde | 6 +++--- mario/tubes.pde | 6 ++---- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Boundary.pde b/Boundary.pde index 65fabe8..c9ddb06 100755 --- a/Boundary.pde +++ b/Boundary.pde @@ -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. diff --git a/docs/codebase.pde b/docs/codebase.pde index 647a1a0..24025e9 100755 --- a/docs/codebase.pde +++ b/docs/codebase.pde @@ -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. @@ -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 */ diff --git a/mario/codebase.pde b/mario/codebase.pde index 647a1a0..24025e9 100755 --- a/mario/codebase.pde +++ b/mario/codebase.pde @@ -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. @@ -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 */ diff --git a/mario/mainlayer.pde b/mario/mainlayer.pde index 49b11e1..7091327 100755 --- a/mario/mainlayer.pde +++ b/mario/mainlayer.pde @@ -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)); @@ -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); } } diff --git a/mario/tubes.pde b/mario/tubes.pde index 78c1882..d3e4193 100755 --- a/mario/tubes.pde +++ b/mario/tubes.pde @@ -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) { @@ -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); @@ -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); } } }