Commit 112567b8 by BellCodeEditor

auto save

parent 7bc667bc
Showing with 55 additions and 0 deletions
import pygame
from pygame import locals
pygame.init()
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock()
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
left = pygame.image.load('left.png')
down = pygame.image.load('down.png')
up = pygame.image.load('up.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
x,y=210,180
pone = [(150,120),(180,150),(180,180),(210,180)]
sett='right'
while True:
for event in pygame.event.get():
if event.type ==locals.QUIT:
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT and sett != 'left':
sett = 'right'
if event.key == locals.K_LEFT and sett != 'right':
sett = 'left'
if event.key == locals.K_UP and sett != 'down':
sett = 'up'
if event.key == locals.K_DOWN and sett != 'up':
sett = 'down'
if sett == 'right':
x+=30
elif sett == 'left':
x-=30
elif sett == 'up':
y-=30
else:
y+=30
screen.blit(background, (0, 0))
pone.append((x,y))
pone.pop(0)
if sett == 'right':
screen.blit(right, (x,y))
elif sett == 'left':
screen.blit(left, (x,y))
elif sett == 'up':
screen.blit(up, (x,y))
else:
screen.blit(down, (x,y))
for i in range(len(pone)-1):
screen.blit(body,pone[i])
# screen.blit(body, (180, 120))
# screen.blit(body, (180, 90))
screen.blit(food, (360, 300))
pygame.display.update()
FPSCLOCK.tick(3)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment