shh_algo_PY

Xin Yee's Slot Machine

Mar 3rd, 2022 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.03 KB | None | 0 0
  1. '''
  2. Hi, Xin Yee!
  3.  
  4. Just a small error. You haven't got a sprite called 'result' (the one that announces you win or you lose)
  5.  
  6. So using the command result.hide() and result.show() before creating the sprite confuses your code! It can't find anything named result, so it gives you an error.
  7.  
  8. Hope this helps!
  9. '''
  10.  
  11. import play
  12. from random import randint
  13.  
  14. #set playing field
  15. w = play.screen.width
  16. h = play.screen.height
  17.  
  18. place1 = play.new_box(color = 'pink', x = -200, y = 0, width = 100, height = 200, border_width=5, border_color='pink')
  19.  
  20. place2 = play.new_box(color = 'light skyblue', x = 0, y = 0, width = 100, height = 200, border_width=5, border_color='light skyblue')
  21.  
  22. place3 = play.new_box(color = 'violet', x = 200, y = 0, width = 100, height = 200, border_width=5, border_color='violet')
  23.  
  24. button = play.new_box(color = 'gold', x = 0, y = 250, width = 100, height = 50, border_width=5, border_color = 'gold')
  25.  
  26. text1 = play.new_text(words = 'Play', color = 'purple', x = 0, y = 250)
  27.  
  28. num1_text = play.new_text(words = '', x = -200, y = 0, font = None, font_size = 100, color='white')
  29.  
  30. num2_text = play.new_text(words = '', x = 0, y = 0, font = None, font_size = 100, color='white')
  31.  
  32. num3_text = play.new_text(words = '', x = 200, y = 0, font = None, font_size = 100,color='white')
  33.  
  34. @play.when_program_starts
  35. def start():
  36.     num1_text.hide()
  37.     num2_text.hide()
  38.     num3_text.hide()
  39.     #result.hide() --- you can uncomment this (remove #) when you have a sprite called result
  40.  
  41. @play.repeat_forever
  42. def do( ):
  43.     pass
  44.  
  45. @button.when_clicked
  46.  
  47. async def clicking():
  48.     num1 = randint(0, 9)
  49.     num2 = randint(0, 9)
  50.     num3 = randint(0, 9)
  51.     num1_text.words = str(num1)
  52.     num2_text.words = str(num2)
  53.     num3_text.words = str(num3)
  54.     num1_text.show()
  55.     num2_text.show()
  56.     num3_text.show()
  57.  
  58.     await play.timer(seconds=2.0)
  59.  
  60.     num1_text.hide()
  61.     num2_text.hide()
  62.     num3_text.hide()
  63.     #result.hide() --- you can uncomment this (remove #) when you have a sprite called result
  64.  
  65. play.start_program()
Add Comment
Please, Sign In to add comment