Play game
Run away!'s itch.io pageHow many characters of code did you use?
489!
Include your code here, if you'd like to show it off!
from pygame import*
init()
d=display
s=d.set_mode((800,600))
p=Rect(300,300,50,50)
i=Rect(0,0,25,25)
f=font.SysFont('Arial',30)
while 1:
k=key.get_pressed()
s.fill(-1)
dr=draw
dr.rect(s,0,p)
dr.rect(s,0,i)
if not i.colliderect(p):
if k[K_a]:p.x-=2
if k[K_d]:p.x+=2
if k[K_s]:p.y+=2
if k[K_w]:p.y-=2
if i.colliderect(p):quit()
if p.x<i.x:i.x-=1
if p.x>i.x:i.x+=1
if p.y<i.y:i.y-=1
if p.y>i.y:i.y+=1
for e in event.get():
if e.type==QUIT:quit()
d.flip()
time.delay(3)
Leave a comment
Log in with itch.io to leave a comment.
Comments
No one has posted a comment yet