Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson1_2
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
0a63f9ab
authored
May 19, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
a2a6ed92
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
35 deletions
111.py → SB.py
snake.py
备课.py
111
.py
→
SB
.py
View file @
0a63f9ab
import
pygame
from
pygame
import
locals
#创建窗口
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
bg
=
pygame
.
image
.
load
(
'bg
.png'
)
pygame
.
init
()
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
background
=
pygame
.
image
.
load
(
'bg.png'
)
right
=
pygame
.
image
.
load
(
'right
.png'
)
food
=
pygame
.
image
.
load
(
'apple.png'
)
body
=
pygame
.
image
.
load
(
'body.png'
)
right
=
pygame
.
image
.
load
(
'right.png'
)
while
True
:
for
event
in
pygame
.
event
.
get
()
:
for
event
in
pygame
.
event
.
get
()
if
event
.
type
==
locals
.
QUIT
:
exit
()
\ No newline at end of file
screen
.
blit
(
bg
,(
0
,
0
))
screen
.
blit
(
food
,(
330
,
240
))
screen
.
blit
(
food
,(
600
,
450
))
screen
.
blit
(
right
,(
240
,
120
))
screen
.
blit
(
body
,(
210
,
120
))
screen
.
blit
(
body
,(
180
,
120
))
pygame
.
display
.
update
()
snake.py
View file @
0a63f9ab
...
...
@@ -8,10 +8,10 @@ pygame.init()
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
# # 背景
#
background = pygame.image.load('bg.png')
#
right = pygame.image.load('right.png')
#
food = pygame.image.load('apple.png')
#
body = pygame.image.load('body.png')
background
=
pygame
.
image
.
load
(
'bg.png'
)
right
=
pygame
.
image
.
load
(
'right.png'
)
food
=
pygame
.
image
.
load
(
'apple.png'
)
body
=
pygame
.
image
.
load
(
'body.png'
)
while
True
:
for
event
in
pygame
.
event
.
get
():
...
...
备课.py
deleted
100644 → 0
View file @
a2a6ed92
# pygame.display.set_mode() #设置窗口大小
# pygame.display.set_mode() #设置窗口大小
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
#pygame.event.get() #获取pygame产生的事件
#渲染图片
#step1载入 pygame.image.load('img')
#step2绘制 pygame.surface.blit(source,dest) #source图像资源 dest坐标位置
#step3画面刷新 pygame.display.update() #需要放到所有的surface.blit()方法后面
# 列表:中括号
# 元组:小括号,一旦创建,内容不能改变
#
\ No newline at end of file
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