MicroPython version for the Mäxchen game.
Requirements:
- Pyboard
- lcd160cr
MicroPython version for the Mäxchen game.
Requirements:
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(" ") |