Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson1_3
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
fb6616c9
authored
Nov 04, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
aacba416
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
0 deletions
1.py
11.py
111.py
2.py
1.py
0 → 100644
View file @
fb6616c9
import
pygame
from
pygame
import
locals
# 初始化pygame,为使用pygame做准备
pygame
.
init
()
background
=
pygame
.
image
.
load
(
'bg.png'
)
#背景
right
=
pygame
.
image
.
load
(
'right.png'
)
#蛇头
body
=
pygame
.
image
.
load
(
'body.png'
)
#蛇身
apple
=
pygame
.
image
.
load
(
'apple.png'
)
#苹果
# 创建一个窗口
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
#接受到退出后结束程序
exit
()
screen
.
blit
(
background
,(
0
,
0
))
#背景
screen
.
blit
(
right
,(
180
,
120
))
#蛇头
screen
.
blit
(
body
,(
150
,
120
))
#蛇身
screen
.
blit
(
body
,(
120
,
120
))
#蛇身
screen
.
blit
(
body
,(
120
,
90
))
#蛇身
screen
.
blit
(
apple
,(
360
,
300
))
#水果
pygame
.
display
.
update
()
#刷新画面
print
(
"0"
)
11.py
0 → 100644
View file @
fb6616c9
class
Person
():
def
__init__
(
self
,
name
,
age
,
gender
,
birth
):
self
.
name
=
name
self
.
age
=
age
self
.
gender
=
gender
self
.
birth
=
birth
def
speak
():
print
(
"我叫"
,
self
.
name
)
print
(
"我今年"
,
self
.
age
)
print
(
"我出生于"
,
self
.
birth
)
tww
=
Person
(
"Tww"
,
"1"
,
"男"
,
"2007-7-6"
)
tww
.
speak
()
\ No newline at end of file
111.py
0 → 100644
View file @
fb6616c9
class
:
def
cat
(
self
,
name
):
self
.
name
=
name
print
(
self
.
name
+
"去捉老鼠"
)
def
sleep
(
self
,
time
):
self
.
time
=
time
print
(
"捉完老鼠要休息"
+
str
(
self
.
time
)
+
"分钟"
)
Tom
=
Cat
()
Tom
.
cat
(
"汤姆"
)
Tom
.
sleep
(
20
)
\ No newline at end of file
2.py
0 → 100644
View file @
fb6616c9
class
Zfx
():
def
__init__
(
self
,
b
):
self
.
b
=
b
def
C
(
self
):
print
(
4
*
b
)
def
S
(
self
):
print
(
b
*
b
)
zfx
=
Zfx
(
4
)
zfx
.
S
\ 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