Script Python pour LeLapin

Le
PiLS
#/. /usr/bin/python2.7
#Please run this script under python 2.something.
#this script depends on python modules subprocess, random, Tkinter, and time.
#Also depends on the Linux program beep because I am a lazy bum.
print "press space to pause, escape to quit"
print "WARNING: pause WILL take a few beats to take effect that's on purpose."
onyva=raw_input('press ENTER to start')
from subprocess import call
import random
from Tkinter import *
import time

class PaceGiver():

def __init__(self, root):
self.running = True
self.aboutToQuit = False
self.root = root
score = 0
paused = 0
self.root.bind("<space>", self.switch)
self.root.bind("<Escape>", self.exit)

while not self.aboutToQuit:
self.root.update() # listen to events
if self.running:
nombre = int( 5 * random.random() + 3 + score/10) #number of repeats per sequence
delai = 1300/(((int(random.random() * 3)) + 3) - score/100) # delay between repeats, in ms
print str(int(score))
longueur = delai / 5
call(["beep", "-f 300", "-l", str(longueur), "-r", str(nombre), "-d", str(delai*2 - paused)])
score = score + (nombre * delai/500)
time.sleep(delai/200)

else: # If paused, decrease score
iscore = score
score = score - 0.1
if int( iscore ) <> int( score ): # only show integer score changes
print str(int(score))
iscore=score
paused=paused+1
time.sleep(0.1)

else:
print "She blows! You scored " + str(int(score)) + " points. Hope you had fun!"

def switch(self, event):
print ["Cooled down", "Edge reached"][self.running]
self.running = not(self.running)

def exit(self, event):
self.aboutToQuit = True
self.root.destroy()

if __name__ == "__main__":
root = Tk()
# root.withdraw() # don't show the tkinter window; depending on your window manager, you may need to uncomment this
PaceGiver(root)
root.mainloop()

#multipostage goret et suivi humour


--
PiLS
Vidéos High-Tech et Jeu Vidéo
Téléchargements
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
PiLS
Le #25131372
Version alternative, moins tendre mais plus sportive sur la fin; il
en faut pour tous les gouts. Ma princesse préfère.

Il y a un bug non résolu dans la version précédente (une division
par zéro dans certains cas, ligne 28). Je suis au courant, ranafout.
Le patch c'est un check pour quand
((int(random.random() * 3)) + 3) == score/100.
10 secondes à taper mais j'ai la flemme, démerdez-vous


#/. /usr/bin/python2.7
#Please run this script under python 2.something.
#this script depends on python modules subprocess, random, Tkinter, and time.
#Also depends on the Linux program beep because I am a lazy bum.
print "press space to pause, escape to quit"
print "WARNING: pause WILL take a few beats to take effect... that's on purpose."
onyva=raw_input('press ENTER to start')
from subprocess import call
import random
from Tkinter import *
import time

class PaceGiver():

def __init__(self, root):
self.running = True
self.aboutToQuit = False
self.root = root
score = 0
paused = 0
self.root.bind("<space>", self.switch)
self.root.bind("<Escape>", self.exit)

while not self.aboutToQuit:
self.root.update() # listen to events
if self.running:
nombre = int( 5 * random.random() + 3 + score/10) #number of repeats per sequence
delai = 1300/(((int(random.random() * 3)) + 3) + score/100) # delay between repeats, in ms
print str(int(score))
longueur = delai / 5
call(["beep", "-f 300", "-l", str(longueur), "-r", str(nombre), "-d", str(delai*2 - paused)])
score = score + (nombre * delai/500)
time.sleep(delai/200)

else: # If paused, decrease score
iscore = score
score = score - 0.1
if int( iscore ) <> int( score ): # only show integer score changes
print str(int(score))
iscore=score
paused=paused+1
time.sleep(0.1)

else:
print "She blows! You scored " + str(int(score)) + " points. Hope you had fun!"

def switch(self, event):
print ["Cooled down", "Edge reached"][self.running]
self.running = not(self.running)

def exit(self, event):
self.aboutToQuit = True
self.root.destroy()

if __name__ == "__main__":
root = Tk()
# root.withdraw() # don't show the tkinter window; depending on your window manager, you may need to uncomment this
PaceGiver(root)
root.mai+loop()

--
PiLS
Publicité
Poster une réponse
Anonyme