Commit f74a1fd3 by BellCodeEditor

auto save

parent 5544a4d2
Showing with 19 additions and 5 deletions
import pygame
import pygame,random
from pygame import locals
pygame.init()
screen = pygame.display.set_mode((660, 480))
FPSCLOCK=pygame.time.clock()
FPSCLOCK=pygame.time.Clock()
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
apple = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
down = pygame.image.load('down.png')
left = pygame.image.load('left.png')
up = pygame.image.load('up.png')
my_font=pygame.font.Font('ariali.ttf',28)
x,y=240,120
apple_x=360
apple_y=300
positipon=[(90,120),(280,120),(210,120),(x,y)]
setheading='rignt'
snake_head = right
......@@ -39,11 +42,21 @@ while True:
y+=30
else:
y-=30
positipon.append((x,y))
if x == apple_x and y == apple_y:
num1=random.randint(1,22)
num2=random.randint(1,16)
apple_x=num1*30-30
apple_y=num2*30-30
screen.blit(background, (0, 0))
screen.blit(right, (240, 120))
screen.blit(snake_head,positipon[-1])
for i in range(len(positipon)-1):
screen.blit(body,positipon[i])
screen.blit(apple,(apple_,apple_y))
score='Score'+str(score)
screen.blit(body, (210, 120))
screen.blit(body, (180, 120))
screen.blit(body, (180, 90))
screen.blit(food, (360, 300))
screen.blit(apple, (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