Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. from microbit import *
  2. import random
  3.  
  4. display.show(5)
  5. sleep(1000)
  6. display.show(4)
  7. sleep(1000)
  8. display.show(3)
  9. sleep(1000)
  10. display.show(2)
  11. sleep(1000)
  12. display.show(1)
  13. sleep(1000)
  14. a = button_a.get_presses()
  15. if a==0:
  16.     m=500
  17.     display.scroll("lagano")
  18. if a==1:
  19.     m=200
  20.     display.scroll("srednje")
  21. if a==2:
  22.     m=100
  23.     display.scroll("tesko")
  24.    
  25. q=random.randint(0,4)
  26. w=random.randint(0,4)
  27. display.set_pixel(q,w,3)
  28.  
  29. x=0
  30. y=0
  31. while True:
  32.     for i in range (25):
  33.         display.set_pixel(x,y,7)
  34.         sleep(m)
  35.         if button_b.is_pressed():
  36.             if q==x and w==y:
  37.                 display.scroll("Pobjednik")
  38.                 sleep(1000000)
  39.                 break
  40.             else:
  41.                 display.scroll("Gubitnik")
  42.                 sleep(1000000)
  43.                 break
  44.         display.set_pixel(x,y,0)
  45.         display.set_pixel(q,w,3)
  46.         x+=1
  47.         if x==5:
  48.             x=0
  49.             y+=1
  50.         if y==5:
  51.             x=0
  52.             y=0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement