Example #1
0
 def run(self):
     '''
     Función que contiene el bucle principal del juego.
     Actualiza y dibuja el estado actual.
     '''
     while not keyboard.quit():
         
         self.clock.tick(self.fps)
         
         keyboard.update()
         
         self.screen.fill((0,0,0))
         
         #self.__actual_state.update()
         #self.__actual_state.draw(screen)
         
         if keyboard.pressed(K_DOWN):
             self.circuit.move(0, self.circuit.get_y() + 50)
         elif keyboard.pressed(K_UP):
             self.circuit.move(0, self.circuit.get_y() - 50)
         
         self.circuit.draw(self.screen, 0)
         self.circuit.draw(self.screen, 1)
         self.circuit.draw(self.screen, 2)
         
         
         pygame.display.flip()
Example #2
0
 def run(self):
     '''
     Función que contiene el bucle principal del juego.
     Actualiza y dibuja el estado actual.
     '''
     while not keyboard.quit():
         
         self.clock.tick(self.fps)
         
         keyboard.update()
         
         self.button.update()
         self.button2.update()
         self.button3.update()
         
         self.screen.fill(THECOLORS['white'])
         
         self.button.draw(self.screen)
         self.button2.draw(self.screen)
         self.button3.draw(self.screen)
         
         #self.__actual_state.update()
         #self.__actual_state.draw(screen)
         
         pygame.display.flip()
Example #3
0
 def run(self):
     '''
     Función que contiene el bucle principal del juego.
     Actualiza y dibuja el estado actual.
     '''
     while not keyboard.quit():
         
         self.clock.tick(self.fps)
         
         keyboard.update()
         
         self.screen.fill((0,0,0))
         
         #self.__actual_state.update()
         #self.__actual_state.draw(screen)
         
         if keyboard.pressed(K_DOWN):
             if self.circuit.get_y() < self.circuit.get_tile_height() * self.circuit.get_height() - self.screen.get_height():
                 self.circuit.move(self.circuit.get_x(), self.circuit.get_y() + 25)
         elif keyboard.pressed(K_UP):
             if self.circuit.get_y() > 0:
                 self.circuit.move(self.circuit.get_x(), self.circuit.get_y() - 25)
         if keyboard.pressed(K_LEFT):
             if self.circuit.get_x() > 0:
                 self.circuit.move(self.circuit.get_x() - 25, self.circuit.get_y())
         elif keyboard.pressed(K_RIGHT):
             if self.circuit.get_x() < self.circuit.get_tile_width() * self.circuit.get_width() - self.screen.get_width():
                 self.circuit.move(self.circuit.get_x() + 25, self.circuit.get_y())
         
         self.circuit.draw(self.screen, 0)
         self.circuit.draw(self.screen, 1)
         self.circuit.draw(self.screen, 2)
         
         
         pygame.display.flip()
Example #4
0
    def run(self):
        '''
        @brief Función que contiene el bucle principal del juego. Actualiza y dibuja el estado actual.
        '''
        
        #Mientras no cerremos la pantalla
        while not keyboard.quit():
            
            self.clock.tick(self.fps)
            
            #Actualizamos el teclado
            keyboard.update()
            mouse.update()
            
            #Ponemos la pantalla a negro completamente
            self.screen.fill(pygame.color.THECOLORS['black'])
            
            #Actualizamos y dibujamos el estado actual
            self.__actual_state.update()
            self.__actual_state.draw(self.screen)
            
            fps = self.clock.get_fps()
            
            render_fps = self.font.render(str(round(fps, 2)), True, (0, 0, 0))

            self.screen.blit(render_fps, (730, 565))
            
            #Actualizamos la pantalla
            pygame.display.flip()
Example #5
0
    def run(self):
        '''
        @brief Función que contiene el bucle principal del juego. Actualiza y dibuja el estado actual.
        '''

        #Mientras no cerremos la pantalla
        while not keyboard.quit():

            self.clock.tick(self.fps)

            #Actualizamos el teclado
            keyboard.update()
            mouse.update()

            #Ponemos la pantalla a negro completamente
            self.screen.fill(pygame.color.THECOLORS['black'])

            #Actualizamos y dibujamos el estado actual
            self.__actual_state.update()
            self.__actual_state.draw(self.screen)

            fps = self.clock.get_fps()

            render_fps = self.font.render(str(round(fps, 2)), True, (0, 0, 0))

            self.screen.blit(render_fps, (730, 565))

            #Actualizamos la pantalla
            pygame.display.flip()
Example #6
0
    def run(self):
        '''
        Función que contiene el bucle principal del juego.
        Actualiza y dibuja el estado actual.
        '''
        while not keyboard.quit():
            
            self.clock.tick(self.fps)
            
            keyboard.update()
            
            self.screen.fill((0,0,0))
            
            ######PRUEBA MODULO GAME CONTROL##########
            
            self.__actual_state.update()
            self.__actual_state.draw(self.screen)
            
            fps = self.clock.get_fps()
            
            render_fps = self.font.render(str(round(fps, 2)), True, (0,0,0))

            self.screen.blit(render_fps, (730, 565))
            
            pygame.display.flip()
Example #7
0
def quit():
	"""
	De-initializes the whole tinygame library.

	It restores the screen and keyboard control modes.
	If you fail to call tinygame.quit() you may get terminal printing issues.
	Hence you should ensure you always call tinygame.quit() even when you leave on error using a try block:

	eg

	tinygame.initialize()
	try:
		... # game code
	finally:
		tinygame.quit()
	"""
	keyboard.quit()
	character_display.quit()
Example #8
0
 def run(self):
     '''
     Función que contiene el bucle principal del juego.
     Actualiza y dibuja el estado actual.
     '''
     while not keyboard.quit():
         
         self.clock.tick(self.fps)
         
         keyboard.update()
         
         self.screen.fill((255,255,255))
         
         if not self.__actual_state.complete():
             self.__actual_state.update()
             self.__actual_state.draw(self.screen)
         
         pygame.display.flip()
Example #9
0
    def run(self):
        """
        Función que contiene el bucle principal del juego.
        Actualiza y dibuja el estado actual.
        """
        while not keyboard.quit():

            self.clock.tick(self.fps)

            keyboard.update()
            mouse.update()

            self.screen.fill((0, 0, 0))

            if mouse.newpressed(mouse.LEFT):
                print "Presiona nuevo izquierda"
            elif mouse.pressed(mouse.LEFT):
                print "Aun presionando izquierdaaaa"
            elif mouse.release(mouse.LEFT):
                print "Soltando izquierda"

            if mouse.newpressed(mouse.CENTER):
                print "Presiona nuevo centro"
            elif mouse.pressed(mouse.CENTER):
                print "Aun presionando centro"
            elif mouse.release(mouse.CENTER):
                print "Soltando centro"

            if mouse.newpressed(mouse.RIGHT):
                print "Presiona nuevo derecha"
            elif mouse.pressed(mouse.RIGHT):
                print "Aun presionando derecha"
            elif mouse.release(mouse.RIGHT):
                print "Soltando derecha"

            print mouse.position()

            # self.__actual_state.update()
            # self.__actual_state.draw(screen)

            pygame.display.flip()
Example #10
0
 def run(self):
     '''
     Función que contiene el bucle principal del juego.
     Actualiza y dibuja el estado actual.
     '''
     while not keyboard.quit():
         
         self.clock.tick(self.fps)
         
         keyboard.update()
         
         if keyboard.pressed(K_UP) or self.__actual_state.get_status() == 'done':
             print "pulsandooo"
             #self.__actual_state = particle.SystemParticle(400, 300, ['particle', 'particle2'], 100, 1, 10, 300, 1)
             self.__actual_state.restart()
                 
         self.screen.fill((255,255,255))
         
         self.__actual_state.update()
         self.__actual_state.draw(self.screen)
         
         pygame.display.flip()
Example #11
0
 def run(self):
     '''
     Función que contiene el bucle principal del juego.
     Actualiza y dibuja el estado actual.
     '''
     while not keyboard.quit():
         
         self.clock.tick(self.fps)
         
         keyboard.update()
         
         for button in self.buttons:
             button.update()
             if button.get_selected() and pygame.mouse.get_pressed()[0]:
                 self.treat_option(button.get_option())
         
         self.timer.update()
         self.timer2.update()
         self.timer3.update()
         
         self.screen.fill(THECOLORS['white'])
         
         for button in self.buttons:
             button.draw(self.screen)
             
         self.timer.draw(self.screen)
         self.timer2.draw(self.screen)
         self.timer3.draw(self.screen)
         #self.__actual_state.update()
         #self.__actual_state.draw(screen)
         
         if self.__start and time.time() - self.__start >= 5:
             self.__start = time.time()
             if self.timer2.less_than(self.timer):
                 self.timer2.assign(self.timer)
             elif self.timer2.more_than(self.timer):
                 print "Es mayoooor"
         
         pygame.display.flip()
Example #12
0
    def run(self):
        """
        @brief Función que contiene el bucle principal del juego. Actualiza y dibuja el estado actual.
        """

        # Mientras no cerremos la pantalla
        while not keyboard.quit():

            self.clock.tick(self.fps)

            # Actualizamos el teclado
            keyboard.update()
            mouse.update()

            # Ponemos la pantalla a negro completamente
            self.screen.fill(THECOLORS["black"])

            # Actualizamos y dibujamos el estado actual
            self.__actual_state.update()
            self.__actual_state.draw(self.screen)

            # Actualizamos la pantalla
            pygame.display.flip()
Example #13
0
    def run(self):
        '''
        Función que contiene el bucle principal del juego.
        Actualiza y dibuja el estado actual.
        '''
        while not keyboard.quit():
            
            self.clock.tick(self.fps)
            
            keyboard.update()
            
            self.screen.fill((0,0,0))
            
            ######PRUEBA MODULO PLAYER CAR##########

            self.car.update()
            #self.car2.update()
            self.car.draw(self.screen)
            #self.car2.draw(self.screen)
            
            #self.__actual_state.update()
            #self.__actual_state.draw(screen)
            
            pygame.display.flip()