Advertisement
timber101

Magic 8 Ball / Mystic Meg

Apr 12th, 2021
860
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None
  1. #  Magic 8 Ball Game - Mystic Meg
  2.  
  3. from sense_hat import SenseHat # Capital S and H needed
  4. from random import choice
  5. from time import sleep
  6.  
  7. sense= SenseHat()
  8.  
  9. #print("Ask me a question >> ")
  10.  
  11. sense.show_message("Ask me a question >> ", scroll_speed = 0.06)
  12.  
  13. sleep (3)  # 3 second delay
  14.  
  15. replies = ["I'm not sure",
  16.     "most definitely",
  17.     "Hmm let me think about that",
  18.     "Looking Good",
  19.     "Signs point to yes",
  20.     "Not a chance",
  21.     "I think thats a posibility",
  22.     "Better ask someone else!"]
  23. """
  24. while True:
  25.  x, y, z = sense.get_accelerometer_raw().values()
  26.  
  27.  x = abs(x)
  28.  y = abs(y)
  29.  z = abs(z)
  30.    
  31. #print(choice(replies))
  32.  if x>2 or y>2 or z >2 :
  33.    
  34.  else:
  35.    sense.clear()
  36. """
  37.  
  38.  
  39. while True:
  40.   for event in sense.stick.get_events():
  41.     # Check if the joystick was pressed
  42.     if event.action == "pressed":
  43.       sense.show_message(choice(replies), scroll_speed = 0.06)
  44.     else:
  45.       sense.clear()
Advertisement
RAW Paste Data Copied
Advertisement