Public Group

# algorithms...

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

## Recommended Posts

Hello, I am learning videogame programming - I've been doing a few tutorials and I noticed that the algorithms used to fill out the vertices/indices arrays can get extremely complicated to create... for example, //This is to set the equidistant vertices to outline the terrain. vertices = new VertexPositionColor[WIDTH * HEIGHT]; for (int x = 0; x < WIDTH; x++) { for (int y = 0; y < HEIGHT; y++) { vertices[x + y * WIDTH].Position = new Vector3(x, y, 0); vertices[x + y * WIDTH].Color = Color.White; } } //This will use the vertices to connect them and create the triangles. int[] indices = new int[(WIDTH - 1) * (HEIGHT - 1) * 3]; for (int x = 0; x < WIDTH - 1; x++) { for (int y = 0; y < HEIGHT - 1; y++) { indices[(x + y * (WIDTH - 1)) * 3] = (x + 1) + (y + 1) * WIDTH; indices[(x + y * (WIDTH - 1)) * 3 + 1] = (x + 1) + y * WIDTH; indices[(x + y * (WIDTH - 1)) * 3 + 2] = x + y * WIDTH; } } is to fill the indices using clockwise triangles to create a terrain (http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/Terrain_basics.php) I can follow through and understand what it does just fine, but if I were asked to create that algorithm from scratch it could take me weeks IF i ever got it... My question is: would a game designer/programmer actually need to create these kind of algorithms from scratch...? Thank you.

##### Share on other sites
The code you posted is trivial to an experienced programmer. Keep going. You'll get there.

##### Share on other sites
Quote:
 Original post by JohnBoltonThe code you posted is trivial to an experienced programmer. Keep going. You'll get there.

QFT. You'll get it with experience. Believe me, theres much, much scarier stuff out there, and for quite a while you will need to rely on references. The only way you will learn/remember stuff is if you apply it.

Also, the one thing I can say about programming is that it does wonders for your problem solving skills. With experience, comes the ability to solve increasingly complex problems. So yes, programmers often have to solve problems, but with the right combination of research and experience, they can be solved.

1. 1
2. 2
3. 3
Rutin
23
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013162
×