Last active
February 8, 2016 19:18
-
-
Save a-bildungSROMAN/73fdda6d847b121c684b to your computer and use it in GitHub Desktop.
Competitive Macbeth Handheld Game - Sense HAT for RPi and Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import time | |
from sense_hat import SenseHat | |
from subprocess import call | |
sh = SenseHat() | |
sh.set_rotation(90) | |
sh.show_message("Let's begin Act I...", text_colour=[0, 50, 220], scroll_speed=.055) | |
time.sleep(4) ###These variables can be edited. Start the game however you'd like.### | |
replies = ['Scene 1, Ln 12-3', | |
'Scene 3, Ln 14-5', | |
'High five Roman +1', | |
'Scene 6, Ln 87-9', | |
'Chicken Dance +2',]###These can all be edited, as they are examples. Shorter is better, depending on your scroll speed.### | |
while True: ###This is using the movement data from the SenseHAT. You're more than welcome to play around. The higher the number, the more rapid the acceleration.### | |
x, y, z = sh.get_accelerometer_raw().values() | |
x = abs(x) | |
y = abs(y) | |
z = abs(z) | |
if x > 2 or y > 2 or z > 2 : | |
sh.show_message(random.choice(replies), text_colour=[0, 50, 220], scroll_speed=.055) ###If you want to edit how the random responses look.### | |
elif x==0 and y==0 and z==0 :###This isn't working. I'll update when it's figured out. For right now, after the game is finished, plug into a monitor so that you may shut it down correctly.### | |
time.delay(240) | |
sh.show_message("Time to shutdown!", text_colour=[0, 50, 220], scroll_speed=.055) | |
time.delay(1) | |
call("sudo nohup shutdown -h now", shell=True) | |
else:###Don't delete this, as it clears the data after each random response.### | |
sh.clear() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment