Advertisement
shh_algo_PY

Ashley's Slot Machine

Mar 3rd, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.91 KB | None | 0 0
  1. '''
  2. Hi, Ashley!
  3.  
  4. The error was caused by a name mix-up.
  5.  
  6. num1 --- these are your numbers, in number form, which can work with randint(). This has no hide() or show()
  7.  
  8. num1_text --- these are your text sprites, which is what shows on the screen. This has hide() and show()
  9.  
  10. '''
  11.  
  12. import play
  13. from random import randint
  14.  
  15. box1 = play.new_box(color = 'blue', x = -200, y = 0, width = 100, height = 200, border_width = 5, border_color = 'medium blue')
  16.  
  17. box2 = play.new_box(color = 'blue', x = 0, y = 0, width = 100, height = 200, border_width = 5, border_color = 'medium blue')
  18.  
  19. box3 = play.new_box(color = 'blue', x = 200, y = 0, width = 100, height = 200, border_width = 5, border_color = 'medium blue')
  20.  
  21. welcome = play.new_text(words = 'Hello! Click the button to try your luck!', x = 0, y = 180, font_size = 40, color = 'black')
  22.  
  23. button = play.new_box(color = 'yellow', x = 0, y = -180, width = 330, height = 100, border_width = 5, border_color = 'gold')
  24.  
  25. start = play.new_text(words = 'PRESS TO START', x = 0, y = -180, font_size = 50, color = 'black')
  26.  
  27. num1_text = play.new_text(words = '1', x = -200, y = 0, font = None, font_size = 220, color='white')
  28.  
  29. num2_text = play.new_text(words = '2', x = 0, y = 0, font = None, font_size = 220, color='white')
  30.  
  31. num3_text = play.new_text(words = '3', x = 200, y = 0, font = None, font_size = 220, color='white')
  32.  
  33. @play.when_program_starts
  34. def start( ):
  35.     num1_text.hide()
  36.     num2_text.hide()
  37.     num3_text.hide()
  38.  
  39. @play.repeat_forever
  40. def do( ):
  41.     pass
  42.  
  43. @button.when_clicked
  44.  
  45. async def clicking():
  46.     num1 = randint(0,9)
  47.     num2 = randint(0,9)
  48.     num3 = randint(0,9)
  49.     num1_text.words = str(num1)
  50.     num2_text.words = str(num2)
  51.     num3_text.words = str(num3)
  52.     num1_text.show()
  53.     num2_text.show()
  54.     num3_text.show()
  55.     await play.timer(seconds=2.0)
  56.     num1_text.hide()
  57.     num2_text.hide()
  58.     num3_text.hide()
  59.  
  60. play.start_program( )
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement