-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
52 lines (40 loc) · 1.09 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
51
52
import pygame
from sys import exit
import config
import components
import population
pygame.init()
clock = pygame.time.Clock()
population = population.Population(100)
def generate_pipes():
config.pipes.append(components.Pipes(config.win_width))
def quit_game():
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
def main():
pipes_spawn_time = 10
while True:
quit_game()
config.window.fill((0, 0, 0))
# Spawn Ground
config.ground.draw(config.window)
# Spawn Pipes
if pipes_spawn_time <= 0:
generate_pipes()
pipes_spawn_time = 200
pipes_spawn_time -= 1
for p in config.pipes:
p.draw(config.window)
p.update()
if p.off_screen:
config.pipes.remove(p)
if not population.extinct():
population.update_live_players()
else:
config.pipes.clear()
population.natural_selection()
clock.tick(60)
pygame.display.flip()
main()