Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
se3xa3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hameed Andy
se3xa3
Commits
ecb7eecd
Commit
ecb7eecd
authored
6 years ago
by
Hameed Andy
Browse files
Options
Downloads
Patches
Plain Diff
comments fixed
parent
f8a7ce23
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BlankProjectTemplate/src/Gameplay.py
+8
-24
8 additions, 24 deletions
BlankProjectTemplate/src/Gameplay.py
BlankProjectTemplate/src/Snake.py
+0
-10
0 additions, 10 deletions
BlankProjectTemplate/src/Snake.py
with
8 additions
and
34 deletions
BlankProjectTemplate/src/Gameplay.py
+
8
−
24
View file @
ecb7eecd
...
...
@@ -36,16 +36,16 @@ location = [food_x, food_y]
##initialize snake
snake
=
Snake
(
size
,
0
,
20
,
0
)
food
=
Food
(
size
)
#Loop through the events as long as the game is running
run
=
True
while
run
:
pygame
.
time
.
delay
(
speed
)
#create a delay to prevent any unwanted behaviour
#delay controls part of speed
pygame
.
time
.
delay
(
speed
)
#events are anything that happens from the user
#we loop through the list of events that happen by the user's actions
for
event
in
pygame
.
event
.
get
():
#Check if the event is a quit command and quit the game if it is
if
event
.
type
==
pygame
.
QUIT
:
run
=
False
...
...
@@ -80,40 +80,24 @@ while run:
#x = 500 - size
x
=
0
#all colors are defined in RGB with Pygame
#consumption of food block
#consumption of food block
food
.
redraw_food
(
x
,
y
,
location
,
screenSize
)
if
(
abs
(
x
-
location
[
0
])
<
15
and
abs
(
y
-
location
[
1
])
<
15
):
score
+=
1
print
(
score
)
## --------------------------DELETE --------------------------
#extend length or size depending on the direction of the snake
## if (axis):
## size += 20
## else:
## size += 20
##---------------------------DELETE----------------------------
win
.
fill
(
white
)
#Draw food item
food
.
draw_food
(
location
)
#food.update_score(x,y,location, score)
#Draw snake
snake
.
draw
(
x
,
y
)
#we have to update the display to see the drawing of our object. Since it does
#not automatically update
#update display
pygame
.
display
.
update
()
#Quit the game
pygame
.
quit
()
This diff is collapsed.
Click to expand it.
BlankProjectTemplate/src/Snake.py
+
0
−
10
View file @
ecb7eecd
...
...
@@ -27,15 +27,5 @@ class Snake():
pygame
.
draw
.
rect
(
win
,
red
,
(
x
,
y
,
self
.
size
,
self
.
size
))
## @brief Snake consumes a food block
## def consume():
##
##class Block():
##
## def __init__(self, width, height):
## self.w = width
## swlf.h = height
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment