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
Loading Zones
You could try setting 2D waypoints around the portal.
You can use them by placing this in the game loop:
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)
Phreak
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;
Code: Select all
core::position2d<f32> where;
where = device->getSceneManager()->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition(camera->getPosition());
"where" now hold the position of the camera. Just compare it to the points variable.
Hope this helps.. (and is basically correct)
Phreak
If you don't succeed, redefine success!
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.
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.