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
3e632bdd
authored
2 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
ae8f8a5d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
snake.py
snake.py
View file @
3e632bdd
...
...
@@ -5,7 +5,7 @@ import random;
import
sys
;
setHeading
=
"right"
;
wasPause
=
Tru
e
;
wasPause
=
Fals
e
;
score
=
0
;
appleX
=
240
;
appleY
=
150
;
...
...
@@ -32,23 +32,7 @@ snakeHead = right;
screen
=
display
.
set_mode
((
660
,
480
));
while
1
:
if
wasPause
:
for
events
in
event
.
get
():
if
events
.
type
==
QUIT
:
sys
.
exit
();
if
events
.
type
==
KEYDOWN
:
if
events
.
key
==
K_w
and
setHeading
!=
"down"
:
setHeading
=
"up"
;
snakeHead
=
up
;
if
events
.
key
==
K_s
and
setHeading
!=
"up"
:
setHeading
=
"down"
;
snakeHead
=
down
;
if
events
.
key
==
K_a
and
setHeading
!=
"right"
:
setHeading
=
"left"
;
snakeHead
=
left
;
if
events
.
key
==
K_d
and
setHeading
!=
"left"
:
setHeading
=
"right"
;
snakeHead
=
right
;
if
not
wasPause
:
if
setHeading
==
"up"
:
playerY
-=
30
;
...
...
@@ -99,7 +83,21 @@ while 1:
sleep
(
0.1
);
for
things
in
event
.
get
():
if
things
.
type
==
KEYDOWN
:
if
things
.
key
==
K_SPACE
:
for
events
in
event
.
get
():
if
events
.
type
==
QUIT
:
sys
.
exit
();
if
events
.
type
==
KEYDOWN
:
if
events
.
key
==
K_SPACE
:
wasPause
=
not
wasPause
;
if
events
.
key
==
K_w
and
setHeading
!=
"down"
:
setHeading
=
"up"
;
snakeHead
=
up
;
if
events
.
key
==
K_s
and
setHeading
!=
"up"
:
setHeading
=
"down"
;
snakeHead
=
down
;
if
events
.
key
==
K_a
and
setHeading
!=
"right"
:
setHeading
=
"left"
;
snakeHead
=
left
;
if
events
.
key
==
K_d
and
setHeading
!=
"left"
:
setHeading
=
"right"
;
snakeHead
=
right
;
\ No newline at end of file
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