当前位置: 首页>>代码示例>>Python>>正文


Python time.wait函数代码示例

本文整理汇总了Python中pygame.time.wait函数的典型用法代码示例。如果您正苦于以下问题:Python wait函数的具体用法?Python wait怎么用?Python wait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wait函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():

	# create two Launchpad instances
	lp1 = launchpad.Launchpad()
	lp2 = launchpad.Launchpad()

	# open them
	lp1.Open(0)
	lp2.Open(1)


	while 1:
	
		# random light show
		lp1.LedCtrlRaw( random.randint(0,127), random.randint(0,3), random.randint(0,3) )
		lp2.LedCtrlRaw( random.randint(0,127), random.randint(0,3), random.randint(0,3) )
		
		# some extra time to give the button events a chance to come through...
		time.wait( 5 )

		# wait until the arm button (lower right) is hit
		but = lp1.ButtonStateRaw()
		if but != []:
			print( but )
			if but[0] == 120:
				break
开发者ID:jesuswithyoyo,项目名称:launchpad.py,代码行数:26,代码来源:launchpad_demo_2devices.py

示例2: main

def main(file_path=None):
    """Play an audio file as a buffered sound sample

    Option argument:
        the name of an audio file (default data/secosmic_low.wav

    """
    if file_path is None:
        file_path = os.path.join(main_dir,
                                 'data',
                                 'secosmic_lo.wav')

    #choose a desired audio format
    mixer.init(11025) #raises exception on fail


    #load the sound    
    sound = mixer.Sound(file_path)


    #start playing
    print ('Playing Sound...')
    channel = sound.play()


    #poll until finished
    while channel.get_busy(): #still playing
        print ('  ...still going...')
        time.wait(1000)
    print ('...Finished')
开发者ID:123jefferson,项目名称:MiniBloq-Sparki,代码行数:30,代码来源:sound.py

示例3: start

def start(LP):
  snake = {}
  
  init_snake(LP, snake)
  
  LP.LedCtrlXY(0, 0, 0, 1)
  LP.LedCtrlXY(1, 0, 0, 1)
  LP.LedCtrlXY(8, 8, 1, 0)
  
  time.wait(500)
  
  while True:
    time.wait(500)
    
    but = LP.ButtonStateXY()
    while but != [] and not but[2]:
      but = LP.ButtonStateXY()
    
    if but != [] and but[2]:
      if but[0:2] == [8, 8]:
        break
      if but[0:2] == snake["food"]:
        snake["head"] = [3, 3]
      elif but[0:2] == [0, 0]:
        snake["dir"] = (snake["dir"] - 1) % 4
      elif but[0:2] == [1, 0]:
        snake["dir"] = (snake["dir"] + 1) % 4
    
    update(LP, snake)
开发者ID:Isti115,项目名称:RaspberryPi_Launchpad_Games,代码行数:29,代码来源:snake_old.py

示例4: update

    def update(self):
        
        self.tick = get_ticks()
        delta = self.tick - self.last_tick

        if self.slow_motion_delay > 0:
            self.slow_motion_delay -= 1

            if self.slow_motion_delay <= 0:
                self.frecuency = self.normal_frecuency


        if delta > self.frecuency:
            skips = delta / self.frecuency

            if skips > self.maxframeskip:
                skips = self.maxframeskip
                self.last_tick = self.tick
            else:
                self.last_tick += skips * self.frecuency

            self._update_status()
            return skips
        else:
            wait(1)
            return 0
开发者ID:HieuLsw,项目名称:sbfury,代码行数:26,代码来源:fps.py

示例5: ledctrlc

def ledctrlc(dev,list,buffer_time_lists,buffer_time_numbers):
 from pygame import time
 franum_total = 0
 for frame in list:
  franum_total += 1
 franum = 1
 print("#####ANIMATION START#####")
 for frame in list:
  colnum = 1
  print("+++++FRAME " + str(franum) + " / " + str(franum_total) + " +++++")
  for color in frame:
   for i in color:
    if colnum == 1:
     dev.LedCtrlRaw(i,3,0)
     print(str(i) + " -> red")
    elif colnum == 2:
     dev.LedCtrlRaw(i,3,3)
     print(str(i) + " -> yellow")
    elif colnum == 3:
     dev.LedCtrlRaw(i,0,3)
     print(str(i) + " -> green")
    else:
     dev.LedCtrlRaw(i,3,3)
     print(str(i) + " -> yellow by else case")
   colnum += 1
   time.wait(buffer_time_numbers)
  time.wait(buffer_time_lists)
  dev.Reset()
  franum += 1
 print("#####ANIMATION END#####\n")
开发者ID:sesshomariu,项目名称:launchpad-matrix,代码行数:30,代码来源:codes.py

示例6: run

    def run(self):
        self.net_tick = 0
        self.clients = {}
        self.lock = Lock()
        self.server = UdpServer(25000)

        self.socket_thread = SocketThread(self)
        self.socket_thread.start()

        print "Server up and running."

        self.input_thread = InputThread(self)
        self.input_thread.start()

        ticks_start = time.get_ticks()
        while not self.quit:
            ticks = time.get_ticks() - ticks_start - self.net_tick * FRAMETIME
            update_count = ticks / FRAMETIME
            with self.lock:
                for i in xrange(update_count):
                    self.update()
                    self.send_new_state()
                    dead_clients = []
                    for addr, client in self.clients.items():
                        client.countdown()
                        if client.is_dead():
                            dead_clients.append(addr)
                    for addr in dead_clients:
                        print "removing client %s (timeout)" % str(addr)
                        del self.clients[addr]
            time.wait(1)
开发者ID:oncer,项目名称:netproto,代码行数:31,代码来源:np_server.py

示例7: authenticate

    def authenticate(self):
        """ call this before opening the game
        gets the current tick from the server
        and synchronizes the game state """

        def threaded_recv(retlist):
            response, addr = self.client.recv()
            retlist.append(response)

        pkg_request = Packet(0)
        self.client.send(pkg_request)
        retlist = []
        t = Thread(target=lambda: threaded_recv(retlist))
        t.daemon = True
        t.start()
        wait_start = time.get_ticks()
        wait_end = wait_start + 1000
        while len(retlist) <= 0 and time.get_ticks() < wait_end:
            time.wait(1)

        if len(retlist) > 0:
            response = retlist[0]
            pkg_response = Packet.unpack(response)
            self.start_tick = pkg_response.tick
            if len(pkg_response.players) <= 0:
                raise RuntimeError("Invalid response: %s" % pkg_response)
            self.id = pkg_response.players[0][0]
            self.set_state(pkg_response, backtrack=False)
        else:
            raise RuntimeError("Server not responding")
开发者ID:oncer,项目名称:netproto,代码行数:30,代码来源:np_client.py

示例8: test

def test():
    sp = SoundPlayer()
    for i in range(8):
        sp.load(i)
    t = sp.sounds[1].get_length() * 1000
    sp.play(1)
    time.wait(t)
开发者ID:BenignCremator,项目名称:RPi-DMX-media-sync,代码行数:7,代码来源:sound_player.py

示例9: setup

def setup():
	random.seed()
	mixer.init()
	#screen = pygame.display.set_mode ((640, 480), 0, 32)
	samples = get_samples("./samples")
	init_playfield(samples)
	tick()
	print_playfield()
	pygame.init ()
	#screen.fill ((100, 100, 100))
	#pygame.display.flip ()
	#pygame.key.set_repeat (500, 30)
	#mixer.init(11025)
	#mixer.init(44100)
	#sample = samples[random.randint(0,len(samples)-1)]
	#print("playing sample:",sample)
	#sound = mixer.Sound(sample)
	#channel = sound.play()

	while True:
		play_sounds()
		#for i in range(2):	
		mutate_playfield()
		tick()
		print_playfield()
		#time.wait(int((1000*60)/80)) # 128bpm
		time.wait(50)

	#while channel.get_busy(): #still playing
	#	print("  ...still going...")
	#	time.wait(1000)
	#print("...Finished")
	pygame.quit()
开发者ID:pez2001,项目名称:Stuff,代码行数:33,代码来源:conwaysa.py

示例10: stopTripod

def stopTripod(t, turnAngle=0, back=False, duty_turn=0):
	""" Adds an ending point to the tripod gait and returns to a
	    standing position. """

	xjusAnalysis.endAccel(PLOT_ANALYSIS)
	xjusAnalysis.endAvgVelocity()
	#acc = xjusAnalysis.getAvgAbsZAccel()
	#print("===============================================")
	#print("Stability measure: %.4f" % (acc))
	current = xjusAnalysis.getAvgCurrent()
	#print("Power usage measure: %.4f" % (current))
	#print("===============================================")
	
	pytime.wait(DT)
	for node in nodes:
		[nA, pA, vA, tA] = addTripodPoint(t, turnAngle, back=back, end=True, duty_turn=duty_turn)
		addPvtArray(nA, pA, vA, tA)

	for node in nodes:
		xjus.stopIPM(node)
		xjus.printIpmStatus(node)

	wait()

	returnToStand()
开发者ID:hmartiro,项目名称:project-thesis,代码行数:25,代码来源:xjus.py

示例11: main

def main():

    LP = launchpad.Launchpad()  # creates a Launchpad instance (first Launchpad found)
    LP.Open()  # start it

    LP.LedCtrlString("HELLO ", 0, 3, -1)  # scroll "HELLO" from right to left

    # random output until button "arm" (lower right) is pressed
    print("---\nRandom madness. Stop by hitting the ARM button (lower right)")
    print("Remember the PyGame MIDI bug:")
    print("If the ARM button has no effect, hit an automap button (top row)")
    print("and try again...")

    while 1:
        LP.LedCtrlRaw(random.randint(0, 127), random.randint(0, 3), random.randint(0, 3))

        # some extra time to give the button events a chance to come through...
        time.wait(5)

        but = LP.ButtonStateRaw()
        if but != []:
            print(but)
            if but[0] == 120:
                break

    LP.Reset()  # turn all LEDs off
    LP.Close()  # close the Launchpad
开发者ID:sesshomariu,项目名称:launchpad-matrix,代码行数:27,代码来源:launchpad_demo.py

示例12: scheduler_loop

def scheduler_loop(timestamp_dictionary, stack):
    global now
    while active:        
        now = pgtime.get_ticks()
        # now schedule pending events ... thus we're having a fixed point of time ('now')
        while len(stack) > 0:
            delayed_event = stack.pop()
            # correct future time if wait was not precise
            future_time = delayed_event[1]                               
            if future_time not in timestamp_dictionary:
                timestamp_dictionary[future_time] = {}
            # get objects uuid
            key = delayed_event[0]
            # store function to be scheduled under the object uuid (necessary for cleaning) 
            timestamp_dictionary[future_time][key] = delayed_event[2]
        # after everything has been said and done, check if there's any garbage left ...
        time_points = timestamp_dictionary.keys()
        past_time_points = [x for x in time_points if x < now]
        for time_point in past_time_points:                    
            #print(str(len(timestamp_dictionary[past])) + " EVENTS at " + str(past))
            for past_event in timestamp_dictionary[time_point]:                
                try:                    
                    async = threading.Thread(target=timestamp_dictionary[time_point][past_event], args=(time_point, now))
                    async.start()
                except Exception as e:
                    print(e) 
                    raise e
            del timestamp_dictionary[time_point]            
            # wait one microsecond              
        pgtime.wait(1) 
开发者ID:the-drunk-coder,项目名称:regraa,代码行数:30,代码来源:regraa_scheduler.py

示例13: progress

def progress():

	global posX
	global posY
	global colour
	global delay

	# Progress by a random number between 2 and 6 blocks
	progression = random.randint(2,6)

	# Run 3 times, one for each state.
	for x in range(0, 3):

		for y in range(0, progression):

			# If progression has reached the 8th column, increase the row number and reset the column number.
			if posX[x] == 8:
				posY[x] += 1
				posX[x] = 0

			# Set LED Colours according to the state and colour var in setup.
			LP.LedCtrlXY(posX[x], posY[x], colour[x][0], colour[x][1])

			# Increase column number.
			posX[x] = posX[x]+1

		# Wait a rancom number of milliseconds according to the delay var.
		time.wait(random.randint(delay[x][0],delay[x][1]))
开发者ID:siddv,项目名称:Defrag.py,代码行数:28,代码来源:defrag.py

示例14: ledctrlfn

def ledctrlfn(dev,list,buffer_time_lists,buffer_time_numbers,red,green):
 from pygame import time
 for i in list:
  dev.LedCtrlRaw(i,red,green)
  print(i)
  time.wait(buffer_time_numbers)
  dev.Reset()
开发者ID:sesshomariu,项目名称:launchpad-matrix,代码行数:7,代码来源:codes.py

示例15: check_for_exit

def check_for_exit(poll_time=KEY_PRESS_POLL_TIME):
    time.wait(poll_time)
    if not event.peek():
        return

    ev = event.poll()
    if ev.type == pygame.KEYDOWN and ev.key == pygame.K_SPACE:
        sys.exit(0)
开发者ID:fjohnson,项目名称:ansidisplay,代码行数:8,代码来源:portrait.py


注:本文中的pygame.time.wait函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。