Esempio n. 1
0
class ScreenManager:
    def __init__(self):
        
        pygame.init()
        
        self.screen = pygame.display.set_mode((640,480))
        pygame.display.set_caption('Pygame - Snake')
        #self.current_screen = GameScreen(self.screen)
        self.current_screen = MenuScreen(self.screen)
        self.clock = pygame.time.Clock()
        
    def run(self):
        
        while 1:            
            new_time = pygame.time.get_ticks()
            
            for event in pygame.event.get():
                
                if event.type == pygame.QUIT:
                    sys.exit()
                else:
                    self.current_screen.manageEvents(event)
                    
            self.current_screen = self.current_screen.update()
            
            #clear screen
            self.screen.fill(Defines.BLUE)
            
            self.current_screen.render()
            
            pygame.display.flip()
            self.clock.tick(5)
Esempio n. 2
0
 def __init__(self):
     
     pygame.init()
     
     self.screen = pygame.display.set_mode((640,480))
     pygame.display.set_caption('Pygame - Snake')
     #self.current_screen = GameScreen(self.screen)
     self.current_screen = MenuScreen(self.screen)
     self.clock = pygame.time.Clock()
Esempio n. 3
0
 def __init__(self):
     pygame.mixer.pre_init(frequency=44100,
                           size=-16,
                           channels=2,
                           buffer=512)
     pygame.init()
     pygame.mixer.init()
     pygame.display.set_caption('S N A K E')
     pygame.mouse.set_visible(True)
     self.snakeSpeed = config.SNAKE_SPEED
     self.display = pygame.display.set_mode(
         (config.DIS_WIDTH, config.DIS_HEIGHT))
     self.clock = pygame.time.Clock()
     self.menuScreen = MenuScreen()
     self.gameScreen = GameScreen()
     self.menuScreen.gameScene = self.gameScreen
     self.gameScreen.menuScene = self.menuScreen