Level Loading

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
android_808
Posts: 13
Joined: Mon Feb 28, 2005 4:12 pm

Level Loading

Post by android_808 »

I'm in the process of writing a function to load a map, just a Q3 .bsp at the moment. I would like to be able to specify what map it loads.

Code: Select all

void CGame::loadLevel()
{
    scenemgr->clear();
    device->getFileSystem()->addZipFileArchive("maps/map-20kdm2.pk3"); 
    quakeLevelMesh = scenemgr->getMesh("20kdm2.bsp");
This is a small extract from my source. What I want to be able to do is pass a variable, the map name to loadLevel, and have it append it to a standard path for the maps eg.

Code: Select all

void CGame::loadLevel(mapname)
{
    scenemgr->clear();
    
    //Pseudo Code
    mappath = "maps/map-" + mapname + ".pk3";
    map = mapname + ".bsp";
    //

    device->getFileSystem()->addZipFileArchive(mappath); 
    quakeLevelMesh = scenemgr->getMesh(map);
Which functions to I need to use to perform this task and what type should mapname be.
rincewind
Posts: 35
Joined: Thu Mar 25, 2004 5:28 pm
Location: Germany --> Bonn

Post by rincewind »

You can do something like

Code: Select all

irr::core::stringc pk3file("maps/map-");
pk3file += mapname;
pk3file += ".pk3";
device->getFileSystem()->addZipFileArchive(pk3file.c_str());

irr::core::stringc bspfile(mapname);
bspfile += ".bsp";
quakeLevelMesh = scenemgr->getMesh(bspfile);
using irr::core::stringc as type for mapname.

EDIT: See api for further information on the irrlicht-string-class. Of course, you could also use std::string.
android_808
Posts: 13
Joined: Mon Feb 28, 2005 4:12 pm

Post by android_808 »

Thank you.

This is exactly what I'm after. Now all I need to do is work out how to implement this into the main game loop. Gonna go research game states.
Post Reply