Mercurial > mamba
changeset 354:46565a047ac0
silly partition helper for level design
author | Adrianna Pińska <adrianna.pinska@gmail.com> |
---|---|
date | Fri, 16 Sep 2011 23:38:53 +0200 |
parents | 62a2a659c69b |
children | 7d5bf8e72c61 17865fe52f1a |
files | scripts/partition_helper |
diffstat | 1 files changed, 37 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/partition_helper Fri Sep 16 23:38:53 2011 +0200 @@ -0,0 +1,37 @@ +#!/usr/bin/env python + + +def partition(total, parts, sepwidth=1): + seps = parts - 1 + space = total - 2 - sepwidth * seps + return float(space) / parts + + +def find_partitions(num, sepwidth): + partitions = [] + for i in range(2, num): + size = partition(num, i, sepwidth) + if size > 0 and int(size) == size: + partitions.append((i, size)) + return partitions + + +if __name__ == "__main__": + height = ["FLOOR HEIGHT: PARTS x PART HEIGHT"] + for sepwidth in range(1, 28): + partitions = find_partitions(30, sepwidth) + if partitions: + height.append("%s: %s" % (sepwidth, + " ".join([" %dx%d" % (i, size) for (i, size) in partitions]))) + + width = ["COLUMN WIDTH: PARTS x PART WIDTH"] + for sepwidth in range(1, 38): + partitions = find_partitions(40, sepwidth) + if partitions: + width.append("%s: %s" % (sepwidth, + " ".join([" %dx%d" % (i, size) for (i, size) in partitions]))) + + height.extend([""] * 6) + height = [l.ljust(50) for l in height] + pairs = zip(height, width) + print "\n".join(["%s %s" % p for p in pairs])