コード例 #1
0
ファイル: levelscene.py プロジェクト: StickOnGit/space-frunks
 def setup(self):
     world, stage = [i + 1 for i in divmod(self.lvl, 4)]
     self.leveltxt.set_text('Level {} - {}'.format(world, stage))
     possibleAI = {1:[Scooter, Scooter],
                     2:[Scooter, Scooter],
                     3:[Sweeper, Sweeper],
                     4:[Sweeper, Sweeper]}
     kinds_of_AI = possibleAI[stage]
     if world >= 2:
         kinds_of_AI.append(Teleporter)
     if world >= 4:
         kinds_of_AI.append(Rammer)
     
     enemies = 2 + world
     for i in xrange(0, enemies):
         variance = random.randint(0, world)
         x, y = self.get_pt_in_lane()
         NewEnemy = random.choice(kinds_of_AI)(
                         x=x, y=y,
                         img=self.imgbank['RedShip'].copy(),
                         heading=random.choice(KEY_VAL.values()))
         NewEnemy.speed = int(math.floor(NewEnemy.speed * (1.05 ** variance)))
         NewEnemy.points = int(math.floor(NewEnemy.points + ((NewEnemy.points / 10) * variance)))
         NewEnemy.add(self.badq)
         self.add_obj(NewEnemy)
     if stage % 4 == 1 and world > 1:
         publish('new_heading')
コード例 #2
0
ファイル: levelscene.py プロジェクト: StickOnGit/space-frunks
 def main(self, events):
     if self.state == 'gameover':
         if self.go_to_gameover in (90, 45):
             self.gameovertxt.show(45)
         if self.go_to_gameover in (78, 23):
             self.gameovertxt.hide(45)
         self.go_to_gameover -= 1
         if self.go_to_gameover <= 0:
             publish('save', 'last_score', self.player.score)
             return False
     if self.state == 'setup':
         self.setup()
         self.state = 'play'
     if self.state == 'paused':
         for e in events:
             if e.type == pygame.KEYDOWN:
                 if e.key == pygame.K_p:
                     self.state = 'play'
         return True
     if self.state == 'play':
         for e in events:
             if e.type == pygame.KEYDOWN:
                 if e.key == pygame.K_p:
                     self.state = 'paused'
                 else:
                     self.player.handle_key(e.key)
         for goodguy in self.goodq:
             hit_list = pygame.sprite.spritecollide(goodguy, self.badq, False, self.check_hits)
             if hit_list:
                 goodguy.got_hit()
                 if goodguy is not self.player:
                     for badguy in hit_list:
                         badguy.got_hit()
                         if badguy not in self.badq and badguy.points:
                             self.player.score += badguy.points
         #maybe offset should be a class attribute
         [x.out_of_bounds() for x in [o for o in self.allq if self.offsides(o)]]
             
         if not self.player.lives:
             self.state = 'gameover'
         elif not self.badq:
             self.lvl += 1
             self.state = 'setup'
     self.allq.update()
     return True
コード例 #3
0
ファイル: gamescene.py プロジェクト: StickOnGit/space-frunks
 def _inner(*a, **k):
     return func(*a, **k), publish('play_sound', func.__name__)