-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
41 lines (32 loc) · 946 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
import pygame
import lib
from lib.settings import Settings
from lib.constants import WIDTH, HEIGHT
import argparser
import neatinterface
if __name__ == "__main__":
args = argparser.get_args()
# pygame initialization
pygame.init()
screen = pygame.display.set_mode((WIDTH * args.z, HEIGHT * args.z))
clock = pygame.time.Clock()
settings = Settings(args)
if args.ai == "neat":
core = neatinterface.NeatCore()
else:
core = lib.Core()
core.new_game()
# main loop
while True:
# set tick rate to 60 per second
clock.tick(settings.tickrate)
# update game state
core.update()
if core.game_over():
core.new_game()
continue
# draw screen
surface = core.draw()
surface = pygame.transform.scale(surface, screen.get_size())
screen.blit(surface, surface.get_rect())
pygame.display.flip()