Commit 4410a264 by BellCodeEditor

save project

parent 21686b77
import pygame
import pygame
from pygame import locals
import random
pygame.init()
screen=pygame.display.set_mode((660,480))
FPS=pygame.time.Clock()
background = pygame.image.load('src=http___img.3dmgame.com_uploads_images_news_20210702_1625220279_673168.jpg&refer=http___img.3dmgame(1).jpg')
right = pygame.image.load('src=http___c-ssl.duitang.com_uploads_item_201911_02_20191102145142_obpiz.thumb.1000_0.png&refer=http___c-ssl.duitang(1).jpg')
food = pygame.image.load('src=http___pic.51yuansu.com_pic3_cover_03_17_15_5b5ee31e003a6_610.jpg&refer=http___pic.51yuansu(1).jpg')
body = pygame.image.load('body.png')
left=pygame.image.load('src=http___c-ssl.duitang.com_uploads_item_201911_02_20191102145142_obpiz.thumb.1000_0.png&refer=http___c-ssl.duitang(1).jpg')
up=pygame.image.load('src=http___c-ssl.duitang.com_uploads_item_201911_02_20191102145142_obpiz.thumb.1000_0.png&refer=http___c-ssl.duitang(1).jpg')
down=pygame.image.load('src=http___c-ssl.duitang.com_uploads_item_201911_02_20191102145142_obpiz.thumb.1000_0.png&refer=http___c-ssl.duitang(1).jpg')
ttf=pygame.font.Font('neuropol.ttf',18)
x,y=240,120
pos=[(180,90),(180,120),(210,120),(x,y)]
set='right'
snake_head = right
ax=360
ay=300
score=0
while True
for event in pygame.event.get()
print(event)
if event.type == locals.QUIT
exit()
elif event.type == locals.KEYDOWN
if event.key ==locals.K_d and set !='left'
set='right'
snake_head=right
if event.key ==locals.K_a and set !='right'
set='left'
snake_head=left
if event.key ==locals.K_w and set !='down'
set='up'
snake_head=up
if event.key ==locals.K_s and set !='up'
set='down'
snake_head=down
if set =='right'
x+=30
elif set == 'left'
x-=30
elif set == 'up'
y-=30
else
y+=30
if x==ax and y==ay
num1=random.randint(1,22)
num2=random.randint(1,16)
ax=30num1-30
ay=30num2-30
score+=10
else
score+=10
pos.pop(0)
if x < 0 or x>630 or y<0 or y>450:
exit()
pos.append((x,y))
screen.blit(background,(0,0))
screen.blit(right,pos[-1])
for i in range(len(pos)-1)
screen.blit(body,pos[i])
screen.blit(food,(ax,ay))
info = 'Score'+str(score)
text = ttf.render(info,True,(0,255,0))
screen.blit(text,(500,10))
pygame.display.update()
FPS.tick(5)
\ 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