コード例 #1
0
    def start(self):
        # Create players
        self.players = []
        self.score_labels = []
        for i, color in enumerate(GameScene.COLORS):
            player = Player(color)
            self.players.append(player)
            # player input handlers
            keys = GameScene.KEY_BINDINGS[i]
            player.input_handler = self.create_input_handler(player, 
                    jump = keys['jump'],
                    left = keys['left'],
                    right = keys['right'],
                    freeze = keys['freeze'])
            # Score Labels
            label_color = color.tup() + (GameScene.SCORE_ALIVE_ALPHA,)
            label = pyglet.text.Label('0', 
                        font_size = GameScene.SCORE_SIZE,
                        bold = True,
                        color = label_color)
            self.score_labels.append(label)
            player.score_label = label
        self.position_labels()

        # Create physics space
        self.space = pymunk.Space()
        # Instantly correct collisions
        #self.space.collision_bias = 0
        self.space.gravity = GameScene.GRAVITY
        Bro.setup_collision_handlers(self.space)

        # Create first section
        self.entities = []
        self.sections = deque()
        self.current_distance = 0
        self.push_section()

        # Create entities
        self.bros = []
        for i, player in enumerate(self.players):
            self.add_bro(player, y=(i+2)*50)

        # slowly panning camera
        self.camera = self.start_projection()

        # Game state
        self.scroll_delay = GameScene.SCROLL_DELAY
        self.scroll_rate =  GameScene.SCROLL_RATE
        self.drop_line = GameScene.DROP_LINE_START

        # Schedule updating game
        pyglet.clock.schedule(rabbyt.add_time)
        pyglet.clock.schedule(self.update)
        pyglet.clock.schedule_interval(self.update_physics, GameScene.PHYSICS_FRAMERATE)
コード例 #2
0
 def add_bro(self, player, old_bro=None, x=0, y=100):
     #x = self.sections[0].first_tile_offset()
     if old_bro is not None:
         x = old_bro.last_tile.x
         y = old_bro.last_tile.y + Tile.SIZE
     bro = Bro(player, self.space, x=x, y=y, old_bro=old_bro)
     self.entities.append(bro)
     self.bros.append(bro)
コード例 #3
0
ファイル: runner.py プロジェクト: michaelmcmillan/BedpresBro
     o©ºº©oo©oº°©           
    /           \          
    |___________|____      
    |            |____)     
    |   B E D    |  | |     
    |            |  | |     
    |  P R  E S  |  | |     
    |            |  | |     
    |   B R O    |  | |     
    |            |__|_|     
    |            |____)     
    |____________|          
   (______________)        
    ''')

    bro = Bro()
    bro.feeds = [Online()]
    bro.channels = [Facebook()]

    # Setup memory if it does not exist
    Brain.setup()

    # Pull events from feeds every 30 minutes
    def pull_events():
        log.info('Pulling events from %d feed(s).' % len(bro.feeds))
        bro.pull_events_from_feeds()
        threading.Timer(60 * 30, pull_events).start()

    # Push events to channel every 10 seconds
    def push_events():
        log.info('Pushing events to %d channel(s).' % len(bro.channels))