本文整理汇总了Python中PiStorms.PiStorms.resetKeyPressCount方法的典型用法代码示例。如果您正苦于以下问题:Python PiStorms.resetKeyPressCount方法的具体用法?Python PiStorms.resetKeyPressCount怎么用?Python PiStorms.resetKeyPressCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PiStorms.PiStorms
的用法示例。
在下文中一共展示了PiStorms.resetKeyPressCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: int
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import resetKeyPressCount [as 别名]
if(x % 2 == 1): # if the number of loop iterations modulo 2 = 1, then:
psm.led(2,255,0,0) #flash LED 2 red
time.sleep(0.06) # for 6/100ths of a second
psm.led(1,0,0,0) # set both LEDs to off
psm.led(2,0,0,0)
time.sleep(0.01) # wait 1/100th of a second
x += 1 # increment loop iteration count
if(x >= num): # if the loop iteration count is higher than the input, then:
x = 0 # set loop iteration to 0
quit = True # quit becomes true and the loop is escaped
### main running loop ###
# moves "Mike" (the smiley face) around the screen to random locations
# tracks the players score
miliseconds = int(round(time.time()*1000))
psm.resetKeyPressCount()
while(not exit):
randX = random.randint(0, 245) # selects a random x coordinate for Mike
# max of 245 so he will not appear off the screen (screen x value is 320, so 320 - Mike's width (75) = 245)
randY = random.randint(0, 115) # selects a random y coordinate for Mike
# max of 115 so he will not appear off the screen (screen y value is 240, but the score display starts at yvalue of 190, so 190 - Mike's height (75) = 115)
psm.screen.fillBmp(randX, randY, 95-score, 95-score, path = currentdir+'/'+"faceAwesome.png") # display Mike at the random coordinates
miliseconds = int(round(time.time()*1000))
while (int(round(time.time()*1000)) - miliseconds)< (150+1000/score):
if(psm.screen.checkButton(randX - (score), randY - (score), 95-score, 95-score)): # if an invisible box drawn around Mike's position is tapped, then:
psm.screen.fillRect(0,0,320,320) # white screen
psm.screen.drawAutoText("You got me!", 15, 140, fill=(0, 0, 0), size = 45) # draw text
score += 1 # increment player's score
if score < 5 :