import pygame,sys
from pygame.locals import *
pygame.init()
d=pygame.display.set_mode((1000,1000));
pygame.display.set_caption("Animation")
fps=30fpsClock=pygame.time.Clock()
white=(255,255,255)
catemg=pygame.img.load('cat.png')
catx=10caty=10direction='right'while True:
d.fill(white)
if(direction=="right"):
catx=catx+5 if(catx==280):
catx='down' elif catx=="down":
caty=caty+5 if caty==220:
direction="left" elif direction=="left":
catx-=5;
if(catx==10):
direction="up" elif direction=="up":
caty-=5 if caty==10:
direction="right" d.blit(catemg,(catx,caty))
for event in pygame.event.get():
if(event==QUIT):
pygame.QUIT
sys.exit()
pygame.display.update()
fpsClock.tick(fps)
Comments
Post a Comment