-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworld.py
23 lines (20 loc) · 825 Bytes
/
world.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from tkinter import *
from balls import *
class World:
def __init__(self, width, height, n_creatures, n_food, initial_size, initial_speed, initial_color):
self.tk = Tk()
self.width = width
self.height = height
self.canvas = Canvas(self.tk, width=width, height=height)
self.canvas.pack()
self.creatures = [Creature(initial_size, initial_speed, initial_color,
self.width, self.height, self.canvas, self.tk)
for _ in range(n_creatures)]
self.food = [Food(self.width, self.height, self.canvas, self.tk)
for _ in range(n_food)]
def run(self):
for c in self.creatures:
c.movement()
for f in self.food:
f.movement()
self.tk.mainloop()