@alexmburns wrote:
Hello there,
I am trying to create a simple dice roller for my Scroll pHAT HD. I have written the following (below) in Python, it works in terminal with no problems… but when I try to display it on my Scroll pHAT HD it will not scroll the text for some reason. It just shows the first part of the “You Rolled A…” string. Furthermore all subsequent sentences just appear on top of the old one… I imagine this is something to do with the clear function.
If anyone can point me in the right direction I would be very grateful.
import random
import signal
import time
import scrollphathd as sphddef roll(sides=6):
num_rolled = random.randint(1,sides)
return num_rolleddef main():
sides = 6
rolling = True
while rolling:
roll_again = raw_input("Ready to roll? ENTER=Roll.Q=Quit. ")
if roll_again.lower() !=“q”:
num_rolled = roll(sides)
sphd.write_string(“You rolled a”, num_rolled)
sphd.show()
sphd.scroll(1)
time.sleep(0.05)else: rolling = False print ("You We're On A Roll!")
main()
Posts: 3
Participants: 2