Advertisement

How GTA Games Load Worlds

Started by November 25, 2018 11:24 PM
3 comments, last by 1024 6 years ago

Hi,im new here :D

im interested in make a 2D game engine ( probably in Python ) , so i think in some things i want in my engine.

 

One i think is : when you play a GTA game ( i remember Vice City but any since III is the same ) , the game waits much more time to load : because it loads all the city/map/buildings,so when you finish the wait you can move to the city streets without loading screens.

In III/Vice City the game puts a short loading screen when you move from one city to another,but since San Andreas this is not necessary.

 

My questions are : what exactly loads the game in the long loading screen when the game begins to run?

And how does that ( example,how much memory needs )?

Its a good idea do that?

The engine in PS2 GTA`s was Renderware but in PS3/4 is Rockstar Advance Game Engine ( RAGE ).

 

Thank you for your answers ?

Im interested in make a 2D Game Engine in Python,so i want make questions to someone who know about hardware/programming ?️

I like JRPG,3D platform,Sandbox and Racing games.

I'll try to explain it to you, but on a 2D game to make it simpler. Here's a screenshot from a random Pokemon game:

pokemon-ruby-screenshot-3.jpg

Imagine that this screen is the same as a city in GTA.

To load this screen, first of all you need the layout of the level: a file that says "There is a tree in bottom left, a bunch of trees on the right in these places, a road from here to there, a house on the left, a different house (a shop) on the right, and a lady in this place that is walking from the house to the shop and back. The rest of the screen is grass." It would be more precise of course, with coordinates and names for everything, but I am too lazy to write some now :) That level file is usually not part of the program, but a separate file that you load when you need it. You would have multiple level files, once for each screen, and you would load the screen that you need.

Once you load the file, you need to load all the images (sprites) for each object on the screen. You would go through the level file and load things one by one. Again, each sprite could be a separate file. So you would have a tree sprite, a road sprite, a house sprite, a shop sprite, and a lady sprite. Or multiple lady sprites if you want to animate between them. Note that you only need to load each sprite once: even if you have many trees, you only load one tree sprite, and then use it multiple times. 

You also have a sprite for your player. You have to load that too before you start the game, but you load it separately from the level, because the player is on every screen. I'll get back to that later.

Now that you loaded everything, you can use it to draw the screen. You go through the objects in the level file one by one, you read which object is on which position, and you draw the correct sprite at that position. The end result: you have a screen like the one above.

Until you are finished loading everything, you can't draw the screen. And you don't want to keep a black screen because that is ugly. So what games do is draw something else during the loading - the loading screen.

That is the basic idea behind loading and loading screens, except that in a 3D game such as GTA you would load 3D models of buildings, people, cars, roads etc. As well as all the textures, animations, AI rules and so on, so it takes longer. 

Now, in the example from above, let's say the player wants to move to another screen. The other screen is not loaded, so the game doesn't know what it looks like. You would have to load the second screen with another level file, other objects and other sprites. And of course with another loading screen. Like moving to another city in GTA III. But, if your levels and sprites take a lot of memory, you can't just keep loading all new screens indefinitely, because you will run out of memory eventually. So, one solution is to unload the previous screen before you load the new one. You don't need the previous screen because you left it, right? And the player is looking at a loading screen anyway, so no need to keep drawing the old screen. 

If the new screen also has trees, and grass, and another lady, it's a bit stupid to unload their sprites just to load them again. What games usually do is that, when they load the new level, they check which sprites are used in both, and then unload all those that aren't used anymore, and load only the new ones. That is why loading screens between the levels are shorter than the loading screen when you start the game. 

And lastly, "streaming". What if you want your Pokemon example to not have any loading screens? You could do that by loading more than one screen (but again not all of them), and then loading and unloading new ones during the game. For example, in the beginning you load the first screen and the second screen. When the player moves from screen 1 to screen 2, you don't need to load anything (because screen 2 is already loaded), so no loading screen. Then, while the player is in screen 2, you load screen 3, and you unload screen 1. So, by the time the player moves to screen 3, it will be loaded. If the player needs goes back and forth between screens, you always keep loaded the current screen and screens around it. This is how open world games work: they load where you are, and they keep your surroundings loaded. As you move, they unload areas that you left and load areas where you will go. That is also how GTA San Andreas doesn't need loading screens when moving to another city.

Finally, another note: if the game is small enough, you can load everything at once. Like everything is one big level. That Pokemon game for example, if you were to make one for an average PC today, you could keep everything loaded at once, even if it has hundreds of screens. That is the least complicated solution, so it's the best for any game that can manage it. 

Advertisement
1 hour ago, 1024 said:

I'll try to explain it to you, but on a 2D game to make it simpler. Here's a screenshot from a random Pokemon game:

pokemon-ruby-screenshot-3.jpg

Imagine that this screen is the same as a city in GTA.

To load this screen, first of all you need the layout of the level: a file that says "There is a tree in bottom left, a bunch of trees on the right in these places, a road from here to there, a house on the left, a different house (a shop) on the right, and a lady in this place that is walking from the house to the shop and back. The rest of the screen is grass." It would be more precise of course, with coordinates and names for everything, but I am too lazy to write some now :) That level file is usually not part of the program, but a separate file that you load when you need it. You would have multiple level files, once for each screen, and you would load the screen that you need.

Once you load the file, you need to load all the images (sprites) for each object on the screen. You would go through the level file and load things one by one. Again, each sprite could be a separate file. So you would have a tree sprite, a road sprite, a house sprite, a shop sprite, and a lady sprite. Or multiple lady sprites if you want to animate between them. Note that you only need to load each sprite once: even if you have many trees, you only load one tree sprite, and then use it multiple times. 

You also have a sprite for your player. You have to load that too before you start the game, but you load it separately from the level, because the player is on every screen. I'll get back to that later.

Now that you loaded everything, you can use it to draw the screen. You go through the objects in the level file one by one, you read which object is on which position, and you draw the correct sprite at that position. The end result: you have a screen like the one above.

Until you are finished loading everything, you can't draw the screen. And you don't want to keep a black screen because that is ugly. So what games do is draw something else during the loading - the loading screen.

That is the basic idea behind loading and loading screens, except that in a 3D game such as GTA you would load 3D models of buildings, people, cars, roads etc. As well as all the textures, animations, AI rules and so on, so it takes longer. 

Now, in the example from above, let's say the player wants to move to another screen. The other screen is not loaded, so the game doesn't know what it looks like. You would have to load the second screen with another level file, other objects and other sprites. And of course with another loading screen. Like moving to another city in GTA III. But, if your levels and sprites take a lot of memory, you can't just keep loading all new screens indefinitely, because you will run out of memory eventually. So, one solution is to unload the previous screen before you load the new one. You don't need the previous screen because you left it, right? And the player is looking at a loading screen anyway, so no need to keep drawing the old screen. 

If the new screen also has trees, and grass, and another lady, it's a bit stupid to unload their sprites just to load them again. What games usually do is that, when they load the new level, they check which sprites are used in both, and then unload all those that aren't used anymore, and load only the new ones. That is why loading screens between the levels are shorter than the loading screen when you start the game. 

And lastly, "streaming". What if you want your Pokemon example to not have any loading screens? You could do that by loading more than one screen (but again not all of them), and then loading and unloading new ones during the game. For example, in the beginning you load the first screen and the second screen. When the player moves from screen 1 to screen 2, you don't need to load anything (because screen 2 is already loaded), so no loading screen. Then, while the player is in screen 2, you load screen 3, and you unload screen 1. So, by the time the player moves to screen 3, it will be loaded. If the player needs goes back and forth between screens, you always keep loaded the current screen and screens around it. This is how open world games work: they load where you are, and they keep your surroundings loaded. As you move, they unload areas that you left and load areas where you will go. That is also how GTA San Andreas doesn't need loading screens when moving to another city.

Finally, another note: if the game is small enough, you can load everything at once. Like everything is one big level. That Pokemon game for example, if you were to make one for an average PC today, you could keep everything loaded at once, even if it has hundreds of screens. That is the least complicated solution, so it's the best for any game that can manage it. 

Thanks for the answer! Its well explained and not too complex to understand.

The idea of make a 2D game with graphics at the GBA level,but in a average PC was something i also think before.

The GBA had less than 1 MB of RAM,so if i make a 2D PC game using only 1 GB of RAM ( to run the game on low spec hardware,like the Raspberry Pi ) , it can load all the graphics at once ( 2D sprites like Kingdom Hearts COM )  and fast? ( i mean,like a only loading screen of 20 seconds or less ). Other reason to use so low RAM its because,if the game runs on more powerful hardware,it can load the graphics in even less time.What you think?

Im interested in make a 2D Game Engine in Python,so i want make questions to someone who know about hardware/programming ?️

I like JRPG,3D platform,Sandbox and Racing games.

Yes, for games like that you will be able to load everything at once. So no need to worry about any complicated loading methods.

As a beginner, you really shouldn't worry about things like loading times or RAM usage. Chances are the game will not use much of either, especially the kind of game you want to make.

This topic is closed to new replies.

Advertisement