Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Hi, Ashley!
- The error was caused by a name mix-up.
- num1 --- these are your numbers, in number form, which can work with randint(). This has no hide() or show()
- num1_text --- these are your text sprites, which is what shows on the screen. This has hide() and show()
- '''
- import play
- from random import randint
- box1 = play.new_box(color = 'blue', x = -200, y = 0, width = 100, height = 200, border_width = 5, border_color = 'medium blue')
- box2 = play.new_box(color = 'blue', x = 0, y = 0, width = 100, height = 200, border_width = 5, border_color = 'medium blue')
- box3 = play.new_box(color = 'blue', x = 200, y = 0, width = 100, height = 200, border_width = 5, border_color = 'medium blue')
- welcome = play.new_text(words = 'Hello! Click the button to try your luck!', x = 0, y = 180, font_size = 40, color = 'black')
- button = play.new_box(color = 'yellow', x = 0, y = -180, width = 330, height = 100, border_width = 5, border_color = 'gold')
- start = play.new_text(words = 'PRESS TO START', x = 0, y = -180, font_size = 50, color = 'black')
- num1_text = play.new_text(words = '1', x = -200, y = 0, font = None, font_size = 220, color='white')
- num2_text = play.new_text(words = '2', x = 0, y = 0, font = None, font_size = 220, color='white')
- num3_text = play.new_text(words = '3', x = 200, y = 0, font = None, font_size = 220, color='white')
- @play.when_program_starts
- def start( ):
- num1_text.hide()
- num2_text.hide()
- num3_text.hide()
- @play.repeat_forever
- def do( ):
- pass
- @button.when_clicked
- async def clicking():
- num1 = randint(0,9)
- num2 = randint(0,9)
- num3 = randint(0,9)
- num1_text.words = str(num1)
- num2_text.words = str(num2)
- num3_text.words = str(num3)
- num1_text.show()
- num2_text.show()
- num3_text.show()
- await play.timer(seconds=2.0)
- num1_text.hide()
- num2_text.hide()
- num3_text.hide()
- play.start_program( )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement