Advertisement
shh_algo_PY

Xin Yen's Slot Machine

Mar 4th, 2022
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.75 KB | None | 0 0
  1. # Start of the game
  2.  
  3. import play
  4. from random import randint
  5.  
  6. # Creating objects for external interface
  7.  
  8. #### BOXES ####
  9.  
  10. place1 = play.new_box(color = 'pink', x = -200, y = 0, width = 100, height = 200, border_width=5, border_color='plum')
  11.  
  12. place2 = play.new_box(color = 'light sky blue', x = 0, y = 0, width = 100, height = 200, border_width=5, border_color='plum')
  13.  
  14. place3 = play.new_box(color = 'orchid', x = 200, y = 0, width = 100, height = 200, border_width=5, border_color='plum')
  15.  
  16. #### WELCOME MESSAGE ####
  17.  
  18. #### RESULT MESSAGE ####
  19.  
  20. #### PLAY BUTTON ####
  21.  
  22. button = play.new_box(color = 'yellow', x = -0, y = -250, width = 200, height = 70, border_width=10, border_color='gold')
  23.  
  24. button_text = play.new_text(words = 'Hello!',color='gold', x = -0, y = -250)
  25.  
  26. #### BONUS TASKS: COUNTER AND MONEY ####
  27.  
  28. # Generate random numbers
  29.  
  30. num1_text = play.new_text(words = '', x = -200, y = 0, font = None, font_size = 100, color='white')
  31.  
  32. num2_text = play.new_text(words = '', x = 0, y = 0, font = None, font_size = 100, color='white')
  33.  
  34. num3_text = play.new_text(words = '', x = 200, y = 0, font = None, font_size = 100,color='white')
  35.  
  36. # SETUP TIME
  37.  
  38. @play.when_program_starts
  39.  
  40. def start():
  41.     num1_text.hide()
  42.     num2_text.hide()
  43.     num3_text.hide()
  44.  
  45. # GAME RULES AND CONTROLS
  46.  
  47. @play.repeat_forever
  48. def do():
  49.     pass
  50.  
  51. @button.when_clicked
  52.  
  53. async def clicking():
  54.     num1 = randint(0, 9)
  55.     num2 = randint(0, 9)
  56.     num3 = randint(0, 9)
  57.     num1_text.words = str(num1)
  58.     num2_text.words = str(num2)
  59.     num3_text.words = str(num3)
  60.     num1_text.show()
  61.     num2_text.show()
  62.     num3_text.show()
  63.    
  64.     await play.timer(seconds=2.0)
  65.  
  66.     num1_text.hide()
  67.     num2_text.hide()
  68.     num3_text.hide()
  69.  
  70. play.start_program()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement