Ejemplo n.º 1
0
void Game_loadMaps(Game *g, const char *dirname) {
    DIR *dir = opendir(dirname);
    if(!dir) {
        fprintf(stderr, "N'a pas pu ouvrir %s.\n", dirname);
        exit(EXIT_FAILURE);
    }
    Util_pushd(dirname);
    struct dirent *entry;
    for(g->map_data_count=0 ; g->map_data_count<MAX_MAPS ; ) {
        entry = readdir(dir);
        if(!entry) {
            if(!g->map_data_count) {
                fprintf(stderr, "Aucune map n'a été trouvée.\n");
                exit(EXIT_FAILURE);
            }
            break;
        }
        const char *extension = strchr(entry->d_name, '.');
        if(!extension || strcasecmp(extension+1, "txt"))
            continue;
        printf("Chargement de '%s'...\n", entry->d_name);
        loadMapData(g->map_data+g->map_data_count, entry->d_name);
        ++(g->map_data_count);
    }
    closedir(dir);
    Util_popd();
}
Ejemplo n.º 2
0
void LabEngine::doMap() {
	static uint16 amigaMapPalette[] = {
		0x0BA8, 0x0C11, 0x0A74, 0x0076,
		0x0A96, 0x0DCB, 0x0CCA, 0x0222,
		0x0444, 0x0555, 0x0777, 0x0999,
		0x0AAA, 0x0ED0, 0x0EEE, 0x0694
	};

	_graphics->_fadePalette = amigaMapPalette;

	updateEvents();
	loadMapData();
	_graphics->blackAllScreen();
	_interface->attachButtonList(&_mapButtonList);
	drawMap(_roomNum, _roomNum, _maps[_roomNum]._pageNumber, true);
	_event->mouseShow();
	_graphics->screenUpdate();
	processMap(_roomNum);
	_event->mouseHide();
	_interface->attachButtonList(nullptr);
	_graphics->fade(false);
	_graphics->blackAllScreen();
	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0);
	freeMapData();
	_event->mouseShow();
	_graphics->screenUpdate();
}
Ejemplo n.º 3
0
bool RCDataCenter::init()
{
    if (!CCNode::init())
    {
        return false;
    }
    
    loadMapData();
    return true;
}
Ejemplo n.º 4
0
Cutscene::Cutscene(const std::string path) : currentPoint_(0), waiting_(false), droneEnabled_(false), fadeOut_(false), fadeStart_(false)
{
	alarmTriggered_ = false;
	alarmBuffer_.loadFromFile("assets/misc/alarm.wav");
	buffer_.loadFromFile("assets/drone/drone.wav");
	sound_.setAttenuation(1);
	if (!lightShader_.loadFromFile("shaders/light.frag", sf::Shader::Fragment))
		fatalError("Failed to load light shader\n");

	loadMapData(path);
	player_ = new Player(playerSpawnPoint_);
	originalPosition_ = playerSpawnPoint_;
}
Ejemplo n.º 5
0
/**
 * 设置游戏地图
 */
ISOMapInfo* GameWorld::createGameMap()
{
    //移除去之前的地图文件
    if (m_isoMap) {
        this->removeChild(m_isoMap);
    }
    
    CCSize visibleSize =this->getContentSize();//CCSizeMake(480,240);//
    
    //取得要使用的layer渲染类型
    int mapLyaerType=ISOTileMapBuilder::NormalLayerType;
    
    CCInteger* mapLyaerTypeValue=static_cast<CCInteger*>(GameSceneDirector::getInstance()->getSceneContext());
    
    if (mapLyaerTypeValue) {
        mapLyaerType=mapLyaerTypeValue->getValue();
    }
    
    //加载数据.mapInfo自动释放
    ISOMapInfo* mapInfo=loadMapData();
    
    //构建地图
    m_isoMap=new ISOTileMap();
    m_isoMap->init();
    m_isoMap->setScale(4);
	m_isoMap->setVisibleSize(visibleSize);
    //    m_isoMap->setUseDynamicGroup(true);
    
    struct timeval now;
    gettimeofday(&now,NULL);
    
    ISOTileMapBuilder* mapBuilder=new ISOTileMapBuilder();
    mapBuilder->init(m_isoMap);
	mapBuilder->setMapLayerType(mapLyaerType);
    mapBuilder->buildWithMapInfo(mapInfo);
    
    struct timeval end;
    gettimeofday(&end,NULL);
    
    CCLOG("use:%ld", (end.tv_sec-now.tv_sec)*1000000+end.tv_usec-now.tv_usec);
    
    //构建dynamic group
    //    m_isoMap->setupDynamicGroup();
    m_isoMap->showCoordLine();
    
    this->addChild(m_isoMap,kGameMapZOrder);
    
    m_isoMap->release();
    
    return mapInfo;
}
Ejemplo n.º 6
0
Level::Level(std::string path) : completed_(false), died_(false), path_(path), alarmTriggered_(true), started_(false), musicTimer_()
{
	buffer_.loadFromFile("assets/drone/drone.wav");
	music_.openFromFile("assets/music/BOGO.wav");
	reverseMusic_.openFromFile("assets/music/BOGOReverse.wav");

	if (!lightShader_.loadFromFile("shaders/light.frag", sf::Shader::Fragment))
		fatalError("Failed to load light shader\n");

	//sound_.setLoop(true);
	sound_.setAttenuation(1);

	loadMapData(path);
	player_ = new Player(playerSpawnPoint_);
	//drone_ = new Drone({ sf::Vector2f(500,500), sf::Vector2f(10000, 1000) , sf::Vector2f(500,500), sf::Vector2f(1000, 10000)});
}
Ejemplo n.º 7
0
void LevelManager::load(string path)
{
	//get level file info
	this->_filepath = path;

	//load the map data from file
	loadMapData();

	//setup floor vertices for rendering
	//int **p_mapArray[10][10];


	setupMapVertices(_floor, _floorVertices);

	//setup layer 1 vertices for rendering;
	
	setupMapVertices(_layer1, _layer1Vertices);

}
Ejemplo n.º 8
0
HRESULT ccTileMap::loadTNT()
{
    //
    // loadTNT
    //
    FILE *stream;
    //if( (stream  = fopen( "..//map//The Pass.tnt", "rb" )) == NULL)
    //if( (stream  = fopen( "..//map//Metal Heck.tnt", "rb" )) == NULL)
    if( (stream  = fopen( "..//map//test.tnt", "rb" )) == NULL)
        //if( (stream  = fopen( "..//map//King of the Hill.tnt", "rb" )) == NULL)
    {
        printf( "The file 'data' was not opened\n" );
        return E_FAIL;
    }

    //
    // loadHeader
    //
    if(fread( &m_header, sizeof( TAMAP ), 1, stream ) == 0 || ferror( stream ))
        return E_FAIL;

    if (m_header.IDiversion != 8192)
        return E_FAIL;

    m_worldTileSize.cx = (m_header.MapWidth/2);
    m_worldTileSize.cy = (m_header.MapHeight/2);

    m_worldSize.cx  = m_worldTileSize.cx*m_tileWidth;
    m_worldSize.cy = m_worldTileSize.cy*m_tileHeight;

    loadMapData(stream);
    // loadScenData(stream);
    loadTileData(stream);

    /* Close stream */
    if(fclose( stream ))
    {
        printf("The file 'data' was not closed\n");
        return E_FAIL;
    }

    return S_OK;
}
Ejemplo n.º 9
0
Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog),
    scale(1.0)
{
    ui->setupUi(this);


    myView = new MapGraphicsView(this);

    QVBoxLayout* layout = new QVBoxLayout();
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(myView);

    ui->frame->setLayout(layout);

//    myView->viewport()->installEventFilter(this);

//    myView->setViewport(new QGLWidget());  //Great boost. Poor rendering for zero width lines

    scene = new QGraphicsScene(this);
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);   //Disables BSP -> Great boost!
//    scene->setItemIndexMethod(QGraphicsScene::BspTreeIndex);
    myView->setScene(scene);
    myView->setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
    myView->setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
//    myView->setDragMode(QGraphicsView::ScrollHandDrag);
//    myView->setDragMode(QGraphicsView::NoDrag);
//    myView->setDragMode(QGraphicsView::RubberBandDrag);

    myView->setOptimizationFlags(QGraphicsView::DontSavePainterState);  //Minor boost
//    myView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
    myView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);   //Minor boost
    myView->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
//    myView->setRenderHint(QPainter::Antialiasing, false);


    QColor c(Qt::darkGray);
    QColor cd = c.darker();
    QColor bg(127, 125, 158);

//    scene->setBackgroundBrush(QBrush(cd));
    myView->setCacheMode(QGraphicsView::CacheBackground);

    int xPos = 0;
    int yPos = 0;

    int row = 200;
    int col = 200;

    QPolygonF* poly = new QPolygonF();
    loadMapData(std::string("/Users/johan/Programmering/Qt/ViewTest/ALG_outline_SHP/ALG_outline"), poly);
    setMap(poly);

    QMatrix m;
    m.scale(1, -1);

//    for(int i = 0; i < row; i++)
//    {
//        for (int j = 0; j < col; j++)
//        {
//            PlotItem* plot = new PlotItem();  //Not actually leaking. The scene will own it
//            plot->setPos(xPos, yPos);
//            myView->addItem(plot);
//            xPos += 15;
//        }
//        yPos += 15;
//        xPos = 0;
//    }

    PlotChannelItem* plots = new PlotChannelItem();
    for(int i = 0; i < row; i++)
    {
        for (int j = 0; j < col; j++)
        {
            plots->addPlot(QPointF(xPos, yPos));
            xPos += 15;
        }
        yPos += 15;
        xPos = 0;
    }
    myView->addItem(plots);


    TrackItem* track = new TrackItem();
    track->setPos(2, -15);
    myView->addItem(track);

//    int maxX = row * 15;
//    int maxY = col * 15;

//    ui->graphicsView->setSceneRect(-maxX, -maxY, maxX, maxY);

//    myView->setSceneRect(-100, -100, 100, 100);

    qDebug() << "Item count: " << row * col;

    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()),scene, SLOT(advance()));
    connect(timer, SIGNAL(timeout()), scene, SLOT(update()));
    timer->start(1000);
}