Loading Zones

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
Cleves
Posts: 224
Joined: Mon Sep 08, 2003 6:40 pm

Loading Zones

Post by Cleves »

Hey all,

I was wondering what is the best way to create loading zones in a game?
What I mean is that let's say you got a level, and there is a portal that once the player steps into it, it will transport him to another level.
How should I do it? do I need to delete all the nodes and recreate them into new postions, new objects etc...
What is the best and efficient way to do it? :)

Thanks
Phreak
Posts: 25
Joined: Mon May 10, 2004 2:01 pm

Post by Phreak »

You could try setting 2D waypoints around the portal.

Code: Select all

core::position2d<f32> points[2];

points[0].X = first_x_coordinate;
points[0].Y = first_y_coordinate;
points[1].X = second_x_coordinate;
points[1].Y = second_y_coordinate;
You can use them by placing this in the game loop:

Code: Select all

core::position2d<f32> where;
where = device->getSceneManager()->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition(camera->getPosition());
You might want to declare the "where" variable somewhere else..
"where" now hold the position of the camera. Just compare it to the points variable.

Hope this helps.. (and is basically correct) :P

Phreak
If you don't succeed, redefine success!
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Actually I'd do it without collision. I'd just do a getPosition, then check if this position is within a limit I set. Like if (pos.X < 10 && pos.X > 3). You've then got a trigger.
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post by Domarius »

I don't think there is a "best and most efficient way to do it" generally speaking, since it just involves;

1. Detecting when the player is entering a new 'zone'.
2. 'unloading' the old zone and saving all the data somehow, and loading the new 'zone'.

How you do those things will determine how efficient it is.
You will need a way to store and retreive all your level data.

Here are some example ways to do it, off the top of my head;

1. Have 'teleport' objects, that, when the player collides with their bounding box, they get sent to a new level - the teleport object has a property that says what level they need to go to.

2. You have your 'original' level data in a file that you created with your 'level editor'. This is what is loaded every time you 'load a level'.
As the player moves through the game, you record all the changes they make to the level - not in cronological order, but as a list of objects that have been modified. They drop the jug on the floor - make an entry for the jug in the "modified objects" list, with the Jugs new position. They drop the cup, make another entry for the cup. They kick the jug again, and you will over write the existing entry for the jug, because it is already there, you just update the position.

When you 'unload a level', you go through the "modified objects" list, and write all that information to a file.

Then you reset the world to nothing.

When you 'load a level', you load the original level data, and then check to see if a "modified objects" list exists in a file on the hard drive. If it does, load it and make all the changes to the objects.
Post Reply