go j67 jfb: menu_start: go je3 jab: all_again: go jf2 jcd: resize_pixi( 0, xsize, ysize ) pixi_transp( 0, 0 ) go jba jc9: handle_hard_keys( { if ghk = 264 { UP = 1 } if ghk = ' ' { UP = 1 } }, { if ghk = 264 { UP = 0 } if ghk = ' ' { UP = 0 } } ) if UP { ggg = 0 while( ggg < gi ) { fd + fd_speed*2 ggg + 1 } } set_screen( scr1 ) go j9a j73: go j51 j33: ggg = 0 while( ggg < gi ) { bx = (xsize*256) / 220 if (rand&511) < 2 { pixi( red_pixi, xsize/2 - ((get_pixi_xsize(red_pixi)/2)*bx)/256, ry1 + ((rand&255)*(ry2-ry1))/256, 1, bx - 256 ) } ggg + 1 } go j9f j29: scr1 = new_pixi( xsize, ysize, 1 ) pixi_transp( scr1, 0 ) go jcd j7c: PEN = { start_timer( 0 ) if ( gpy > 5 ) & ( gpy < 5+16 ) { el = 2 } if ( gpy > -5 ) & ( gpy < -5+16 ) { el = 1 } if ( gpy > -15 ) & ( gpy < -15+16 ) { el = 0 } VOL_CONTROL } go jc2 j4a: make_pixi( red_pixi ) es = 64 expl = new_pixi( es, es, 1 ) pixi_alpha( expl, expl ) set_screen( expl ) p = 0 y = 0 while( y < es ) { x = 0 while( x < es ) { xx = x - es/2 yy = y - es/2 r = ( (ccos( xx * 4 )+128) * (ccos( yy * 4 )+128) ) / 256 expl[ p ] = get_color( (r*200)/100, (r*150)/100, r ) p + 1 x + 1 } y + 1 } set_screen( 0 ) go jec jec: cols = 0 prev_r = 0 c = 0 while( c < 255 ) { cc = get_color( c, 0, 0 ) r = get_red( cc ) if prev_r != r { cols + 1 } prev_r = r c + 1 } go j29 j5a: max_cave_size_p - ( ( size_step * ((xspeed*1024)/xsize) ) / 6 ) max_cave_size = max_cave_size_p / 256 if max_cave_size < ysize/3 { y1=0 y2=0 } go j2e j2e: go j63 j1b: handle_pen_keys( PEN, PEN_MOVE, PEN_UP ) frame( 0 ) set_screen( scr1 ) if score_show = 0 { pixi( 0, 0, 0, 1, 32 ) } effector( BLACK, 256, 0, -2000, -2000, 4000, 4000, 1 ) if ok = 0 { go menu_start } go je8 j67: rand_seed( get_hours + get_minutes + get_seconds ) real_xsize = get_window_xsize real_ysize = get_window_ysize go jc6 je3: noesc(0) ok = 0 set_screen( 0 ) transp( 256 ) pixi( scr1, 0, 0, 1, 0 ) t = get_timer( 0 ) if ( ( t / 5000 ) & 1 ) = 0 { transp( 4700 - (t%5000) ) print( "PIXEL CAVE", -(10*15)/2, -50, get_color( sin(t), cos(t), sin(t) ) ) if el = 0 { c = WHITE } print( "START", -(5*15)/2, -15, c ) c = YELLOW if el = 1 { c = WHITE } print( "SND VOLUME", -(10*15)/2, -5, c ) c = YELLOW if el = 2 { c = WHITE } print( "EXIT", -(4*15)/2, 5, c ) c = YELLOW t_reset t_translate( 0, 256 * 20, 0 ) t_scale( 150, 150, 150 ) transp( 180 ) print( " by", -(12*15)/2, 30, #605050 ) print( "Alex Zolotov", -(12*15)/2, 40, #605050 ) print( "warmplace.ru", -(12*15)/2, 50, #605050 ) transp( 128 ) print( " by", -(12*15)/2, 31, #605050 ) print( "Alex Zolotov", -(12*15)/2, 41, #605050 ) print( "warmplace.ru", -(12*15)/2, 51, #605050 ) transp( 256 ) t_reset transp( 256 ) score_show = 0 } else { transp( 4700 - (t%5000) ) y = -( scores_num * 16 ) / 2 s = 0 while( s < scores_num ) { if scores[ s ] = 0 { print( ". . .", -(5*15)/2, y, YELLOW ) } else { ss = scores[ s ] gg = golds[ s ] if ss / 1 { size = 1 } if ss / 10 { size = 2 } if ss / 100 { size = 3 } if ss / 1000 { size = 4 } if ss / 10000 { size = 5 } if ss / 100000 { size = 6 } print( "$ss", -size*15 - 10, y, WHITE ) print( "-", -8, y, WHITE ) print( "$gg", 10, y, YELLOW ) } s + 1 y + 16 } transp( 256 ) score_show = 1 } go j46 j51: xsize = real_xsize ysize = real_ysize if xsize != 160 { d = (240*256)/320 y = ( xsize * d ) / 256 if y < ysize { ysize = y } } if xsize > 640 { xsize = 640 } if ysize > 480 { ysize = 480 } go jff je8: g_cnt2 = 0 g_cnt = 0 start_timer( 0 ) go je7 jf2: start_timer( 0 ) start_timer( 1 ) el = -1 go jfb j54: PEN_UP = { prev_el = el el = -1 if ( gpy > 5 ) & ( gpy < 5+16 ) { el = 2 } if ( gpy > -5 ) & ( gpy < -5+16 ) { el = 1 } if ( gpy > -15 ) & ( gpy < -15+16 ) { el = 0 } if prev_el = el { if el = 1 { SAVE_OPTIONS } if el = 2 { exit } if el = 0 { ok = 1 } } el = -1 } go jf8 jff: b = #FF4040 a = #902020 red_pixi = " .bbba.abaaaaa. bbaabaaaaaaaaa bbaaaaaaaaaaa. .baaaaa.aaaa.. " go j4a j8d: y1 = -ysize/2 y2 = ysize/2 cnt_max = 8 cnt = 0 score = 0 max_cave_size_p = ((ysize*3)/4) * 256 size_step = ysize / 20 fy = 0 g_fy = 0 fd = 0 fd_speed = ysize / 10 expl_on = 0 expl_timer = 0 prev_fy = 0 mc = 0 gold_on = 0 gold_y = 0 gold_x = 0 exoff = 0 eyoff = 0 xspeed_ptr2 = 0 xspeed_step = (xsize*256) / 130 g_prev_t = get_timer( 0 ) prev_gi = 0 noesc(1) go j76 j69: g_f = load_pixi( "cave_font.gif" ) pixi_transp( g_f, 1, g_f[ 0 ] ) pixi_font( g_f ) load_music( "cave.sunvox" ) go j73 jf8: if el = 1 { transp( 128 ) x = ( mus_vol * (10*15) ) / 256 - ((10*15)/2) fbox( x - 4, -5, 8, 16, WHITE ) transp( 256 ) } go j1b j32: if expl_on { t = expl_timer*16 if t > 128 { t = 128 } size = (xsize/5) + ( sin( t ) * (xsize/16) ) / 256 if skip_frame = 0 { pixi( expl, expl_xx, fy/256, 1, ((size*256)/get_pixi_xsize(expl))-256 + expl_timer*4 ) } expl_xx - xspeed expl_timer + 1 if expl_timer > 32 { record = 1 last_empty = 9999 s = 0 while( s < scores_num ) { if scores[ s ] > g_cnt { record = 0 } if scores[ s ] = 0 { last_empty = s s = 9999 } s + 1 } if record { if last_empty < scores_num { scores[ last_empty ] = g_cnt golds[ last_empty ] = score } if last_empty >= scores_num { s = 0 while( s < scores_num ) { scores[ s ] = scores[ s + 1 ] golds[ s ] = golds[ s + 1 ] s + 1 } scores[ scores_num-1 ] = g_cnt golds[ scores_num-1 ] = score } } SAVE_OPTIONS go end_dialog } exoff = ( ((rand&3)-2) * (32-expl_timer) ) / 32 eyoff = ( ((rand&3)-2) * (32-expl_timer) ) / 32 } go jd j9f: main_color = get_color( mc, mc, mc ) mc + 8 if mc > 255 { mc = 255 } if ( expl_on = 0 ) & ( xspeed > 0 ) { ggg = 0 while( ggg < gi ) { g_fy - fd fd - fd_speed ggg + 1 } fy = ( ( g_fy / 8 ) * xsize ) / 512 c = get_dot( 0, fy / 256 ) if ( get_red( c ) > 32 ) | ( get_green( c ) > 32 ) | (fy/256<(-ysize/2)) | (fy/256>(ysize/2)) { expl_on = 1 expl_xx = 0 } off = xspeed xx = 0 while( xx > -xspeed ) { d = (off*128) / xspeed yy = ( ( fy * d ) / 128 ) + ( ( prev_fy * (128-d) ) / 128 ) transp( 256 - ( yy & 255 ) ) dot( xx, yy / 256, main_color ) transp( yy & 255 ) dot( xx, yy / 256 + 1, main_color ) transp( 256 ) off-1 xx-1 } prev_fy = fy } go jc9 j76: start: skip_frame = 0 t = get_timer( 0 ) xspeed_ptr2 + ( xspeed_step * (t-g_prev_t) ) / 32 xspeed = (xspeed_ptr2/256) - (prev_xptr2/256) prev_xptr2 = xspeed_ptr2 g_prev_t = t if xspeed < 0 { xspeed = 0 } fd_speed = 11 a = ( ( (640*256) / xsize ) * xspeed ) gi = (prev_gi+a)/256 - prev_gi/256 prev_gi + a set_screen( 0 ) go j5a j63: if xspeed > 0 { pixi( 0, -xspeed, 0, 1, 0 ) } if xspeed > 0 { xoff = xspeed - 1 while( xoff >= 0 ) { cnt + 1 if cnt > cnt_max { cnt_max = ( ( rand & 31 ) * ( xsize / 5 ) ) / 32 cnt = 0 d1 = rand & 1 d2 = rand & 1 } ry1 = y1 + (rand&1) ry2 = y2 - (rand&1) line( xsize/2-1, ysize/2, xsize/2-1, -ysize/2, BLACK ) sub = xspeed + 1 - ((xspeed-1)-xoff) s = 0 y = -ysize/2 p = (y+ysize/2) * xsize + xsize-sub while( y < ry1 ) { c1 = s[ p - xsize ] c2 = s[ p + xsize ] c = get_blend( c1, c2, 128 ) rr = get_red( c ) if rand&1 { rr + 14 } else { rr - 14 } rr+4 s[ p + 1 ] = get_color( rr, rr, rr ) y + 1 p + xsize } y = ysize/2 p = (y+ysize/2) * xsize + xsize-sub while( y > ry2 ) { c1 = s[ p - xsize ] c2 = s[ p + xsize ] c = get_blend( c1, c2, 128 ) rr = get_red( c ) if rand&1 { rr + 14 } else { rr - 14 } rr+4 s[ p + 1 ] = get_color( rr, rr, rr ) y - 1 p - xsize } ss = ry2 - ry1 ss = ( 256 * 256 ) / ss sss = 0 s = 0 y = ry1 p = (y+ysize/2) * xsize + xsize-sub if cols <= 16 { while( y < ry2 ) { sss + ss c = (sss/256)/2 c + ((rand&63)-32) s[ p + 1 ] = get_color( 0, 0, c ) y + 1 p + xsize } } if ( cols > 16 ) & ( cols <= 64 ) { while( y < ry2 ) { sss + ss c = (sss/256)/8 c1 = s[ p - xsize ] c2 = s[ p + xsize ] cc = get_blend( c1, c2, 128 ) rr = get_blue( cc ) if rand&1 { rr + c } else { rr - c } rr - 6 if rr < 0 { rr = 0 } s[ p + 1 ] = get_color( 0, 0, rr ) y + 1 p + xsize } } if cols > 64 { while( y < ry2 ) { sss + ss c = (sss/256)/16 c1 = s[ p - xsize ] c2 = s[ p + xsize ] cc = get_blend( c1, c2, 128 ) rr = get_blue( cc ) if rand&1 { rr + c } else { rr - c } s[ p + 1 ] = get_color( 0, 0, rr ) y + 1 p + xsize } } transp( 128 ) dot( xsize/2-1-xoff, ry1, WHITE ) dot( xsize/2-1-xoff, ry2, WHITE ) transp( 256 ) add = 1 if d1 { y1 + add } else { y1 - add } if d2 { y2 - add } else { y2 + add } if rand & 1 { y1 + add } else { y1 - add } if rand & 1 { y2 - add } else { y2 + add } if y1 < -ysize/2 { y1 = -ysize/2 d1 = d1 ^ 1 } if y2 > ysize/2 { y2 = ysize/2 d2 = d2 ^ 1 } yy = y2 - y1 if yy <= max_cave_size { d1 = 0 d2 = 0 } if yy >= max_cave_size*3 { d1 = 1 d2 = 1 } xoff - 1 } } go j33 jd: if ( ttt < 512 ) & ( skip_frame = 0 ) { t = 512 - ttt transp( 256 ) fbox( -xsize/2, -ysize/2, ( t * (xsize/2) ) / 512, ysize, #303030 ) fbox( ( ttt * (xsize/2) ) / 512, -ysize/2, xsize, ysize, #303030 ) } transp( 256 ) g_cnt = g_cnt2 / 4 if skip_frame = 0 { print( "$g_cnt", -xsize / 2 + 3, -ysize / 2 + 1, BLACK ) print( "$g_cnt", -xsize / 2 + 2, -ysize / 2 + 0, WHITE ) print( "$$$score", -xsize / 2 + 3 + 90, -ysize / 2 + 1, BLACK ) print( "$$$score", -xsize / 2 + 2 + 90, -ysize / 2 + 0, YELLOW ) } if expl_on = 0 { g_cnt2 + ((xspeed*1024)/xsize) } go jb7 j66: ttt = get_timer( 0 ) gold_scale = xsize / 160 if gold_scale < 1 { gold_scale = 1 } if gold_on { if gold_x < -xsize/2 { gold_on = 0 } fade = get_timer( 2 ) / 8 if gold_on < 2 { fade = 0 } tr = 100 - fade transp( tr ) if tr <= 0 { gold_on = 0 } if skip_frame = 0 { pixi( expl, gold_x, gold_y, gold_scale, (-200+sin(ttt/2)/32+fade)*gold_scale ) } transp( 256 ) if xsize <= 240 { transp( csin( ttt/2 ) + 128 ) } if gold_on = 1 { if ( 0 > gold_x - 5*gold_scale ) & ( 0 < gold_x + 5*gold_scale ) & ( fy/256 > gold_y-5*gold_scale ) & ( fy/256 < gold_y+5*gold_scale ) { score + 1 gold_on = 2 start_timer( 2 ) } if skip_frame = 0 { pixi( expl, gold_x, gold_y, gold_scale, (-235)*gold_scale ) } } if ( gold_on > 1 ) { transp( 256 ) a = 0 while( a < 1 ) { dot( gold_x + (((rand&15)-8)*(14*gold_scale))/16, gold_y + (((rand&15)-8)*(14*gold_scale))/16, WHITE ) a + 1 } } gold_x - xspeed } transp( 256 ) go j32 j58: go start go ja3 j9a: if skip_frame = 0 { pixi( 0, exoff, eyoff, 1, 0 ) } if gold_on = 0 { ggg = 0 while( ggg < gi ) { if (rand&511)<5 { gold_on = 1 gold_x = xsize/2 + 8 gold_y = ry1 + ((rand&255)*(ry2-ry1))/256 ggg = 999999 } ggg + 1 } } go j66 jc2: PEN_MOVE = { start_timer( 0 ) VOL_CONTROL } go j54 ja3: LOAD_OPTIONS: f = fopen( "cave.opt", "rb" ) if f { s = 0 while( s < scores_num ) { scores[ s ] = fgetc( f ) scores[ s ] = scores[ s ] | (fgetc( f )*256) scores[ s ] = scores[ s ] | (fgetc( f )*(256*256)) golds[ s ] = golds[ s ] | (fgetc( f )) golds[ s ] = golds[ s ] | (fgetc( f )*256) s + 1 } mus_vol = fgetc( f ) fclose( f ) } SET_VOLUME ret SAVE_OPTIONS: f = fopen( "cave.opt", "wb" ) if f { s = 0 while( s < scores_num ) { fputc( ( scores[ s ] / 1 ) & 255, f ) fputc( ( scores[ s ] / 256 ) & 255, f ) fputc( ( scores[ s ] / (256*256) ) & 255, f ) fputc( ( golds[ s ] / 1 ) & 255, f ) fputc( ( golds[ s ] / 256 ) & 255, f ) s + 1 } fputc( mus_vol, f ) fclose( f ) } ret SET_VOLUME: music_volume( mus_vol & 255 ) if ( play_status = 0 ) & ( mus_vol > 0 ) { play_music play_status = 1 } ret end_dialog: transp( 256 ) t_reset y = -ysize/2 while( y < ysize/2 ) { x = -xsize/2-1 while( x < xsize/2 ) { x + 1 xx = ( ( x + xsize/2 ) * 1024 ) / xsize yy = ( ( y + ysize/2 ) * 1024 ) / ysize r = ( sin( xx/16 ) * cos( yy/8 ) ) / 128 g = ( sin( xx/7 ) * cos( yy/7 ) ) / 128 b = ( sin( xx/4 ) * cos( yy/4 ) ) / 128 g + csin( xx*554 )/16 + ccos( yy*15 )/16 c = get_color( r, g, b ) dot( x, y, c ) } y + 1 } transp( 100 ) fbox( -1000, -74, 2000, 108, WHITE ) transp( 256 ) print( "This is", -(7*15)/2, -70, BLUE ) print( "demo", -(4*15)/2, -55, BLUE ) print( "version", -(7*15)/2, -40, BLUE ) pixi_font( 1 ) print( "You can download", -(16*8)/2, -10, #000080 ) print( "full version at", -(15*8)/2, 0, #000080 ) print( "www.warmplace.ru", -(16*8)/2, 12, BLACK ) print( "/games", -(6*8)/2, 20, BLACK ) pixi_font( g_f ) a = 0 e = 0 while( 1 ) { b = a handle_hard_keys( { a = 1 }, { a = 0 } ) if ( b = 1 ) & ( a = 0 ) { go all_again } handle_pen_keys( {}, {}, { e = 1 } ) if e = 1 { go all_again } frame( 10 ) } go all_again go j0 jb7: if ( expl_on = 0 ) & ( skip_frame = 0 ) { transp( ( csin( ttt / 4 ) + 128 ) / 4 ) line( 0, fy/256-2, 0, fy/256+2, WHITE ) line( 0, fy/256-1, 0, fy/256+1, WHITE ) line( -2, fy/256, 2, fy/256, WHITE ) line( -1, fy/256, 1, fy/256, WHITE ) transp( 256 ) } need_exit = 0 handle_hard_keys( {}, { if ghk = 27 { need_exit = 1 } } ) if need_exit { go all_again } go j31 j31: if expl_on { frame( 33 ) } else { frame( 0 ) } go j58 je7: set_screen( scr1 ) clear( BLACK ) set_screen( 0 ) clear( BLACK ) go j8d jba: mus_vol = 200 play_status = 0 LOAD_OPTIONS go jab jc6: scores_num = 8 scores = new_array( scores_num ) golds = new_array( scores_num ) s = 0 while( s < scores_num ) { scores[ s ] = 0 golds[ s ] = 0 s + 1 } go j69 j46: transp( 48 ) t_reset t = get_timer( 1 ) t_rotate_z( sin( t / 16 ) / 2, 0, 0, 0 ) t_rotate_x( sin( t / 8 ) / 2, 0, 0, 0 ) t_rotate_y( sin( t / 10 ) / 2, 0, 0, 0 ) t_scale( 256*3, 256*3, 256 ) print( "PIXEL CAVE", -(10*15)/2, -8, WHITE ) t_reset transp( 256 ) handle_hard_keys( { if ghk != 10 { ok = 1 } }, 0 ) VOL_CONTROL = { if el = 1 { mus_vol = ( ( gpx + (10*15)/2 ) * 256 ) / (10*15) if mus_vol > 255 { mus_vol = 255 } if mus_vol < 32 { mus_vol = 0 } SET_VOLUME } } go j7c