import play
import time
play.set_backdrop('grey')
w=play.screen.width
h=play.screen.height
@play.repeat_forever
def do():
if play.key_is_pressed('w'):
cat.y+=2
if play.key_is_pressed('s'):
cat.y-=2
if play.key_is_pressed('d'):
cat.x+=2
if play.key_is_pressed('a'):
cat.x-=2
if play.key_is_pressed('up'):
mouse.y+=2
if play.key_is_pressed('down'):
mouse.y-=2
if play.key_is_pressed('right'):
mouse.x+=2
if play.key_is_pressed('left'):
mouse.x-=2
if (cat.x-20<=mouse.x<=cat.x+20) and (cat.y-35<=mouse.y<=cat.y+35):
ToT=play.new_box(color='grey', x=0,y=0, width=w, height=h)
win=play.new_text(words='Cat win',
x=0, y=0, color='red',
font_size=150)
play.pygame.mixer_music.load('Fluffing-a-Duck.mp3')
play.pygame.mixer_music.play()
cat.x+=10
mouse.x-=10
time.sleep(0.8)
if cat.y>=h/2:
cat.y-=2
if cat.y<=h/2:
cat.y+=2
if cat.x>=w/2:
cat.x-=2
if cat.x<=w/2:
cat.x+=2
if mouse.y>=h/2:
mouse.y-=2
if mouse.y<=h/2:
mouse.y+=2
if mouse.x>=w/2:
mouse.x-=2
if mouse.x<=w/2:
mouse.x+=2
cat=play.new_circle(color='blue', x=-320, y=-220, radius=20, border_color='light blue')
mouse=play.new_circle(color='brown', x=320, y=220, radius=10, border_color='yellow')