Commit af2db324 by BellCodeEditor

auto save

parent 9f3d4d2a
Showing with 21 additions and 13 deletions
......@@ -2,7 +2,7 @@ import pygame
from pygame import locals
import random
pygame.init()
screen = pygame.display.set_mode((1320,960))
screen = pygame.display.set_mode((660,480))
FPSCLOCK = pygame.time.Clock()
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
......@@ -11,7 +11,13 @@ body = pygame.image.load('body.png')
left = pygame.image.load('left.png')
up = pygame.image.load('up.png')
down = pygame.image.load('down.png')
z = pygame.font.Font('neuropol.ttf',18)
a = pygame.font.Font('neuropol.ttf',18)
b = pygame.font.Font('neuropol.ttf',18)
c = pygame.font.Font('neuropol.ttf',18)
d = pygame.font.Font('neuropol.ttf',18)
e = pygame.font.Font('neuropol.ttf',18)
f = pygame.font.Font('neuropol.ttf',18)
g = pygame.font.Font('neuropol.ttf',18)
x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right"
......@@ -48,33 +54,35 @@ while True:
y += 30
position.append((x, y))
if x == a and y == b:
a = random.randint(0,43)
b = random.randint(0,31)
a = random.randint(0,21)
b = random.randint(0,15)
a *= 30
b *= 30
score += 10
elif x == c and y == d:
c = random.randint(0,43)
d = random.randint(0,31)
c = random.randint(0,21)
d = random.randint(0,15)
c *= 30
d *= 30
score += 10
else:
position.pop(0)
if x < 0 or x > 1290 or y < 0 or y > 930:
if x < 0 or x > 630 or y < 0 or y > 450:
print("Your score is:" + str(score))
exit()
screen.blit(background, (0, 0))
screen.blit(background, (661, 0))
screen.blit(background, (0, 481))
screen.blit(background, (661, 481))
screen.blit(background, (1322, 0))
screen.blit(background, (0, 480))
screen.blit(background, (661, 480))
screen.blit(background, (1322, 480))
screen.blit(snake_head, position[-1])
for i in range(len(position)-1):
screen.blit(body, position[i])
screen.blit(food, (a,b))
screen.blit(food, (c,d))
info = "Score:" + str(score)
text = z.render(info,True,(0,0,0))
a = "Score:" + str(score)
text = a.render(z,True,(0,255,255))
screen.blit(text,(540,10))
pygame.display.update()
FPSCLOCK.tick(5)
\ No newline at end of file
FPSCLOCK.tick(score/10+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