Browse Source

delay is now a command line argument

master
informaniac 7 years ago
parent
commit
df9332777c
  1. 4
      generators/gameOfLife.py

4
generators/gameOfLife.py

@ -12,7 +12,6 @@ HEIGHT = 16
COLOR_DEPTH = 256 COLOR_DEPTH = 256
COLORS = 3 COLORS = 3
DELAY = 300
DEAD = 0 DEAD = 0
DEAD_COLOR = (0, 0, 0) DEAD_COLOR = (0, 0, 0)
@ -46,6 +45,7 @@ if __name__ == "__main__":
argument_parser = argparse.ArgumentParser(description="Game of Life bml generator") argument_parser = argparse.ArgumentParser(description="Game of Life bml generator")
argument_parser.add_argument('-w', dest="world", type=list, default=None, help="pre-constructed world (optional)") argument_parser.add_argument('-w', dest="world", type=list, default=None, help="pre-constructed world (optional)")
argument_parser.add_argument('-o', dest="output_path", type=str, help="output file (mandatory)") argument_parser.add_argument('-o', dest="output_path", type=str, help="output file (mandatory)")
argument_parser.add_argument('-d', dest="delay", type=int, default=300, help="delay between frames (optional)")
args = argument_parser.parse_args() args = argument_parser.parse_args()
if args.output_path is None: if args.output_path is None:
@ -68,7 +68,7 @@ if __name__ == "__main__":
for frame in range(500): for frame in range(500):
# construct frame # construct frame
new_frame = animation.AnimationFrame(dimension, DELAY) new_frame = animation.AnimationFrame(dimension, args.delay)
for row_index in range(HEIGHT): for row_index in range(HEIGHT):
for col_index in range(WIDTH): for col_index in range(WIDTH):
cell_status = game_board[row_index][col_index] cell_status = game_board[row_index][col_index]

Loading…
Cancel
Save