瓷砖向右移动

时间:2014-06-24 02:58:44

标签: c++ loading tiling

我在地图编辑器上工作以配合我已经工作了一段时间的游戏;但是,当我尝试将地图加载到游戏中时,一切都会向右移动两到三个图块。

我的一位朋友提出这可能是一个解决错误,但我从未见过任何证据。

这里是加载函数(它在主循环之前调用):

const int SAVEGAME_VERSION=0x1100;

void Engine::load(bool pause) {
    TCODZip zip;
    engine.gui->menu.clear();
    engine.gui->menu.addItem(Menu::NEW_GAME,"New map");
    if ( TCODSystem::fileExists("map.atm")) {
        zip.loadFromFile("map.atm");
        int version = zip.getInt();
        if ( version == SAVEGAME_VERSION ) {
            engine.gui->menu.addItem(Menu::CONTINUE,"Load");
        }
    }
    engine.gui->menu.addItem(Menu::EXIT,"Exit");

    Menu::MenuItemCode menuItem=engine.gui->menu.pick(
            pause ? Menu::PAUSE : Menu::MAIN);
    if ( menuItem == Menu::EXIT || menuItem == Menu::NONE ) {
        // Exit or window closed
        exit(0);
    } else if ( menuItem == Menu::NEW_GAME ) {
        // New game
        engine.term();
        engine.init();
    } else {
        // continue a saved game
        engine.term();
        // load the map
        level=zip.getInt();
        int width=zip.getInt();
        int height=zip.getInt();
        map = new Map(width,height);
        map->load(zip);
        // then the player
        player=new Actor(0,0,0,NULL,TCODColor::white);
        actors.push(player);
        player->load(zip);
        // then all other actors
        int nbActors=zip.getInt();
        while ( nbActors > 0 ) {
            Actor *actor = new Actor(0,0,0,NULL,TCODColor::white);
            actor->load(zip);
            actors.push(actor);
            nbActors--;
        }
        // finally the message log
        gui->load(zip);
    }
}

这是map-> init函数(从Engine :: init调用并设置新游戏的地图尺寸):

void Map::init(bool withActors) {
    TCODZip zip;
    if ( TCODSystem::fileExists("map.atm")) {
        zip.loadFromFile("map.atm");
        //rng = new TCODRandom(seed, TCOD_RNG_CMWC);
        tiles=new Tile[width*height];
        map=new TCODMap(width,height);
        for (int i=0; i < width*height; i++) {
            tiles[i].canWalk=zip.getInt();
            //TCODBsp bsp(0,0,width,height);
            //bsp.splitRecursive(rng,8,ROOM_MAX_SIZE,ROOM_MAX_SIZE,1.5f,1.5f);
            //BspListener listener(*this);
            //bsp.traverseInvertedLevelOrder(&listener,(void *)withActors);
        }
    }
}

0 个答案:

没有答案