-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.py
59 lines (34 loc) · 1007 Bytes
/
Game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from turtle import Turtle
import random
###### Create Game Class
class gameEngine:
def __init__(self):
self.random = 0
self.foodLocation = 0
self.food = Turtle()
#### Foood
def randomPosition(self):
randomX = random.randrange(-280, 280, 20)
randomY = random.randrange(-280, 280, 20)
randomPosition = (randomX, randomY)
self.random = randomPosition
return self.random
def createFood(self,var):
### Variables
self.food.shape('circle')
self.food.color('blue')
self.food.penup()
self.food.goto(var)
def showFood(self):
self.food.st()
def hideFood(self):
self.food.ht()
def foodPosition(self):
Y = round(self.random[1],2)
X = round(self.random[0],2)
self.food.goto(X,Y)
self.foodLocation = self.food.pos()
return self.foodLocation
## Interaction Logic
gameBoundry = 600
### Add Loop Background Music ###