Managing game worlds

Started by
5 comments, last by Satharis 10 years ago

Hey!

I've done some thinking on how game levels are managed and have come to the conclussion - I'm not sure. Maybe there is a good read on the topic of handling game levels and their logic? Do all game levels consist of some kind of a tile map? As far as i know, for example, in 3D games the game worlds are split in to chunks, and only the few closest to the player are rendered and there logic processed. Am I right? What about RTS ganes in which units move all around a map? AoE2 is on my mind, also AoE3 because it's 3D.

Advertisement

Do all game levels consist of some kind of a tile map?

You should ask this after specifying a more narrow field of games that are relevant to the question, because as asked the answer is an obvious no. There is no tile map in Super Mario 64, for example.
Games similar to Age of Empires 2 typically use tile maps and an isometric engine.
I have never played either game so I can’t speak from authority on Age of Empires 3 but the terrain appears to be a heightmap and structures seem not to necessarily need to be aligned to any grids etc.

As far as i know, for example, in 3D games the game worlds are split in to chunks, and only the few closest to the player are rendered and there logic processed. Am I right?

There are massive games with sprawling worlds that are split into areas.
Splitting the world into chunks is most often done for graphics purposes to avoid drawing parts of the map that are not on the screen.

Rendering and logic are completely separate and unrelated.
Logic is still going to happen on every single enemy unit across the whole map. Again I am talking in the context of Age of Empires because in games such as Super Mario Bros. yes logic only happens to things that are on the screen.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

You might want to feed google the search term "scene graph".

A scene graph can be the element that renderer and entity logic / collision detection etc. share.

As L.Spiro wrote the game state / progress can be managed independently from the rendering.

For games like AoE 2 the object states might fit into the memory of the client PC.

For more complex games the entity state might be stored in databases of a server environment ... in a distributed way and only the relevant data would be forwarded to the client (into the scene graph).

Given enough eyeballs, all mysteries are shallow.

MeAndVR


in 3D games the game worlds are split in to chunks, and only the few closest to the player are rendered and there logic processed. Am I right?

only for shooters.

sims will tend to simulate or model (at least to some degree), the entire game world (or its pertinent impacts on gameplay) at all times.

red barron II and red barron 3D simulated every aircraft aloft on the western front in ww1, you could fly over no-man's land from switzerland to the channel and engage in any dogfight you came across. its not hard, moving units and making them fire and take damage is easy and fast, modeling estimated result thereof for a far off battle is even easier and faster. the trick is you just draw whats nearby.

silent hunter 4 models every ship in the pacific during ww2 down to the last sampan!

3d shooters evolved from 2d side view shooters: one screen per level, you can jump, and shoot. hence the level based design, with level maps, entry and exit points, spawn points, power ups, save points, hard coded design with zero replayability, hostiles that don't chase you across levels cause they only run the logic for one level at a time, etc. oh - and don't forget the best thing ever invented by level based designed games: load screens between levels!

the sim i'm working on now, Caveman (a caveperson simulator), models a randomly generated persistent modifiable 2500x2500 mile game world with no level based stuff. its all driven by random encounters. only shelters and caverns have "spawn points" for npcs or animals (monsters). so caverns are like a shooter level, and the rest of the game is a seamless open world simulation. the result is, its more of a virtual paleo-world than it is a fps/rpg or person sim. and NO in-game load screens! and no, it doesn't take 5 years to load, like silent hunter! <g>. about 20 seconds at program start is it. not bad for a game as big a skyrim. the trick is heavy reuse of assets and procedurally generated content. as opposed to tons of hand edited level maps.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Sorry for the late reply and thanks for the answers!
I was mainly interested in 2D isometric games, because I'm slowly building the engine. I just was thinking about how other games take care of the logic and the rendering. If for example I have a large map, it would be silly to go through all of the game objects currently present to check if I need to render them, or no? That's why I was thinking of AoE or any other RTS game.

At the momment i have come up with the following: the game level is made of a 2D array of tile-objects, which have all kinds of properties. I just could create a sub list of objects on screen from looking at which tile the player is. The same for game logic, as I dont need to simulate what's hapening too far away. Also, would it be good if a tile knew what was on it? A mere pointer.

Another thing, in a game like Skyrim, it seems that some NPC's are doing something when I'm not there.. How do they accomplish that? Or is it just hardcoded where one should be at a given time?

Sorry for the late reply and thanks for the answers!
I was mainly interested in 2D isometric games, because I'm slowly building the engine. I just was thinking about how other games take care of the logic and the rendering. If for example I have a large map, it would be silly to go through all of the game objects currently present to check if I need to render them, or no? That's why I was thinking of AoE or any other RTS game.

At the momment i have come up with the following: the game level is made of a 2D array of tile-objects, which have all kinds of properties. I just could create a sub list of objects on screen from looking at which tile the player is. The same for game logic, as I dont need to simulate what's hapening too far away. Also, would it be good if a tile knew what was on it? A mere pointer.

Another thing, in a game like Skyrim, it seems that some NPC's are doing something when I'm not there.. How do they accomplish that? Or is it just hardcoded where one should be at a given time?

Just because you don't need to render an object, does not mean that you don't need to simulate it's behavior. This is where separating logic falls into play. Your rendering methods should only render what is visible, but your update methods should update all entities on the map in an RTS style game.

rather than looking through each tile to see if it is visible, then adding each object on the tile to the renderable list, why not just check against each entity in the game and see if it is within a certain distance of the player. Usually you will have more tiles than entities, and this should be a faster method.

I've not played skyrim, but I would assume that they use some kind of quest table that uses boolean values to identify key events in the game, such as whether the player has killed some monster, or spoken to some character. The game logic can use this table to decide what should happen to NPCs. Say for instance, you save a villager just outside town. when the battle is over, the quest table is updated to reflect that jimmy two shoes has been saved, which starts a script that gets jimmy to tell the players that his family has been taken by a monster in a cave, and then lead the players to the cave. When cavemonster is dead, the quest table is updated, and a script now puts jimmy and his family back in the town, so that next time you arrive they can shower you with appreciation.

Depends a lot on the game in particular.

For instance in an rts you never really want game objects to stop updating because a key part of an rts is that units will always be under the implication of something might be happening to them, your band of warriors across the map might be getting attacked by ghosts while your camera is at your main base clicking create units.

In a game like skyrim you have different states objects may be in depending on distance and such. For instance when you're out in the world map the game world is split into cells, cells are loaded and unloaded based on distance around your character. However you still need to render things like the terrain, and distant mountains, the game has a system where it renders the terrain at low detail level depending on your distance to it and it starts to load and change the asset quality as you get closer, when you move a certain distance from a cell it will also unload the entities in it(small detail objects like rocks and plants and things) essentially a lot of game cells will be "dead" at any given time, as in they won't be updating any objects in them, just rendering the basics of the height map and certain large objects.

For things like the ai I'm not entirely sure how skyrim does it despite the fact I play it a lot. In oblivion they tried to sort of "patent" a new system of ai where every npc had a set routine based on time, they modified that a bit because it was really robotic always seeing the SAME conversation happen at the same exact clock time in game. My assumption based on that, is that when you enter an unloaded cell like a town it probably loads the entities and then simulates their behavior, a lot of this might be trickery and assumption. For instance a shop might restock itself automagically just as a product of time having passed. Npcs migh be moved depending on the current clock time, some randomization factor and their "schedule" so it looks like they were going about their business before you walked in, but they may not have been. They might even continue doing this behavio if you leave town but are nearby still to add a bit more realism to their movements if you enter the town again. These are all mainly guesses, but are ways you could handle it.

Using LOD and unloading chunks like that also happens in other open world games like farcry, the real meat of the behavior is based on the fact the player needs to be able to see distant things like terrain and large structures but it would be a total waste to be updating objects or actors in these far off areas if you are nowhere near them. Thats the trick of it, and that varies wildly from game to game. On some game types areas may always need to be loaded, in others they might be completely unloaded. Something like minecraft for example, when it unloads a chunk it flat out removes it and stops drawing it.

Explaining the rendering is a bit of a large topic for one thread, a lot of how to remove excess geometry in rendering depends on what tools you have for subdividing the game world(is the map split into chunks? can you use the position of the camera to cause certain areas to not be set to render?) Its a case by case thing.

This topic is closed to new replies.

Advertisement