Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

how to start an environment

This topic is 5152 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I''m new here. (god, I hate that phrase!) I''m quite new to oenGL and computer graphics, having only just been introduced to it on my final year of my software engineering degree. So far we''ve covered the basics (2D/3D objects, texture mapping, lighting...). For my final year we''ve been asked to do a project, I decided (foolishly) to create a simple 3D game for children, where the user has to move around a small and simple maze collecting one or two items along the way. Unfortunately I have no idea how to create environments! I thought we''d have covered it by now in my degree, but we havent. How do I go about starting to build a simple maze environment? Nothing fancy (I''ll worry about collision detection and the collecting later) just a simple maze. What needs to be done first? I need to get this done in a couple of weeks so any help would be much appretiated. Thanks for any help, and if you need more info on my project, feel free to ask.

Share this post


Link to post
Share on other sites
Advertisement
Probably the easiest way is to define the maze as a 2D-array like this:

11111111
12010031
11010111
11004111
11111111

The numbers here are:
1 - wall
2 - start point
3 - end point
4 - collectable item

Maps like this are easy to create/edit/load/render and implementing collision detection is simple. The downside is that the map will look quite blocky (though I''d guess it''s possible to do some tricks to avoid it).

Share this post


Link to post
Share on other sites
Looking blocky doesn''t bother me as thats something that can be altered later if its needed.

I''m not looking for anything complicated, just something to get me up and running really.

My inspiration came from the 3D maze screen saver that you get with Windows, but it doent have to be that good (or endless :0P ).

How would I begin? would I just render a bunch of rectangles against each other to act as walls? e.g render a cube as the environment with a bunch of rectangles joined together for walls... is that how I would approach it?

Share this post


Link to post
Share on other sites
Well, I once made something like this myself. My algorithm iterated through the map and whenever a ''wall'' block was encountered it drew a cube with a wall texture to the corresponding position in the world. To draw the floor and ceiling it drew two big rectangles (big enough to cover the whole map) with floor and ceiling textures below and above the cubes.

Share this post


Link to post
Share on other sites
Ok, I under stand about the ceiling and floor.

can you explain what you meant with...
"a ''wall'' block was encountered it drew a cube with a wall texture to the corresponding position in the world"

im not quite sure what you mean. :0)

Share this post


Link to post
Share on other sites

// map position->world coords
void map_to_world_coords (int map_row, int map_col, vector& cube_origin)
{
// cube_size = length of edges
cube_origin.x = float(map_row)*cube_size;
cube_origin.y = 0.0f;
cube_origin.z = float(map_col)*cube_size;
}


void render_cube (vector& origin, float size, texture tex)
{
set_texture (tex);
// well, you know how to render a cube, don't you?
}


void render_map ()
{
// map = map array (2d)
// map_rows & map_cols = map array size
// cube_size = length of cube edges
// wall_texture = guess...
// BLOCKTYPE_WALL = 1 in my first example
for (int row = 0; row < map_rows; ++row)
{
for (int col = 0; col < map_cols; ++col)
{
if (map[row][col] == BLOCKTYPE_WALL)
{
vector cube_origin;
map_to_world_coords (row, col, cube_origin);
render_cube (cube_origin, cube_size, wall_texture);
}
}
}
}



[edited by - nonpop on April 12, 2004 6:33:21 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!