Translations of this page:

Landscape

Автор: ALex Zolotov (NightRadio)

xsize = 320
ysize = 240
hx = xsize / 2
hy = ysize / 2
resize_pixi( 0, xsize, ysize )
 
map = new_pixi( 64, 64, 1 )
 
calc_map = new_pixi( 64, 64, 1 )
 
set_screen( map )
p = 0
y = 0 while( y < 64 ) {
x = 0 while( x < 64 ) {
	v = (sin(x*16)*cos(y*16))/256
	v / 2
	map[ p ] = get_color( v, v, v )
	p + 1
	x + 1
}
y + 1
}
 
start_timer( 0 )
 
start:
 
t = get_timer( 0 ) / 8
 
handle_pen_keys( { sx = gpx sa = angle }, { angle = sa - (gpx-sx) }, {} )
 
set_screen( calc_map )
clear( BLUE )
t_reset
t_rotate_z( angle+t, 0, 0, 0 );
pixi( map, 0, 0, 2, 0 )
t_scale( 512, 512, 512 )
transp( 128 )
print( "VOXEL LANDSCAPE", 16-t/8, 4, get_color( sin(t)/4+128, sin(t)/2, sin(t)/2 ) )
transp( 256 )
t_reset
 
set_screen( 0 )
clear( BLACK )
map_xsize = get_pixi_xsize( calc_map )
map_ysize = get_pixi_ysize( calc_map )
xstep = xsize / get_pixi_xsize( calc_map )
start_p = map_xsize * ( map_ysize - 1 )
x = 0 while( x < xsize ) 
{
	p = start_p
	max_v = -1000
	prev_v = -1000
	cam_x = ( map_xsize / 2 ) * 256
	cam_d = ( ( ( x / xstep ) * 256 ) - cam_x ) / map_ysize
	my = 0 while( my < map_ysize )
	{
		pixel = calc_map[ p + ( cam_x / 256 ) ]
		//pixel = get_blend( calc_map[ p + ( cam_x / 256 ) ], calc_map[ p + ( cam_x / 256 ) + 1 ], cam_x & 255 )
		if my = 0 { my = 1 }
		v = ( (get_red( pixel )/2-64) * ( (64*64)/my ) ) / 64
		if v > max_v
		{
			c = 255 - my*4
			//c = 255 - ( v - prev_v ) * 8
			fbox( x - hx, -v, xstep, v - max_v, get_color( c, c, c ) )
			max_v = v
		}
		p - map_xsize
		cam_x + cam_d
		prev_v = v
		my + 1
	}
	x + xstep
}
 
frame( 0 )
 
go start
pixi-examples/3d_landscape.txt · Последние изменения: 2009/01/02 03:45 — 89.169.160.32
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki