Skip to content

Instantly share code, notes, and snippets.

@anapaulagomes
Last active July 12, 2019 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anapaulagomes/c9430af74244fcadbcee556194c49441 to your computer and use it in GitHub Desktop.
Save anapaulagomes/c9430af74244fcadbcee556194c49441 to your computer and use it in GitHub Desktop.
Mäxchen game
import lcd160cr
import random
lcd = lcd160cr.LCD160CR('X')
HEIGHT = lcd.h
WIDTH = lcd.w
lcd.erase()
lcd.set_orient(lcd160cr.PORTRAIT)
lcd.set_pos(35, 0)
lcd.set_text_color(lcd.rgb(255, 255, 255), lcd.rgb(0, 0, 0))
lcd.set_font(0, scale=1)
lcd.write('Maxchen')
lcd.set_pen(lcd.rgb(255, 0, 0), lcd.rgb(0, 0, 0))
for number in range(1, WIDTH):
lcd.dot(number, 15)
lcd.set_text_color(lcd.rgb(255, 255, 255), lcd.rgb(0, 0, 0))
lcd.set_font(10)
lcd.set_pos(10, 20)
lcd.write('Press to roll')
lcd.set_pos(25, 30)
lcd.write('the dices')
while True:
if lcd.is_touched():
first_dice = random.randint(1, 6)
second_dice = random.randint(1, 6)
lcd.set_pos(40, 70)
lcd.set_font(0, scale=3)
lcd.write('{} {}'.format(first_dice, second_dice))
lcd.set_pos(10, 100)
if first_dice == second_dice:
lcd.set_pos(30, 100)
lcd.set_font(0, scale=2)
lcd.write("PASCH")
elif (first_dice == 2 and second_dice == 1) or (first_dice == 1 and second_dice == 2):
lcd.set_font(0, scale=1)
lcd.write("WHAT'S THE NAME")
lcd.set_pos(10, 120)
lcd.write("OF THE GAME?")
else:
for position in range(100, 121):
lcd.set_pos(10, position)
lcd.write(" ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment