コード例 #1
0
ファイル: Game.cpp プロジェクト: AdrienBourgois/EternalSonata
void Game::loadMap()
{
    terrainSceneNode = scene_manager->addTerrainSceneNode("assets/terrain-heightmap.bmp", 0, -1, {0.f,0.f,0.f}, {0.f,0.f,0.f}, {40.f,1.f,40.f}, {255,255,255,255}, 1);
    terrainSceneNode->setMaterialFlag(video::EMF_LIGHTING, false);
    terrainSceneNode->setMaterialTexture(0, driver->getTexture("assets/terrain-texture.jpg"));
    terrainSceneNode->setMaterialTexture(1, driver->getTexture("assets/detailmap3.jpg"));
    terrainSceneNode->setMaterialType(video::EMT_DETAIL_MAP);
    terrainSceneNode->scaleTexture(1.0f, 20.0f);

    terrain = terrainSceneNode->getMesh();

    irr::scene::ITriangleSelector* explorationSelector = scene_manager->createTerrainTriangleSelector(terrainSceneNode, 0);

    mapSelector = scene_manager->createMetaTriangleSelector();
    mapSelector->addTriangleSelector(explorationSelector);

    battleSceneNode = scene_manager->addTerrainSceneNode("assets/terrain-heightmap.bmp", 0, -1, {0.f, 2000.f, 0.f}, {0.f, 0.f, 0.f}, {5.f, 0.f, 5.f}, {255, 255, 255, 255}, 1);
    battleSceneNode->setMaterialFlag(video::EMF_LIGHTING, false);
    battleSceneNode->setMaterialTexture(0, driver->getTexture("assets/terrain-texture.jpg"));
    battleSceneNode->setMaterialType(video::EMT_DETAIL_MAP);
    
    irr::scene::ITriangleSelector* battleSelector = scene_manager->createTerrainTriangleSelector(battleSceneNode, 0);

    mapSelector->addTriangleSelector(battleSelector);

    addMob({1150,1250,1500});
    addMob({1050,1250,1500});
    addMob({1250,1250,1500});
}
コード例 #2
0
ファイル: map.cpp プロジェクト: jastadj/johnrl
void Map::genGrass()
{
    if(mItemList == NULL)
    {
        printError("Unable to generate, no item list is referenced.\n");
        return;
    }

    //this is not a very good way of creating a random seed per map
    // since 0 * anything will be zero, so all mapes on a 0 axis will gen the same
    int seed = mSeed + (mGlobalX * mGlobalY);

    srand(seed);


    //put code here for a one time generation
    if(!mDiscovered)
    {
        if(rand()%1000 > 500)
        {
            ItemRef *newitem = new ItemRef( &(*mItemList)[0]);
            newitem->setPos( rand()%MAP_WIDTH, rand()%MAP_HEIGHT);
            newitem->setGlobalPos(mGlobalX, mGlobalY);
            mMapItems.push_back(newitem);
        }

        //mob debug
        if(mGlobalX == 0 && mGlobalY == 0)
        {
            MobRef *tmob = new MobRef( &(*mMobList)[0]);
            tmob->setPos(1,1);
            tmob->setGlobalPos(mGlobalX, mGlobalY);
            addMob(tmob,0,0);
        }
        if(mGlobalX == -1 && mGlobalY == -1)
        {

        }

    }

    srand(seed);


    for(int i = 0; i < MAP_HEIGHT; i++)
    {
        for(int n = 0; n < MAP_WIDTH; n++)
        {

            mMapArray[i][n] = rand()%9 + 1;

            //random chance to generate a tree
            if(rand()%1000 > 998) mMapArray[i][n] = 10;
            else if(rand()%1000 > 995) mMapArray[i][n] = rand()%4 + 11;


            //put code here for a one time generation
            if(!mDiscovered)
            {

            }

        }
    }

    //debug
    if(mGlobalX == 0 && mGlobalY == 0)
    {
        for(int i = 12; i < 19; i++)
        {
            for(int n = 12; n < 19; n++)
            {
                mMapArray[i][n] = 15;
            }
        }
    }

    //now that the map generation is complete, set the discovered flag to true
    mDiscovered = true;

}