def main(): lp = launchpad.LaunchpadMk2() init(lp) setLayout(lp) pressed = [] while True: but = lp.ButtonStateXY() if but != []: highlightPressed(lp, but) if (but[2] == 127): #pressed pressed.append(but) else: removal = 0 for i in range(len(pressed)): if ([pressed[i][0], pressed[i][1]] == [but[0], but[1]]): removal = i try: del pressed[removal] releaseFunction(lp, but) except IndexError: pass if (pressed != []): print(pressed) pressedFunctions(lp, pressed) time.sleep(0.025)
def updates(self): time.sleep(1.5) while True: # Data comes in as a dictionary of 'obs', 'state', 'meta' data = self.dataPipe.recv() vehicle_name = self.current_vehicle_feed.get() # Run the inertial update thread self.t_states = threading.Thread(target = self.update_inertial_states, args = (data[vehicle_name]['state'],)) self.t_states.start() # Start Updater thread by setting the event # Run the Image Data thread self.t_imgs = threading.Thread(target = self.update_image_feeds, args = (data[vehicle_name]['obs'],)) self.t_imgs.start() # Run the meta data update self.t_meta = threading.Thread(target = self.update_metas, args = (data[vehicle_name]['meta'],)) self.t_meta.start() self.t_v_imu_viz = threading.Thread(target = self.update_virtual_imu_visualization, args = (data[vehicle_name]['state'],)) self.t_v_imu_viz.start() self.t_3d_track_viz = threading.Thread(target = self.update_object_3DVisualization, args = (data[vehicle_name]['state'],)) self.t_3d_track_viz.start() # Join Threads self.t_states.join() self.t_imgs.join() self.t_meta.join() self.t_v_imu_viz.join() self.t_3d_track_viz.join()
def run(self): while running: try: url = "http://192.168.1.101/api/game" data = json.load(urllib.urlopen(url)) print "---------" for _answer in data["answers"]: print " - " answer = int(_answer["id"]) if _answer["answer"] not in self.game.answer_strings and _answer["id"] < len(self.game.answer_strings): print "Oh Shit" print _answer print len(self.game.answer_strings) self.game.reset() if _answer["answer"] not in self.game.answer_strings: self.game.answer_strings.append(_answer["answer"]) self.game.answers.append( Answer(helper.get_answer_size()[0], helper.get_answer_size()[1], len(self.game.answer_strings), _answer["answer"])) print "Is this progress" if answer not in self.animating and answer not in self.animated and _answer["answered"]: print answer print _answer self.animating.append(answer) self.game.animate(_answer) finally: time.sleep(0.5)
def gameOver(self): _screen.gameOver(self.score) time.sleep(1) # Sleep so that we don't accidentally hit a button too fast to see our score. while True: for e in pygame.event.get(): if e.type == 2 or e.type == 0: # If we fire the quit event, or press a Key, quit. pygame.quit() sys.exit()
def draw_initial_screen(card_deck, visible_deck, sleep_time, difficulty): """ draws the an amount of cards onto the screen according to "difficulty", show them for "sleep_time" seconds, switch to card backs :param card_deck: string array, image paths :param visible_deck: string array, image paths :param sleep_time: int :param difficulty: int :return: """ card_draw(card_deck, difficulty) pygame.display.update() time.sleep(sleep_time) card_draw(visible_deck, difficulty)
def stop(self, block_timeout_sec=None): """Stop the video player. block_timeout_sec is how many seconds to block waiting for the player to stop before moving on. """ t1 = time.time() # Stop the player if it's running. if self._process is not None and self._process.returncode is None: # There are a couple processes used by omxplayer, so kill both # with a pkill command. # subprocess.call(['pkill', '-9', 'fbi']) # subprocess.call(['killall' 'fbi']) subprocess.call(['pkill', '-9', 'omxplayer']) # If a blocking timeout was specified, wait up to that amount of time # for the process to stop. start = time.time() while self._process is not None and self._process.returncode is None: if (time.time() - start) >= block_timeout_sec: break time.sleep(0) # Let the process be garbage collected. self._process = None # Clear the screen self._blank_screen()
import pygame.mixer, pygame.time import time mixer = pygame.mixer mixer.init() sound = mixer.Sound("that one wind sound from undertale (tm).wav") #channel = sound.play() #channel = sound.play(loops = -1) This will make the audio loop indefinitely ## ##while channel.get_busy(): ## pygame.time.wait(100) ## print("Playing...") ##print("finished") channel = sound.play(loops=-1, maxtime=0, fade_ms=10000) time.sleep(5) channel = sound.stop()
def ChangeToImage(data, base): image = Button(base, font="Helvetica", bg="grey") image.place(x=440, y=305, height=100, width=100) image.config(state=DISABLED) for i in range(len(data)): if data[i] == 'a' or data[i] == 'A': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) if data[i] == 't' or data[i] == 'T': image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'b' or data[i] == 'B': image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'c' or data[i] == 'C': image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) if data[i] == 'd' or data[i] == 'D': image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) if data[i] == 'e' or data[i] == 'E': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'f' or data[i] == 'F': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'g' or data[i] == 'G': image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'h' or data[i] == 'H': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'i' or data[i] == 'I': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'j' or data[i] == 'J': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'k' or data[i] == 'K': image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'l' or data[i] == 'L': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'm' or data[i] == 'M': image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'n' or data[i] == 'M': image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'o' or data[i] == 'O': image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'p' or data[i] == 'P': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'q' or data[i] == 'Q': image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'r' or data[i] == 'R': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'r' or data[i] == 'R': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 's' or data[i] == 'S': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'u' or data[i] == 'U': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'v' or data[i] == 'V': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'w' or data[i] == 'W': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'x' or data[i] == 'X': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25) if data[i] == 'z' or data[i] == 'Z': image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="red") time.sleep(2.25) image.configure(bg="grey") time.sleep(0.25) image.configure(bg="red") time.sleep(2.25) image.configure(bg="yellow") time.sleep(0.75) image.configure(bg="grey") time.sleep(0.25)
def ChangeToSound(data): for i in range(len(data)): if (data[i] == 'a' or data[i] == 'A'): mixer.init() soundPath = os.path.abspath('Sounds/A_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'b' or data[i] == 'B'): mixer.init() soundPath = os.path.abspath('Sounds/B_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'c' or data[i] == 'C'): mixer.init() soundPath = os.path.abspath('Sounds/C_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'd' or data[i] == 'D'): mixer.init() soundPath = os.path.abspath('Sounds/D_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'e' or data[i] == 'E'): mixer.init() soundPath = os.path.abspath('Sounds/E_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'f' or data[i] == 'F'): mixer.init() soundPath = os.path.abspath('Sounds/F_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'g' or data[i] == 'G'): mixer.init() soundPath = os.path.abspath('Sounds/G_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'h' or data[i] == 'H'): mixer.init() soundPath = os.path.abspath('Sounds/H_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'i' or data[i] == 'I'): mixer.init() soundPath = os.path.abspath('Sounds/I_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'j' or data[i] == 'J'): mixer.init() soundPath = os.path.abspath('Sounds/J_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'k' or data[i] == 'K'): mixer.init() soundPath = os.path.abspath('Sounds/K_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'm' or data[i] == 'M'): mixer.init() soundPath = os.path.abspath('Sounds/M_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'n' or data[i] == 'N'): mixer.init() soundPath = os.path.abspath('Sounds/N_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'o' or data[i] == 'O'): mixer.init() soundPath = os.path.abspath('Sounds/O_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'p' or data[i] == 'P'): mixer.init() soundPath = os.path.abspath('Sounds/P_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'r' or data[i] == 'R'): mixer.init() soundPath = os.path.abspath('Sounds/R_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 's' or data[i] == 'S'): mixer.init() soundPath = os.path.abspath('Sounds/S_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 't' or data[i] == 'T'): mixer.init() soundPath = os.path.abspath('Sounds/T_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'u' or data[i] == 'U'): mixer.init() soundPath = os.path.abspath('Sounds/U_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'v' or data[i] == 'V'): mixer.init() soundPath = os.path.abspath('Sounds/V_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'w' or data[i] == 'W'): mixer.init() soundPath = os.path.abspath('Sounds/W_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'x' or data[i] == 'X'): mixer.init() soundPath = os.path.abspath('Sounds/X_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'y' or data[i] == 'Y'): mixer.init() soundPath = os.path.abspath('Sounds/Y_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1) if (data[i] == 'z' or data[i] == 'Z'): mixer.init() soundPath = os.path.abspath('Sounds/Z_morse_code.mp3') mixer.music.load(soundPath) mixer.music.play() time.sleep(1)
objhelper.show_text(screen, objhelper.left_player_score_coord[0], objhelper.left_player_score_coord[1], objhelper.blue, "Left Player Score:" + str(paddleleft.score)) objhelper.show_text(screen, objhelper.right_player_score_coord[0], objhelper.right_player_score_coord[1], objhelper.red, "Right Player Score:" + str(paddleright.score)) time_elapsed = int(time_end - objhelper.start_time) objhelper.show_text(screen, objhelper.time_coord[0], objhelper.time_coord[1], objhelper.red, "Time:" + str(time_elapsed)) if time_elapsed > objhelper.game_over_time: objhelper.show_text(screen, objhelper.game_over_coord[0], objhelper.game_over_coord[1], objhelper.red, "GAME OVER!!!") if paddleleft.score > paddleright.score: objhelper.show_text(screen, objhelper.game_over_coord[0], objhelper.game_over_coord[1]+50, objhelper.red, "Player 1 won") if paddleleft.score < paddleright.score: objhelper.show_text(screen, objhelper.game_over_coord[0], objhelper.game_over_coord[1]+50, objhelper.red, "Player 2 won") if paddleleft.score == paddleright.score: objhelper.show_text(screen, objhelper.game_over_coord[0], objhelper.game_over_coord[1]+50, objhelper.red, "DRAW!!") pygame.display.update() time.sleep(2) pygame.quit() exit() for event in pygame.event.get(): if event.type == QUIT: pygame.quit() exit() elif event.type == KEYDOWN: if event.key == K_w: paddleleft.paddle_up = 1 elif event.key == K_s: paddleleft.paddle_down = 1 if event.key == K_UP: paddleright.paddle_up = 1 elif event.key == K_DOWN:
volume.SetMasterVolumeLevel(-10.0, None) else: #not muted volume.SetMasterVolumeLevel(-10.0, None) ##--------------------------------------------------------- window = Tk() window.withdraw() window.lift() messagebox.showinfo("Mistake1","You Shouldn't have done that", icon='warning') changeVol(volume) channel = music.play(loops = -1, maxtime = 0, fade_ms = 8000) time.sleep(4) voice('Prepare to get hacked.') time.sleep(1) ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0,b'C:\Users\Austen Brownfield\Desktop\Sophomore Semester1\Python\Final\Images\Skulls.jpg', 3) messagebox.showinfo("Mist","Nice Background Image", icon = 'warning') index = 0 while index < 400: brightnessChangeOld(index) index += 4 messagebox.showinfo("01100110","Downloading Files...", icon = 'warning') time.sleep(1)
#screen.fill((0,0,255)) arrow_group.draw(screen) #pygame.display.flip() pygame.display.update(arrow.rect) from weather import Weather weather = Weather() weather.update() tick = 0 while 1: if tick == 0: weather_info = weather.getWeatherInfo() weather.update() arrow.setTargetDirection(weather_info['angle']) arrow.setAirspeed(weather_info['speed']) arrow_shadow.setTargetDirection(weather_info['angle']) arrow_shadow.setAirspeed(weather_info['speed']) tick += 1 updateArrow() pygame.image.save(screen, "cache/screen_%i.tga" % (int(arrow.direction))) time.sleep(1/FRAMES_PER_SECOND) if tick >= 180: tick = 0