Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson2_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
c55f5d2c
authored
Nov 27, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
9d94b5cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
65 deletions
snake.py
snake.py
View file @
c55f5d2c
import
pygame
import
random
from
pygame
import
locals
pygame
.
init
()
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
asd
=
pygame
.
time
.
Clock
()
background
=
pygame
.
image
.
load
(
'bg.png'
)
right
=
pygame
.
image
.
load
(
'right.png'
)
up
=
pygame
.
image
.
load
(
'up.png'
)
left
=
pygame
.
image
.
load
(
'left.png'
)
down
=
pygame
.
image
.
load
(
'down.png'
)
food
=
pygame
.
image
.
load
(
'apple.png'
)
body
=
pygame
.
image
.
load
(
'body.png'
)
sb
=
pygame
.
sb
(
'neuropol.ttf'
,
18
)
x
,
y
=
240
,
120
apple_x
,
apple_y
=
300
,
360
score
=
0
a12
=
[(
210
,
120
),(
210
,
120
),(
210
,
120
),(
x
,
y
)]
asdwww
=
'right'
add
=
right
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
exit
()
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_RIGHT
and
asdwww
!=
'left'
:
asdwww
=
'right'
if
event
.
key
==
locals
.
K_LEFT
and
asdwww
!=
'right'
:
asdwww
=
'left'
if
event
.
key
==
locals
.
K_UP
and
asdwww
!=
'down'
:
asdwww
=
'up'
if
event
.
key
==
locals
.
K_DOWN
and
asdwww
!=
'up'
:
asdwww
=
'down'
if
asdwww
==
'right'
:
add
=
right
x
+=
30
elif
asdwww
==
'left'
:
add
=
left
x
-=
30
elif
asdwww
==
'up'
:
add
=
up
y
-=
30
else
:
add
=
down
y
+=
30
if
x
==
apple_x
and
y
==
apple_y
:
a
=
random
.
randint
(
0
,
21
)
b
=
random
.
randint
(
0
,
15
)
apple_x
=
30
*
a
apple_y
=
30
*
b
score
+=
10
else
:
a12
.
pop
(
0
)
screen
.
blit
(
background
,
(
0
,
0
))
screen
.
blit
(
add
,
(
x
,
y
))
a12
.
append
((
x
,
y
))
for
i
in
range
(
len
(
a12
)
-
1
):
screen
.
blit
(
body
,
a12
[
i
])
screen
.
blit
(
food
,
(
apple_x
,
apple_y
))
info
=
"Score"
+
str
(
score
)
text
=
sb
.
render
(
info
,
True
,(
0
,
0
,
0
))
screen
.
blit
(
text
,(
540
,
10
))
pygame
.
display
.
update
()
asd
.
tick
(
3
)
\ No newline at end of file
print
(
5
+
3
==
9
)
\ 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