Exemplo n.º 1
0
    def __init__(self):
        self.game = None #
        self.playCount = 0
        #Make the loading screen call loadGame for us
        loadscreen = LoadingScreen (self)
        self.logo = TgaTexture("media/pyCaveMenu.tga")
        self.logo.newGLTexture()

        music.new_music("media/pycave.mp3")
        music.play()
        if pyCaveOptions['mute']:
            music.mute()
        #MENU ITEMS------------------------------
        self.helpMenu= HelpScreen(self)
        self.hscores = HighScores(self)
        self.asker = AskName(self)
        
        self.buttonList = [
            ((133,166), #Start
             362,
             201,self.startGame),
            ((129, 239), #Help
             201,
             279,self.helpMenu.getControl),
            ((128, 321), #Mute
             316,
             353,self.toggleMute),
            ((129, 395), #Exit
             199,
             429,exit),
            ((129,470),#highscores
             293,
             505,self.hscores.getControl)
            ]
Exemplo n.º 2
0
 def Rock(self):
     '''
     Rock and playing music
     '''
     music.play(self.file)
     self.control([10,10.5,7,90,1,0,1,1,0,15,1])
     self.send_control([145,10,95,70,55, 90,0,0,10,   5,1])
     self.send_control([145,10,95,70,55, 90,30,0,10,   5,1])
     self.send_control([145,10,95,70,55, 90,0,0,10,   5,1])
     self.send_control([145,10,95,70,55, 90,30,0,10,   5,1])
     '''
     self.send_control([145,10,95,70,55, 90,180,70,10,   20,1])
     self.send_control([145,10,95,70,55, 90,150,60,10,   20,1])
     self.send_control([145,10,95,70,55, 90,180,70,10,   20,1])
     self.send_control([145,10,95,70,55, 90,150,60,10,   20,1])
     
     self.send_control([145,10,95,70,55, 90,180,70,10,   20,1])
     self.send_control([145,10,95,70,55, 90,150,60,10,   20,1])
     self.send_control([145,10,95,70,55, 90,180,70,10,   20,1])
     self.send_control([145,10,95,70,55, 90,150,60,10,   20,1])
     '''
     self.send_control([60,10,15,15,55, 90,45,0,90,   20,1])
     print("Waiting to shake hand")
     self.shake_hand()
     self.send_control([60,115,85,60,115, 90,45,0,90,   10,1])
     time.sleep(0.5)
     self.send_control([60,115,85,60,115, 90,45,50,90,   10,1])
     self.send_control([145,135,95,70,125, 180,100,50,90,   10,1])
     time.sleep(0.5)
     self.send_control([145,135,95,70,125, 180,50,0,90,   15,1])
Exemplo n.º 3
0
def play_game():
    score = 0
    for x in range(0, 5):

        # Set result
        actual = random.choice(["A", "B"])

        # Guess
        display.show(Image.DIAMOND)
        guess = None
        while (guess == None):
            if button_a.is_pressed():
                guess = "A"
            elif button_b.is_pressed():
                guess = "B"

        # Show
        if actual == "A":
            display.show(Image.ARROW_W)
        else:
            display.show(Image.ARROW_E)

        sleep(1000)

        # Judge
        if guess == actual:
            score = score + 1
            display.show(Image.HAPPY)
            music.play(music.DADADADUM)
        else:
            display.show(Image.SAD)
            music.play(music.WAWAWAWAA)

    return score > 2
Exemplo n.º 4
0
def jingleBells():
    music.set_tempo(bpm=80)
    # without 1/8th notes (faster)
    full = [
        'e4:1', 'e4:1', 'e4:2', 'e4:1', 'e4:1', 'e4:2', 'e4:1', 'g4:1', 'c4:1',
        'd4:1', 'e4:4', 'f4:1', 'f4:1', 'f4:1', 'f4:1', 'f4:1', 'e4:1', 'e4:1',
        'e4:1', 'e4:1', 'd4:1', 'd4:1', 'e4:1', 'd4:2', 'g4:2', 'e4:1', 'e4:1',
        'e4:2', 'e4:1', 'e4:1', 'e4:2', 'e4:1', 'g4:1', 'c4:1', 'd4:1', 'e4:4',
        'f4:1', 'f4:1', 'f4:1', 'f4:1', 'f4:1', 'e4:1', 'e4:1', 'e4:1', 'g4:1',
        'g4:1', 'f4:1', 'd4:1', 'c4:4'
    ]
    # notes = ['e4:1', 'e4:1', 'e4:2',
    #          'e4:1', 'e4:1', 'e4:2',
    #          'e4:1', 'g4:1', 'c4:1', 'd4:1',
    #          'e4:4']

    # with 1/8th notes present
    music.set_tempo(bpm=100)
    full = [
        'e4:2', 'e4:2', 'e4:4', 'e4:2', 'e4:2', 'e4:4', 'e4:2', 'g4:2', 'c4:2',
        'd4:1', 'e4:8', 'f4:2', 'f4:2', 'f4:2', 'f4:1', 'f4:2', 'e4:2', 'e4:2',
        'e4:1', 'e4:1', 'e4:2', 'd4:2', 'd4:2', 'e4:2', 'd4:4', 'g4:4', 'e4:2',
        'e4:2', 'e4:4', 'e4:2', 'e4:2', 'e4:4', 'e4:2', 'g4:2', 'c4:2', 'd4:1',
        'e4:8', 'f4:2', 'f4:2', 'f4:2', 'f4:2', 'f4:2', 'e4:2', 'e4:2', 'e4:1',
        'e4:1', 'g4:2', 'g4:2', 'f4:2', 'd4:2', 'c4:8'
    ]
    # notes = ['e4:2', 'e4:2', 'e4:4',
    #          'e4:2', 'e4:2', 'e4:4',
    #          'e4:2', 'g4:2', 'c4:2', 'd4:2',
    #          'e4:8']
    music.play(full)
Exemplo n.º 5
0
 def die(self):
     """
     Player dies - show their score and play sad music
     """
     self.alive = False
     display.show(str(self.score))
     music.play(music.WAWAWAWAA)
Exemplo n.º 6
0
def degNColor(degC):
    if degC > 30:
        display.scroll("HOT!")
        redVal = degC * 4
        blueVal = 0
        greenVal = 255 - (degC * 4)
        pin8.write_analog(redVal)
        pin12.write_analog(greenVal)
        pin16.write_analog(blueVal)
        music.play(tune)
    elif degC < 30 and degC > 15:
        display.show(Image.HAPPY)
        redVal = 85 - degC
        blueVal = 85 + degC
        greenVal = 85
        pin8.write_analog(redVal)
        pin12.write_analog(greenVal)
        pin16.write_analog(blueVal)
    elif degC < 15:
        display.scroll("COLD!")
        redVal = 0
        blueVal = 255 - degC * 2
        greenVal = degC * 2
        pin8.write_analog(redVal)
        pin12.write_analog(greenVal)
        pin16.write_analog(blueVal)
        music.play(tune)
Exemplo n.º 7
0
def play_game(delay=100, accelerometer_sensitivity=1/300):
    """Enter game main event loop."""
    x, y = 2, 2   # Pixel coordinates, starting in middle of display
    winner = None
    while winner is None:
        if button_a.is_pressed():
            x = x + 1
            play('A:1')
        if button_b.is_pressed():
            x = x - 1
            play('B:1')

        if x > 4:
            winner = 'A'
        elif x < 0:
            winner = 'B'
        else:
            # No winner - continue
            set_pixel(x, y)

        # Change row based on accelerometer angle
        delta = accelerometer.get_y() * accelerometer_sensitivity
        y = max(0, min(4, int(y + delta)))

        sleep(delay)

    return winner
Exemplo n.º 8
0
def game_run():
    global level
    global crash
    global speed
    terrain = build_terrain(2+(level*2))
    image_height = terrain.height()    
    ship_height = 4
    for i in range(image_height):
        if button_a.was_pressed():
            play(JUMP_UP, wait=False)
            ship_height -= 1
            if ship_height < 0:
                ship_height = 0
        if button_b.was_pressed():
            play(JUMP_DOWN, wait=False)
            ship_height += 1
            if ship_height > 4:
                ship_height = 4
        if terrain.get_pixel(ship_height, 0) == 5:
            crash = True
            break
        terrain.set_pixel(ship_height, 0, 9)
        display.show(terrain)
        sleep(speed)
        terrain = terrain.shift_up(1)
Exemplo n.º 9
0
def levels(rndCounter):
    """game is divised into seven levels
    each round shows an amount of random patterns which grows each levels
    the user has to copy the pattern in order to win"""

    # lvl 1
    rndCounter += 1
    music.play(lvlM)
    display.scroll('Level 1')
    show(rndCounter)

    # lvl 2
    rndCounter += 1
    music.play(lvlM)
    display.scroll('Level 2')
    show(rndCounter)

    # lvl 3
    rndCounter += 1
    music.play(lvlM)
    display.scroll('Level 3')
    show(rndCounter)

    # lvl 4
    rndCounter += 1
    music.play(lvlM)
    display.scroll('Level 4')
    show(rndCounter)

    # lvl 5
    rndCounter += 1
    music.play(lvlM)
    display.scroll('Level 5')
    show(rndCounter)
    youDidIt()
Exemplo n.º 10
0
def increase_happiness():
    global happiness

    if happiness < 10:
        happiness = happiness + 1
        display.show(Image.HAPPY)
        music.play(music.DADADADUM)
Exemplo n.º 11
0
def show_introduction():
    global happiness, music_played

    #display.scroll("Hello, I'm " + name + ".")

    for _ in range(2):
        display.show(walking, loop=False, delay=500)
    if happiness > 3:
        display.show(Image.HAPPY)
        if not music_played:
            music.play(music.POWER_UP)
            music_played = True
        else:
            sleep(1000)

    elif happiness > 0:
        display.show(Image.CONFUSED)
        sleep(1000)

    else:
        display.show(Image.SAD)
        if not music_played:
            music.play(music.POWER_DOWN)
            music_played = True
        else:
            sleep(1000)
Exemplo n.º 12
0
def decrease_happiness():
    global happiness

    if happiness > 0:
        happiness = happiness - 1
        display.show(Image.SAD)
        music.play(music.WAWAWAWAA)
Exemplo n.º 13
0
def send_bomb():
    "Send a bomb to a random location (hope it's not us...)"
    x, y = (random.randint(0, 4), random.randint(0, 4))

    music.play(music.BA_DING)

    radio.send('%d%d' % (x, y))
Exemplo n.º 14
0
	def handle_option(self, choice):
		if choice == 0: # if we want to wipe our saves...
			self.dlog.show_choices(["Yes, wipe all of my saves.", "No, I want to keep my saves."])
			self.handle_c = self.handle_wipe
		elif choice == 5: # ...or return to the main menu, we should not use our start_options() function for our toggles.
			self.update_func = self.update
			settings.save()

			sub_bg_pos = (MENU_POS[0], settings.screen_y-self.dlog.dlog_height+MENU_POS[1])
			sub_bg =  self.titlescreen.bg.subsurface(pygame.Rect(
													sub_bg_pos, (self.dlog.dlog_width, self.dlog.dlog_height) ))
			self.surf.blit(sub_bg, sub_bg_pos)

			self.g.sounds['openMenu'].play()
			self.show()
		else: # otherwise, we should activate our toggle switch and refresh the options menu
			if choice == 1:
				settings.option_music = not settings.option_music
				music.play(-1)
				if not settings.option_music: music.fadeout(500)
			elif choice == 2: settings.option_sound = not settings.option_sound
			elif choice == 3: settings.parallax = not settings.parallax
			elif choice == 4:
				fullscreen = pygame.FULLSCREEN if settings.fullscreen else 0 #if fullscreen is turned on in the settings, enable it
				self.g.screen = pygame.display.set_mode((settings.screen_x*settings.screen_scale, settings.screen_y*settings.screen_scale), fullscreen) #recreate the window to draw on
			self.start_options()
Exemplo n.º 15
0
def checkForCatch():
    global fallingLightRow
    global fallingLightPosition
    global playerPosition
    global playerLife
    global gameOver
    global score
    global dropDelay
    if (fallingLightRow == 4):
        if (fallingLightPosition == playerPosition):
            #gameOver = True
            #player caughdet the light
            #speed up the drops for ever two points earned
            if score % 2 is 0:
                dropDelay -= 5
            #display.scroll("You win")
            spawnLight()
            music.play(music.BA_DING)
            score += 1
        else:
            #dim the playerLife
            playerLife -= 3
            #playerLife is not working properly, I need to add a switch for changing the number of lives the player has left
            if (playerLife <= 0):
                #out of life, game over
                gameOver = True
                music.play(music.POWER_DOWN)
                display.show(Image.SKULL)
                sleep(1000)
                display.scroll("Score: " + str(score))
        #the light has hit the bottom so change the flag so another light will spawn
        lightShowing = False
    return
Exemplo n.º 16
0
def play_it(chars):
    pitches = []
    for t in range(3):
        for d in chars:
            pitches.append(None if d in whitespace else ord(d) - 48)
        pause(pitches)
    music.play(pitches, dur=.1, vel=127)
Exemplo n.º 17
0
def debug_output_module():
    # 开关水泵
    relay.write_digital(True)
    sleep(1000*5)
    relay.write_digital(False)
    # 蜂鸣器
    music.play('f4:2', pin = buzzer, wait = True, loop = False)
Exemplo n.º 18
0
 def __init__(self):
     '''
     Neues Spiel
     '''
     self.ball = Ball()
     self.bat = Bat()
     self.round = 0
     music.play(music.POWER_UP)
Exemplo n.º 19
0
 def incChord(self):
     global chordIndex
     self.chordIx = self.chordIx + 1
     if self.chordIx >= len(chordIndex):
         self.chordIx = 0
     self.chordName = chordIndex[self.chordIx]
     music.play(chords[self.chordName], wait=False)
     self.display()
Exemplo n.º 20
0
 def playMusic(self):
     if self.doPlay:
         music.play(music.POWER_DOWN)
         # DADADADUM PRELUDE ENTERTAINER ODE NYAN RINGTONE FUNK BLUES
         # WEDDING FUNERAL PUNCHLINE PYTHON BADDY CHASE BA_DING WAWAWAWAA
         # BIRTHDAY JUMP_UP JUMP_DOWN POWER_UP POWER_DOWN
         self.doPlay = False
         display.set_pixel(0, 0, 8)
Exemplo n.º 21
0
 def clear_screen():
     music.play(music.NYAN, wait=False)
     update_frame(0)
     while not (button_a.get_presses() or button_b.get_presses()):
         SNAKE.body.insert(0, SNAKE.head)
         SNAKE.head = SNAKE.body.pop()
         update_frame(0)
     display.scroll('GAMECLEAR')
Exemplo n.º 22
0
def change():
    global flag
    if button_a.is_pressed():
        music.play(music.POWER_UP)
        flag = flag + 1
    elif button_b.is_pressed():
        music.play(music.POWER_DOWN)
        flag = flag - 1
Exemplo n.º 23
0
def zombie():
    # Become mass murdering zombie
    display.show(Image.ANGRY)
    music.play(music.NYAN, wait=False)
    for x in range(0, 5):
        for y in range(0, 5):
            radio.send('%d%d' % (x, y))
            sleep(600)
Exemplo n.º 24
0
def sing(song=None):
    """ sing something simple """
    song = choose(songs, song)

    if quiet:
        display.scroll(song)
    else:
        music.play(song)
Exemplo n.º 25
0
def start_countdown(count=3):
    """Play a countdown animation for the specified number of seconds."""
    for i in range(count, 0, -1):
        display.show(str(i))
        play('C:1')
        sleep(1000)
    play('A:3')
    display.clear()
Exemplo n.º 26
0
def tooBad():
    """shown when user response is incorrect"""
    music.play(loserM)
    display.scroll('Too Bad...')
    sadFaceA()
    display.clear()
    """restart"""
    sleep(2)
    intro()
Exemplo n.º 27
0
def youDidIt():
    """shown when user has completed all levels"""
    music.play(winnerM)
    display.scroll('You Did It!')
    happyFaceA()
    display.clear()
    """restart"""
    sleep(2)
    intro()
Exemplo n.º 28
0
def intro():
    """play intro music & show title"""
    music.play(introM)
    display.scroll('Memory Game')
    """start game when button a is pressed"""
    display.scroll('Press A to Start')
    while True:
        if button_a.is_pressed():
            levels(rndCounter)
Exemplo n.º 29
0
def play_ascii_txt(data):
    lines = data.split('\n')
    pitches = []
    for line in lines:
        for t in range(3):
            for d in line:
                pitches.append(ord(d) - 48)
            pause(pitches)
    music.play(pitches, dur=.02)
Exemplo n.º 30
0
def test_music():
    print("Switching mode to digital for music pins")
    music.play(music.DADADADUM, pin=pin0, wait=False)
    try:
        pin0.write_digital(0)
    except ValueError:
        pass
    music.stop()
    pin0.write_digital(0)
Exemplo n.º 31
0
def test_music():
    print("Switching mode to digital for music pins")
    music.play(music.DADADADUM, pin=pin0, wait=False)
    try:
        pin0.write_digital(0)
    except ValueError:
        pass
    music.stop()
    pin0.write_digital(0)
Exemplo n.º 32
0
def game_run():
    terrain = Image(
        "00000:"
        "00000:"
        "00000:"
        "00000:"
        "00000:"
        "00005:"
        "00055:"
        "05555:"
        "00555:"
        "00055:"
        "00005:"
        "00055:"
        "05555:"
        "00555:"
        "00055:"
        "00005:"
        "50005:"
        "00055:"
        "50000:"
        "55000:"
        "55500:"
        "55000:"
        "50000:"
        "00000:"
        "00005:"
        "00055:"
        "00005:"
        "00055:"
        "00555:"
        "00055:"
        "55055"
    )
    image_height = terrain.height()
    ship_height = 4
    global crash
    global speed
    for i in range(image_height):
        if button_a.was_pressed():
            play(JUMP_UP, wait=False)
            ship_height -= 1
            if ship_height < 0:
                ship_height = 0
        if button_b.was_pressed():
            play(JUMP_DOWN, wait=False)
            ship_height += 1
            if ship_height > 4:
                ship_height = 4
        if terrain.get_pixel(ship_height, 0) == 5:
            crash = True
            break
        terrain.set_pixel(ship_height, 0, 9)
        display.show(terrain)
        sleep(speed)
        terrain = terrain.shift_up(1)
Exemplo n.º 33
0
def update_display():
    if not result:
        m.display.scroll('d' + str(dices[dice]), wait=False, loop=True)
        music.play(music.POWER_UP)
    else:
        if result < 10:
            m.display.show(result)
        else:
            m.display.scroll(result, wait=False, loop=True)
        music.play(music.JUMP_UP)
Exemplo n.º 34
0
def twinkleTwinkle():
    music.set_tempo(bpm=60)
    notes = [
        'c5:1', 'c:1', 'g:1', 'g:1', 'a:1', 'a:1', 'g:2', 'f:1', 'f:1', 'e:1',
        'e:1', 'd:1', 'd:1', 'c:2', 'g:1', 'g:1', 'f:1', 'f:1', 'e:1', 'e:1',
        'd:2', 'g:1', 'g:1', 'f:1', 'f:1', 'e:1', 'e:1', 'd:2', 'c:1', 'c:1',
        'g:1', 'g:1', 'a:1', 'a:1', 'g:2', 'f:1', 'f:1', 'e:1', 'e:1', 'd:1',
        'd:1', 'c:2'
    ]
    music.play(notes)
Exemplo n.º 35
0
    def __init__(self, game):
        super(GameLevel, self).__init__()

        glevels.append(self)
        if self.music:
            music.play(self.music)

        # in game coords. viewport is your window into game world
        self.game = game
        pyglet.gl.glClearColor(*settings.BACKGROUND_COLOUR)
        self.width = self.game.window.width
        self.height = self.game.window.height
        self.viewport = scene.ViewportManager(Rect(0.0, 0.0, self.width, self.height))

        self.main_batch = pyglet.graphics.Batch()

        self.score_ruby = RubyScore(batch=self.main_batch)
        self.score_ruby.x = settings.SCORE_LABEL_X + self.score_ruby.width / 2
        self.score_ruby.y = settings.SCORE_LABEL_Y + self.score_ruby.height / 2
        self.score_label = pyglet.text.Label(
            text="",
            x=settings.SCORE_LABEL_X + self.score_ruby.width + 10,
            y=settings.SCORE_LABEL_Y + 5,
            color=settings.MENU_COLOR_OPTION,
            batch=self.main_batch,
        )

        self.score_cart = pyglet.sprite.Sprite(img=pyglet.resource.image(settings.CART_IMAGE), batch=self.main_batch)
        self.score_cart.scale = 0.25
        self.score_cart.x = settings.LIVES_LABEL_X + 0
        self.score_cart.y = settings.LIVES_LABEL_Y + 0
        self.lives_label = pyglet.text.Label(
            text="",
            x=settings.LIVES_LABEL_X + self.score_cart.width + 10,
            y=settings.LIVES_LABEL_Y + 5,
            color=settings.MENU_COLOR_OPTION,
            batch=self.main_batch,
        )

        self.quit_label = pyglet.text.Label(
            text="By NSTeamStrong: q [quit] space [jump]",
            x=settings.QUIT_LABEL_X,
            color=settings.MENU_COLOR_OPTION,
            y=settings.QUIT_LABEL_Y,
            batch=self.main_batch,
        )

        self.cart = None
        self.entities = []
        self.catchup = True
        self.setup(self.name)
Exemplo n.º 36
0
def init(game_type):
	assert type(game_type) is str
	
	
	# Store scene (when ready)
	scene.set('game')
	
	# Store mode (when ready)
	mode.set(game_type)

	# Load the data
	data.load()

	# Not yet loaded
	if not GAME_IMAGES:
		# Main layers
		GAME_IMAGES['delay'] = pyglet.image.load('./data/img/backgrounds/game.delay.bg.png')
		GAME_IMAGES['pause'] = pyglet.image.load('./data/img/backgrounds/game.pause.bg.png')
		GAME_IMAGES['win'] = pyglet.image.load('./data/img/backgrounds/game.end.win.bg.png')
		GAME_IMAGES['loose'] = pyglet.image.load('./data/img/backgrounds/game.end.loose.bg.png')
		
		# Sprites
		GAME_IMAGES['projectile'] = pyglet.image.load(data.get_image('projectile'))
		GAME_IMAGES['bacteria'] = pyglet.image.load(data.get_image('bacteria'))
		GAME_IMAGES['virus'] = pyglet.image.load(data.get_image("virus"))
		GAME_IMAGES['cell'] = pyglet.image.load(data.get_image('cellule'))
		GAME_IMAGES['cell1'] = pyglet.image.load(data.get_image('cellule1'))
		GAME_IMAGES['cell2'] = pyglet.image.load(data.get_image('cellule2'))
		GAME_IMAGES['cell3'] = pyglet.image.load(data.get_image('cellule3'))
		GAME_IMAGES['phagocyte'] = pyglet.image.load(data.get_image('Phagocyte'))
	
	# Faster backgrounds
	background.scene_speed('game')
	
	# No game cursor
	cursor.disable()
	
	# Game music
	if game_type is 'bacteria':
		music.play(data.get_musique())
	else:
		music.play('04')
	
	# Launch the game
	launch()
	
	# Process first update
	animer(0)
	
	return True
Exemplo n.º 37
0
def toggleMusic():
	global SETTINGS_MUSIC
	
	# Change setting
	if SETTINGS_MUSIC == True:
		SETTINGS_MUSIC = False
		music.stop()
	else:
		SETTINGS_MUSIC = True
		music.play('01')
	
	# Store setting
	db.store('setting', 'music', SETTINGS_MUSIC)
	
	return SETTINGS_MUSIC
Exemplo n.º 38
0
def init():
	# Not yet loaded
	if not LEVELS_IMAGES:
		# Main layers
		LEVELS_IMAGES['select'] = pyglet.image.load('./data/img/backgrounds/levels.select.bg.png')
		LEVELS_IMAGES['bottom'] = pyglet.image.load('./data/img/backgrounds/menu.bottom.bg.png')
		
		# UI images
		LEVELS_IMAGES['fight_button'] = pyglet.image.load('./data/img/buttons/levels.fight.button.png')
		LEVELS_IMAGES['help_button'] = pyglet.image.load('./data/img/buttons/levels.help.button.png')
		LEVELS_IMAGES['logo'] = pyglet.image.load('./data/img/logos/levels.logo.png')
		LEVELS_IMAGES['back_button'] = pyglet.image.load('./data/img/buttons/levels.back.button.png')
		
		# UI labels
		LEVELS_IMAGES['bacteria_label'] = pyglet.image.load('./data/img/labels/levels.bacteria.label.png')
		LEVELS_IMAGES['virus_label'] = pyglet.image.load('./data/img/labels/levels.virus.label.png')
		
		# UI texts
		LEVELS_IMAGES['bacteria_text'] = pyglet.image.load('./data/img/texts/levels.bacteria.text.png')
		LEVELS_IMAGES['virus_text'] = pyglet.image.load('./data/img/texts/levels.bacteria.text.png')
		
		# UI buttons
		LEVELS_IMAGES['difficulty_easy_disabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.easy.disabled.png')
		LEVELS_IMAGES['difficulty_easy_enabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.easy.enabled.png')
		
		LEVELS_IMAGES['difficulty_medium_disabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.medium.disabled.png')
		LEVELS_IMAGES['difficulty_medium_enabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.medium.enabled.png')
		
		LEVELS_IMAGES['difficulty_hard_disabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.hard.disabled.png')
		LEVELS_IMAGES['difficulty_hard_enabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.hard.enabled.png')
	
	# Faster backgrounds
	background.scene_speed('levels')
	
	# Levels cursor
	cursor.set('default')
	
	# Levels music
	music.play('02')
	
	# Store scene (when ready)
	scene.set('levels')
	
	return True
Exemplo n.º 39
0
def init():
	global MENU_IMAGES
	
	# Not yet loaded
	if not MENU_IMAGES:
		# Top & bottom layers
		MENU_IMAGES['top'] = pyglet.image.load('./data/img/backgrounds/menu.top.bg.png')
		MENU_IMAGES['bottom'] = pyglet.image.load('./data/img/backgrounds/menu.bottom.bg.png')
		
		# UI images
		MENU_IMAGES['logo'] = pyglet.image.load('./data/img/logos/menu.logo.png')
		MENU_IMAGES['play_button'] = pyglet.image.load('./data/img/buttons/menu.play.button.png')
		MENU_IMAGES['info_button'] = pyglet.image.load('./data/img/buttons/menu.info.button.png')
		MENU_IMAGES['music_checkbox_checked'] = MENU_IMAGES['sound_checkbox_checked'] = pyglet.image.load('./data/img/checkboxes/menu.checkbox.checked.png')
		MENU_IMAGES['music_checkbox_unchecked'] = MENU_IMAGES['sound_checkbox_unchecked'] = pyglet.image.load('./data/img/checkboxes/menu.checkbox.unchecked.png')
		
		# UI labels
		MENU_IMAGES['music_label'] = pyglet.image.load('./data/img/labels/menu.music.label.png')
		MENU_IMAGES['sound_label'] = pyglet.image.load('./data/img/labels/menu.sound.label.png')
		
		# About bubble
		MENU_IMAGES['about_bubble'] = pyglet.image.load('./data/img/others/menu.about.png')
	
	# Add backgrounds
	background.add(1, 0.2)
	background.add(2, 1)
	background.add(3, -1)
	
	# Slower backgrounds
	background.scene_speed('menu')
	
	# Menu cursor
	cursor.set('default')
	
	# Menu music
	music.play('01')
	
	# Store scene (when ready)
	scene.set('menu')
	
	return True
Exemplo n.º 40
0
    def __init__(self, game):

        # create a window and grab fullscreen with exclusive mouse
        #super(MainMenu, self).__init__(width = 1024, height = 768)
        #self.set_exclusive_mouse()
        super(MainMenu, self).__init__()
        music.load()
        music.play('pink')

        self.game = game
        
        self.num_options = 4 #number of menu items to choose from
        self.main_batch = pyglet.graphics.Batch()

        self.game_label = pyglet.text.Label(batch = self.main_batch)
        self.game_label.text = "Python on Rails"

        self.start_label = pyglet.text.Label(batch = self.main_batch)
        self.start_label.text = "Start Game"
        self.instructions_label = pyglet.text.Label(batch = self.main_batch)
        self.instructions_label.text = "Instructions"
        self.highscores_label = pyglet.text.Label(batch = self.main_batch)
        self.highscores_label.text = "Highscores"
        self.quit_label = pyglet.text.Label(batch = self.main_batch)
        self.quit_label.text = "Quit"
        
        self.controls_label = pyglet.text.Label(batch = self.main_batch)
        self.controls_label.text = "[UP], [DOWN] to select an option, [SPACE] to select"

        self.by_label = pyglet.text.Label(batch = self.main_batch)
        self.by_label.text = "By NSTeamStrong - jtrain, kburd, danaran and rozifus. Piece."
        
        self.option_labels = [self.start_label, self.instructions_label,
                self.highscores_label, self.quit_label]
        self.all_labels = [self.game_label, self.controls_label, self.by_label]
        self.all_labels.extend(self.option_labels)
        
        self.layout_items()
        self.selected_option = 1
 def gainFocus(self, previous, previous_name, *args, **kwargs):
     """What should be done when the state gets focus.  Previous is the state that had focus before this one."""
     music.play(assets.path("music/state_title.mp3"))
     pass
Exemplo n.º 42
0
             "00000:"
             "00000")

idleFrames = [idleFrame1, idleFrame2, idleFrame3]

# Animate pokeball on startup
for i in range(2):
    display.show(pokeballFrames, delay=ONE_SECOND_MS)

while True:
    display.clear()
    
    if (gameState == STATE_INTRO):
        if (introMusicPlayed == False):
            introMusicPlayed = True
            music.play(palletTownNotes, wait=False)

        if (button_a.is_pressed()):
            music.stop()
            gameState = STATE_MAIN
        else:
            display.show('A')
            sleep(ONE_SECOND_MS / 2)

            display.show(Image.ARROW_W)
            sleep(ONE_SECOND_MS / 2)
    elif (gameState == STATE_MAIN):

        if (initialPromptShown == False):
            initialPromptShown = True
            display.scroll('Lets get walking!')
    "f#:4", "R:4",
    # we do what we must
    "R:2", "R:1", "a5:1", "g6", "f#:1", "e", "e:3", 
    # because we can
    "f#:1", "d:3", "e:1", "a5:5", 
    "R:4", 
    # for the good of all 
    "e6:2", "f#:1", "g:3", "e:1", "c#:3", 
    # of us except for the
    "d:1", "e:2", "a5:1", "d6", "e", 
    # ones who are dead. But theres
    "f", "e", "d", "c", "R:2", "a5:1", "a#:1", 
    # no sense crying over 
    "c6:2", "f:2", "e:1", "d", "d", "c", 
    # every mistake you just 
    "d:1", "c6:1", "c6:2", "c6:2", "a5:1", "a#:1", 
    # keep on trying till you 
    "c6:2", "f:2", "g:1", "f:1", "e:1", "d:1", 
    # run out of cake and the
    "d:1", "e6:1", "f6:2", "f:2", "g:1", "a:1", 
    # science gets done and you 
    "a#:1", "a#:1", "a:2", "g:2", "f:1", "g:1", 
    # make a neat gun for the 
    "a:1", "a:1", "g:2", "f:2", "d:1", "c:1",
    # people who are still alive
    "d:1", "f", "f", "e:2", "f#:1", "f#:1"
] 

music.set_tempo(bpm=60)
music.play(still_alive)
Exemplo n.º 44
0
from microbit import *
import music

# Plays a different note when pressing different fruits

# Put a buzzer between pin0 and Gnd
# Attach a fruit to Pin1 and Pin2
# Have a loose wire from Gnd

# Hold the Gnd wire
# Press your other hand on the fruits to hear notes

note_low = ["C4:4"]
note_high = ["C5:4"]

while True:
    if pin1.is_touched():
        music.play(note_low)
        display.show(Image.HAPPY)
    elif pin2.is_touched():
        music.play(note_high)
        display.show(Image.SURPRISED)
    else:
        display.show(Image.SAD)
Exemplo n.º 45
0
def test_rapid_pin_switch():
    for i in range(20):
        for pin in PINS:
            music.play(music.NYAN, pin, wait=False)
Exemplo n.º 46
0
        terrain = terrain.shift_up(1)


speed = 500
crash = False
won = False
level = 1

display.scroll("Kettle Run")

while level < 6:  # increase this number to add more levels
    display.show(str(level))
    sleep(1000)
    game_run()
    if crash:
        play(FUNERAL, wait=False)
        display.scroll("CRASH!")
        break
    else:
        play(POWER_UP, wait=False)
        display.scroll("Tea up!")
        level += 1
        speed -= 20  # increase this number to speed up more on each level

if not crash:
    play(NYAN, wait=False)
    display.show("YOU WIN")
    while True:
        display.scroll("Press reset to play again")
else:
    display.show("GAME OVER")
Exemplo n.º 47
0
 def on_play(self):
     music.play()
     self.broadcast('play')
Exemplo n.º 48
0
while True:
    sleep(100)
    if -256 < accelerometer.get_y() < 450:
        bird = max(0, bird - 1)
    elif 568 < accelerometer.get_y() < 1024:
        bird = min(4, bird + 1)

    display.clear()
    display.set_pixel(0, bird, 9)

    pos_terrain = pos // terrain_multiplier
    lost_status = False
    for column, (top, bottom) in enumerate(
            terrain[pos_terrain:pos_terrain + 5]):
        for y in range(top):
            display.set_pixel(column, y, 4)
            if column == 0 and bird == y:
                lost_status = True
        for y in range(bottom):
            display.set_pixel(column, 4 - y, 4)
            if column == 0 and bird == (4 - y):
                lost_status = True
    if lost_status:
        display.show(Image.SAD)
        music.play(music.FUNERAL)
        reset()
    pos += 1
    if pos_terrain > len(terrain):
        pos = 0
Exemplo n.º 49
0
mb = 32     # define maximum LED brightness

# Define a Python list of useful RGB colors. These colors
# include RED, GRN, BLU, ORG, YEL, CYN, MAG, and WHT.
colors = [(mb, 0, 0),  (0, mb, 0),  (0, 0, mb),  (mb, mb/2, 0),
          (mb, mb, 0), (0, mb, mb), (mb, 0, mb), (mb, mb, mb)]

black = (0, 0, 0)

gestureSensitivity = 128
delay = 200

np.clear()

music.play(music.RINGTONE)

# Set initial position of pong game's "paddle"
padX = 2

# Set color of pong game's "paddle" to blue
padColor = colors[2]

# Display initial paddle
npPlot2(padX, 7, padColor)
np.show()

# Set initial position of pong game's "ball"
ballX = 0
ballY = 0
Exemplo n.º 50
0
 def getControl(self):
     Frame.getControl(self)
     glutPostRedisplay()
     music.play()
Exemplo n.º 51
0
"""
    music.py
    ~~~~~~~~

    Plays a simple tune using the Micropython music module.
    This example requires a speaker/buzzer/headphones connected to P0 and GND.
"""
from microbit import *
import music

# play Prelude in C.
notes = [
    'c4:1', 'e', 'g', 'c5', 'e5', 'g4', 'c5', 'e5', 'c4', 'e', 'g', 'c5', 'e5', 'g4', 'c5', 'e5',
    'c4', 'd', 'g', 'd5', 'f5', 'g4', 'd5', 'f5', 'c4', 'd', 'g', 'd5', 'f5', 'g4', 'd5', 'f5',
    'b3', 'd4', 'g', 'd5', 'f5', 'g4', 'd5', 'f5', 'b3', 'd4', 'g', 'd5', 'f5', 'g4', 'd5', 'f5',
    'c4', 'e', 'g', 'c5', 'e5', 'g4', 'c5', 'e5', 'c4', 'e', 'g', 'c5', 'e5', 'g4', 'c5', 'e5',
    'c4', 'e', 'a', 'e5', 'a5', 'a4', 'e5', 'a5', 'c4', 'e', 'a', 'e5', 'a5', 'a4', 'e5', 'a5',
    'c4', 'd', 'f#', 'a', 'd5', 'f#4', 'a', 'd5', 'c4', 'd', 'f#', 'a', 'd5', 'f#4', 'a', 'd5',
    'b3', 'd4', 'g', 'd5', 'g5', 'g4', 'd5', 'g5', 'b3', 'd4', 'g', 'd5', 'g5', 'g4', 'd5', 'g5',
    'b3', 'c4', 'e', 'g', 'c5', 'e4', 'g', 'c5', 'b3', 'c4', 'e', 'g', 'c5', 'e4', 'g', 'c5',
    'b3', 'c4', 'e', 'g', 'c5', 'e4', 'g', 'c5', 'b3', 'c4', 'e', 'g', 'c5', 'e4', 'g', 'c5',
    'a3', 'c4', 'e', 'g', 'c5', 'e4', 'g', 'c5', 'a3', 'c4', 'e', 'g', 'c5', 'e4', 'g', 'c5',
    'd3', 'a', 'd4', 'f#', 'c5', 'd4', 'f#', 'c5', 'd3', 'a', 'd4', 'f#', 'c5', 'd4', 'f#', 'c5',
    'g3', 'b', 'd4', 'g', 'b', 'd', 'g', 'b', 'g3', 'b3', 'd4', 'g', 'b', 'd', 'g', 'b'
]

music.play(notes)
Exemplo n.º 52
0
def sound():
    music.play(music.DADADADUM)
    music.play(music.ENTERTAINER)
    music.play(music.PRELUDE)
    music.play(music.ODE)
    music.play(music.NYAN)
    music.play(music.RINGTONE)
    music.play(music.FUNK)
    music.play(music.BLUES)
    music.play(music.BIRTHDAY)
    music.play(music.WEDDING)
    music.play(music.FUNERAL)
    music.play(music.PUNCHLINE)
    music.play(music.PYTHON)
    music.play(music.BADDY)
    music.play(music.CHASE)
    music.play(music.BA_DING)
    
    music.play(music.WAWAWAWAA)
    music.play(music.JUMP_UP)
    music.play(music.JUMP_DOWN)
    music.play(music.POWER_UP)
    music.play(music.POWER_DOWN)
from microbit import *
import music

ringtone = [ 
    "e7:1", "d", "f#6", "g#",  
    "c#7:1", "b6", "d", "e",  
    "b", "a", "c#6", "e",  
    "a:4", "R:4"
] 

music.set_tempo(bpm=60)

for repeat in range(2):
  music.play(ringtone) 
Exemplo n.º 54
0
def get_sad(loops=2):
    music.play(music.POWER_DOWN, wait=False)
    for i in range(loops):
        animate([neutral_face, frowning_face, sad_face])
Exemplo n.º 55
0
def get_happy(loops=2):
    music.play(music.BA_DING, wait=False)
    for i in range(loops):
        animate([neutral_face, grin_face, happy_face])
Exemplo n.º 56
0
from microbit import *
import music

"""
A short set of demos of the micropy
"""

music.play(music.POWER_UP, wait=False)
display.scroll("HELLO! I'm a micropy!")

display.scroll("You can use me to play music, and play games")

display.scroll("Try hitting the 'A' button")
while True:
    if button_a.is_pressed():
        music.play(music.PYTHON, wait=False)
        display.scroll("This is all written in python!")
        display.show(Image.SNAKE)

display.scroll("Now try hitting the 'B' button")