Author: simplet
Date: 2008-12-15 13:13:51 +0100 (Mon, 15 Dec 2008)
New Revision: 3132

Added:
   software_suite_v2/software/scripts/twister/
   software_suite_v2/software/scripts/twister/twister.py
Log:
* first version of the game. I love the voice lol !


Added: software_suite_v2/software/scripts/twister/twister.py
===================================================================
--- software_suite_v2/software/scripts/twister/twister.py                       
        (rev 0)
+++ software_suite_v2/software/scripts/twister/twister.py       2008-12-15 
12:13:51 UTC (rev 3132)
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+# -*- coding: latin1 -*-
+
+"""
+======================================================================
+
+  Twister Game  
+
+  Simplet <simplet _at_ ptigeek _dot_ net>
+
+
+  Use this script to play the game TWISTER !
+  
+  
+  TODO
+  =====
+  - Command line argument to play with a timer instead of waiting for a push.
+  - Add sounds and attitunes.
+  
+======================================================================
+"""
+
+__author__  = 'Simplet <simplet _at_ ptigeek _dot_ net>'
+__appname__ = 'Twister script'
+__version__ = '0.0.1'
+__date__    = '2008/12/15'
+__license__ = 'GPL'
+
+
+import random, threading, time
+from tuxisalive.api import *
+
+def onSpeakOn(*args):
+    tux.mouth.open()
+    
+def onSpeakOff(*args):
+    tux.mouth.close()
+
+def GetRandomTwist(*args):
+    element = random.sample(["Pied" , "Main"],  1)
+    cote = random.sample(["droit" , "gauche"],  1)
+    couleur = random.sample(["rouge" , "jaune", "vert", "bleu"],  1)
+
+    my_text = "%s %s sur le rond %s" % (element, cote, couleur)
+    my_text = my_text.replace("'", "") # ugly hack :p
+    my_text = my_text.replace("[", "") # ugly hack :p
+    my_text = my_text.replace("]", "") # ugly hack :p
+    my_text = "%s. Je r�p�te : %s." % (my_text, my_text)
+    
+    t = threading.Thread(target = tux_speak, args = [my_text,])
+    t.start()
+
+def Quitter(*args):
+    global iEtat
+    my_text = "Partie de Twisteur termin�e !. A bientot !"
+    t = threading.Thread(target = tux_speak, args = [my_text,])
+    t.start()
+    iEtat = 0
+    
+def tux_speak(text):
+    tux.tts.speakPush(text)
+
+
+# Start game
+tux = TuxAPI('127.0.0.1', 270)
+tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'Twister', 'NONE')
+tux.server.waitConnected(10.0)
+tux.dongle.waitConnected(10.0)
+tux.radio.waitConnected(10.0)
+if tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL):
+
+  # Register game events
+  tux.button.head.registerEventOnPressed(GetRandomTwist)
+  tux.button.remote.registerEventOnPressed(GetRandomTwist, K_OK)
+  tux.button.remote.registerEventOnPressed(Quitter, K_STANDBY)
+  tux.tts.registerEventOnSoundOn(onSpeakOn)
+  tux.tts.registerEventOnSoundOff(onSpeakOff)
+
+  tux.tts.speak("Bienvenue dans Twisteur!. Appuyez sur ma t�te pour avoir un " 
+
+  "ordre au hasard. La partie peut maintenant commencer !.", "Julie", 140)
+  
+  iEtat = 1
+  while iEtat == 1:
+     time.sleep(1)
+
+tux.access.release() 
+tux.server.disconnect()
+tux.destroy()


Property changes on: software_suite_v2/software/scripts/twister/twister.py
___________________________________________________________________
Name: svn:executable
   + *


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to