Exemple #1
0
def start_game(params, name):
    pygame.init()
    clock = pygame.time.Clock()
    screen = pygame.display.set_mode(
        (params['screen']['width'], params['screen']['height']), 0, 32)
    pygame.display.set_caption('Pymagotchi')
    font = pygame.font.Font('Sans.ttf', 12)

    # Ouverture de la connexion
    connexion = PyClient(port=15130)
    Thread(target=connexion.start).start()

    # Lecture des sprites
    sprites = read_sprites(screen, params)

    # Création du Pymagotchi
    pymagotchi = Pymagotchi(name)
    connexion.hello(name)
    # Salutation
    sleep(1)
    for other_pymagotchi in connexion.get_result().split(':'):
        if other_pymagotchi != '':
            print(f'Salut : {other_pymagotchi}')

    # Initialisation du timer
    timer = Timer(pygame.time.get_ticks())

    while True:
        screen.fill(params['color']['background'])

        # Gestion des événements
        for event in pygame.event.get():
            if event.type == QUIT:
                connexion.quit()
                pygame.quit()
                exit(0)

        # Événement du Pymagotchi
        if timer.isDuration(1, pygame.time.get_ticks()):
            pymagotchi.events()

        # Affichage de l'animation
        pygame.time.wait(100)
        animation(pymagotchi.get_state(), sprites)

        # Affichage des statistiques
        statistics(screen, font, pymagotchi)

        # Mise à jour du contenu de la fenêtre
        pygame.display.update()
        clock.tick(params['screen']['fps'])
Exemple #2
0
 print "Choose one of the options below:"
 print "1. Basic Ping Request to this MOOC"
 print "2. List Courses on this MOOC"
 print "3. Get Description for a course"
 print "4. Contest Competition"
 print "5. Get More Courses from other MOOC's"
 print "6. Mock Inter-Mooc request"
 print "7. Quit"
 
 choice = int(input("\nYour Option -> "))
 if choice == 1:
     #Sending Ping Request to Server
     requestType = "ping"
     host = str(input("Enter host: "))
     port = int(input("Enter port: "))
     PyClient().chooseOperation(requestType, host, port)
 elif choice == 2:
     #Sending ListCourses Request to Server
     requestType = "listcourses"
     host = str(input("Enter host: "))
     port = int(input("Enter port: "))
     PyClient().chooseOperation(requestType, host, port)
 elif choice == 3:
     #Sending GetDescription Request to Server
     requestType = "getdescription"
     host = str(input("Enter host: "))
     port = int(input("Enter port: "))
     PyClient().chooseOperation(requestType, host, port)
 elif choice == 4:
     #Sending Competition Request to Server
     requestType = "competition"
Exemple #3
0
	client.fatal("Game over", 666)
	client.debug("Elvis has entered the building")
	client.activate().zoomout().debug("Action!!!")



### API


"""

from PyClient import PyClient
from utils import classproperty
import sys

pyclient = PyClient()


class client:
    @classmethod
    def activate(self, window_title=None):
        """
		 - `client.activate([window_title = "Die Siedler Online"])`  
		   Tries to find game window, activate it and recognize flash-plugin dimensions.  
		   Returns `self`.
		"""
        # searching and activating browser window
        if not pyclient.activate(window_title):
            self.fatal('Failed to find or activate game window')
        return self