Sign in to follow this  
pcmattman

How to load/draw levels

Recommended Posts

I'm about to start work on my game engine, but I've run into some problems while figuring out how to make it work. I'm thinking of having a set of functions such as DrawCube, DrawSphere, etc... to make drawing much simpler, and maybe some functions to dynamically change textures on the fly. I'm using Direct3D, so all this isn't that difficult. My main question is, how do I go about loading level data? How would my level files (which I haven't thought about yet, hence the reason I'm asking) be formatted and translated into on-screen geometry?

Share this post


Link to post
Share on other sites
unfotunately, that's all information that you'll have to figure out on your own, as the data is up to you as to what data you want your levels to consist of.

and it doesn't sound like your ready to make an engine at this stage of your learning, I'd just suggest thinking about making the game.

Share this post


Link to post
Share on other sites
There are many ways to go about this, and nearly every game uses a different method for storing and drawing levels. Assuming your game is 3D, you can come up with a file format that basically tells the computer how to draw your level.
Something like this:

mylevel.txt

LevelName: "MyLevel" // Name of the level
Texture: "mytex.bmp" // Name of the current texture
Cube: 5, 3, 2, 10 // x, y, z, sidelength
Sphere: 2, 2, 2, 5 // x, y, z, radius
Mesh: "mymesh.x", 3, 5, 6 // Name of mesh file, x, y, z



All your program has to do now is go through the level file and do what it says. So when it reaches the line "Cube: ...", it calls the DrawCube function with the supplied data, and if there is a collision detection system it passes this information to that system so that it becomes "aware" of the cube.

This is an extremely simple example, your game will probably require a more sophisticated level format but the general idea remains the same.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this