コード例 #1
0
ファイル: window.py プロジェクト: NElias/swottc
    def __init__(self, log, colors, options, args):
        logging.basicConfig(filename=log, level=logging.DEBUG, filemode='w')

        Color.init(colors)

        self.background = Color.by_html('c6cfbf')

        if len(args) > 0:
            self.world = World.load_json(args[0])
            self.cols = self.world.cols
            self.rows = self.world.rows
            self.density = int(100.0 * len(self.world._objects) / (self.cols * self.rows))
        else:
            self.cols = options.cols
            self.rows = options.rows
            self.density = options.density
            self.world = self.create_world()

        self.is_force = False
        self.size = (self.cols * Window.CELL_SIZE, self.rows * Window.CELL_SIZE)
        self.scale = float(min(Window.SIZE)) / max(self.size)
        self.position = [Window.SIZE[0]/2, Window.SIZE[0]/2]

        # set up pygame
        pygame.init()
        pygame.display.set_caption('Life')
        self.clock = pygame.time.Clock()

        # set up the window
        self.surface = pygame.display.set_mode(Window.SIZE, 0, 32)
        self.world_surface = pygame.Surface(self.size)

        # set up fonts
        self.font = pygame.font.SysFont(None, 16)
        self.font_color = Color.by_name('white')

        self.downpos = None
コード例 #2
0
ファイル: plant.py プロジェクト: NElias/swottc
 def __init__(self, *args, **kwargs):
     super(Plant, self).__init__(*args, **kwargs)
     self.base_health = 100
     self.current_health = self.base_health
     self.color = Color.by_name('YellowGreen')
コード例 #3
0
ファイル: predator.py プロジェクト: NElias/swottc
 def __init__(self, *args, **kwargs):
     super(Predator, self).__init__(*args, **kwargs)
     self.base_health = 100
     self.current_health = self.base_health
     self.color = Color.by_name('OrangeRed')