-
Notifications
You must be signed in to change notification settings - Fork 0
/
cat.py
44 lines (36 loc) · 936 Bytes
/
cat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import pygame, sys
from pygame.locals import *
pygame.init()
FPS=30
fpsClock = pygame.time.Clock()
DISPLAYSURF = pygame.display.set_mode((800, 650), 0, 32)
pygame.display.set_caption('Cat Animation')
WHITE = (255,255,255)
catImg = pygame.image.load('cat.png')
catx=10
caty=10
direction = 'right'
while True:
DISPLAYSURF.fill(WHITE)
if direction == 'right':
catx+=0.5
if catx == 500 :
direction ='down'
elif direction == 'down':
caty+=0.5
if caty==500:
direction = 'left'
elif direction == 'left':
catx-=0.5
if catx==10:
direction = 'up'
elif direction == 'up':
caty -=0.5
if caty == 10:
direction = 'right'
DISPLAYSURF.blit(catImg,(catx,caty))
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()