Автор: ZUF
a = #111111 img= " ...a ..a.a ...a .aaaaa .a.a.a .aaaaa .aaaaa ..a.a + ...a .aa.aa ...a .aaaaa .a.a.a .aaaaa .aaaaa ..a.a + ...a aaa.aaa ...a .ooooo .o.o.o .ooooo .ooooo ..o.o " init: make_pixi( img ) ////////////////////////////////////////////////////////// // SETTINGS player_y_step = 2 player_x_step = 2 reset_key = 1 screen_width=320-20 screen_height=240-20 min_down_height = 5 max_down_height = screen_height/2 ///////////////////////////////////////////////////////// player_y=10 player_x=100 score = 0 land_points_count = 600 //screen_width / 10 down_land = new_array(land_points_count) down_gold = new_array(land_points_count) ///////////////////// // land generator i=0 down_land_gen: down_land[i] = rand down_land[i] = down_land[i]/700 i=i + 1 if (i<land_points_count) {go down_land_gen} /////////////////////// color_cold = #FFE241 //////////////////////////////// // gold generator // coolor = #FFE241 ii=0 down_gold_gen: down_gold[ii] = rand down_gold[ii] = down_gold[ii]/2000 ii=ii + 1 if (ii<land_points_count) {go down_gold_gen} /////////////////////////////// head=0 cfg_x_shift_every_frames = 300 x_shift_every_frames = cfg_x_shift_every_frames x_shift=0 x_shift_every_frames_gold = cfg_x_shift_every_frames x_shift_gold=0 repeat_marker: clear(WHITE) box (0,0,screen_width,screen_height,#000000) ////////////////////// // some debug ff=fps() print("fps: $ff",0,10, #ff0000) print("player pos: ($player_x; $player_y)",0,20, #ff0000) print("Score: $score",0,30, #ff0000) print("pen en=$pen_down: ($pen_x; $pen_y)",0,40, #ff0000) /////////////////////// ///////////////////// // draw gold i=0 draw_gold: n = 0 inner_loop_dg: if ((i)*10+x_shift>0) { line ((i-1)*10+x_shift, screen_height-30+n+down_gold[i-1], (i)*10+x_shift, screen_height-30+n+down_gold[i], color_cold) } n=n+1 if (n<60) {go inner_loop_dg} if (x_shift_every_frames_gold<0) { x_shift_every_frames_gold=cfg_x_shift_every_frames x_shift_gold=x_shift_gold-1 if (x_shift_gold<-land_points_count*10) {x_shift_gold = 0} } x_shift_every_frames_gold = x_shift_every_frames_gold-1 //head=head+1 i=i + 1 if (i<land_points_count) {go draw_gold} ///////////////////// ///////////////////// // Рисуем землю i=0 draw_land: n = 0 inner_loop_dl: if ((i)*20+x_shift>0) { line ((i-1)*20+x_shift, screen_height-60+n+down_land[i-1], (i)*20+x_shift, screen_height-60+n+down_land[i], #000000) } n=n+1 if (n<80) {go inner_loop_dl} if (x_shift_every_frames<0) { x_shift_every_frames=cfg_x_shift_every_frames x_shift=x_shift-1 if (x_shift<-land_points_count*10) {x_shift = 0} } x_shift_every_frames = x_shift_every_frames-1 //head=head+1 i=i + 1 if (i<land_points_count) {go draw_land} ///////////////////// ////////////////////////////////////////// // Управление игроком handle_pen_keys( {pen_down=1}, {pen_x=get_pen_x}, {pen_down=0} ) handle_pen_keys( {pen_down=1}, {pen_y=get_pen_y}, {pen_down=0} ) if (pen_down=1) { keyb_control=0 if (player_x<pen_x){player_x=player_x+player_x_step} if (player_x>pen_x){player_x=player_x-player_x_step} if (player_y<pen_y){player_y=player_y+player_y_step} if (player_y>pen_y){player_y=player_y-player_y_step} } else { handle_hard_keys( {keyb_control=1}, 0, 0 ) if (keyb_control=1) { handle_hard_keys( {key_code=get_hard_key}, 0, 0 ) if (key_code=264) {player_y=player_y-player_y_step} // player move up if (key_code=265) {player_y=player_y+player_y_step} // player move down if (key_code=266) {player_x=player_x-player_x_step} // player move left if (key_code=267) {player_x=player_x+player_x_step} // player move right } } if (player_y<10) {player_y = 10} if (player_x<5) {player_x = 5} if (player_x>screen_width-5) {player_x = screen_width-5} ///////////////////////////////////////// if (get_dot(player_x+1, player_y+1)=#000000) {go game_over} if (get_dot(player_x+1, player_y+1)=color_cold) {score = score + 1} pixi(img, player_x, player_y) //player_x = player_x + palyer_x_step frame(25) go repeat_marker game_over: clear(WHITE) print("Game Over!",0,0) print("Your score: $score",0,30) print("Press space to restart...",0,50) handle_hard_keys( {key_code=get_hard_key}, 0, 0 ) if (key_code=' ') {go init} frame(25) go game_over
