New answers tagged procedural-generation
4
Just a quick note about voxel landscapes. It is a wide field and there are a variety of representations and algorithms for display.
Heightfield voxel terrain: stored as a heightmap, but rendered with vertical strips rather than polygons. Check out "Outcast"
Cuboid terrain: I believe stored in terrain chunks as run-length encoded strips. Displayed as a ...
1
If you already have code that generates rooms connected with hallways in 2D simply update your code to do this:
Each generated room gets a random height (pretty obvious right?). I would try with picking from a list of predefined height values or simply pick a random value from a good interval. Then proceed as usual - connect the rooms with hallways, but ...
1
3D Graphic with XNA Game Studio 4.0 has a chapter dedicated to this topic. It includes a complete process for generating the terrain and layering it with a variety of textures.
As luck would have it, that chapter is the sample provided by Packt on the book's page:
In this chapter, we will focus on building a full 3D environment. We will start by
...
1
The most expeditious way to extract height information might be to draw it:
Set draw parameters to an orthographic projection directly down toward the terrain.
Draw to a render target with a depth-map shader.
Store render target contents to a 2D array, sample it for heights, and save it for as long as it is useful (no need to reproduce every frame).
I ...
0
cameraPos_Y = desiredDistanceFromGround + currentTerrainVertex_Y.
As the camera moves, keep updating cameraPosY checking the height of which vertex the camera is over or closest to. Use the the camera's X and Z coordinates to help single out which vertex the camera is over.
In case you you have big faces for your terrain, you may have to use a bounding ...
0
I had some similar problems. Maybe the camera is in model space instead of worldspace? That was causing the problem in may project...
Does something like that helps?
// Calculate the position of the vertex in the world.
worldPosition = mul(input.position, worldMatrix);
// Determine the viewing direction based on the position of the camera and the ...
0
here is some code for any number of equally spaced vertices of a sphere, its like an orange peel it winds a line of dots around a sphere in a spiral. afterwards, how you join the vertices is up to you. you can use neighbour dots in the loop as 2 of each triangle and then find the third would be a proportional one twist around the sphere higher up or lower ...
0
For actually randomly generating a platform, you define the:
x = max horizontal distance away from last platform
y = max vertical distance away from last platform
Use these values along with a random number generator to figure out the new distance. And like I stated in the previous post, you want to change this as the game proceeds. For instance the max ...
0
I actually made a game like this in cocos2d. I chose something similar to a GDC talk about the making of Jetpack Joyride. Which is:
Randomly generate about 1000 pixels of platforms at a time. Let's call this a section.
When the players starts to get close to the top of this section, go generate another section.
This allows you to maybe kind of add some ...
5
You aren't resetting the modelview matrix, so each cube's translation is added to all further cubes. Use glPushMatrix and glPopMatrix around each translate-and-call.
1
I have a harvest system implemented in my game that utilizes rejection sampling. Each item has a weighted chance of being produced. It's easy to assign weights to certain items and get one randomly using that weighted chance. This is similar to your situation, except you don't have harvest items, you have number of heads. So, you'd first assign a weighted ...
4
The usual answer will be some code that can tweak the random number distribution to give you the properties you want. I'd suggest instead working backwards:
first decide what distribution you actually want and draw it out
calculate the “cumulative distribution” which is the sum of the function in step 1
choose a random number from the cumulative ...
3
One way to do it is to apply a power function. Start with a random number in [0, 1] and then raise it to the power of some positive number. Powers < 1 will bias upward, i.e. the numbers will be more likely to be higher than lower within [0, 1], and powers > 1 will bias downward. Then use multiplication and addition to shift the range of numbers from ...
Top 50 recent answers are included


