예제 #1
0
def verificarChoqueReg():
    global juegoCorriendo, reloj
    for b in listaRegs:
        ancho=b.width
        alto=b.height
        if pato.x>=b.x-ancho/2 and pato.x<=b.x+ancho/2:
            if pato.y>=b.y-alto/2 and pato.y<=b.y+alto/2:
                reloj-=5
                listaRegs.remove(b)
                b.undraw()
                sound =Myro.makeSound("Punch_-_Sound_Effect.wav") 
                Myro.play("Punch_-_Sound_Effect.wav")
예제 #2
0
def verificarChoqueObjeto():
    global juegoCorriendo
    global puntos
    for b in listaObjetos:
        ancho=b.width
        alto=b.height
        if pato.x>=b.x-ancho/2 and pato.x<=b.x+ancho/2:
            if pato.y>=b.y-alto/2 and pato.y<=b.y+alto/2:
                puntos+=1
                listaObjetos.remove(b)
                b.undraw()
                sound =Myro.makeSound("You_win_sound_effect_1.wav") 
                Myro.play("You_win_sound_effect_1.wav")
예제 #3
0
def verificarChoqueBomba():
    global juegoCorriendo
    global puntos
    for b in listaBombas:
        ancho=b.width
        alto=b.height
        if pato.x>=b.x-ancho/2 and pato.x<=b.x+ancho/2:
            if pato.y>=b.y-alto/2 and pato.y<=b.y+alto/2:
                puntos-=1
                listaBombas.remove(b)
                b.undraw()
                sound =Myro.makeSound("Punch_-_Sound_Effect.wav") 
                Myro.play("Punch_-_Sound_Effect.wav")
예제 #4
0
파일: tone.py 프로젝트: is44c/Calico
    array = [0] * width
    function(array, 0)
    prev = (0, width)
    for i in range(0, width, 2):
        Graphics.Line(prev, (i/2, array[i])).draw(win)
        prev = (i/2, array[i])

def plotMoreSound(function, color, width=500):
    win = Myro.getWindow()
    width = 44100
    array = [0] * width
    function(array, 0)
    prev = (0, width)
    for i in range(0, width, 2):
        l = Graphics.Line(prev, (i/2, array[i]))
        l.color = Myro.Color(color)
        l.draw(win)
        prev = (i/2, array[i])

#Myro.play(0, wave)

tone440 = makeTone(440)
tone441 = makeTone(441)
tone = make2Tone(440, 441)

plotSound(tone)
plotMoreSound(tone440, "red")
plotMoreSound(tone441, "blue")

Myro.play(2, tone)
예제 #5
0
def main():
    fondo5=makePicture("Nivel 5.jpg")
    fondo5.border=0
    fondo5.draw(v)    
    fondo4=makePicture("Nivel 4.jpg")
    fondo4.border=0
    fondo4.draw(v)
    fondo3=makePicture("Nivel 2.jpg")
    fondo3.border=0
    fondo3.draw(v)    
    fondo2=makePicture("Nivel 3.jpg")
    fondo2.border=0
    fondo2.draw(v)
    fondo1=makePicture("Nivel 1.jpg")
    fondo1.border=0
    fondo1.draw(v)
    global fondo1, fondo2, fondo3, fondo4
    fTiempo=RoundedRectangle((50, 35), (150, 60), 10)
    fTiempo.fill=Color("black")
    fTiempo.draw(v)
    txtTiempo.color=Color("white")
    txtTiempo.draw(v)
    fPuntos=RoundedRectangle((650, 35), (750, 65), 10)
    fPuntos.fill=Color("black")
    fPuntos.draw(v)
    txtPuntos.color=Color("white")
    txtPuntos.draw(v)
    escogerPersonaje()
    
    onKeyPress(atenderTeclado)
    global reloj
    tiempo=0
    tiempo2=0
    limite=1
    limite2=3
    

    while True:
        v.step(0.034)
        global juegoCorriendo
        global nivel, listaObjetos
        global puntos, highS, txtHS, p
        
        if juegoCorriendo:
            tiempo+=0.05
            if tiempo>=limite:
                tiempo=0
                reloj-=1
                txtTiempo.text="Tiempo "+str(reloj)
                txtPuntos.text="Puntos:"+str(puntos)
                if reloj<=0: 
                    juegoCorriendo=False                                       
                    perder=makePicture("Roasted.jpg")                    
                    txtPerder=Text((400,50),"GAME OVER")
                    txtPerder.color=Color("white")
                    perder.draw(v)
                    txtPerder.draw(v)                    
                    sound =Myro.makeSound("Wrong_Buzzer_-_Sound_Effect.wav") 
                    Myro.play("Wrong_Buzzer_-_Sound_Effect.wav")
                    highS=((nivel-1)*20)+puntos
                    entrada=open("highScore.txt","r")
                    cadena=entrada.read()
                    if highS>int(cadena):     
                        salida=open("highScore.txt","w")
                        salida.write(str(highS))
                        salida.close()
                        txtHS.text="HIGH SCORE:"+str(highS)
                        txtHS.color=Color("white")
                        txtHS.draw(v)
                    else:
                        print(cadena)
                        txtHS.text="HIGH SCORE:"+ str(cadena)
                        txtHS.color=Color("white")
                        txtHS.draw(v)
                    entrada.close()
                    btnSalir=Button((400,550), "Salir" )
                    btnSalir.draw(v)
                    btnSalir.connect("click",salirVentana )

                    
                if nivel==1:
                    obj=makePicture("barco.png")
                    crearObjetos1(obj)
                    crearBombas()                            
                    if puntos>=p:
                        nivel+=1
                        reloj=60
                        puntos=0
                        fondo1.undraw()                                                           
                        for b in listaObjetos:
                            b.undraw()
                        listaObjetos=[]
                if nivel==2:
                    obj=makePicture("congo.png")
                    crearObjetos(obj)
                    crearBombas()
                    if puntos>=p:
                        nivel+=1
                        reloj=60
                        puntos=0
                        fondo2.undraw()
                        for b in listaObjetos:
                            b.undraw()
                        listaObjetos=[]
                if nivel==3:
                    obj=makePicture("queso.png")
                    crearObjetos(obj)
                    crearBombas()
                    if puntos>=p:
                        nivel+=1
                        reloj=60
                        puntos=0
                        fondo3.undraw()
                        for b in listaObjetos:
                            b.undraw()
                        listaObjetos=[]
                if nivel==4:
                    obj=makePicture("koo.png")
                    crearObjetos(obj)
                    crearBombas()
                    if puntos>=p:
                        nivel+=1
                        reloj=60
                        puntos=0
                        fondo4.undraw()
                        for b in listaObjetos:
                            b.undraw()
                        listaObjetos=[]
                if nivel==5:
                    obj=makePicture("sushi.png")
                    crearObjetos(obj)
                    crearBombas()
                    crearRegresos()
                    if puntos>=p:
                        juegoCorriendo=False
                        a=makePicture("winner.png")
                        a.draw(v)
                        fondo5.undraw()
                        sound =Myro.makeSound("Sonic_Unleashed_Soundtrack_-_Clear_Fanfare_2.wav") 
                        Myro.play("Sonic_Unleashed_Soundtrack_-_Clear_Fanfare_2.wav")
                        highS=100
                        txtHS=Text((400,75),"HIGH SCORE:"+ str(highS))
                        txtHS.color=Color("white")
                        txtHS.draw(v)
                        btnSalir=Button((400,550), "Salir" )
                        btnSalir.draw(v)
                        btnSalir.connect("click",salirVentana )
                        
                        
            if nivel==4:
                tiempo2+=0.05            
                if tiempo2>=limite2:
                    tiempo2=0
                    crearRegresos()
                        
            if nivel==1:
                moverBombas()
                verificarChoqueObjeto()
                verificarChoqueBomba()
                   
            if nivel==2:
               moverLento()
               moverBombas()
               verificarChoqueObjeto()
               verificarChoqueBomba()
           
            if nivel==3:
                moverRapido()
                moverBombas()
                verificarChoqueObjeto()
                verificarChoqueBomba()
                
            if nivel==4:
                moverRapido()
                moverBombas()
                moverRegs()
                verificarChoqueObjeto()
                verificarChoqueBomba()
                verificarChoqueReg()
                
            if nivel==5:
                moverRapido()
                moverBombas()
                moverRegs()
                verificarChoqueObjeto()
                verificarChoqueBomba()
                verificarChoqueReg()