Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

Administrator / pygame_lesson3_diy4

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit 4410a264 authored 2 years ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent 21686b77
Hide whitespace changes
Inline Side-by-side
Showing with 71 additions and 0 deletions
  • src=http___c-ssl.duitang.com_uploads_item_201911_02_20191102145142_obpiz.thumb.1000_0.png&refer=http___c-ssl.duitang(1).jpg
  • src=http___img.3dmgame.com_uploads_images_news_20210702_1625220279_673168.jpg&refer=http___img.3dmgame(1).jpg
  • src=http___pic.51yuansu.com_pic3_cover_03_17_15_5b5ee31e003a6_610.jpg&refer=http___pic.51yuansu(1).jpg
  • 老六.py
src=http___c-ssl.duitang.com_uploads_item_201911_02_20191102145142_obpiz.thumb.1000_0.png&refer=http___c-ssl.duitang(1).jpg 0 → 100644
View file @ 4410a264
src=http___c-ssl.duitang.com_uploads_item_201911_02_20191102145142_obpiz.thumb.1000_0.png&refer=http___c-ssl.duitang(1).jpg

1.72 KB

This diff is collapsed. Click to expand it.
src=http___img.3dmgame.com_uploads_images_news_20210702_1625220279_673168.jpg&refer=http___img.3dmgame(1).jpg 0 → 100644
View file @ 4410a264
src=http___img.3dmgame.com_uploads_images_news_20210702_1625220279_673168.jpg&refer=http___img.3dmgame(1).jpg

121 KB

This diff is collapsed. Click to expand it.
src=http___pic.51yuansu.com_pic3_cover_03_17_15_5b5ee31e003a6_610.jpg&refer=http___pic.51yuansu(1).jpg 0 → 100644
View file @ 4410a264
src=http___pic.51yuansu.com_pic3_cover_03_17_15_5b5ee31e003a6_610.jpg&refer=http___pic.51yuansu(1).jpg

1.69 KB

This diff is collapsed. Click to expand it.
老六.py 0 → 100644
View file @ 4410a264
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
This diff is collapsed. Click to expand it.
  • Write
  • Preview
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