Commit b4f3e879 by BellCodeEditor

save project

parent 55dfeb04
Showing with 32 additions and 4 deletions
import pygame import pygame
...@@ -8,23 +8,51 @@ b = pygame.time.Clock() ...@@ -8,23 +8,51 @@ b = pygame.time.Clock()
screen = pygame.display.set_mode((660,480)) screen = pygame.display.set_mode((660,480))
screen2 = pygame.image.load("bg.png") screen2 = pygame.image.load("bg.png")
apple = pygame.image.load("apple.png") apple = pygame.image.load("apple.png")
snackR = pygame.image.load("right.png") right = pygame.image.load("right.png")
body = pygame.image.load("body.png") body = pygame.image.load("body.png")
left = pygame.image.load("left.png")
up = pygame.image.load("up.png")
down = pygame.image.load("down.png")
x,y = 240,120 x,y = 240,120
sh = right
position = [(180,90),(180,120),(210,120),(x,y)] position = [(180,90),(180,120),(210,120),(x,y)]
st = "right"
while True: while True:
for i in pygame.event.get(): for i in pygame.event.get():
if i.type == locals.QUIT: if i.type == locals.QUIT:
exit() exit()
x+=30 if i.type == locals.KEYDOWN:
if i.type == locals.K_UP and st != "down":
st == "up"
sh == up
if i.type == locals.K_DOWN and st != "up":
st == "down"
sh == down
if i.type == locals.K_LEFT and st != "right":
st == "left"
sh == left
if i.type == locals.K_RIGHT and st != "left":
st == "right"
sh == right
if st == "right":
x+=30
elif st == "up":
y-=30
elif st == "left":
x -= 30
else:
y += 30
position.append((x,y)) position.append((x,y))
position.pop(0) position.pop(0)
screen.blit(screen2,(0,0)) screen.blit(screen2,(0,0))
screen.blit(apple,(360,300)) screen.blit(apple,(360,300))
screen.blit(snackR,(x,y)) screen.blit(sh,position[-1])
for j in range(len(position)-1): for j in range(len(position)-1):
screen.blit(body,position[j]) screen.blit(body,position[j])
......
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