[RESOLVED] Generating Random Terrain using GX January 09, 2011 12:55AM | Registered: 13 years ago Posts: 363 |
Re: Generating Random Terrain using GX January 09, 2011 11:58AM | Registered: 14 years ago Posts: 379 |
Re: Generating Random Terrain using GX January 09, 2011 08:52PM | Registered: 13 years ago Posts: 363 |
Re: Generating Random Terrain using GX January 14, 2011 03:05PM | Registered: 13 years ago Posts: 363 |
Re: Generating Random Terrain using GX January 24, 2011 06:30PM | Registered: 13 years ago Posts: 363 |
int terrain_color_threshold=100; //how bright or how dark to fade the terrain as it gets higher/lower int terrain_grid=100; //100 //this number squared must be smaller than terrain_max int terrain_height=170;//the scale of the terrain box float terrain_max=10000, terrain[10000][4]={}; //4th is the direction of the point (for water effect) void draw_terrain3( u32 col ) { int i, g; GRRLIB_ObjectView( 0, -200,-1500, 0,0,0,500,100,500); //uses grrlib int grid=terrain_grid, p=0, p2=0; int grid_cols=grid*grid; float x=-1, y=-1, z=-1, grid_inc=2/(float)grid; for(g=0; g0) & (g > 0) ) { p2=(g+i)-grid-1; terrain[p][0]=terrain[p2][0]; terrain[p][1]=terrain[p2][1]; terrain[p][2]=terrain[p2][2]; } else { terrain[p][0]=x; terrain[p][1]=y; terrain[p][2]=z; } GX_Position3f32(terrain[p][0],terrain[p][1],terrain[p][2]); GX_Color1u32(col); } GX_End(); switch( randnum2(3) ){ case 1: col=GRRLIB_GRAY; break; case 2: col=GRRLIB_SILVER; break; case 3: default: col=GRRLIB_GREEN; } } }