Автор: intre
SCREEN_WIDTH = 240 SCREEN_HEIGHT = 320 resize_pixi(0, SCREEN_WIDTH, SCREEN_HEIGHT) x_max = 16 y_min = 2 y_max = 10 expected_length = SCREEN_HEIGHT current_point = 0 die_flag = 0 set_screen(0) X=0 Y=1 SIZE=2 points = new_array(expected_length/y_min * SIZE) points_num = 0 points[X] = 0 points[Y] = SCREEN_HEIGHT/2 clear(SNEG) while 1 { //clear(SNEG) draw_crack n = 0 while(n < 1000){ add_point n+1 } frame(10) } add_point: if points_num < get_array_size(points) { current_point+1 x = points[(current_point-1)*SIZE + X] + rand*x_max/32767-x_max/2 y = points[(current_point-1)*SIZE + Y] - y_min-rand*(y_max-y_min)/32767 points[current_point*SIZE + X] = x points[current_point*SIZE + Y] = y // check for out of range if (x < -SCREEN_WIDTH/2) | (x > SCREEN_WIDTH/2) | (y < -SCREEN_HEIGHT/2) | (y > SCREEN_HEIGHT/2) { die_flag = 1 } points_num+1 } if die_flag | (points_num >= get_array_size(points)) { points_num = 0 current_point = 0 die_flag = 0 points[X] = rand*SCREEN_WIDTH/32767 - SCREEN_WIDTH/2 } ret draw_crack: col = get_color(rand*256/32767, rand*256/32767, rand*256/32767) last_x = points[X] last_y = points[Y] n = 1 while(n < points_num){ transp(64) line(last_x, last_y, points[n*SIZE + X], points[n*SIZE + Y], col) last_x = points[n*SIZE + X] last_y = points[n*SIZE + Y] n+1 } ret