Commit af2db324 by BellCodeEditor

auto save

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