Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Hi, Xin Yee!
- Just a small error. You haven't got a sprite called 'result' (the one that announces you win or you lose)
- 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.
- Hope this helps!
- '''
- import play
- from random import randint
- #set playing field
- w = play.screen.width
- h = play.screen.height
- place1 = play.new_box(color = 'pink', x = -200, y = 0, width = 100, height = 200, border_width=5, border_color='pink')
- place2 = play.new_box(color = 'light skyblue', x = 0, y = 0, width = 100, height = 200, border_width=5, border_color='light skyblue')
- place3 = play.new_box(color = 'violet', x = 200, y = 0, width = 100, height = 200, border_width=5, border_color='violet')
- button = play.new_box(color = 'gold', x = 0, y = 250, width = 100, height = 50, border_width=5, border_color = 'gold')
- text1 = play.new_text(words = 'Play', color = 'purple', x = 0, y = 250)
- num1_text = play.new_text(words = '', x = -200, y = 0, font = None, font_size = 100, color='white')
- num2_text = play.new_text(words = '', x = 0, y = 0, font = None, font_size = 100, color='white')
- num3_text = play.new_text(words = '', x = 200, y = 0, font = None, font_size = 100,color='white')
- @play.when_program_starts
- def start():
- num1_text.hide()
- num2_text.hide()
- num3_text.hide()
- #result.hide() --- you can uncomment this (remove #) when you have a sprite called result
- @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()
- #result.hide() --- you can uncomment this (remove #) when you have a sprite called result
- play.start_program()
Add Comment
Please, Sign In to add comment