コード例 #1
0
def run_game():
    """Initialise the game and create a screen object.""" 
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode(
        (ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Catch")

    # Create an instance to store game stats.
    stats = GameStats(ai_settings)

    # Make a catcher and a ball and groups of both
    catcher = Catcher(ai_settings, screen)
    ball = Ball(ai_settings, screen)
    balls = Group()
    balls.add(ball)
    

    # Main game loop
    while True:
        gf.check_events(ai_settings, screen, catcher)

        if stats.game_active:
            catcher.update()
            gf.update_balls(ai_settings, stats, screen, catcher, balls)
        
        gf.update_screen(ai_settings, screen, catcher, balls)
コード例 #2
0
def run_game():
    # Initialize pygame, settings, and screen object.
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode(
        (ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Catch")

    # Create an instance to store game statistics.
    stats = GameStats(ai_settings)

    # Make a catcher, and ball group
    catcher = Catcher(ai_settings, screen)
    balls = Group()

    # Create the falling ball.
    gf.create_ball(ai_settings, screen, balls)

    # Start the main loop for the game.
    while True:
        # Check for any input events
        gf.check_events(catcher)

        # Keep updating the catcher and ball until gameover
        if stats.game_active:
            catcher.update()
            gf.update_ball(ai_settings, stats, screen, catcher, balls)

        gf.update_screen(ai_settings, screen, catcher, balls)
コード例 #3
0
 def __init__(self, **opts):
   Catcher.__init__(self, **opts)
   self.stats = {}
   self.old = {}
   self.output = None
   for (stat) in Vitals.statl:
     self.stats[stat] = 0
     self.old[stat] = 0
コード例 #4
0
def update_catcher(ai_settings, screen, catcher):
    screen_rect = screen.get_rect()
    catcher.update(ai_settings, screen)
    if len(catcher) == 0:
        c = Catcher(screen)
        c.center = screen_rect.centerx
        c.rect.centerx = c.center
        c.rect.bottom = screen_rect.bottom
        catcher.add(c)
コード例 #5
0
def update_catcher(ai_settings, screen, catcher):
    screen_rect = screen.get_rect()
    catcher.update(ai_settings, screen)
    if len(catcher) == 0:
        new_catcher = Catcher(ai_settings, screen)
        new_catcher.center = screen_rect.centerx
        new_catcher.rect.centerx = new_catcher.center
        new_catcher.rect.bottom = screen_rect.bottom
        catcher.add(new_catcher)
コード例 #6
0
def update_catcher(ai_settings, screen, catcher):
    #get the rect screen position so can insert catcher_img
    screen_rect = screen.get_rect()
    catcher.update(ai_settings, screen)
    if len(catcher) == 0:
        # make a c variabe insantiate Catcher screen
        c = Catcher(ai_settings, screen)
        #at first center the catcher at screen centerx
        c.center = screen_rect.centerx
        #then the catcher rect centerx should align with c.center because have to user rect to insert the img
        c.rect.centerx = c.center
        #same center the rect_img bottom at screen bottom
        c.rect.bottom = screen_rect.bottom
        #add the catcher value from function and append the c class
        catcher.add(c)
コード例 #7
0
 def line(self, text):
   m = Armors._std_re.match(text)
   if (m and m.group(1) == 'ring'):
     self.maybe_ring = 1
   elif (not m and self.maybe_ring): # workaround since the number of lines can be +1 for two rings
     self.expects = self.expects + 1
     self.maybe_ring = 0
   return Catcher.line(self, text)
コード例 #8
0
ファイル: main.py プロジェクト: razor-87/learning-python
def run_game():
    # Initialize game, settings, and screen object.
    pygame.init()
    cat_settings = Settings()
    screen = pygame.display.set_mode(
        (cat_settings.screen_width, cat_settings.screen_height))
    pygame.display.set_caption("Catcher")

    # Create a ball and catcher.
    ball = Ball(cat_settings, screen)
    catcher = Catcher(cat_settings, screen)

    # Start the main loop for the game.
    while True:
        gf.check_events(cat_settings, screen, catcher)
        catcher.update()
        ball.update()
        gf.detect_collisions(cat_settings, screen, catcher, ball)
        gf.update_screen(cat_settings, screen, ball, catcher)
コード例 #9
0
def run_game():
    # Инициализация игры и создание объекта экрана
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Catch Balls")
    # Создание корабля
    catcher = Catcher(ai_settings, screen)
    # catchers = Group()
    # catchers.add(catcher)
    # Создание группы пришельцев
    balls = Group()
    gf.create_ball(ai_settings, screen, balls)

    # Запуск основного цика игры
    while True:
        gf.check_events(catcher)
        catcher.update()
        gf.update_balls(ai_settings, screen, balls, catcher)
        gf.update_screen(ai_settings, screen, catcher, balls)
コード例 #10
0
ファイル: catch.py プロジェクト: enlambdment/my_pcc
def run_game():
	# Initialize pygame, settings, and screen object.
	pygame.init()
	c_settings = Settings()
	screen = pygame.display.set_mode(
		(c_settings.screen_width, c_settings.screen_height))
	pygame.display.set_caption("Catch")

	# Create an instance to store game stats.
	stats = GameStats(c_settings)

	# Make a catcher and a ball.
	# The ball will be kept track of inside a group,
	# so that we can use pygame collisions method on it.
	# In order for this to work, catcher must belong 
	# inside a group of as well (even though we never
	# replace it.)

	balls = Group()
	catchers = Group()

	# Create the initial ball
	ball = Ball(c_settings, screen)
	balls.add(ball)

	# and the catcher.
	catcher = Catcher(c_settings, screen)
	catchers.add(catcher)

	# Start the main loop for the game.
	while True:
		for catcher in catchers:
			gf.check_events(c_settings, screen, catcher)

		# just as bullet positions are updated, *then*
		# all collisions checked, inside a function call
		# before updating the screen, something similar 
		# should happen inside an 'update_bullets' call

		# pass update_catcher the group containing the
		# sole catcher, since update_catcher will cal
		# a function using groupcollisions()

		if stats.game_active:
			gf.update_catcher(c_settings, screen, catchers, balls)
			gf.update_balls(c_settings, stats, screen, balls)
		
		gf.update_screen(c_settings, screen, catchers, balls)
コード例 #11
0
from catcher import Catcher

videoApi = 'http://api.bilibili.com/x/web-interface/view?aid='
aidlist = ["415066206","670085138"]
catcher = Catcher()

def getVideo(aid):
    url = videoApi+aid
    data = catcher.getRes(url)
    if data
        stat = data['stat']

        view = stat['view'] #播放数
        favorite = stat['favorite'] #收藏数
        danmaku = stat['danmaku'] #弹幕数
        reply = stat['reply'] #评论数
        coin = stat['coin'] #投币数
        share = stat['share'] #分享数
        now_rank = stat['now_rank'] #当前排名
        like = stat['like'] #点赞数

for i in aidlist:
    getVideo(i)
コード例 #12
0
 def __init__(self, **opts):
   Catcher.__init__(self, **opts)
   self.maybe_ring = 0
   return
コード例 #13
0
 def __init__(self,**opts):
   Catcher.__init__(self, **opts)
   self.seen_once = 0
   self.curr_line = 0
   return
コード例 #14
0
 def __init__(self, **opts):
   Catcher.__init__(self, **opts)
   self.pending_done = 0