Beispiel #1
0
def main():

    #creacion de objetos para el programa
    bg = background.background(settings.pantalla,'01.png',alpha = True)
    mouse = cursor.cursor()
    bgmusic = bgm.bgm("003.mp3")
    running = True
    directorio = os.getcwd()


    #acciones de uso unico
    bgmusic.play(inicio = 2.0)

    #bucle principal
    while running:
        #variables que se comprueban cada bucle


        #lista de los eventos que se ejecutaron
        for evento in pygame.event.get():
            if evento.type == pygame.QUIT:
                running = False

        #actualizacion de objetos en pantalla
        bg.update()
        mouse.update()
        if not(running): bgmusic.stop()
    
        #actualizamos la pantalla
        pygame.display.flip()
        settings.reloj.tick(60)
Beispiel #2
0
def main():

    #creacion de objetos para el programa
    bg = background.background(settings.pantalla,'00.jpg')

    #configuramos boton principal
    boton = button.button(settings.pantalla,posicion=(40,450))
    boton.agregar_img('00.png')
    boton.agregar_img('01.png')
    boton.agregar_img('02.png')
    boton.actual(0)
    
    mouse = cursor.cursor()
    bgmusic = bgm.bgm("001.mp3")
    running = True
    directorio = os.getcwd()

    #acciones de uso unico
    bgmusic.play()

    #bucle principal
    while running:
        #variables que se comprueban cada bucle
            

        #lista que contiene todos los eventos que se ejecutaron
        for evento in pygame.event.get():
            if evento.type == pygame.MOUSEBUTTONUP:
                if evento.button == 1:
                    if boton.rectangulo.left < mouse.posicion[0] < boton.rectangulo.right and boton.rectangulo.top < mouse.posicion[1] < boton.rectangulo.bottom:
                        s1.main()
                        running = False
                        
                        
            if evento.type == pygame.QUIT:
                running = False


        #opciones de posicion del mouse
        if mouse.posicion[0] > boton.rectangulo.right or \
           mouse.posicion[0] < boton.rectangulo.left or \
           mouse.posicion[1] > boton.rectangulo.bottom or \
           mouse.posicion[1] < boton.rectangulo.top:
            boton.actual(0)
        else:
            if mouse.estado[0]:
                boton.actual(2)
            if not(mouse.estado[0]):
                boton.actual(1)

        #Actualizamos posicion de las cosas
        bg.update()
        boton.update()
        mouse.update()
        if not(running): bgmusic.stop()
        
        #actualizamos la pantalla
        pygame.display.flip()
        settings.reloj.tick(60)                     #60 frames por segundo
Beispiel #3
0
def main():
    # ================== setup myo-python (do not change) =====================
    myo.init(sdk_path='../../myo_sdk')  # Compile Python binding to Myo's API
    hub = myo.Hub()  # Create a Python instance of MYO API
    if not ConnectionChecker(
    ).ok:  # Check connection before starting acquisition:
        quit()
    # =========================================================================
    # calculate the Mean Absolute Value
    # Setup our custom processor of MYO's events.
    # EmgBuffer will acquire new data in a buffer (queue):
    listener = Buffer(
        buffer_len=512
    )  # At sampling rate of 200Hz, 512 samples correspond to ~2.5 seconds of the most recent data.
    calculate = Feature(input_len=512)
    # Setup multichannel plotter for visualisation:
    plotter = MultichannelPlot(
        nchan=8, xlen=512
    )  # Number of EMG channels in MYO armband is 8 , window size is 15 for MAV
    freq = 200
    move = cursor(freq)

    # Tell MYO API to start a parallel thread that will collect the data and
    # command the MYO to start sending EMG data.
    with hub.run_in_background(
            listener
    ):  # This is the way to associate our listener with the MYO API.
        print('Streaming EMG ... Press shift-c to stop.')
        while hub.running:
            time.sleep(0.040)
            # Pull recent EMG data from the buffer
            emg_data = listener.get_emg_data()
            # Transform it to numpy matrix
            emg_data = np.array([x[1] for x in emg_data])

            # avoid len() report error
            if (emg_data.ndim == 2):
                if (emg_data.shape[0] == 512):
                    # calculate MAV of emg data
                    mav_data = calculate.MAV(emg_data)
                    mav_data = np.array(mav_data.T)

                    plotter.update_plot(mav_data)

                    move.move_cursor(mav_data)

            if keyboard.is_pressed('C'):
                print('Stop.')
                break
Beispiel #4
0
    def refreshCursors(self):
        
        lim = len(self.cursors)
        self.cursors = []
        
        res = len(self.exp[self.ui.slide1.value()-1][-1].peaks)

        for i in xrange(lim):
            curveInd = len(self.exp[self.ui.slide1.value()-1])-1
            currName = self.ui.cursCmbBox.itemText(i)
            for k in self.cursColors.keys():
                if currName in self.cursColors[k]:
                    currInd = i
            self.cursors.append(cursor(self.ui.grafo.plotItem,curveInd,True,True,'+',self.cursColors[currInd][1]))
            QtCore.QObject.connect(self.cursors[-1], QtCore.SIGNAL(_fromUtf8("moved()")), self.updateCursNums)
Beispiel #5
0
 def addCursor(self):
     
     curveInd = len(self.exp[self.ui.slide1.value()-1])-1
     lim = len(self.cursors)
     currInd = lim
     for i in xrange(lim):
         currName = self.cursColors[i][0]
         names = []
         for c in xrange(self.ui.cursCmbBox.count()):
             names.append(self.ui.cursCmbBox.itemText(c))
         if currName not in names:
             currInd = i
             break
     self.cursors.append(cursor(self.ui.grafo.plotItem,curveInd,True,True,'+',self.cursColors[currInd][1]))
     self.ui.cursCmbBox.addItem(self.cursColors[currInd][0])
     self.ui.cursCmpCmbBox.addItem(self.cursColors[currInd][0])
     
     self.ui.cursCmbBox.setCurrentIndex(currInd)
     QtCore.QObject.connect(self.cursors[self.ui.cursCmbBox.currentIndex()], QtCore.SIGNAL(_fromUtf8("moved()")), self.updateCursNums)
     if len(self.cursors) == 4:
         self.ui.addCursBtn.setEnabled(False)
     if not self.ui.removeCursBtn.isEnabled():
         self.ui.removeCursBtn.setEnabled(True)
def main():

    #creacion de objetos para el programa
    bg = background.background(settings.pantalla,
                               "01.png",
                               alpha=True,
                               posicion=settings.screen_center)
    barra = img.img(settings.pantalla,
                    "001.png",
                    posicion=settings.screen_center)

    #control de los textos
    l0 = text.text(settings.pantalla,
                   color=(255, 255, 255),
                   nombre="COOPBL.ttf",
                   tamano=settings.text_tamano_1,
                   posicion=(40, 405),
                   linea=u"Marcelo")
    l1 = text.text_anim_01(settings.pantalla,
                           nombre="ARLRDBD.ttf",
                           tamano=settings.text_tamano_1,
                           velocidad=settings.text_speed_1,
                           color=(255, 255, 255),
                           posicion=(25, 455),
                           linea=u"Puta, y ahora como chucha voy a permutar ")
    l2 = text.text_anim_01(settings.pantalla,
                           nombre="ARLRDBD.ttf",
                           tamano=settings.text_tamano_1,
                           velocidad=settings.text_speed_1,
                           color=(255, 255, 255),
                           posicion=(25, 495),
                           linea=u"transgénicos...")
    l3 = text.text_anim_01(settings.pantalla,
                           nombre="ARLRDBD.ttf",
                           tamano=settings.text_tamano_1,
                           velocidad=settings.text_speed_1,
                           color=(255, 255, 255),
                           posicion=(25, 535),
                           linea="")
    lista = [l1, l2, l3]

    #marcelo
    marcelo = sprites.personaje(settings.pantalla, posicion=(-300, 450))
    marcelo.add("marcelo.png")
    marcelo.add("marcelo01.png")
    x2 = pygame.transform.scale2x(marcelo.imagenes[0])
    marcelo.imagenes[0] = x2
    x3 = pygame.transform.scale2x(marcelo.imagenes[1])
    marcelo.imagenes[1] = x3
    marcelo.current(0)
    marcelo.anim_01((150, 450), 180)

    #marmota
    marmota = sprites.personaje(settings.pantalla, posicion=(1000, 450))
    marmota.add("marmota.png")
    marmota.add("marmota01.png")

    #utiles
    indicador = 0

    mouse = cursor.cursor()
    bgmusic = bgm.bgm("003.mp3")
    running = True

    #acciones de uso unico
    bgmusic.play(inicio=2.0)

    #bucle principal
    while running:
        #variables que se comprueban cada bucle

        #lista de los eventos que se ejecutaron
        for evento in pygame.event.get():
            if evento.type == pygame.KEYDOWN:
                if evento.key == pygame.K_z:
                    marcelo.end_anim_01()
                    marmota.end_anim_01()
                    if not (l3.renderizado):
                        for linea in lista:
                            linea.velocidad = 5000
                    else:
                        indicador += 1

            if evento.type == pygame.KEYUP:
                if evento.key == pygame.K_z:
                    for linea in lista:
                        if indicador == 16:
                            break
                        linea.velocidad = settings.text_speed_1

            if evento.type == pygame.QUIT:
                running = False

        #manejo de textos
        if indicador == 1:
            indicador += 1
            marcelo.current(1)
            marmota.current(0)
            #modificamos textos
            l0.line(u"Voz Sexona")
            lista[0].void_line(
                u"Solo tienes que viajar hacia el mar Atlántico")
            lista[1].void_line("")
            lista[2].void_line("")

        if indicador == 3:
            indicador += 1
            marcelo.current(0)
            marmota.current(1)
            #modificamos textos
            l0.line(u"Marcelo")
            lista[0].void_line(u"Ohh! Pero que sorpresa!")
            lista[1].void_line("")
            lista[2].void_line("")

        if indicador == 5:
            indicador += 1
            marmota.anim_01((600, 450), 180)

            #modificamos los textos
            l0.line(u"Marcelo")
            lista[0].void_line(
                u"Es una marmota sexona índica magnética leedora ")
            lista[1].void_line(u"de mentes transversales impulsadas hacia el ")
            lista[2].void_line(u"infinito y lo desconocido!")

        if indicador == 7:
            indicador += 1
            marcelo.current(1)
            marmota.current(0)
            #modificamos los textos
            l0.line(u"Marmota Sexona")
            lista[0].void_line(u"No tienes porque sorpenderte hijo mio")
            lista[1].void()
            lista[2].void()

        if indicador == 9:
            indicador += 1
            marcelo.current(0)
            marmota.current(1)
            #modificamos los textos
            l0.line(u"Marcelo")
            lista[0].void_line(u"Dame una buena razón para no sorpenderme")
            lista[1].void()
            lista[2].void()

        if indicador == 11:
            indicador += 1
            marcelo.current(1)
            marmota.current(0)
            #modificamos los textos
            l0.line(u"Jesucristo")
            lista[0].void_line(
                u"Lo que pasa es que soy Jesucristo, pero se me")
            lista[1].void_line(u"perdió mi gorro y tengo que ir a buscarlo")
            lista[2].void_line(u"")

        if indicador == 13:
            indicador += 1
            marmota.anim_01((1000, -200), 60)

            #modificamos los textos
            l0.line(u"Jesucristo")
            lista[0].void_line(u"así que chaoo chaoo nos vemos, no olviden")
            lista[1].void_line(
                u"rendirme culto y subscribirse a la iglesia católica,")
            lista[2].void_line(u"soy Jesucristo y te deseo buenas noches.")

        if indicador == 15:
            indicador += 1
            marcelo.current(0)
            marmota.current(1)
            #modificamos textos
            l0.line(u"Marcelo")
            lista[0].velocidad = 2
            lista[0].void_line(u". . .")
            if lista[0].renderizado: lista[0].velocidad = settings.text_speed_1
            lista[1].void()
            lista[2].void()

        #termino de la pantalla
        if indicador == 17:
            running = False
            s3.main()

        #actualizacion de objetos en pantalla
        bg.update()
        mouse.update()
        marcelo.update()
        marmota.update()
        barra.update()
        l0.update()
        text.texto_lista_update(lista)
        if not (running): bgmusic.stop()

        #actualizamos la pantalla
        if running: pygame.display.flip()
        settings.reloj.tick(60)
Beispiel #7
0
 def cursor(self, cursor_factory=None):
     return cursor(self.connection,
                   cursor_factory or self.default_cursor,
                   self.hstore,
                   self.log,
                   self.logf)
Beispiel #8
0
def main():

    #creacion de objetos para la pantalla
    bg = background.background(settings.pantalla,
                               "02.png",
                               posicion=settings.screen_center)

    l0 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 50),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l1 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 100),
                           linea=u"Marcelo Salas emprendió su viaje hacia el",
                           velocidad=settings.text_speed_2)
    l2 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 150),
                           linea=u"mar Atlántico, donde se encontraban sus",
                           velocidad=settings.text_speed_2)
    l3 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 200),
                           linea=u"transgénicos.",
                           velocidad=settings.text_speed_2)
    l4 = text.text_anim_01(
        pantalla=settings.pantalla,
        nombre="COOPBL.ttf",
        color=(255, 255, 255),
        tamano=settings.text_tamano_2,
        posicion=(settings.WIDTH / 10 - 20, 250),
        linea=u"                                                          ",
        velocidad=settings.text_speed_2)
    l5 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 300),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l6 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 350),
                           linea=u"Su viaje duro 30 años y 2 segundos hasta",
                           velocidad=settings.text_speed_2)
    l7 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 400),
                           linea=u"que llegó al tan anhelado mar Atlántico.",
                           velocidad=settings.text_speed_2)
    l8 = text.text_anim_01(
        pantalla=settings.pantalla,
        nombre="COOPBL.ttf",
        color=(255, 255, 255),
        tamano=settings.text_tamano_2,
        posicion=(settings.WIDTH / 10 - 20, 450),
        linea=u"                                                            ",
        velocidad=settings.text_speed_2)
    l9 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 500),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    lis = [l0, l1, l2, l3, l4, l5, l6, l7, l8, l9]
    parrafo = text.group_text(lis)

    mouse = cursor.cursor()
    bgmusic = bgm.bgm()

    running = True

    while running:
        #variables que se comprueban cada bucle

        #control de eventos
        for evento in pygame.event.get():
            if evento.type == pygame.QUIT:
                running = False
                bgmusic.fadeout(1000)

        #manejo de textos
        if parrafo.contador == 1 and parrafo.renderizado == True:

            parrafo.void()

            l2.line(u"Al llegar a este mar, divisó una manzana")
            l3.line(u"gigante que flotaba sobre una ballena que")
            l4.line(u"comía uretras del fósil de un mamut")
            l5.line(u"congelado que data de aproximadamente")
            l6.line(u"30.000 Mickeys.")
            l7.line(
                u"                                                            "
            )

        if parrafo.contador == 2 and parrafo.renderizado == True:

            parrafo.void()

            l1.line(u"Marcelo Salas rápidamente fue navegando")
            l2.line(u"hacia el (Por cierto, Marcelo Salas viaja")
            l3.line(u"por el mar con el cuerpo del Padre Pío) ")
            l4.line(u"hasta que finalmente llegó hasta la manzana. ")
            l5.line(u"                                           ")
            l6.line(u"Pero, al llegar a esta manzana fue  ")
            l7.line(u"teletransportado a un lugar oscuro.")
            l8.line(u"                                                  ")

        #paso a la siguiente pantalla
        if parrafo.contador == 3:
            running = False
            bgmusic.fadeout(1000)
            s4.main()

        #actualizacion de objetos en pantalla
        bg.update()
        parrafo.update()

        #actualizamos pantalla
        if running: pygame.display.flip()
        settings.reloj.tick(60)
Beispiel #9
0
def main():
    pygame.init()
    # menu check server or client
    mennu()
    screen = pygame.display.set_mode(DISPLAY)
    timer = pygame.time.Clock()

    # klavisha press
    iszoomincres = False
    iszoomdecres = False
    isrotaterigth = False
    isrotateleft = False
    isrotateup = False
    isrotatedown = False
    ismovecamup = False
    ismovecamdown = False
    ismovecamleft = False
    ismovecamrigth = False
    isinventar = False

    #black rectanges in the map
    objects = []
    fobjects = []

    #for borders lines (rows and columns)
    grows, gcolumns = borders()
    #map with borders
    mymap = mapgen(screen, grows, gcolumns)
    fmymap = []
    for obj in mymap:
        fmymap.append(obj[1])
    frows = []
    fcolumns = []
    trows = []
    tcolumns = []

    for i in range(GAMESIZE + 1):
        frows.append(grows[i])
        fcolumns.append(gcolumns[i])
        trows.append(grows[i])
        tcolumns.append(gcolumns[i])

    #start angle2d, angle3d and scale
    myalfa2d = 0
    cosa = 1
    sina = 0
    mybeta3d = 0
    scale = 1
    zoom = ZOOM + 0.0

    pos = WIN_CENTER
    center = WIN_CENTER
    move = [WIN_CENTER[0] - 8, WIN_CENTER[1] - 35]
    #loop
    gamemap = pygame.Surface(DISPLAY)
    gamemap.fill((250, 250, 250))

    while True:
        # zooming
        if iszoomincres == True:
            if scale < MAXSCALE:
                zoom += 2
                scale = zoom / ZOOM
                (frows, fcolumns, fobjects,
                 fmymap) = updateobjects(gamemap, scale, sina, cosa, mybeta3d,
                                         grows, gcolumns, mymap, objects)

        elif iszoomdecres == True:
            if scale > MINSCALE:
                zoom -= 2
                scale = zoom / ZOOM
                (frows, fcolumns, fobjects,
                 fmymap) = updateobjects(gamemap, scale, sina, cosa, mybeta3d,
                                         grows, gcolumns, mymap, objects)

        #map rotating
        if isrotaterigth == True:
            myalfa2d += 1
            sina = math.sin(myalfa2d * math.pi / 180)
            cosa = math.cos(myalfa2d * math.pi / 180)

            (frows, fcolumns, fobjects,
             fmymap) = updateobjects(gamemap, scale, sina, cosa, mybeta3d,
                                     grows, gcolumns, mymap, objects)

        elif isrotateleft == True:
            myalfa2d -= 1
            sina = math.sin(myalfa2d * math.pi / 180)
            cosa = math.cos(myalfa2d * math.pi / 180)
            (frows, fcolumns, fobjects,
             fmymap) = updateobjects(gamemap, scale, sina, cosa, mybeta3d,
                                     grows, gcolumns, mymap, objects)

        if isrotateup == True:
            if mybeta3d > -80:
                mybeta3d -= 1
                (frows, fcolumns, fobjects,
                 fmymap) = updateobjects(gamemap, scale, sina, cosa, mybeta3d,
                                         grows, gcolumns, mymap, objects)

        if isrotatedown == True:
            if mybeta3d < 0:
                mybeta3d += 1
                (frows, fcolumns, fobjects,
                 fmymap) = updateobjects(gamemap, scale, sina, cosa, mybeta3d,
                                         grows, gcolumns, mymap, objects)
                xbool = True
                ybool = False
                gamemap = pygame.transform.flip(gamemap, xbool, ybool)
        #camera fbackgr
        if ismovecamup == True:
            center[1] += 10
            (frows, fcolumns) = rotozoom3d(grows, gcolumns, scale, sina, cosa,
                                           mybeta3d)
            fobjects = []
            for obj in objects:
                fobjects.append(rotozoom3d1(obj, scale, sina, cosa, mybeta3d))

        if ismovecamdown == True:
            center[1] -= 10
            (frows, fcolumns) = rotozoom3d(grows, gcolumns, scale, sina, cosa,
                                           mybeta3d)
            fobjects = []
            for obj in objects:
                fobjects.append(rotozoom3d1(obj, scale, sina, cosa, mybeta3d))

        if ismovecamleft == True:
            center[0] -= 10
            (frows, fcolumns) = rotozoom3d(grows, gcolumns, scale, sina, cosa,
                                           mybeta3d)
            fobjects = []
            for obj in objects:
                fobjects.append(rotozoom3d1(obj, scale, sina, cosa, mybeta3d))

        if ismovecamrigth == True:
            center[0] += 10
            (frows, fcolumns) = rotozoom3d(grows, gcolumns, scale, sina, cosa,
                                           mybeta3d)
            fobjects = []
            for obj in objects:
                fobjects.append(rotozoom3d1(obj, scale, sina, cosa, mybeta3d))

        # ALL EVENTS for gamemode
        for e in pygame.event.get():
            # check multipress
            keystate = pygame.key.get_pressed()

            # exit
            if e.type == QUIT:
                pygame.quit()
                sys.exit()

            # start moving and rotating
            elif e.type == KEYDOWN:
                if keystate[K_ESCAPE]:
                    pygame.quit()
                    sys.exit()
                if keystate[K_UP]:
                    isrotateup = True
                if keystate[K_DOWN]:
                    isrotatedown = True
                if keystate[K_LEFT]:
                    isrotateleft = True
                if keystate[K_RIGHT]:
                    isrotaterigth = True
                if keystate[K_1]:
                    iszoomincres = True
                if keystate[K_2]:
                    iszoomdecres = True
                if keystate[K_w]:
                    ismovecamup = True
                if keystate[K_s]:
                    ismovecamdown = True
                if keystate[K_a]:
                    ismovecamleft = True
                if keystate[K_d]:
                    ismovecamrigth = True
                if keystate[K_i]:
                    isinventar = True

            # stop moving and rotating
            elif e.type == KEYUP:
                if e.key == K_UP:
                    isrotateup = False
                if e.key == K_DOWN:
                    isrotatedown = False
                if e.key == K_LEFT:
                    isrotateleft = False
                if e.key == K_RIGHT:
                    isrotaterigth = False
                if e.key == K_1:
                    iszoomincres = False
                if e.key == K_2:
                    iszoomdecres = False
                if e.key == K_w:
                    ismovecamup = False
                if e.key == K_s:
                    ismovecamdown = False
                if e.key == K_a:
                    ismovecamleft = False
                if e.key == K_d:
                    ismovecamrigth = False
                if e.key == K_i:
                    isinventar = False

            #cursor
            elif e.type == pygame.MOUSEBUTTONDOWN:
                fobjects = cursor(scale, sina, cosa, myalfa2d, mybeta3d,
                                  gcolumns, grows, objects, fobjects)
                drawobjects(gamemap, mymap, fmymap, fcolumns, frows, fobjects,
                            scale)

        drawtext(gamemap, timer)
        screen.blit(gamemap, (0, 0))
        pygame.display.flip()
Beispiel #10
0
def main():

    #creacion de objetos para la pantalla
    bg = background.background(settings.pantalla,
                               "02.png",
                               posicion=settings.screen_center)

    l0 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=30,
                           posicion=(settings.WIDTH / 10 - 20, 50),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l1 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=30,
                           posicion=(settings.WIDTH / 10 - 20, 100),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l2 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=30,
                           posicion=(settings.WIDTH / 10 - 20, 150),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l3 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=30,
                           posicion=(settings.WIDTH / 10 - 20, 200),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l4 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=30,
                           posicion=(settings.WIDTH / 10 - 20, 250),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l5 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=30,
                           posicion=(settings.WIDTH / 10 - 20, 300),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l6 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=30,
                           posicion=(settings.WIDTH / 10 - 20, 350),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l7 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=30,
                           posicion=(settings.WIDTH / 10 - 20, 400),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l8 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=30,
                           posicion=(settings.WIDTH / 10 - 20, 450),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l9 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=30,
                           posicion=(settings.WIDTH / 10 - 20, 500),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    lis = [l0, l1, l2, l3, l4, l5, l6, l7, l8, l9]
    parrafo = text.group_text(lis)

    mouse = cursor.cursor()
    bgmusic = bgm.bgm()
    running = True

    while running:
        #variables que se comprueban cada bucle

        #control de eventos
        for evento in pygame.event.get():
            if evento.type == pygame.QUIT:
                running = False
                bgmusic.fadeout(1000)

        #manejo de textos
        if parrafo.contador == 1 and parrafo.renderizado == True:

            parrafo.void()

            #modificamos textos
            l2.line(u"Jesucristo le hizo un hechizo y Marcelo ")
            l3.line(u"Salas se transformó en Dante Allighieri,")
            l4.line(u"                          ")
            l5.line(u"pero aún no sabe que aventuras le ")
            l6.line(u"esperarán con su nuevo cuerpo y sus ")
            l7.line(u"nuevas Divinas Comedias.")
            l8.line(u"                                  ")

        if parrafo.contador == 2 and parrafo.renderizado:

            parrafo.void()

            #modificamos textos
            l5.isRect = True
            l5.position(settings.screen_center)
            l5.velocidad = 2
            l5.line(u" Continuará...")

        #paso a la siguiente pantalla
        if parrafo.contador == 3:
            running = False
            s6.main()

        #actualizacion de objetos en pantalla
        bg.update()
        parrafo.update()

        #actualizamos pantalla
        if running: pygame.display.flip()
        settings.reloj.tick(60)
Beispiel #11
0
def main():
    pygame.init()
    # menu check server or client
    mennu()
    screen = pygame.display.set_mode(DISPLAY) 
    timer = pygame.time.Clock()

    # klavisha press
    iszoomincres    = False
    iszoomdecres    = False
    isrotaterigth   = False
    isrotateleft    = False
    isrotateup      = False
    isrotatedown    = False
    ismovecamup     = False
    ismovecamdown   = False
    ismovecamleft   = False
    ismovecamrigth  = False
    isinventar      = False
    
    #black rectanges in the map
    objects = []
    fobjects = []
    
    #for borders lines (rows and columns)
    grows, gcolumns = borders()
    #map with borders
    mymap = mapgen(screen, grows, gcolumns)
    fmymap = []
    for obj in mymap:
        fmymap.append(obj[1])
    frows =    []
    fcolumns = []
    trows =    []
    tcolumns = []

    for i in range(GAMESIZE+1): 
        frows.append(grows[i])
        fcolumns.append(gcolumns[i])
        trows.append(grows[i])
        tcolumns.append(gcolumns[i])
        
    #start angle2d, angle3d and scale
    myalfa2d = 0
    cosa = 1
    sina = 0  
    mybeta3d = 0
    scale = 1
    zoom = ZOOM + 0.0
      
    pos = WIN_CENTER
    center = WIN_CENTER
    move = [WIN_CENTER[0]-8, WIN_CENTER[1]-35]
    #loop
    gamemap = pygame.Surface(DISPLAY)
    gamemap.fill((250, 250, 250))

    while True:
        # zooming
        if iszoomincres   == True:
            if scale<MAXSCALE:
                zoom += 2
                scale = zoom/ZOOM
                (frows,fcolumns, fobjects, fmymap) = updateobjects(gamemap, scale, sina, cosa, mybeta3d, 
                                                               grows, gcolumns, mymap, objects)
                
        elif iszoomdecres == True:
            if scale>MINSCALE:
                zoom -= 2
                scale = zoom/ZOOM
                (frows,fcolumns, fobjects, fmymap) = updateobjects(gamemap, scale,  sina, cosa, mybeta3d, 
                                                                  grows, gcolumns, mymap, objects)
                
        #map rotating
        if isrotaterigth  == True:
            myalfa2d+=1
            sina = math.sin(myalfa2d*math.pi/180)
            cosa = math.cos(myalfa2d*math.pi/180)
    
            (frows,fcolumns, fobjects, fmymap) = updateobjects(gamemap, scale, sina, cosa, mybeta3d, 
                                                               grows, gcolumns, mymap, objects)
           
        elif isrotateleft == True:
            myalfa2d-=1
            sina = math.sin(myalfa2d*math.pi/180)
            cosa = math.cos(myalfa2d*math.pi/180)
            (frows,fcolumns, fobjects, fmymap) = updateobjects(gamemap, scale, sina, cosa, mybeta3d, 
                                                               grows, gcolumns, mymap, objects)
             
        if isrotateup   == True:
            if mybeta3d > -80:
                mybeta3d-=1
                (frows,fcolumns, fobjects, fmymap) = updateobjects(gamemap, scale,  sina, cosa, mybeta3d, 
                                                                   grows, gcolumns, mymap, objects)
                
        if isrotatedown == True:
            if mybeta3d < 0:
                mybeta3d+=1
                (frows,fcolumns, fobjects, fmymap) = updateobjects(gamemap, scale,  sina, cosa, mybeta3d, 
                                                                   grows, gcolumns, mymap, objects)
                xbool = True
                ybool = False
                gamemap = pygame.transform.flip(gamemap, xbool, ybool) 
        #camera fbackgr
        if ismovecamup    == True:
            center[1]+=10
            (frows,fcolumns) = rotozoom3d(grows, gcolumns, scale,
                                          sina, cosa, mybeta3d)
            fobjects = []
            for obj in objects:
                fobjects.append(rotozoom3d1(obj, scale,sina, cosa, mybeta3d))
            
        if ismovecamdown  == True:
            center[1]-=10
            (frows,fcolumns) = rotozoom3d(grows, gcolumns, scale,
                                          sina, cosa, mybeta3d)
            fobjects = []
            for obj in objects:
                fobjects.append(rotozoom3d1(obj, scale, sina, cosa, mybeta3d))
            
        if ismovecamleft  == True:
            center[0]-=10
            (frows,fcolumns) = rotozoom3d(grows, gcolumns, scale,
                                          sina, cosa, mybeta3d)
            fobjects = []
            for obj in objects:
                fobjects.append(rotozoom3d1(obj, scale, sina, cosa, mybeta3d))
               
        if ismovecamrigth == True:
            center[0]+=10
            (frows,fcolumns) = rotozoom3d(grows, gcolumns, scale,
                                          sina, cosa, mybeta3d)
            fobjects = []
            for obj in objects:
                fobjects.append(rotozoom3d1(obj, scale,sina, cosa, mybeta3d))

            
                 
        # ALL EVENTS for gamemode
        for e in pygame.event.get():
            # check multipress 
            keystate = pygame.key.get_pressed()
        
            # exit
            if e.type == QUIT:
                pygame.quit()
                sys.exit()
 
            # start moving and rotating
            elif e.type == KEYDOWN:
                if keystate[K_ESCAPE]:
                    pygame.quit()
                    sys.exit()
                if keystate[K_UP]:
                    isrotateup     = True
                if keystate[K_DOWN]:
                    isrotatedown   = True
                if keystate[K_LEFT]:
                    isrotateleft   = True
                if keystate[K_RIGHT]:
                    isrotaterigth  = True
                if keystate[K_1]:
                    iszoomincres   = True
                if keystate[K_2]:
                    iszoomdecres   = True
                if keystate[K_w]:
                    ismovecamup    = True
                if keystate[K_s]:
                    ismovecamdown  = True
                if keystate[K_a]:
                    ismovecamleft  = True 
                if keystate[K_d]:
                    ismovecamrigth = True 
                if keystate[K_i]:
                    isinventar     = True           

            # stop moving and rotating        
            elif e.type == KEYUP:
                if e.key == K_UP:
                    isrotateup     = False
                if e.key == K_DOWN:
                    isrotatedown   = False
                if e.key == K_LEFT:
                    isrotateleft   = False
                if e.key == K_RIGHT:
                    isrotaterigth  = False
                if e.key == K_1:
                    iszoomincres   = False
                if e.key == K_2:
                    iszoomdecres   = False
                if e.key == K_w:
                    ismovecamup    = False
                if e.key == K_s:
                    ismovecamdown  = False
                if e.key == K_a:
                    ismovecamleft  = False       
                if e.key == K_d:
                    ismovecamrigth = False
                if e.key == K_i:
                    isinventar     = False    

            #cursor    
            elif e.type == pygame.MOUSEBUTTONDOWN:        
                fobjects = cursor( scale, sina, cosa, myalfa2d, mybeta3d, gcolumns, 
                                  grows, objects, fobjects)
                drawobjects(gamemap, mymap, fmymap,fcolumns, frows, fobjects, scale)
               
        drawtext(gamemap, timer)
        screen.blit(gamemap,(0,0))
        pygame.display.flip()
Beispiel #12
0
def main():

    #creacion de objetos para la pantalla
    bg = background.background(settings.pantalla,
                               "02.png",
                               posicion=settings.screen_center)

    l0 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 100),
                           linea=u"Hace 30 años, un cazador furtivo llamado",
                           velocidad=settings.text_speed_2)
    l05 = text.text_anim_01(pantalla=settings.pantalla,
                            nombre="COOPBL.ttf",
                            color=(255, 255, 255),
                            tamano=settings.text_tamano_2,
                            posicion=(settings.WIDTH / 10 - 20, 150),
                            linea=u"Marcelo Salas, fue al mar índico a",
                            velocidad=settings.text_speed_2)
    l1 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 200),
                           linea=u"permutar transgénicos.  ",
                           velocidad=settings.text_speed_2)
    l2 = text.text_anim_01(
        pantalla=settings.pantalla,
        nombre="COOPBL.ttf",
        color=(255, 255, 255),
        tamano=settings.text_tamano_2,
        posicion=(settings.WIDTH / 10 - 20, 0),
        linea="                                                             ",
        velocidad=settings.text_speed_2)
    l3 = text.text_anim_01(
        pantalla=settings.pantalla,
        nombre="COOPBL.ttf",
        color=(255, 255, 255),
        tamano=settings.text_tamano_2,
        posicion=(settings.WIDTH / 10 - 20, 300),
        linea=u"Estuvo allí durante eones (Si, leiste bien:",
        velocidad=settings.text_speed_2)
    l35 = text.text_anim_01(pantalla=settings.pantalla,
                            nombre="COOPBL.ttf",
                            color=(255, 255, 255),
                            tamano=settings.text_tamano_2,
                            posicion=(settings.WIDTH / 10 - 20, 350),
                            linea=u"EONES) y no pudo permutar ningún",
                            velocidad=settings.text_speed_2)
    l4 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 400),
                           linea=u"transgénico. ",
                           velocidad=settings.text_speed_2)
    l5 = text.text_anim_01(
        pantalla=settings.pantalla,
        nombre="COOPBL.ttf",
        color=(255, 255, 255),
        tamano=settings.text_tamano_2,
        posicion=(settings.WIDTH / 10 - 20, 0),
        linea="                                                             ",
        velocidad=settings.text_speed_2)
    lis = [l0, l05, l1, l2, l3, l35, l4, l5]

    mouse = cursor.cursor()
    bgmusic = bgm.bgm()

    running = True

    while running:
        #variables que se comprueban cada bucle

        #control de eventos
        for evento in pygame.event.get():

            if evento.type == pygame.QUIT:
                running = False
                bgmusic.fadeout(1000)

        #manejo de textos

        #actualizacion de objetos en pantalla
        bg.update()
        text.texto_lista_update(lis)

        #paso a la siguiente pantalla
        if l5.renderizado == True:
            running = False
            bgmusic.fadeout(1000)
            s2.main()

        #actualizamos pantalla
        if running: pygame.display.flip()
        settings.reloj.tick(60)
Beispiel #13
0
def main():

    #creacion de objetos para la pantalla
    bg = background.background(settings.pantalla,
                               "03.jpg",
                               posicion=settings.screen_center)

    l0 = text.text_anim_02(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_credits_normal,
                           posicion=(settings.screen_center[0], 600),
                           linea=u"Gracias por jugar",
                           direccion=(0, -1),
                           velocidad=settings.text_speed_credits,
                           rectangulo=True)
    l1 = text.text_anim_02(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_credits_title,
                           posicion=(settings.screen_center[0], 1300),
                           linea=u"Programación",
                           direccion=(0, -1),
                           velocidad=settings.text_speed_credits,
                           rectangulo=True)
    l2 = text.text_anim_02(pantalla=settings.pantalla,
                           nombre="ARLRDBD.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_credits_normal,
                           posicion=(settings.screen_center[0], 1350),
                           linea=u"Sergio Álvarez",
                           direccion=(0, -1),
                           velocidad=settings.text_speed_credits,
                           rectangulo=True)
    l3 = text.text_anim_02(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_credits_title,
                           posicion=(settings.screen_center[0], 1450),
                           linea=u"Historia",
                           direccion=(0, -1),
                           velocidad=settings.text_speed_credits,
                           rectangulo=True)
    l4 = text.text_anim_02(pantalla=settings.pantalla,
                           nombre="ARLRDBD.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_credits_normal,
                           posicion=(settings.screen_center[0], 1500),
                           linea=u"Felix Cerda",
                           direccion=(0, -1),
                           velocidad=settings.text_speed_credits,
                           rectangulo=True)
    l5 = text.text_anim_02(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_credits_title,
                           posicion=(settings.screen_center[0], 1600),
                           linea=u"Arte y fondos",
                           direccion=(0, -1),
                           velocidad=settings.text_speed_credits,
                           rectangulo=True)
    l6 = text.text_anim_02(pantalla=settings.pantalla,
                           nombre="ARLRDBD.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_credits_normal,
                           posicion=(settings.screen_center[0], 1650),
                           linea=u"Alguien en internet",
                           direccion=(0, -1),
                           velocidad=settings.text_speed_credits,
                           rectangulo=True)
    l7 = text.text_anim_02(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_credits_title,
                           posicion=(settings.screen_center[0], 1750),
                           linea=u"Especialmente gracias",
                           direccion=(0, -1),
                           velocidad=settings.text_speed_credits,
                           rectangulo=True)
    l8 = text.text_anim_02(pantalla=settings.pantalla,
                           nombre="ARLRDBD.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_credits_normal,
                           posicion=(settings.screen_center[0], 1800),
                           linea=u"Marcelo Salas",
                           direccion=(0, -1),
                           velocidad=settings.text_speed_credits,
                           rectangulo=True)
    l9 = text.text_anim_02(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_credits_normal,
                           posicion=(settings.screen_center[0], 2400),
                           linea=u"Nos vemos en el capitulo 2",
                           direccion=(0, -1),
                           velocidad=settings.text_speed_credits,
                           rectangulo=True)
    parrafo = text.group_text_02([l0, l1, l2, l3, l4, l5, l6, l7, l8, l9])

    l10 = text.text(settings.pantalla,
                    color=(255, 255, 255),
                    tamano=15,
                    linea=u"Pulsa cualquier tecla para adelantar",
                    posicion=(685, 580),
                    rectangulo=True)

    mouse = cursor.cursor()
    bgmusic = bgm.bgm()

    marcador = 0

    running = True

    while running:
        #variables que se comprueban cada bucle
        tiempo = pygame.time.get_ticks() / 1000

        #control de eventos
        for evento in pygame.event.get():
            if evento.type == pygame.KEYDOWN:
                for linea in parrafo.lista:
                    linea.velocidad = 200

            if evento.type == pygame.QUIT:
                running = False
                bgmusic.fadeout(1000)

        #manejo de textos
        if l9.rect_center[1] <= settings.screen_center[1]:
            parrafo.stop()
            if marcador == 0: marcador = tiempo

        #actualizacion de objetos en pantalla
        bg.update()
        parrafo.update()
        l10.update()

        #paso a la siguiente pantalla
        if tiempo == marcador + 3 and marcador != 0:
            running = False
            bgmusic.fadeout(1000)
            s0.main()

        #actualizamos pantalla
        if running: pygame.display.flip()
        settings.reloj.tick(60)
Beispiel #14
0
 def cursor(self, cursor_factory=None):
     return cursor(self.connection, cursor_factory or self.default_cursor,
                   self.hstore, self.log, self.logf)
Beispiel #15
0
def main():

    #creacion de objetos para el programa
    bg = background.background(settings.pantalla,
                               '00.jpg',
                               posicion=(settings.WIDTH / 2,
                                         settings.HEIGHT / 2))
    negro = background.background(settings.pantalla,
                                  "black.png",
                                  posicion=(settings.WIDTH / 2,
                                            settings.HEIGHT / 2),
                                  alpha=True)

    #configuramos boton principal
    boton = button.button(settings.pantalla, posicion=(170, 470))
    boton.add('00.png')
    boton.add('01.png')
    boton.add('02.png')

    boton2 = button.button(settings.pantalla, posicion=(600, 470))
    boton2.add("03.png")
    boton2.add("04.png")
    boton2.add("05.png")
    l2 = text.text(settings.pantalla,
                   linea=u"Controles",
                   posicion=(600, 470),
                   color=(0, 0, 0),
                   tamano=30,
                   rectangulo=True)
    l3 = text.text(settings.pantalla,
                   linea=u"Salir",
                   posicion=(600, 470),
                   color=(0, 0, 0),
                   tamano=30,
                   rectangulo=True)
    indicador = False

    l0 = text.text(settings.pantalla,
                   linea=u"Controles",
                   posicion=(70, 50),
                   nombre="COOPBL.TTF",
                   color=(255, 255, 255))
    l1 = text.text(settings.pantalla,
                   linea="Pulza Z para avanzar los textos",
                   posicion=(70, 100),
                   color=(255, 255, 255))

    mouse = cursor.cursor()
    bgmusic = bgm.bgm("001.mp3")
    running = True
    directorio = os.getcwd()

    #acciones de uso unico
    bgmusic.play()

    #bucle principal
    while running:
        #variables que se comprueban cada bucle

        #lista que contiene todos los eventos que se ejecutaron
        for evento in pygame.event.get():
            if evento.type == pygame.MOUSEBUTTONUP:
                if evento.button == 1:
                    if boton.rect.left < mouse.posicion[
                            0] < boton.rect.right and boton.rect.top < mouse.posicion[
                                1] < boton.rect.bottom and not (indicador):
                        s1.main()
                        running = False
                    if boton2.rect.left < mouse.posicion[
                            0] < boton2.rect.right and boton2.rect.top < mouse.posicion[
                                1] < boton2.rect.bottom:
                        aux = not (indicador)
                        indicador = aux

            if evento.type == pygame.QUIT:
                running = False

        #opciones de posicion del mouse
        if mouse.posicion[0] > boton.rect.right or \
           mouse.posicion[0] < boton.rect.left or \
           mouse.posicion[1] > boton.rect.bottom or \
           mouse.posicion[1] < boton.rect.top:
            boton.current(0)
        else:
            if mouse.estado[0] and not (indicador):
                boton.current(2)
            if not (mouse.estado[0]) and not (indicador):
                boton.current(1)

        if mouse.posicion[0] > boton2.rect.right or \
           mouse.posicion[0] < boton2.rect.left or \
           mouse.posicion[1] > boton2.rect.bottom or \
           mouse.posicion[1] < boton2.rect.top:
            boton2.current(0)
        else:
            if mouse.estado[0]:
                boton2.current(2)
            if not (mouse.estado[0]):
                boton2.current(1)

        #Actualizamos posicion de las cosas
        bg.update()
        boton.update()
        boton2.update()
        l2.update()
        mouse.update()
        if indicador:
            negro.update()
            boton2.update()
            l0.update()
            l1.update()
            l3.update()
        if not (running): bgmusic.stop()

        #actualizamos la pantalla
        if running: pygame.display.flip()
        settings.reloj.tick(60)  #60 frames por segundo