Esempio n. 1
0
 def set_pos(self, xy, y=None):
     if y==None: x,y = xy
     else: x,y = xy, y
     self.x, self.y = x,y
     self.rect.x = ir(x - self.rect.w/2.)
     self.rect.y = ir(y - self.rect.h/2.)
Esempio n. 2
0
            if s.y > H-10:
                print 'HIT!' + ' Score:' + str(score)               
                pos = random()*world.W, random()*100  # Respawn
                vel = 100*cos(random()), 100*sin(random())
                s.set_pos( pos )
                s.set_vel( vel )
                score += 1
                if score>=points: game_over = 1                    
                

        # Screen
        screen.fill((0,0,0))
        all_sprites.draw(screen)

        for f in feet:
            pygame.draw.circle( screen, (255,255,255), ir((f.x,f.y)), 60, 0 )
            pygame.draw.circle( screen, (255,0,0), ir((f.x,f.y)), 60, 2 )

        text_score = font.render("%d" % score, 2, (255, 255, 255))
        screen.blit( text_score, (world.W/2-20, 40) )

        if game_over:
            tt = time.time() - t_start
            mini, sec = int(tt//60), int(tt%60)
            screen.blit( font_big.render("Game over", 3, (255, 255, 255)), (100, 250) )
            screen.blit( font_big.render("Time %d:%.02d" % (mini, sec), 3, (255, 255, 255)), (120,450) )

        pygame.draw.rect( screen, (255,255,255), (0,0,W,H), 10 )
        pygame.display.flip()
        
        if game_over: