-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathourGameFile.py
More file actions
57 lines (57 loc) · 1.99 KB
/
ourGameFile.py
File metadata and controls
57 lines (57 loc) · 1.99 KB
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
import random
class Positional:
def __init__(self,x,y,size):
self.x = x
self.y = y
self.age = 0
self.size = size
class Plant(Positional):
def __init__(self, x, y, size):
super(Plant, self).__init__(x, y, size)
class Bush(Plant):
def __init__(self, x, y):
super(Bush, self).__init__(x,y,1.0)
class Tree(Plant):
def __init__(self,x,y):
super(Tree, self).__init__(x,y,0.5)
class Animals(Positional):
def __init__(self,x,y,size):
super(Animals, self).__init__(x,y,size)
self.speed = 0
self.hunger = 10
self.visionAngle = 0
self.visionRange = 0
class Wolf(Animals):
def __init__(self,x,y):
super(Wolf, self).__init__(x,y,0.3)
self.visionAngle = 360
self.visionRange = 30
class Horse(Animals):
def __init__(self,x,y):
super(Horse, self).__init__(x,y,0.2)
self.visionAngle = 120
self.visionRange = 20
class Controller:
def __init__(this, width, height):
this.width = width
this.height = height
this.objList = []
def createPlants(this, n, opt = 0):
tr = 0
bu = 0
this.opt = opt
for i in range(n):
plantType = random.randrange(0,2,1)
if (plantType == 1):
this.objList.append(Tree(random.randrange(0,this.width,1),random.randrange(0, this.height, 1)))
tr += 1
else:
this.objList.append(Bush(random.randrange(0,this.width,1),random.randrange(0,this.height,1)))
bu += 1
if (this.opt == 'showList'):
for i in this.objList:
print("X: {0} Y: {1} - {2}".format(i.x,i.y,type(i)))
print("Added {0} trees and {1} bushes".format(tr,bu))
i = Controller(30,30)
#Необязательный параметр showList - показать список созданных объектов
i.createPlants(75, 'showList')