-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (38 loc) · 1.1 KB
/
main.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
import pygame
from lib.creatures import Plant, Herbivore, Carnivore
from lib.world import World
import sys
import time
if __name__ == '__main__':
pygame.init()
WIDTH = 800
HEIGHT = 800
SCREEN_SIZE = (WIDTH, HEIGHT)
clock = pygame.time.Clock()
screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32)
pixels_per_sec = 10
world = World(SCREEN_SIZE)
gen_h = True
gen_c = True
# Add Creatures
for i in range(50):
world.add_creture(Plant(world))
time.sleep(0.01)
for i in range(15):
world.add_creture(Herbivore(world, gender=gen_h))
time.sleep(0.01)
world.add_creture(Carnivore(world, gender=gen_c))
time.sleep(0.01)
gen_c = not gen_c
gen_h = not gen_h
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
# main loop
screen.fill((0,150,20))
time_elapsed = clock.tick(70)
time_elapsed = time_elapsed/1000
world.process(time_elapsed)
world.render(screen)
pygame.display.update()