예제 #1
0
def login_clicked(dialog):
    email = dialog.line_email.text()
    password = dialog.line_password.text()
    if email == "" or password == "":
        dialog.lbl_notification.setText(
            "Tolong isi email dan password dengan benar")
        return
    if not lq.isEmailExist(email):
        dialog.lbl_notification.setText(
            "Email belum terdaftar, silahkan register")
        clear(dialog)
        return
    loginInfo = lq.getLoginInfo(email)
    databasePass = loginInfo[0]
    databaseRole = loginInfo[1]
    if password != databasePass:
        dialog.lbl_notification.setText("Password salah")
        clear(dialog)
        return
    clear(dialog)
    dialog.close()
    # Jika password benar, maka akan ke Main Menu
    if databaseRole == 'Customer':  # Kasus akun adalah customer
        main_page = mainmenu.MainMenu(email)
    else:  # Kasus akun adalah Admin
        main_page = mainmenuAdmin.MainMenuAdmin(email)
    main_page.show()  # Memperlihatkan main menu
    return
예제 #2
0
    def input(self, events):
        """input handler method

        This method handles all user's input and passes them to the right game object.

        """
        for event in events:
            if event.type == QUIT:
                sys.exit(0)
            elif event.type == KEYDOWN:
                if (event.key == K_q) or (event.key == K_ESCAPE):
                    #print 'q/Q/Esc'
                    if pygame.key.get_mods() & (KMOD_LSHIFT | KMOD_SHIFT):
                        # panic quit
                        pygame.event.post(pygame.event.Event(QUIT))
                    e = self.show_message("quit game [y/n]?",
                                          allowed_keys=[K_y, K_n, K_ESCAPE])
                    if e.key == K_y:
                        mainmenu.MainMenu(self.screen)
                elif (event.key == K_LEFT or event.key == K_RIGHT
                      or event.key == K_UP or event.key == K_DOWN):
                    self.spaceship.control(event.type, event.key)
                if pygame.key.get_mods() & (KMOD_LCTRL | KMOD_RCTRL):
                    if not self.spaceship.get_exploding():
                        bullet = self.spaceship.fire_bullet()
                        bullet.add(self.group_bullets)
                        self.d_sounds['shoot'].play()
                if pygame.key.get_mods() & (KMOD_LALT | KMOD_RALT):
                    self.spaceship.hyperspace()
            elif event.type == KEYUP:
                if (event.key == K_LEFT or event.key == K_RIGHT
                        or event.key == K_UP or event.key == K_DOWN):
                    self.spaceship.control(event.type, event.key)
            else:
                pass
예제 #3
0
파일: results.py 프로젝트: wolmir/cristina
    def goHome(self):
        # We create a new layer, an instance of HelloWorld
        hello_layer = mainmenu.MainMenu()  #gameplay.GamePlay()

        # A scene that contains the layer hello_layer
        main_scene = cocos.scene.Scene(hello_layer)

        # And now, start the application, starting with main_scene
        cocos.director.director.run(main_scene)
예제 #4
0
    def treat_option(self, option):
        '''
        @brief Función encargada de tratar la opción actual del menú seleccionada
        '''
        if option == "Aceptar":
            print "Aceptar"
            self.save_options()
            self.game.change_state(
                mainmenu.MainMenu(self.game, 'menu/mainmenu.xml'))

        elif option == "Cancelar":
            print "Cancelar"
            self.game.change_state(
                mainmenu.MainMenu(self.game, 'menu/mainmenu.xml'))

        elif option == "Sonido":
            self.actual_layer = "Sonido"

        elif option == "Pantalla":
            self.actual_layer = "Pantalla"

        elif option == "Controles":
            self.actual_layer = "Controles"

        elif option == "DerechaDireccion":
            print "DerechaDireccion"
            if self.direction == 'letters':
                self.direction = 'rows'
            else:
                self.direction = 'letters'

        elif option == "DerechaItem":
            print "DerechaItem"
            if self.item == 'space':
                self.item = 'enter'
            else:
                self.item = 'space'

        elif option == "DerechaPausa":
            print "DerechaPausa"
            if self.pause == 'p':
                self.pause = 'esc'
            else:
                self.pause = 'p'
예제 #5
0
 def __init__(self):
     self.pal_control = palette.PaletteControl()
     
     self.screen_shake = screenshake.ScreenShake(self)
     
     self.main_menu = mainmenu.MainMenu(self)
     self.stage = stage.Stage(self, 0)
     self.hud = hud.Hud(self)
     
     self.pal_index = 0
     
     audio.play_music(audio.MUS_TITLE, True)
예제 #6
0
 def treat_option(self, option):
     '''
     @brief Método encargado de manejar las opciones del menú
     '''
     if option == "Reanudar":
         print "Elegido: Reanudar"
         self.game_control.set_state('race')
     elif option == u"Menú":
         print "Elegido: Menú"
         self.game.change_state(
             mainmenu.MainMenu(self.game, 'menu/mainmenu.xml'))
     elif option == "Reiniciar":
         print "Ha elegido: Reinicar"
         self.game_control.reboot_race()
예제 #7
0
 def start(self, level_filename=None):
     self.window = pyglet.window.Window(width=self.width,
                                        height=self.height,
                                        caption="Lemming")
     try:
         self.window.set_icon(pyglet.resource.image('icon.png'))
     except AttributeError:
         pass
     self.level_filename = level_filename
     if level_filename is None:
         self.current_screen = mainmenu.MainMenu(self)
         self.current_screen.start()
     else:
         self.current_screen = levelplayer.LevelPlayer(
             self, open(level_filename, 'rb'))
         self.current_screen.start()
     pyglet.app.run()
예제 #8
0
 def startMainMenu(self):
     # By Nisha
     self.Window = main_menu.MainMenu(self)
     self.setWindowTitle("North Spine Food Explorer")
     self.setCentralWidget(self.Window)
     for x in range(25):
         self.Window.btn[x].clicked.connect(
             partial(self.startStallMenu, info.stalls_list[x]))
     # If time has been set by user, then don't run live timer, just show the user-set time.
     # But if it's not, it will throw an error, which we want to avoid, so just do nothing for the error
     try:
         if "Set Time: " in self.StallMenu.time_label.text():
             self.Window.timer.stop()
             self.Window.time_label.setText(
                 self.StallMenu.time_label.text())
     except:
         pass
     self.show()
예제 #9
0
파일: game.py 프로젝트: Subserial/PyArchery
    def initGame(self):
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA,
                    GL_ONE_MINUS_SRC_ALPHA)  # Enable transparency
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
        glEnable(GL_DEPTH_TEST)
        glDepthFunc(
            GL_LEQUAL)  # Depth must be lower to be placed above other objects.
        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
        glViewport(0, 0, self.width, self.height)  # Basic window size.

        self.addScreen(mainmenu.MainMenu(self.width, self.height,
                                         visible=True),
                       "main")  # Add initial menu
        self.addScreen(
            pauseScreen.PauseScreen(self.width, self.height, visible=False),
            "pause")  # Pause functionality via escape key
        pygame.mouse.set_visible(False)
        pygame.event.set_grab(True)  # Lock the cursor to the pygame window
예제 #10
0
    def log_in(self):
        """
        Esta funcion crea el objeto magizoologo asociado al nombre de
        usuario y lo ocupa como argumento al llamar a la funcion MainMenu
        """

        # usuarios con toda la informacion en el archivo magizoologos.csv
        usuarios_registrados = self.usuarios_registrados(solo_nombres=False)
        # nombres de magizoologos para chequear existencia
        nombres = self.usuarios_registrados(solo_nombres=True)

        usuario_input = input("\nNombre de Usuario : ")

        # ignorar mayusculas
        if usuario_input.lower() in nombres:
            for info in usuarios_registrados:
                nombre = info.pop(0)
                tipo = info.pop(0)
                if usuario_input.lower() == nombre.lower():
                    if tipo == "Docencio":
                        magizoologo = magizoologos.Docencio(nombre)
                    elif tipo == "Tareo":
                        magizoologo = magizoologos.Tareo(nombre)
                    elif tipo == "Híbrido":
                        magizoologo = magizoologos.Hibrido(nombre)

                    # argumento de modificar_parametros() del magizoologo
                    informacion = info

            # hacer override a los atributos generados random por los ya existentes
            magizoologo.modificar_parametros(*informacion)
            # guardar objeto magizoologo
            self.magizoologo = magizoologo
            # guardar nombre de magizoologo aparte por conveniencia
            self.usuario = magizoologo.nombre
            print(f"\nBienvenido(a) {self.usuario}")
            # instanciar menu de acciones con usuario loggeado como argumento
            siguiente_menu = mainmenu.MainMenu(self.usuario, self.magizoologo)
            # ir a la interfaz del menu de acciones
            siguiente_menu.interfaz()

        else:
            print("\nUsuario inexistente")
예제 #11
0
    def treat_option(self, option):
        '''
        @brief Método que se llama cuando se pulsa algun boton
        '''
        #Si pulsamos el botón de aceptar
        if option == "Aceptar":
            #Guardamos el coche seleccionado
            selected_player = self.group_option.actual_selected()
            print "Aceptar"
            print "Jugador Elegido:" + self.cars[selected_player]['path_xml']
            config.Config().set_player(self.cars[selected_player]['path_xml'])

            config.Config().clear_competitors()
            #Si el modo de juego no es Contrarreloj, obtenemos los rivales
            if config.Config().get_mode() != config.TIMED:
                #Obtenemos los rivales
                rivals = self.get_rivals(selected_player)

                #Los añadimos a la configuracion
                for rival in rivals:
                    config.Config().add_competitor(
                        self.cars[rival]['path_xml'])

                print "Rivales :", config.Config().get_competitors()

            #Si estamos en modo contrarreloj cargamos el menu Contrarreloj
            if config.Config().get_mode() == config.TIMED:
                self.game.change_state(
                    circuitmenu.CircuitMenu(self.game, 'menu/cronomenu.xml'))

            #Si estamos en Carrera Rápida cargamos el menú de Carrera Rápida
            elif config.Config().get_mode() == config.FASTRACE:
                self.game.change_state(
                    circuitmenu.CircuitMenu(self.game,
                                            'menu/fastracemenu.xml'))

            elif config.Config().get_mode() == config.CHAMPIONSHIP:
                self.game.change_state(
                    circuitmenu.CircuitMenu(self.game,
                                            'menu/fastracemenu.xml'))

        #Si pulsamos cancelar
        elif option == "Cancelar":
            #Volveriamos al menú anterior
            print "Cancelar"
            self.game.change_state(
                mainmenu.MainMenu(self.game, 'menu/mainmenu.xml'))

        #Si pulsamos la felcha hacia la izquierda
        elif option == "Izquierda":

            #Y no estaba el ratón pulsado anteriormente
            if self.new_pressed:
                print "Izquierda"
                #Movemos hacia la izquierda el grupo de opciones
                self.group_option.move_right()

                #Coche actual
                selected_car = self.group_option.actual_selected()

                self.update_car_features(selected_car)

        #Si pulsamos la flecha hacia la derecha
        elif option == "Derecha":
            #Y no estaba el ratón pulsado anteriormente
            if self.new_pressed:
                print "Derecha"
                #Movemos el grupo de opciones
                self.group_option.move_left()

                #Coche actual
                selected_car = self.group_option.actual_selected()

                self.update_car_features(selected_car)
예제 #12
0
    def run(self, level=1):
        """Game main method"""

        # game clock
        clock = pygame.time.Clock()

        # hide mouse pointer
        pygame.mouse.set_visible(False)

        # test font system
        if pygame.font.get_init() == True:
            print "font system initialized"
        else:
            print "font system not initialized"

        # generating objects
        self.spaceship = SpaceShip(self.screen.get_rect())

        # generating groups of sprites
        self.group_bullets = pygame.sprite.RenderUpdates()
        self.group_rocks = pygame.sprite.RenderUpdates()
        for i in xrange(self.level):
            self.group_rocks.add(Rock(self.screen.get_rect()))
        self.group_spaceship = pygame.sprite.Group((self.spaceship))

        # initial position for the objects
        self.spaceship.move_to(
            (self.screen.get_rect()[2] / 2, self.screen.get_rect()[3] / 2))

        # set players vars
        self.player_lives = PLAYER_LIVES

        # set lives surface
        if pygame.font:
            (lives_surface, lives_rect) = self.get_lives_surface()
            (score_surface, score_rect) = self.get_lives_surface()

        self.show_message("get ready", timeout=1)

        while True:
            # time-ticks
            clock.tick(GAME_FRAMERATE)

            # handle events
            self.input(pygame.event.get())

            # update sprite groups
            self.group_rocks.update()
            self.group_spaceship.update()
            self.group_bullets.update()

            # draw everything
            self.screen.blit(self.background, (0, 0))
            self.group_bullets.draw(self.screen)
            self.group_rocks.draw(self.screen)
            if not self.spaceship.get_exploding():
                self.group_spaceship.draw(self.screen)

            # update score
            if pygame.font:
                (score_surface, score_rect) = self.get_score_surface()

            # update game status
            if self.player_lives == 0:
                self.screen.blit(self.background, (0, 0))  # blank bg
                self.show_message("GAME OVER", timeout=2)
                mainmenu.MainMenu(self.screen)

            if len(self.group_rocks.sprites()) == 0:
                self.screen.blit(self.background, (0, 0))  # blank bg
                self.show_message("LEVEL CLEAR", timeout=2)
                self.level += 1
                self.group_bullets.empty()
                self.group_rocks.empty()
                for i in xrange(self.level):
                    self.group_rocks.add(Rock(self.screen.get_rect()))
                self.spaceship.reset()

            # collision spaceship-rocks
            if (self.spaceship.get_exploding() == False
                    and pygame.sprite.spritecollideany(self.spaceship,
                                                       self.group_rocks)):
                print "debug: spaceship hits a rock!"
                self.player_lives -= 1
                self.spaceship.explode()
                # update lives surface
                if pygame.font:
                    (lives_surface, lives_rect) = self.get_lives_surface()

            # collision bullets-rocks
            dict_bullets_rocks_collision = pygame.sprite.groupcollide(
                self.group_bullets, self.group_rocks, True, True)
            if len(dict_bullets_rocks_collision) > 0:
                # a bullet collides with one or more rocks
                # every rock will be divided in two half-rock until it reaches ROCK_MIN_RADIOUS
                for b in dict_bullets_rocks_collision:
                    for r in dict_bullets_rocks_collision[b]:
                        # rock explosion and division
                        r_pos = r.get_pos()
                        r_radious = r.get_radious()
                        self.group_rocks.remove(r)
                        # score
                        self.spaceship.add_to_score(ROCK_RADIOUS_MAX -
                                                    r_radious +
                                                    ROCK_RADIOUS_MIN)
                        del (r)
                        if r_radious > ROCK_RADIOUS_MIN:
                            self.group_rocks.add(
                                Rock(self.screen.get_rect(),
                                     pos=r_pos,
                                     radious=r_radious / 2))
                            self.group_rocks.add(
                                Rock(self.screen.get_rect(),
                                     pos=r_pos,
                                     radious=r_radious / 2))
                    # destroy bullet
                    self.group_bullets.remove(b)
                    del (b)

            # text on screen
            if pygame.font:
                self.screen.blit(lives_surface, lives_rect)
                self.screen.blit(score_surface, score_rect)
                if self.spaceship.get_exploding():
                    self.screen.blit(*self.get_message_surface(
                        'spaceship destroyed! :(',
                        position=self.screen.get_rect().center))

            # flip
            pygame.display.flip()
예제 #13
0
from constants import *
import mainmenu
import overworld
import os

if __name__ == "__main__":
    # Use
    os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (0, 0)
    # Initialize the pygame library
    pygame.init()
    # Create screen
    size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
    screen = pygame.display.set_mode(size, pygame.NOFRAME)
    # Set window title
    pygame.display.set_caption("Food War")
    # Used to manage how fast the screen updates
    clock = pygame.time.Clock()
    # Initialize the joysticks
    pygame.joystick.init()

    current_surface = mainmenu.MainMenu(screen)
    load = current_surface.run()
    current_surface = overworld.OverworldScreen(screen, load)
    current_surface.run()
예제 #14
0
파일: modes.py 프로젝트: jmarente/zycars
 def go_on(self):
     '''
     @brief Vuelve al menú principal
     '''
     self.game.change_state(
         mainmenu.MainMenu(self.game, 'menu/mainmenu.xml'))
예제 #15
0
파일: modes.py 프로젝트: jmarente/zycars
 def complete_championship(self):
     '''
     @brief Termina el campeonato y volvemos al menú principal
     '''
     self.game.change_state(
         mainmenu.MainMenu(self.game, 'menu/mainmenu.xml'))
예제 #16
0
import os, sys, random, pygame
from pygame.locals import *
import mainmenu
game = mainmenu.MainMenu()
game.game()