# # A routine to display Snowflakes floating down the matrix by Peter Weaver. # # initialize :init config number_of_flakes = 3 config red_value = 200 config green_value = 200 config blue_value = 255 # config size = 5 # # Set the show_shape_x fields to 1 to show the shape # or 0 to hide it. If you hide too many shapes you # will want to increase the number_of_flakes. # config show_shape_1 = 1 config show_shape_2 = 1 config show_shape_3 = 1 config show_shape_4 = 1 config show_shape_5 = 1 end # render frame :render clear for i=1 to number_of_flakes # # If the flake is not currently active then start it # if visible[i] <> 1 # # Get a shape that is an integer number in the range # 1 to 5 # shape[i] = rnd(4) + 1 # # Get the speed, make it an integer too that is at least 1 # speed[i] = rnd(matrix_y/8) + 0.25 # # Starting position, x can be anywhere across the matrix, # y will be below 0, somewhere between the top row and # 25% above the top row # pos_x[i] = rnd(matrix_x) pos_y[i] = rnd(matrix_y) * (0-0.25) # # Turn it on # visible[i] = 1 endif # # Move down # pos_y[i] = pos_y[i] + speed[i] # # Jiggle occasionally, but not too often # if rnd(100) > 99 pos_x[i] = pos_x[i] + 1 else if rnd(100) < 1 pos_x[i] = pos_x[i] - 1 endif # # Draw one of the shapes # if shape[i] <= 1 & show_shape_1 = 1 gosub draw_flake_1 else if shape[i] = 2 & show_shape_2 = 1 gosub draw_flake_2 else if shape[i] = 3 & show_shape_3 = 1 gosub draw_flake_3 else if shape[i] = 4 & show_shape_4 = 1 gosub draw_flake_4 else if show_shape_5 = 1 gosub draw_flake_5 endif if pos_y[i] > matrix_y + 5 visible[i] = -1 endif next end ################################################### # Shape #1 ################################################### :draw_flake_1 # debug text 0,pos_y[i],0,8,255,0,0,"1","Arial",0 point_x = pos_x[i] point_y = pos_y[i] gosub draw_point # North Arm 1 for x = 1 to 3 point_x = point_x-1 gosub draw_point next # South Arm 1 point_x = pos_x[i] for x = 1 to 3 point_x = point_x+1 gosub draw_point next # East Arm 1 point_x = pos_x[i] for y = 1 to 3 point_y = point_y + 1 gosub draw_point next # West Arm 1 point_y = pos_y[i] for y = 1 to 3 point_y = point_y - 1 gosub draw_point next # North East 1 point_y = pos_y[i] for x = 1 to 2 point_y = point_y - 1 point_x = point_x + 1 gosub draw_point next # North West 1 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 2 point_y = point_y - 1 point_x = point_x - 1 gosub draw_point next # South West 1 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 2 point_y = point_y + 1 point_x = point_x - 1 gosub draw_point next # South East 1 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 2 point_y = point_y + 1 point_x = point_x + 1 gosub draw_point next # Points 1 point_x = pos_x[i] - 1 point_y = pos_y[i] - 4 gosub draw_point point_y = point_y + 8 gosub draw_point point_x = point_x + 2 gosub draw_point point_y = point_y - 8 gosub draw_point point_x = pos_x[i] - 4 point_y = pos_y[i] - 1 gosub draw_point point_y = point_y + 2 gosub draw_point point_x = point_x + 8 gosub draw_point point_y = point_y - 2 gosub draw_point return end ################################################### # Shape #2 ################################################### :draw_flake_2 # text 10,pos_y[i],0,8,255,0,0,"2","Arial",0 point_x = pos_x[i] point_y = pos_y[i] gosub draw_point # North Arm 2 for x = 1 to 3 point_x = point_x-1 gosub draw_point next # South Arm 2 point_x = pos_x[i] for x = 1 to 3 point_x = point_x+1 gosub draw_point next # East Arm 2 point_x = pos_x[i] for y = 1 to 3 point_y = point_y + 1 gosub draw_point next # West Arm 2 point_y = pos_y[i] for y = 1 to 3 point_y = point_y - 1 gosub draw_point next # North East 2 point_y = pos_y[i] for x = 1 to 3 point_y = point_y - 1 point_x = point_x + 1 gosub draw_point next # North West 2 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 3 point_y = point_y - 1 point_x = point_x - 1 gosub draw_point next # South West 2 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 3 point_y = point_y + 1 point_x = point_x - 1 gosub draw_point next # South East 2 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 3 point_y = point_y + 1 point_x = point_x + 1 gosub draw_point next return end ################################################### # Shape #3 ################################################### :draw_flake_3 # debug text 20,pos_y[1],0,8,255,0,0,"3","Arial",0 point_x = pos_x[i] point_y = pos_y[i] gosub draw_point # North Arm 3 for x = 1 to 3 point_x = point_x-1 gosub draw_point next # South Arm 3 point_x = pos_x[i] for x = 1 to 3 point_x = point_x+1 gosub draw_point next # East Arm 3 point_x = pos_x[i] for y = 1 to 3 point_y = point_y + 1 gosub draw_point next # West Arm 3 point_y = pos_y[i] for y = 1 to 3 point_y = point_y - 1 gosub draw_point next # North East 3 point_y = pos_y[i] for x = 1 to 3 point_y = point_y - 1 point_x = point_x + 1 gosub draw_point next # North West 3 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 3 point_y = point_y - 1 point_x = point_x - 1 gosub draw_point next # South West 3 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 3 point_y = point_y + 1 point_x = point_x - 1 gosub draw_point next # South East 4 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 3 point_y = point_y + 1 point_x = point_x + 1 gosub draw_point next return end ################################################### # Shape #4 ################################################### :draw_flake_4 # debug text 30,pos_y[i],0,8,255,0,0,"4","Arial",0 point_x = pos_x[i] point_y = pos_y[i] gosub draw_point # North Arm 4 for x = 1 to 4 point_x = point_x-1 gosub draw_point next # South Arm 4 point_x = pos_x[i] for x = 1 to 4 point_x = point_x+1 gosub draw_point next # East Arm 4 point_x = pos_x[i] for y = 1 to 4 point_y = point_y + 1 gosub draw_point next # West Arm 4 point_y = pos_y[i] for y = 1 to 4 point_y = point_y - 1 gosub draw_point next # North East 1 point_y = pos_y[i] for x = 1 to 2 point_y = point_y - 1 point_x = point_x + 1 gosub draw_point next # North West 1 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 2 point_y = point_y - 1 point_x = point_x - 1 gosub draw_point next # South West 1 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 2 point_y = point_y + 1 point_x = point_x - 1 gosub draw_point next # South East 1 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 2 point_y = point_y + 1 point_x = point_x + 1 gosub draw_point next # Points 1 point_x = pos_x[i] - 1 point_y = pos_y[i] - 4 gosub draw_point point_y = point_y + 8 gosub draw_point point_x = point_x + 2 gosub draw_point point_y = point_y - 8 gosub draw_point point_x = pos_x[i] - 4 point_y = pos_y[i] - 1 gosub draw_point point_y = point_y + 2 gosub draw_point point_x = point_x + 8 gosub draw_point point_y = point_y - 2 gosub draw_point return end ################################################### # Shape #5 ################################################### :draw_flake_5 # debug text 40,pos_y[i],0,8,255,0,0,"5","Arial",0 point_x = pos_x[i] point_y = pos_y[i] gosub draw_point # North Arm 5 for x = 1 to 4 point_x = point_x-1 gosub draw_point next # South Arm 5 point_x = pos_x[i] for x = 1 to 4 point_x = point_x+1 gosub draw_point next # East Arm 5 point_x = pos_x[i] for y = 1 to 4 point_y = point_y + 1 gosub draw_point next # West Arm 5 point_y = pos_y[i] for y = 1 to 4 point_y = point_y - 1 gosub draw_point next # North East 5 point_y = pos_y[i] for x = 1 to 3 point_y = point_y - 1 point_x = point_x + 1 gosub draw_point next # North West 5 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 3 point_y = point_y - 1 point_x = point_x - 1 gosub draw_point next # South West 5 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 3 point_y = point_y + 1 point_x = point_x - 1 gosub draw_point next # South East 5 point_y = pos_y[i] point_x = pos_x[i] for x = 1 to 3 point_y = point_y + 1 point_x = point_x + 1 gosub draw_point next # Points 5 point_x = pos_x[i] - 1 point_y = pos_y[i] - 4 gosub draw_point point_x = point_x -1 gosub draw_point point_y = point_y + 8 gosub draw_point point_x = point_x + 1 gosub draw_point point_x = point_x + 2 gosub draw_point point_x = point_x + 1 gosub draw_point point_y = point_y - 8 gosub draw_point point_x = point_x - 1 gosub draw_point point_x = pos_x[i] - 4 point_y = pos_y[i] - 1 gosub draw_point point_y = point_y - 1 gosub draw_point point_y = point_y + 3 gosub draw_point point_y = point_y + 1 gosub draw_point point_x = point_x + 8 gosub draw_point point_y = point_y - 1 gosub draw_point point_y = point_y - 2 gosub draw_point point_y = point_y - 1 gosub draw_point return end :draw_point # if point_x>=0 & point_y>=0 & point_x<=matrix_x & point_y<=matrix_y pset point_x, point_y, red_value, green_value, blue_value # endif return end