Sign in to follow this  
Storyyeller

Organizing level data

Recommended Posts

Well I previously asked about ways to improve the design of my level loading system here (http://www.gamedev.net/community/forums/topic.asp?topic_id=556387), but that topic has now been retired. At the time, my game was relatively small, so I wasn't sure what I was doing, but now it is a lot larger, so I thought it might be possible to find some common behavior to redesign. The problem is that every room seems different to me. I don't know what to do. My current system is pretty ugly, but it works, and I haven't been able to think of a better design. Here is the room definition code.
#include "ColossusFight/roomdef_cf.h"

#include "TutorialTunnel/roomdef_tt.h"

#include "ebrush.h"
#include "victoryorb.h"
#include "triggerscripts.h"
#include "ColossusFight/tinytorchflame.h"
#include "ColossusFight/ropeandbomb.h"
#include "ColossusFight/collisionmanager.h"
#include "ColossusFight/triggers_cf.h"

using namespace ColossusFight;

void ColossusFight::AddMultiBlock(entitymanager_ptr myManager, int x, int y, int w, int h) const
{
    myManager->AddEntity(new Brush(myManager,x*32,y*32,w*32,h*32, Brush::SOLID));
}

void ColossusFight::AddMultiBlockReflect(entitymanager_ptr myManager, int x, int y, int w, int h) const
{
    myManager->AddEntity(new Brush(myManager,x*32,y*32,w*32,h*32, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager,(51-x-w)*32,y*32,w*32,h*32, Brush::SOLID));
}

bounds_sptr ColossusFight::GetBoundsManager() const {return bounds_sptr(new LargeRoom(0,0,1632,768,AABB(-64,0,1632,768)));}

void ColossusFight::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info) const
{
    assert(myManager);

    //Background - offset -.6 to counteract rounding errors in the camera function
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("ColossusFight/background_cf.bmp")),0,-.6));

    //Music
    myManager->AddEntity((new TriggerBrush(myManager, 0,0,1632,768, true))
        ->AddAction(trigPlayMusic(myManager, "colossusfight_1.ogg")));

    //Collision Manager
    cf_collmanager_sptr mycfmanager(new ColossusFightDataManager());

    {
        entity_sptr bomb = myManager->AddEntity(newBomb(myManager,816,268));
        myManager->AddEntity( new HangingRope(myManager,mycfmanager,816,64,139,bomb,118));
    }

    myManager->AddEntity((new TriggerBrush(myManager, -32,672,32,64, true))
        ->AddActionDbl(myManager->GetWarpCallback(TutorialTunnel::wdRight())));

    if (!myManager->BossesDefeated().GetBossStatus(BossList::COLOSSUS))
    {
        myManager->AddEntity((new TriggerBrush(myManager, 70,0,1540,768, false))
            ->AddAction(trigStartColossusFight(myManager,mycfmanager)));
    }
    else
    {
        myManager->AddEntity(newVictoryOrb(myManager,816,720, BossList::COLOSSUS, true));
    }

    //Brushes
    AddMultiBlockReflect(myManager,0,1,1,20); //the left wall
    AddMultiBlock(myManager,50,21,1,2); //fills in the gap on the right wall
    AddMultiBlockReflect(myManager,1,1,7,1);
    AddMultiBlockReflect(myManager,7,0,18,1);
    //AddMultiBlockReflect(myManager,0,23,25,1); //the floor //See below
    AddMultiBlockReflect(myManager,1,20,1,1);
    //A left facing stairstep
    AddMultiBlockReflect(myManager,1,10,1,1);
    AddMultiBlockReflect(myManager,1,11,2,1);
    AddMultiBlockReflect(myManager,1,12,3,1);

    AddMultiBlockReflect(myManager,6,5,2,16);  //The substrate of the weird block
    //A right facing stairstep
    AddMultiBlockReflect(myManager,5,15,1,1);
    AddMultiBlockReflect(myManager,4,16,2,1);
    AddMultiBlockReflect(myManager,3,17,3,1);
    //And another
    AddMultiBlockReflect(myManager,5,5,1,1);
    AddMultiBlockReflect(myManager,4,6,2,1);
    AddMultiBlockReflect(myManager,3,7,3,1);

    AddMultiBlockReflect(myManager,8,20,2,1);
    AddMultiBlockReflect(myManager,8,6,2,1);

    AddMultiBlockReflect(myManager,12,6,2,1);
    AddMultiBlockReflect(myManager,16,6,2,1);
    AddMultiBlockReflect(myManager,20,6,2,1);

    AddMultiBlockReflect(myManager,11,16,2,1);
    AddMultiBlockReflect(myManager,15,13,2,1);
    AddMultiBlockReflect(myManager,21,12,2,1);

    //Now for the nonsymetrical parts
    AddMultiBlock(myManager,25,1,1,1);    //Part above rope
    //AddMultiBlock(myManager,25,23,1,1);   //Part in the middle of the floor
    AddMultiBlock(myManager,0,23,51,1); //If the floor is not a single continous surface, Box2d gets messed up
    AddMultiBlock(myManager,48,21,2,1); //Bottom right staircase
    AddMultiBlock(myManager,47,22,3,1);

    //off screen brushes used for transition to previous level
    AddMultiBlock(myManager,-2,23,2,1);
    AddMultiBlock(myManager,-2,20,2,1);
    AddMultiBlock(myManager,-2,21,1,2);
}


#include "TutorialTunnel/roomdef_tt.h"

#include "goodroominclude.h"

#include "ebrush.h"
#include "triggerregion.h"
#include "triggerscripts.h"
#include "savepoint.h"
#include "TutorialTunnel/giantspike.h"
#include "TutorialTunnel/trig_createdustcloud.h"

using namespace TutorialTunnel;

void TutorialTunnel::AddMultiBlock(entitymanager_ptr myManager, int x, int y, int w, int h) const
{
    myManager->AddEntity(new Brush(myManager,x*32,y*32,w*32,h*32, Brush::SOLID));
}

bounds_sptr TutorialTunnel::GetBoundsManager()  const {return bounds_sptr(new LargeRoom(-94, 0,3327,1000,AABB(0,-64,3391,956)));}

void TutorialTunnel::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info)  const
{
    double SPIKEMARGIN = 5;

    assert(myManager);

    //Background - offset 1 because it doesn't line up right otherwise for some reason.
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("TutorialTunnel/background.bmp")),-96,1));

    //Music
    myManager->AddEntity((new TriggerBrush(myManager, 100,0,3291,956, true))->AddAction(trigPlayMusic(myManager, "tutorialtunnel.ogg")));

    myManager->AddEntity(new trigCreateDustCloud(myManager, 32, 544, 128));
    myManager->AddEntity((new TriggerBrush(myManager, 32,-32,64,32, true))->
        AddActionDbl(myManager->GetWarpCallback(KaizoPickory::wdBotRight())));
    myManager->AddEntity(new SavePoint(myManager, 2592,641, MEDIUM));
    myManager->AddEntity(new SavePoint(myManager, 3296,836, HARD));
    myManager->AddEntity((new TriggerBrush(myManager, 3328,800,32,64, true))->
        AddActionDbl(myManager->GetWarpCallback(ColossusFight::wdLeft())));
    myManager->AddEntity(newSpikeUp(myManager,89*32,26*32+SPIKEMARGIN));
    myManager->AddEntity(newSpikeUp(myManager,89*32+40,26*32+SPIKEMARGIN));
    myManager->AddEntity(newSpikeUp(myManager,93*32,26*32+SPIKEMARGIN));
    myManager->AddEntity(newSpikeUp(myManager,93*32+40,26*32+SPIKEMARGIN));
    myManager->AddEntity(newSpikeUp(myManager,97*32,26*32+SPIKEMARGIN));

    //Trick spike
    {
        entity_sptr tempspike = myManager->AddEntity(newSpikeUp(myManager,97*32+40,26*32+SPIKEMARGIN, Brush::fBULLETPROOF));

        myManager->AddEntity((new TriggerBrush(myManager, 97*32+44,25*32,28,64, true))
                    ->AddAction(trigInstantMove(tempspike, 24, 0)));

        myManager->AddEntity((new TriggerBrush(myManager, 97*32+184,25*32,28,64, true))
                    ->AddAction(trigGiantizeSpike(myManager,tempspike)));
    }

    //Brushes
    AddMultiBlock(myManager,0,-2,4,1);
    AddMultiBlock(myManager,0,-1,1,19);
    AddMultiBlock(myManager,3,-1,1,16);
    AddMultiBlock(myManager,1,17,47,1);
    AddMultiBlock(myManager,4,14,41,1);

    AddMultiBlock(myManager,47,13,1,4);
    AddMultiBlock(myManager,44,10,1,4);
    AddMultiBlock(myManager,48,13,8,1);
    AddMultiBlock(myManager,45,10,14,1);

    AddMultiBlock(myManager,56,13,1,5);
    AddMultiBlock(myManager,59,10,1,5);
    AddMultiBlock(myManager,57,17,21,1);
    AddMultiBlock(myManager,60,14,21,1);

    AddMultiBlock(myManager,77,18,1,5);
    AddMultiBlock(myManager,80,15,1,5);
    AddMultiBlock(myManager,78,22,8,1);
    AddMultiBlock(myManager,81,19,8,1);

    AddMultiBlock(myManager,85,23,1,5);
    AddMultiBlock(myManager,88,20,1,5);
    //these extend 2 units offscreen
    AddMultiBlock(myManager,86,27,20,1);
    AddMultiBlock(myManager,89,24,17,1);

    //off screen brush used for transition to next level
    AddMultiBlock(myManager,105,25,1,2);
}



#include "goodroominclude.h"

#include "triggerregion.h"
#include "savepoint.h"
#include "spikes.h"
#include "triggerscripts.h"
#include "commonbehaviors.h"
#include "DoomedHometown/house.h"
#include "DoomedHometown/cloudgenerator.h"

using namespace DoomedHometown;

bounds_sptr DoomedHometown::GetBoundsManager()  const {return bounds_sptr(new NormalRoom(AABB(0,-32,864,600)));}

void DoomedHometown::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info)  const
{
    assert(myManager);


    //Backgrounds
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("DoomedHometown/background.bmp")),0,0));
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlOVERLAY2, ImgDataStruct("DoomedHometown/officebuilding.bmp")),0,0));

    //Music
    myManager->AddEntity((new TriggerBrush(myManager, 0,0,800,600, false))->AddAction(trigPlayMusic(myManager, "doomedhometown.ogg")));

    myManager->AddEntity(new CloudGenerator(myManager));

    //Brushes
    myManager->AddEntity(new Brush(myManager, 0,-32,864,32, Brush::SOLID)); //Top
    myManager->AddEntity(new Brush(myManager, 832,0,32,600, Brush::SOLID)); //Right side
    myManager->AddEntity(new Brush(myManager, 800,40,32,390, Brush::SOLID)); //Right side 2
    myManager->AddEntity(new Brush(myManager, 134,511,730,25, Brush::SOLID)); //road

    myManager->AddEntity(new Brush(myManager, 0,0,102,600, Brush::SOLID)); //Office building 1
    myManager->AddEntity(new Brush(myManager, 102,0,32,415, Brush::SOLID)); //Office building 2
    myManager->AddEntity(new Brush(myManager, 102,511,32,89, Brush::SOLID)); //Office building 3

    myManager->AddEntity(new Brush(myManager, 0,-32,864,1, Brush::fDEADLY)); //to kill them if they go off the edge

    //Entities
    myManager->AddEntity(new SavePoint(myManager, 456,400, HARD));
    myManager->AddEntity( newHouse(myManager, 229, 475) );

    for(int y=430;y>0;y-=130)
    {
        myManager->AddEntity( newSpikeLeft(myManager, 768, y) );
    }

    {
        entity_sptr temp(myManager->AddEntity( newHouse(myManager,763,540, Brush::fKINEMATIC)));
        myManager->AddEntity((new TriggerBrush(myManager, 762,462,40,50, false))
                    ->AddAction(trigSetVelocity(temp, 0, -217.0)));
    }

    myManager->AddEntity((new TriggerBrush(myManager, 800,430,32,81, true))->AddActionDbl(myManager->GetWarpCallback(KaizoPickory::wdLeft())));
    myManager->AddEntity((new TriggerBrush(myManager, 102,415,32,96, true))->AddActionDbl(myManager->GetWarpCallback(OfficeElevator::wdFloor1())));
    myManager->AddEntity((new TriggerBrush(myManager, 800,0,32,40, true))->AddActionDbl(myManager->GetWarpCallback(FailHome::wdTopLeft())));
}



#include "KaizoPickory/roomdef_kp.h"

#include "goodroominclude.h"

#include "triggerregion.h"
#include "savepoint.h"
#include "secretitem.h"
#include "triggerscripts.h"

#include "KaizoPickory/scrollingbrush.h"
#include "KaizoPickory/bulletbill.h"
#include "KaizoPickory/chomper.h"
#include "KaizoPickory/stoneblock.h"
#include "KaizoPickory/jumper.h"
#include "KaizoPickory/InvertibleBlock.h"
#include "KaizoPickory/blueswitch.h"
#include "KaizoPickory/victorybar.h"
#include "KaizoPickory/triggers_kp.h"

#include "parallaxanim.h"

using namespace KaizoPickory;

bounds_sptr KaizoPickory::GetBoundsManager() const {return bounds_sptr(new ScrollWithKidRightOnly(0,-83,ROOMWIDTH,600,-5,-115,ROOMWIDTH+32,664));}

void KaizoPickory::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info) const
{
    assert(myManager);

    myManager->AddDecoration(new ParallaxWCA( new PlainImage(zlBACKGROUND, ImgDataStruct("KaizoPickory/cloudbg.bmp")),0,-83,CalcParallax(ROOMWIDTH,1024,800),1.0));
    myManager->AddDecoration(new ParallaxWCA( new PlainImage(zlBACKGROUND, ImgDataStruct("KaizoPickory/mountainbg.bmp",0,255,0)),0,275,CalcParallax(ROOMWIDTH,1536,800), 1.0));
    myManager->AddDecoration(new ParallaxWCA( new PlainImage(zlBACKGROUND, ImgDataStruct("KaizoPickory/tunnelbg.bmp",0,255,0)),2271,504,1.0,1.0));

    //Music
    myManager->AddEntity((new TriggerBrush(myManager, 0,-83,ROOMWIDTH,683, true))->AddAction(trigPlayMusic(myManager, "kaizopickory.ogg")));

    //Pickory start screen
    if (info != 0)
    {
        assert(info == 1);
        myManager->AddOverlay((new PlainImage(zlOVERLAY2,
            ImgHandle(ImgDataStruct("KaizoPickory/PickoryStart.bmp",0,255,0)), NULL, 60)));
    }

    //Brushes and Beginning
    {
        myManager->AddEntity(new Brush(myManager,-32,-115,32,747, Brush::SOLID)); //Left
        myManager->AddEntity(new ScrollingBrush(myManager,-32,-32,32,664)); //Scrolling left
        myManager->AddEntity(new Brush(myManager, 0,-115,ROOMWIDTH,32, Brush::SOLID)); //Top
        myManager->AddEntity(new Brush(myManager, ROOMWIDTH,-115,32,779, Brush::SOLID)); //Right side
        myManager->AddEntity(new Brush(myManager, 0,600,2271+32,32, Brush::SOLID)); //Bottom
        myManager->AddEntity(new Brush(myManager, 2271,632,ROOMWIDTH - 2271,32, Brush::SOLID)); //Bottom
        myManager->AddEntity(new Brush(myManager, 0,599,1807,1, Brush::fDEADLY)); //Bottom

        myManager->AddEntity(new BillBlaster(myManager, 160,392));
        myManager->AddEntity(newBlackChomper(myManager, 160,364)); //It is 2 farther don then it should be to prevent ugly gap with the blaster

        myManager->AddEntity(new Brush(myManager,0,536,192,64, Brush::SOLID,
            new PlainImage(zlENTITY, ImgDataStruct("KaizoPickory/ground.bmp",255,255,255), CreateOptSdlRect(64,0,192,64)))); //Ground 1
    }

    double xoff=864;
    double yoff=264;

    myManager->AddEntity(newStoneBlock(myManager,xoff,yoff));
    myManager->AddEntity(new SavePoint(myManager, xoff+96,yoff-23, EASY));
    //myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlENTITY, ImgDataStruct("KaizoPickory/arrowsign.bmp",0,255,0)),xoff+4,yoff-24));
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlENTITY, ImgDataStruct("KaizoPickory/arrowsign.bmp",
        0,255,0)),xoff+98,yoff-47));

    //The corridor of the jiggly platform
    myManager->AddEntity(newStoneBlock(myManager,xoff-80,yoff-96));
    myManager->AddEntity(newStoneBlock(myManager,xoff-300,yoff-86));

    myManager->AddEntity(newMultiChomper(myManager, xoff-322,yoff-64,10,1));
    myManager->AddEntity(newMultiChomper(myManager, xoff-256,yoff-155,5,1));
    myManager->AddEntity(newMultiChomper(myManager, xoff-128,yoff-184,4,1));
    myManager->AddEntity(newBlackChomper(myManager, xoff-32,yoff-155));

    {
        entity_sptr tempj1(myManager->AddEntity(newStoneBlock(myManager,xoff-151,yoff-82, Brush::fKINEMATIC)));
        entity_sptr tempj2(myManager->AddEntity(newStoneBlock(myManager,xoff-112,yoff-62, Brush::fKINEMATIC)));
        myManager->AddEntity((new TriggerBrush(myManager,xoff-80,yoff-155,32,59, false))
                        ->AddAction(trigAddBehavior(tempj1,new OscillateBehavior(tempj1,612,729, -100, 1.57)))
                        ->AddAction(trigAddBehavior(tempj2,new OscillateBehavior(tempj2,651,768, -100, 0.00))));
    }

    //The side bit
    {
        entity_sptr temp(myManager->AddEntity(newMultiChomper(myManager, xoff-338,yoff-244,1,6,Brush::fKINEMATIC)));
        myManager->AddEntity((new TriggerBrush(myManager, xoff-306,yoff-244,40,150, false))
                    ->AddAction(trigSetVelocity(temp, 625, 0)));
    }

    //Now for the upper path
    myManager->AddEntity(newStoneBlock(myManager, xoff-160,yoff-187));
    myManager->AddEntity(newMultiChomper(myManager, xoff-322,yoff-274,6,1));
    //myManager->AddEntity(newStoneBlock(myManager, xoff-163,yoff-244));
    myManager->AddEntity(newStoneBlock(myManager, xoff-161,yoff-247));
    //myManager->AddEntity(new SavePoint(myManager, xoff-191,yoff-244, MEDIUM));
    myManager->AddEntity(new SavePoint(myManager, xoff-130,yoff-271, MEDIUM));
    myManager->AddEntity(newMultiStoneBlock(myManager, xoff-160,yoff-304,6,1));
    myManager->AddEntity(newMultiStoneBlock(myManager, xoff,yoff-187,7,1));
    myManager->AddEntity(newMultiStoneBlock(myManager, xoff+32,yoff-347,5,1));

    //Jumpy guys
    {
        double left = xoff + 32; //= 896
        double top = yoff - 315; //= -51

        myManager->AddEntity(newMultiStoneBlock(myManager, left,top,1,3));
        myManager->AddEntity(newMultiStoneBlock(myManager, left+64,top,1,3));
        myManager->AddEntity(new FootballJumper(myManager, left+48,top+128,0));
        myManager->AddEntity(newMultiStoneBlock(myManager, left+128,top,1,3));
        myManager->AddEntity(new FootballJumper(myManager, left+112,top+128,30));
    }

    //Vertical corridor
    {
        double left = xoff + 224;
        double top = yoff - 187;

        myManager->AddEntity(newMultiChomper(myManager, left,top,1,18));
        myManager->AddEntity(newMultiChomper(myManager, left+96,top-160,1,13));
        myManager->AddEntity(newMultiChomper(myManager, left+192,top+150,1,13));
        {
            entity_sptr tempj(myManager->AddEntity(newStoneBlock(myManager,left+96,top+278, Brush::fKINEMATIC)));
            myManager->AddEntity((new TriggerBrush(myManager, left+32,top,160,222, false))
                        ->AddAction(trigAddBehavior(tempj,new OscillateBehavior(tempj,left+45,left+179, 150, 0.00))));
        }

    }

    //ground 2
    {
        double left = xoff + 530;
        double top = 472;

        myManager->AddEntity(new Brush(myManager, left,top,256,128, Brush::SOLID,
            new PlainImage(zlENTITY2, ImgDataStruct("KaizoPickory/ground.bmp",255,255,255)))); //Ground 2

        myManager->AddEntity(newStoneBlock(myManager, left-4,top+36)); //To make this jump easier

        myManager->AddEntity(new FootballJumper(myManager, left+1*64,607,50));
        myManager->AddEntity(new FootballJumper(myManager, left+2*64,607,50));
        myManager->AddEntity(new FootballJumper(myManager, left+3*64,607,50));

        myManager->AddEntity(new FootballJumper(myManager, left+32+0*64,607,0));
        myManager->AddEntity(new FootballJumper(myManager, left+32+1*64,607,0));
        myManager->AddEntity(new FootballJumper(myManager, left+32+2*64,607,0));

        jumper_sptr temp(new FootballJumper(myManager, left+32+3*64,607,0));
        myManager->AddEntity(temp);

        myManager->AddEntity((new TriggerBrush(myManager, left+197,top-200,54,200, false))
            ->AddAction(trigFootballSuperjump(temp)));

        //The emoticon part
        myManager->AddEntity(newMultiChomper(myManager, left+.1,top-90,2,2));
        myManager->AddEntity(newMultiChomper(myManager, left+.1,top-240,2,2));
        entity_sptr temp2 = myManager->AddEntity(
            newMultiChomper(myManager, left+128,top-240,1,7, Brush::fKINEMATIC));
        myManager->AddEntity(newMultiChomper(myManager, left+160,top-240,2,1));
        myManager->AddEntity(newMultiChomper(myManager, left+160,top-150,2,1));
        myManager->AddEntity(newMultiChomper(myManager, left+224,top-210,1,2));
        myManager->AddEntity((new TriggerBrush(myManager, left+32,top-240,96,120, false))
                    ->AddAction(trigSetVelocity(temp2, -800, 0)));
    }

    myManager->AddEntity(new ICB_finalregion(myManager, xoff+786,472,xoff+943,504));

    invertblock_sptr theIBcontroller( new InvertibleBlockManager(myManager));
    //ground 3
    {
        double left = xoff + 943; //1807
        double top = 504;
        myManager->AddEntity(new Brush(myManager, left,top,240,96, Brush::SOLID,
            new PlainImage(zlENTITY, ImgDataStruct("KaizoPickory/ground.bmp",255,255,255), CreateOptSdlRect(0,0,240,96))));

        myManager->AddEntity(new SavePoint(myManager, left+33, 305, EASY));

        {
            myManager->AddEntity(theIBcontroller);
            myManager->AddEntity(new BlueSwitch(myManager,left+64,112,theIBcontroller));

            for (Uint32 i=0;i<15;++i)
            {
                theIBcontroller->RegisterEntity(
                    myManager->AddEntity(newBrownBlock(myManager,left+16,416.0-32*i)), true);
                theIBcontroller->RegisterEntity(
                    myManager->AddEntity(newBrownBlock(myManager,left+112,416.0-32*i)), true);
            }

            theIBcontroller->RegisterEntity(
                myManager->AddEntity(newBrownBlock(myManager,left+80,416)), true);
            theIBcontroller->RegisterEntity(
                myManager->AddEntity(newBrownBlock(myManager,left+48,288)), true);
            theIBcontroller->RegisterEntity(
                myManager->AddEntity(newBrownBlock(myManager,left+80,160)), true);
            theIBcontroller->RegisterEntity(
                myManager->AddEntity(newFruit(myManager,left+48,80)), false);
            /*theIBcontroller->RegisterEntity(
                myManager->AddEntity(newFruit(myManager,left+112,-32)), false);
            theIBcontroller->RegisterEntity(
                myManager->AddEntity(newFruit(myManager,left+112,-64)), false);*/
        }

        //Apple arrow
        {
            double arrowx = left + 531;
            double arrowy = top - 222;
            double d = 30;
            theIBcontroller->RegisterEntity(myManager->AddEntity(newFruit(myManager,arrowx-d*4,arrowy)), false);
            theIBcontroller->RegisterEntity(myManager->AddEntity(newFruit(myManager,arrowx-d*3,arrowy)), false);
            theIBcontroller->RegisterEntity(myManager->AddEntity(newFruit(myManager,arrowx-d*2,arrowy)), false);
            theIBcontroller->RegisterEntity(myManager->AddEntity(newFruit(myManager,arrowx-d,arrowy-2*d)), false);
            theIBcontroller->RegisterEntity(myManager->AddEntity(newFruit(myManager,arrowx-d,arrowy)), false);
            theIBcontroller->RegisterEntity(myManager->AddEntity(newFruit(myManager,arrowx-d,arrowy+2*d)), false);
            theIBcontroller->RegisterEntity(myManager->AddEntity(newFruit(myManager,arrowx,arrowy-d)), false);
            theIBcontroller->RegisterEntity(myManager->AddEntity(newFruit(myManager,arrowx,arrowy)), false);
            theIBcontroller->RegisterEntity(myManager->AddEntity(newFruit(myManager,arrowx,arrowy+d)), false);
            theIBcontroller->RegisterEntity(myManager->AddEntity(newFruit(myManager,arrowx+d,arrowy)), false);
        }


        double GROUNDLEFTEDGE = left+496; //2303

        myManager->AddEntity(new Brush(myManager, left+240,top,256,96, Brush::SOLID,
            new PlainImage(zlENTITY, ImgDataStruct("KaizoPickory/ground.bmp",255,255,255), CreateOptSdlRect(16,0,224,96)))); //The final 32 is accounted for by the bsckground stones

        theIBcontroller->RegisterEntity(
            myManager->AddEntity(newFruit(myManager,GROUNDLEFTEDGE+26,top+16)), false);
        theIBcontroller->RegisterEntity(
            myManager->AddEntity(newFruit(myManager,GROUNDLEFTEDGE+60,top+16)), false);
        theIBcontroller->RegisterEntity(
            myManager->AddEntity(newFruit(myManager,GROUNDLEFTEDGE+94,top+16)), false);
        //Edge of far ground = nearedge+120

        //The victory gate
        //myManager->AddEntity( new VictoryBar(myManager,left+160,top-288));
        CreateVictoryGate(myManager,left+192,top-144);

        {
            double GROUNDRIGHTEDGE = GROUNDLEFTEDGE+120; //2423
            //The first 32 is accounted for by teh background stones
            myManager->AddEntity(new Brush(myManager, GROUNDRIGHTEDGE,top,256,128, Brush::SOLID,
                new PlainImage(zlENTITY, ImgDataStruct("KaizoPickory/ground.bmp",255,255,255), CreateOptSdlRect(16,0,240,96)),32,0));

            myManager->AddEntity(newMultiChomper(myManager, GROUNDRIGHTEDGE+48,-90,1,15));

            theIBcontroller->RegisterEntity(
                myManager->AddEntity(newBrownBlock(myManager,GROUNDRIGHTEDGE+96,top-128)), true);

            myManager->AddEntity(newMultiChomper(myManager, GROUNDRIGHTEDGE+144,top-146,2,1));
            myManager->AddEntity(newMultiChomper(myManager, GROUNDRIGHTEDGE+208,top-161,2,1));
            myManager->AddEntity(newMultiChomper(myManager, GROUNDRIGHTEDGE+144,top-64,1,2));
            myManager->AddEntity(newMultiChomper(myManager, GROUNDRIGHTEDGE+224,top-64,1,2));
            myManager->AddEntity(new FootballJumper(myManager, GROUNDRIGHTEDGE+200,top,0));

            //Secret Item
            myManager->AddEntity(newSecretItem(myManager, GROUNDRIGHTEDGE+80,top-176, Secret::NONPOISONOUSMUSHROOM()));

            //myManager->AddEntity(newStoneBlock(myManager, GROUNDRIGHTEDGE+80,top-176));
        }

        assert(GROUNDLEFTEDGE == 2303);//Rember to change the warpzone in the header if this is changed
        myManager->AddEntity((new TriggerBrush(myManager,GROUNDLEFTEDGE,600,120,32, true))
            ->AddActionDbl(myManager->GetWarpCallback(TutorialTunnel::wdTopLeft())));
    }

}




#include "goodroominclude.h"

#include "ebrush.h"
#include "triggerregion.h"
#include "triggerscripts.h"

bounds_sptr TitleScreen::GetBoundsManager()  const {return bounds_sptr(new NormalRoom(AABB(-32,-32,864,664)));}

void TitleScreen::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info) const
{
    assert(myManager);


    //Backgrounds
    myManager-&gt;AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("TitleScreen/background.bmp")),0,0));
    myManager-&gt;AddDecoration(new WorldCoordAnim( new PlainImage(zlOVERLAY, ImgDataStruct("TitleScreen/building.bmp",0,255,0)),481,416));

    //Music
    myManager-&gt;AddEntity((new TriggerBrush(myManager, 0,0,800,600, false))
        -&gt;AddAction(trigPlayMusic(myManager, "titlescreen.ogg")));

    myManager-&gt;AddEntity(new Brush(myManager, -32,-32,864,32, Brush::SOLID)); //Top
    myManager-&gt;AddEntity(new Brush(myManager, -32,600,864,32, Brush::SOLID)); //Bottom
    myManager-&gt;AddEntity(new Brush(myManager, -32,0,32,600, Brush::SOLID)); //Left
    myManager-&gt;AddEntity(new Brush(myManager, 800,0,32, 600, Brush::SOLID)); //Right

    myManager-&gt;AddEntity(new Brush(myManager, 511,426,289,174, Brush::SOLID)); //Office building
    myManager-&gt;AddEntity(new Brush(myManager, 481,416,30,184, Brush::SOLID)); //Office building 2

    myManager-&gt;AddEntity(new Brush(myManager, 0,599,800,1, Brush::fDEADLY)); //On the Bottom

    //myManager-&gt;AddEntity( newSpikeDown(myManager, 704, 394) );
    //myManager-&gt;AddEntity( newSpikeRight(myManager, 736, 394) );
}

#include "OfficeElevator/roomdef_oe.h"

#include "goodroominclude.h"

#include "triggerregion.h"
#include "spikes.h"
#include "savepoint.h"
#include "triggerscripts.h"
#include "OfficeElevator/groundblock.h"
#include "OfficeElevator/zoomspikewall.h"
#include "OfficeElevator/barrier.h"
#include "OfficeElevator/elevator.h"

using namespace OfficeElevator;

boost::shared_ptr&lt;Brush&gt; OfficeElevator::GridAlignedPlatform(entitymanager_ptr myManager, int x, int y, int w, int h) const
{
    return boost::shared_ptr&lt;Brush&gt;(new Brush(myManager, x*32,y*32 - 8,w*32,h*32, Brush::SOLID));
}

bounds_sptr OfficeElevator::GetBoundsManager() const {return bounds_sptr(new NormalRoom(AABB(-64,-64,864,664)));}

void OfficeElevator::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info) const
{
    assert(myManager);


    myManager-&gt;AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("OfficeElevator/background.bmp")),0,0));

    //Music
    myManager-&gt;AddEntity((new TriggerBrush(myManager,0,0,800,600, false))-&gt;AddAction(trigPlayMusic(myManager, "officeelevator.ogg")));

    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,10,-2,5,1)); //Cover the top of shaft
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,0,-1,11,2)); //Top
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,14,-1,11,2));

    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,10,20,5,1)); //Cover the bottom of shaft
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,-2,18,13,2)); //bottom layer
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,14,18,13,2)); //(extends 2 to the right side also)

    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,-1,1,2,14)); //Left side top
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,-2,14,1,5)); //Left side cover

    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,24,1,2,13)); //Right side top
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,26,13,1,5)); //Right side cover

    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,1,6,2,1));   //Middle ledges top layer
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,6,6,5,1));
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,14,6,5,1));
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,22,6,4,1));

    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,1,10,2,1));   //Middle ledges mid layer
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,6,10,5,1));
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,14,10,5,1));
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,22,10,4,1));

    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,1,14,2,1));   //Middle ledges bottom layer
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,6,14,5,1));
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,14,14,5,1));
    myManager-&gt;AddEntity(   GridAlignedPlatform(myManager,22,14,4,1));

    myManager-&gt;AddEntity(new Elevator(myManager, 400,596));

    {
        zspikewall_sptr zsw1(new ZoomSpikeWall(myManager,-14,473, ZoomSpikeWall::RIGHT ));
        zspikewall_sptr zsw2(new ZoomSpikeWall(myManager,814,345, ZoomSpikeWall::LEFT ));
        //zspikewall_sptr zsw3(new ZoomSpikeWall(myManager,-14,217, ZoomSpikeWall::RIGHT, true ));
        zspikewall_sptr zsw3(new ZoomSpikeWall(myManager,814,217, ZoomSpikeWall::LEFT, true ));
        zspikewall_sptr zsw4(new ZoomSpikeWall(myManager,-14,79, ZoomSpikeWall::RIGHT ));
        zspikewall_sptr zsw5(new ZoomSpikeWall(myManager,814,79, ZoomSpikeWall::LEFT ));

        barrier_sptr bar1(new SegmentBarrier(myManager,96,452));
        barrier_sptr bar2(new SegmentBarrier(myManager,352,452));
        barrier_sptr bar3(new SegmentBarrier(myManager,608,452));
        barrier_sptr bar4(new SegmentBarrier(myManager,96,324));
        barrier_sptr bar5(new SegmentBarrier(myManager,352,324));
        barrier_sptr bar6(new SegmentBarrier(myManager,608,324));
        barrier_sptr bar7(new SegmentBarrier(myManager,96,196));
        barrier_sptr bar8(new SegmentBarrier(myManager,608,196));

        zsw1-&gt;AddBarrier(bar1);
        zsw1-&gt;AddBarrier(bar3);

        zsw2-&gt;AddBarrier(bar1);
        zsw2-&gt;AddBarrier(bar2);
        zsw2-&gt;AddBarrier(bar3);
        zsw2-&gt;AddBarrier(bar4);
        zsw2-&gt;AddBarrier(bar6);

        zsw3-&gt;AddBarrier(bar4);
        zsw3-&gt;AddBarrier(bar5);
        zsw3-&gt;AddBarrier(bar6);
        zsw3-&gt;AddBarrier(bar7);
        zsw3-&gt;AddBarrier(bar8);

        zsw4-&gt;AddBarrier(bar7);
        zsw4-&gt;AddBarrier(bar8);
        zsw5-&gt;AddBarrier(bar7);
        zsw5-&gt;AddBarrier(bar8);

        myManager-&gt;AddEntity(zsw1);
        myManager-&gt;AddEntity(zsw2);
        myManager-&gt;AddEntity(zsw3);
        myManager-&gt;AddEntity(zsw4);
        myManager-&gt;AddEntity(zsw5);

        myManager-&gt;AddEntity(bar1);
        myManager-&gt;AddEntity(bar2);
        myManager-&gt;AddEntity(bar3);
        myManager-&gt;AddEntity(bar4);
        myManager-&gt;AddEntity(bar5);
        myManager-&gt;AddEntity(bar6);
        myManager-&gt;AddEntity(bar7);
        myManager-&gt;AddEntity(bar8);
    }

    //Temporary spikes to block off unfinished sections
    //myManager-&gt;AddEntity(newSpikeDown(myManager,352,0));
    //myManager-&gt;AddEntity(newSpikeDown(myManager,352+32,0));
    //myManager-&gt;AddEntity(newSpikeDown(myManager,352+64,0));

    myManager-&gt;AddEntity(newSpikeUp(myManager,0,536));
    myManager-&gt;AddEntity(newSpikeUp(myManager,768,536));

    myManager-&gt;AddEntity(newSpikeRight(myManager,352,440));
    myManager-&gt;AddEntity(newSpikeLeft(myManager,416,440));
    myManager-&gt;AddEntity(newSpikeUp(myManager,288,408));
    myManager-&gt;AddEntity(newSpikeUp(myManager,320,408));
    myManager-&gt;AddEntity(newSpikeUp(myManager,448,408));
    myManager-&gt;AddEntity(newSpikeUp(myManager,480,408));

    myManager-&gt;AddEntity(newSpikeUp(myManager,192,280));
    myManager-&gt;AddEntity(newSpikeUp(myManager,320,280));
    myManager-&gt;AddEntity(newSpikeUp(myManager,448,280));
    myManager-&gt;AddEntity(newSpikeUp(myManager,576,280));

    for (int i=1;i&lt;11;++i)
    {
        myManager-&gt;AddEntity(newSpikeDown(myManager,32*i, 24));
        myManager-&gt;AddEntity(newSpikeDown(myManager,416 + 32*i, 24));
    }

    {
        double x=330;
        double y=150;
        myManager-&gt;AddEntity(newGroundBlock(myManager,x,y));
        myManager-&gt;AddEntity(newSpikeUp(myManager,x,y-32));
        myManager-&gt;AddEntity(newSpikeDown(myManager,x,y+32));
        myManager-&gt;AddEntity(newSpikeRight(myManager,x+32,y));
        myManager-&gt;AddEntity(newSpikeLeft(myManager,x-32,y));
    }
    {
        double x=438;
        double y=150;
        myManager-&gt;AddEntity(newGroundBlock(myManager,x,y));
        myManager-&gt;AddEntity(newSpikeUp(myManager,x,y-32));
        myManager-&gt;AddEntity(newSpikeDown(myManager,x,y+32));
        myManager-&gt;AddEntity(newSpikeRight(myManager,x+32,y));
        myManager-&gt;AddEntity(newSpikeLeft(myManager,x-32,y));
    }

    myManager-&gt;AddEntity(new SavePoint(myManager, 738, 472, EASY));

    myManager-&gt;AddEntity((new TriggerBrush(myManager,352,600,96,32, true))-&gt;AddActionDbl(myManager-&gt;GetWarpCallback(TestChamber::wdTop01())));
    myManager-&gt;AddEntity((new TriggerBrush(myManager,-32,472,32,96, true))-&gt;AddActionDbl(myManager-&gt;GetWarpCallback(SectorI::wdBotRight())));
    myManager-&gt;AddEntity((new TriggerBrush(myManager,352,0,96,32, true))-&gt;AddActionDbl(myManager-&gt;GetWarpCallback(RooftopGardens::wdElevator())));
    //X coord is 803 instead of 800 to prevent people from immediately teleporting back after warping
    myManager-&gt;AddEntity((new TriggerBrush(myManager,803,472,32,96, true))-&gt;AddActionDbl(myManager-&gt;GetWarpCallback(DoomedHometown::wdLeft())));

}

#include "BottomlessPit/roomdef_bp.h"

#include "ebrush.h"
#include "entitymanagerinterface.h"
#include "BottomlessPit/offsetteleporter.h"

using namespace BottomlessPit;

bounds_sptr BottomlessPit::GetBoundsManager()  const {return bounds_sptr(new LargeRoom(0, 0,800,1312,AABB(320,-64,480,1344)));}

void BottomlessPit::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info) const
{
    assert(myManager);


    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("BottomlessPit/background.bmp")),0,0));

    myManager->AddEntity(new Brush(myManager, 320,-32,32,1344, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager, 448,-32,32,1344, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager, 320,-64,160,32, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager, 320,1312,160,32, Brush::SOLID));

    myManager->AddEntity(new CrudeOffsetTeleporter(myManager, 320,975,160,350,0,-512));
}

#include "goodroominclude.h"

#include "ebrush.h"
#include "triggerregion.h"
#include "triggerscripts.h"
#include "secretitem.h"

bounds_sptr FailHome::GetBoundsManager()  const {return bounds_sptr(new NormalRoom(AABB(-1,-1,801,601)));}

void FailHome::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info)  const
{
    assert(myManager);


    //Backgrounds
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("FailHome/background.bmp")),0,0));

    //Music
    myManager->AddEntity((new TriggerBrush(myManager, 0,0,800,600, false))->AddAction(trigPlayMusic(myManager, "failhome.ogg")));

    //Secret Item
    myManager->AddEntity(newSecretItem(myManager, 448,380, Secret::FAILKIRBY()));

    //Boundary Brushes
    myManager->AddEntity(new Brush(myManager, -32,-32,864,32, Brush::SOLID)); //Top
    myManager->AddEntity(new Brush(myManager, -32,600,864,32, Brush::SOLID)); //Bottom
    myManager->AddEntity(new Brush(myManager, -32,0,32,600, Brush::SOLID)); //Left
    myManager->AddEntity(new Brush(myManager, 800,0,32,600, Brush::SOLID)); //Right

    myManager->AddEntity(new Brush(myManager, 131,398,92,43, Brush::SOLID)); //Fail sign
    myManager->AddEntity(new Brush(myManager, 263,287,21,52, Brush::SOLID)); //House smokestack

    myManager->AddEntity(new Brush(myManager, 259,288,
        (SimplePointList().AddPoint(56.5,0).AddPoint(113,58).AddPoint(0,58)
        .CreateNewShape()), Brush::SOLID)); //House Roof

    myManager->AddEntity(new Brush(myManager, 0,400,(SimplePointList().AddPoint(0,200).
        AddPoint(0,150).AddPoint(59,110).AddPoint(101,94).AddPoint(148,85).AddPoint(258,81)
        .CreateNewShape()), Brush::SOLID)); //Ground
    myManager->AddEntity(new Brush(myManager, 0,400,(SimplePointList().AddPoint(0,200).
        AddPoint(258,81).AddPoint(585,81).AddPoint(702,101).AddPoint(800,138).AddPoint(800,200)
        .CreateNewShape()), Brush::SOLID)); //Ground 2
}

#include "goodroominclude.h"

#include "ebrush.h"
#include "triggerregion.h"
#include "triggerscripts.h"
#include "victoryorb.h"
#include "Iji/ijidatamanager.h"
#include "Iji/hud.h"
#include "Iji/torfightmanager.h"
#include "Iji/resonancereflector.h"

using namespace Iji;

bounds_sptr TorFight::GetBoundsManager()  const
{
    return bounds_sptr(new LargeRoom(0, 0,ROOMW,ROOMH,AABB(-32,-32,ROOMW+32,ROOMH+32)));
}

void TorFight::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info) const
{
    assert(myManager);


    ijimanager_sptr myIjiManager(new IjiDataManager());

    //Music
    myManager->AddEntity((new TriggerBrush(myManager, 0,0,ROOMW,ROOMH, false))->AddAction(trigPlayMusic(myManager, "torfight.ogg")));

    //Backgrounds
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("Iji/TorFightBG.bmp")),0,0));
    //Hud Overlay
    hud_sptr thehud(new Hud());
    myManager->AddOverlay(thehud);

    myManager->AddEntity(new Brush(myManager, -32,-32,ROOMW+32,32, Brush::SOLID)); //Top
    myManager->AddEntity(new Brush(myManager, -32,ROOMH,ROOMW+32,32, Brush::SOLID)); //Bottom
    myManager->AddEntity(new Brush(myManager, -32,0,32,ROOMH, Brush::SOLID)); //Left
    myManager->AddEntity(new Brush(myManager, ROOMW,0,32, ROOMW+32, Brush::SOLID)); //Right

    myManager->AddEntity(new Brush(myManager, 0,492,ROOMW,108, Brush::SOLID));

    myManager->AddEntity(new Brush(myManager, 82,367,27,1, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager, 249,366,24,1, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager, 367,375,101,1, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager, 588,370,55,1, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager, 786,373,14,1, Brush::SOLID));

    if (!myManager->BossesDefeated().GetBossStatus(BossList::TOR))
    {
        myManager->AddEntity(new TorFightManager(myManager, myIjiManager, false));
    }
    else
    {
        myManager->AddEntity(newVictoryOrb(myManager,700,476, BossList::TOR, true));
    }

    {
        myManager->AddEntity((new TriggerBrush(myManager, 0, 0, 800, 600, false))
            ->AddAction(trigSwitch2Reflector(myManager, myIjiManager, thehud)));
    }
}

#include "goodroominclude.h"

#include "ebrush.h"
#include "spikes.h"
#include "savepoint.h"
#include "triggerregion.h"
#include "triggerscripts.h"
#include "Iji/ijidatamanager.h"
#include "Iji/resonancereflector.h"

using namespace Iji;

//////////////////////////////////////////////////////////
Entity* SectorI::MakePlatform(entitymanager_ptr myManager, Uint32 x, Uint32 y, Uint32 w, Uint32 h) const
{
    assert(w>0 && h>0);
    return new Brush(myManager, LEFT()+32*x,TOP()+32*y,32*w,32*h, Brush::SOLID);
}

//////////////////////////////////////////////////////////

bounds_sptr SectorI::GetBoundsManager()  const {return bounds_sptr(new NormalRoom(AABB(LEFT(),TOP(),LEFT()+288,TOP()+224)));}
//bounds_sptr SectorI::GetBoundsManager()  const {return bounds_sptr(new NormalRoom(AABB(0,0,800,600)));}

void SectorI::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info) const
{
    assert(myManager);

    ijimanager_sptr myIjiManager(new IjiDataManager());

    //Music
    myManager->AddEntity((new TriggerBrush(myManager, LEFT(),TOP(),320,224, false))->AddAction(trigPlayMusic(myManager, "sectori.ogg")));

    //Backgrounds
    //myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("Iji/TorFightBG.bmp")),0,0));
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("Iji/sectX_endbg.bmp")),LEFT(),TOP()));
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlOVERLAY, ImgDataStruct("Iji/sectX_endbgmask.bmp", 0, 255, 0)),0,0));

    myManager->AddEntity(MakePlatform(myManager,0,0,10,1));
    myManager->AddEntity(MakePlatform(myManager,0,6,10,1));
    myManager->AddEntity(MakePlatform(myManager,0,1,1,5));
    myManager->AddEntity(MakePlatform(myManager,9,1,1,5));
    myManager->AddEntity(MakePlatform(myManager,3,3,6,1));

    myManager->AddEntity(new SavePoint(myManager, LEFT() + 130, TOP() + 128, HARD));

    myManager->AddEntity(newSpikeDown(myManager,LEFT() + 82,TOP() + 1 * 32));

    {
        entity_sptr temp(myManager->AddEntity( newSpikeDown(myManager,LEFT() + 164,TOP() + 1 * 32, Brush::fKINEMATIC)));
        myManager->AddEntity((new TriggerBrush(myManager, LEFT() + 176, TOP() + 128,32,64, false))
                    ->AddAction(trigSetVelocity(temp, 0, 405.0)));
    }

    {
        myManager->AddEntity((new TriggerBrush(myManager, LEFT()+97, TOP()+72,31,23, false, new PlainImage(zlOVERLAY,
            ImgDataStruct("Iji/pickup_resonancereflector.bmp",0,255,0))))
            ->AddAction(trigSwitch2Reflector(myManager, ijimanager_sptr(), hud_sptr())));
    }

    myManager->AddEntity((new TriggerBrush(myManager, LEFT() + 8 * 32,TOP() + 1 * 32,32,64, true))->
        AddActionDbl(myManager->GetWarpCallback(TorFight::wdBotLeft())));
    //Move it over by 9 to cut down on instant room switches when moving bakc and forth over the edge
    myManager->AddEntity((new TriggerBrush(myManager, LEFT() + 265 ,TOP() + 4 * 32,32,64, true))->
        AddActionDbl(myManager->GetWarpCallback(OfficeElevator::wdFloor1Left())));
}






#include "roomdef_rg.h"

#include "ebrush.h"
#include "triggerregion.h"
#include "triggerscripts.h"
#include "RooftopGardens\sensornpc.h"
#include "RooftopGardens\drinkvendor.h"

using namespace RooftopGardens;

////////////////////////////////////////////////////
Brush* newOctagonalTable(entitymanager_ptr manager, double x, double y, Brush::FlagType flags = Brush::NOFLAGS)
{
    return new Brush(manager,x,y,
        (SimplePointList().AddPoint(0,15).AddPoint(15,0).AddPoint(49,0).AddPoint(64,15).
        AddPoint(64,35).AddPoint(48,51).AddPoint(16,51).AddPoint(0,35).CreateNewShape()),  flags | Brush::SOLID);
}

////////////////////////////////////////////////////

bounds_sptr RooftopGardens::GetBoundsManager()  const {return bounds_sptr(new NormalRoom(AABB(LEFT(),TOP(),LEFT()+528,TOP()+256)));}

void RooftopGardens::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info) const
{
    assert(myManager);

    //Music
    myManager->AddEntity((new TriggerBrush(myManager, LEFT(),TOP(),528,256, false))->AddAction(trigPlayMusic(myManager, "rooftopgardens.ogg")));

    //Backgrounds
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND,
        ImgDataStruct("RooftopGardens/rgbackground.bmp")),LEFT(),TOP()));
    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlOVERLAY,
        ImgDataStruct("RooftopGardens/bgmask.bmp",0,255,0)),0,0));

    myManager->AddEntity(new Brush(myManager,LEFT(),TOP(),8,256, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager,LEFT()+520,TOP(),8,256, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager,LEFT()+8,TOP(),512,32, Brush::SOLID));
    myManager->AddEntity(new Brush(myManager,LEFT()+8,TOP()+224,512,32, Brush::SOLID));

    myManager->AddEntity(newOctagonalTable(myManager,LEFT()+72,TOP()+64));
    myManager->AddEntity(newOctagonalTable(myManager,LEFT()+200,TOP()+128));

    {
        npc_sptr thegirl(new npc_DrinkSensor(myManager,LEFT()+333,TOP()+175));
        myManager->AddEntity(thegirl);
        myManager->AddEntity(new DrinkVendor(myManager,LEFT()+328,TOP()+96,32,128,thegirl));
    }
}






#include "Portal/roomdef_portal.h"

#include "BottomlessPit\roomdef_bp.h"
#include "DoomedHometown\roomdef_dh.h"
#include "triggerregion.h"
#include "savepoint.h"
#include "entitymanagerinterface.h"
#include "Portal/elevatorfactory.h"
#include "Portal/helperfactory.h"
#include "Portal/scaffold.h"

using namespace Portal;

Entity* newGrill(entitymanager_ptr manager, double centerx, double centery)
{
    return new Brush(manager,centerx-2,centery-32,4,64, Brush::fPLATFORM,
        new PlainImage(zlOVERLAY, ImgDataStruct("Portal/grill.bmp",0,255,0)));
}

void LoadChamber1(entitymanager_ptr myManager, RoomLoadInfo info, double x, double y)
{
    PRoomdefHelper helper(myManager,x,y);

    const double bx = x-16; //For entities which expect coordinate of top corner
    const double by = y-16;
    Vec2d off(x,y);

    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("Portal/background01.bmp")),0,0));
    helper.CreateCommonStuff(-400,-300,400,300,false);

    //Temporary
    {
        myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlOVERLAY, ImgDataStruct("Under Construction - Dead End",
            "Fonts/verdana.ttf", 27, 2, MakeColor(255,10,10), MakeColor(100,0,0))),170,40));
    }

    helper.CreateBrush(0,-348,160,32); //top cap
    helper.CreateBrush(0,+348,160,32); //bot cap
    myManager->AddEntity((new TriggerBrush(myManager,bx-64,by+316,160,32, true))
        ->AddActionDbl(myManager->GetWarpCallback(BottomlessPit::wdTop())));

    //Left Section
    helper.CreateBrush(-64,-214,32,236); //left top
    helper.CreateBrush(-64,0,32,64); //left mid
    helper.CreateBrush(-224,0,32,64); //left far mid
    helper.CreateBrush(-64,214,32,236); //left bot
    myManager->AddEntity(newGrill(myManager, x-64,y-64));

    //Outer surface
    helper.CreatePortalSurface(Vec2d(-304,-96), Vec2d(-80,-96), false);
    helper.CreatePortalSurface(Vec2d(-304,-96), Vec2d(-304,96), true);
    helper.CreatePortalSurface(Vec2d(-304,96), Vec2d(-80,96), true);
    //Inner surface
    helper.CreatePortalSurface(Vec2d(-208,-32), Vec2d(-80,-32), true);
    helper.CreatePortalSurface(Vec2d(-208,32), Vec2d(-80,32), false);

    //Right Section
    helper.CreateBrush(64,-214,32,236); //top
    helper.CreateBrush(64,150,32,364); //mid
    myManager->AddEntity(newGrill(myManager, x+64,y-64));

    helper.CreateBrush(224,0,32,64); //far mid
    helper.CreateBrush(144,16,128,32); //above elevator
    helper.CreateBrush(224,112,224,32); //below elevator

    //Outer surface
    helper.CreatePortalSurface(Vec2d(304,-96), Vec2d(80,-96), true);
    helper.CreatePortalSurface(Vec2d(304,-96), Vec2d(304,96), false);
    //Inner surface
    helper.CreatePortalSurface(Vec2d(208,-32), Vec2d(80,-32), false);
    helper.CreatePortalSurface(Vec2d(144,32), Vec2d(144,96), true);

    CreateExitElevator(myManager, bx+192,by+80, TestChamber::wdEle02());

    helper.AddController_1button( helper.CreateDoor(224,64,false), helper.CreateWeightButton(272,96) );
    helper.AddController_exists( helper.CreateDoor(-64,64,true), helper.CreatePortalGun(-179,53), false );
}

Warpdest TestChamber::wdEle02() {return Warpdest(TESTCHAMBER2,DOELEVATOR,48,348,32,32);}

void LoadChamber2(entitymanager_ptr myManager, RoomLoadInfo info, double x, double y)
{
    PRoomdefHelper helper(myManager,x,y);
    const double rhw = 272;

    Vec2d off(x,y);

    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("Portal/background02.bmp")),0,0));
    helper.CreateCommonStuff(-400,-300,400,300,true);

    //Walls
    helper.CreatePortalSurface(Vec2d(-rhw,-128), Vec2d(-rhw,0), true);
    helper.CreatePortalSurface(Vec2d(rhw,-128), Vec2d(rhw,0), false);
    helper.CreateBrush(0,-240,544,32); //Ceiling
    helper.CreateBrush(-rhw-16,-192,32,128);
    helper.CreateBrush(+rhw+16,-192,32,128);

    //myManager->AddEntity(new PortalSurface(myManager,mySurfDcastMap,myLinker, off+Vec2d(-rhw,96), off+Vec2d(rhw,96), true));
    helper.CreatePortalSurface(Vec2d(-rhw,96), Vec2d(198,96), true);
    helper.CreateBrushTLWH(198,96,rhw-198,32); //To make sure they can't put portals under the button

    //Left sideroom
    helper.CreateBrush(-rhw-64,16,128,32);
    helper.CreateBrush(-rhw-64,112,128,32);
    helper.CreateBrush(-rhw-112,64,32,64);
    helper.CreateFizzler_1x2(-rhw-16,64);
    CreateEntranceElevator(myManager, x - rhw - 64, y + 64, (info != TestChamber::DOELEVATOR));
    //Rember to update the warpdest when these coordinates are changed!

    //Right sideroom
    helper.CreateBrush(rhw+64,16,128,32);
    helper.CreateBrush(rhw+64,112,128,32);
    helper.CreateBrush(rhw+112,64,32,64);
    CreateExitElevator(myManager, x + rhw + 64, y + 64, TestChamber::wdEle03());

    //Ledge
    helper.CreateBrushTLWH(112,-160,160,32);
    helper.CreateCube(160,-176);
    //myManager->AddEntity(new StorageCube(myManager, x+160,y-176));
    helper.AddController_1button( helper.CreateDoor(rhw+16,64,false), helper.CreateWeightButton(224,96) );
}

Warpdest TestChamber::wdEle03() {return Warpdest(TESTCHAMBER3,DOELEVATOR,144,112,32,32);}

void LoadChamber3(entitymanager_ptr myManager, RoomLoadInfo info, double x, double y)
{
    PRoomdefHelper helper(myManager,x,y);

    myManager->AddDecoration(new WorldCoordAnim( new PlainImage(zlBACKGROUND, ImgDataStruct("Portal/background03.bmp")),0,0));
    helper.CreateCommonStuff(-336,-236,688,276,true);

    //Part 1 /////////////////////////////////////////////////////////////////////////////////////////////////
    helper.SetOffsetAbs(x-336,y-236); ////////////////////////////////////////////////////////////////////////
    helper.CreateBrushTLWH(0,0,416,32);
    helper.CreateBrushTLWH(0,96,160,32); helper.CreateBrushTLWH(224,96,32,32);
    helper.CreateBrushTLWH(0,192,352,32);
    helper.CreateBrushTLWH(0,32,32,160);
    helper.CreateBrushTLWH(416,0,32,128);
    helper.CreatePortalSurface(Vec2d(320,32), Vec2d(320,128), false);
    helper.CreateFizzler_1x2(144,64);
    helper.CreateFizzler_1x2(240,64);
    helper.AddController_1button( helper.CreateDoor(144,160,false), helper.CreateWeightButton(192,192) );
    helper.AddController_1button( helper.CreateDoor(240,160,false), helper.CreateWeightButton(288,192) );

    CreateEntranceElevator(myManager, (x-336) + 96, (y-236) + 64, (info != TestChamber::DOELEVATOR));
    CreateExitElevator(myManager, (x-336) + 96, (y-236) + 160, DoomedHometown::wdMansionDoor());

    helper.CreateLauncher(32,176);
    myManager->AddEntity(new SavePoint(myManager, (x-336) + 34, (y-236) + 33, MEDIUM));

    //Part 2 /////////////////////////////////////////////////////////////////////////////////////////////////
    helper.SetOffsetRel(544,128); ////////////////////////////////////////////////////////////////////////
    helper.CreateBrush(-160,16,128,32); //Side ceilings
    helper.CreateBrush(160,16,128,32);
    helper.CreatePortalSurface(Vec2d(-128,32), Vec2d(-128,128), false);
    helper.CreatePortalSurface(Vec2d(128,32), Vec2d(128,128), true);
    helper.CreateBrush(-208,224,32,320); //Left wall
    helper.CreateBrush(208,248,32,272); //Right wall is 48 shorter then left
    helper.CreateBrush(0,144,256,32); //Passage ceiling
    helper.CreateBrush(0,368,384,32); //The floor
    helper.CreateSolidSpike(208,96, 1); //Upward facing

    {
        boost::shared_ptr<ScaffoldController> tempsc(new ScaffoldController(myManager, helper.CurrentOffset()));
        myManager->AddEntity(tempsc);
        tempsc->AddNodeRelative(Vec2d(-120,248));
        tempsc->AddNodeRelative(Vec2d(120,248));
        helper.CreateCatcher(-192,112, ScaffoldCallback(tempsc));
    }

    //Make the image 1 pixel wider then normal to prevent ugly gaps
    helper.CreateBrush(0,320,384,64, Brush::fDEADLY | Brush::fBULLETPROOF | Brush::fSENSOR, (new PlainImage(zlOVERLAY,ImgHandle(
        ImgDataStruct("Portal/poison2.bmp")), CreateOptSdlRect(0,0,385,65)))->SetAlpha(200));

    //Part 3 /////////////////////////////////////////////////////////////////////////////////////////////////
    helper.SetOffsetRel(224,-96); ////////////////////////////////////////////////////////////////////////
    helper.CreateBrushTLWH(0,448,128,32); //The floor
    helper.CreateBrush(32,328+8/2,64,8); //Platform
    helper.CreateBrushTLWH(128,224,64,256); //Lower Right Wall
    helper.CreateBrushTLWH(192,160,64,128); //Upper Right Wall
    helper.CreateFizzler_1x2(144,192);
    helper.CreateBrushTLWH(128,128,128,32); //Ledge bottom
    helper.CreateBrushTLWH(128,96,16,32); //Ledge UL
    helper.CreatePortalSurface(Vec2d(144,96), Vec2d(208,96), true);
    helper.CreateBrushTLWH(208,96,16,32); //Ledge UR
    helper.CreateBrushTLWH(0,0,32,128); //Left wall
    helper.CreateBrushTLWH(224,0,32,128); //Right wall
    helper.CreateBrushTLWH(32,0,192,32); //Ceiling
    helper.CreateCube(176,80);

    //Make the image 1 pixel wider then normal to prevent ugly gaps
    helper.CreateBrushTLWH(0,384,128,64, Brush::fDEADLY | Brush::fBULLETPROOF | Brush::fSENSOR, (new PlainImage(zlOVERLAY,
        ImgHandle(ImgDataStruct("Portal/poison2.bmp")), CreateOptSdlRect(0,0,129,65)))->SetAlpha(200));
}

bounds_sptr TestChamber::GetBoundsManager()  const
{
    switch (chambernum)
    {
        case 0:
        case 1: return bounds_sptr(new NormalRoom(AABB(0,-64,800,664)));
        case 2: return bounds_sptr(new LargeRoom(20,20,1132,620,AABB(64,64,1088,576)));
        default: assert(false); return bounds_sptr();
    }
}

void TestChamber::LoadEverything(entitymanager_ptr myManager, RoomLoadInfo info) const
{
    //should probably change loadchamberx to take a bool rather then info
    switch (chambernum)
    {
        case 0: LoadChamber1(myManager, info, 400, 300); break;
        case 1: LoadChamber2(myManager, info, 400, 300); break;
        case 2: LoadChamber3(myManager, info, 400, 300); break;
        default: assert(false);
    }
}






Share this post


Link to post
Share on other sites
Quote:
entitymanager_ptr


Your main problem, probably, is the existence of the thing(s) that these point to. "Entity manager"? That's about as vague as it gets. Sounds like something that is trying to do everything, and failing. What is an "entity"? Just any old thing? No. Handle them separately. What does it mean to "manage" an entity? To keep it in a container? No. Just use a container. To create them? No. Just call constructors if you can; if you need factory functions, use static functions of the class that is created, instead.

Objects are supposed to be able to take care of themselves. Having a "manager" class of any sort is a big fat warning sign; it demonstrates lazy thinking about how classes work, drawing an analogy to real-life social organization and then blindly assuming that what we do in real life is necessarily best, or even good. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this