Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson3_diy3
This project
Loading...
Sign in
Toggle navigation
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
b3d617b5
authored
2 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
de29e5a7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
123.py
snake.py
123.py
View file @
b3d617b5
import
pygame
import
pygame
from
pygame
import
locals
import
random
pygame
.
init
()
pygame
.
init
()
screen
=
pygame
.
display
.
set_mode
((
800
,
600
))
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
FPSCLOCK
=
pygame
.
time
.
Clock
()
background
=
pygame
.
image
.
load
(
'bg.png'
)
right
=
pygame
.
image
.
load
(
'right.png'
)
food
=
pygame
.
image
.
load
(
'apple.png'
)
while
True
:
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
exit
()
This diff is collapsed.
Click to expand it.
snake.py
View file @
b3d617b5
import
pygame
import
pygame
from
pygame
import
locals
from
pygame
import
locals
import
random
import
random
# 初始化pygame,为使用硬件做准备
pygame
.
init
()
pygame
.
init
()
# 创建一个窗口
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
FPSCLOCK
=
pygame
.
time
.
Clock
()
# pygame时钟,控制游戏速度(帧数)
# 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'
)
food
=
pygame
.
image
.
load
(
'apple.png'
)
# 食物 苹果
food
=
pygame
.
image
.
load
(
'apple.png'
)
body
=
pygame
.
image
.
load
(
'body.png'
)
# 身体
# 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')
my_font
=
pygame
.
font
.
Font
(
'neuropol.ttf'
,
18
)
my_font
=
pygame
.
font
.
Font
(
'neuropol.ttf'
,
18
)
food_x
,
food_y
=
360
,
300
food_x
,
food_y
=
360
,
300
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment