-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar.py
More file actions
71 lines (50 loc) · 1.57 KB
/
Car.py
File metadata and controls
71 lines (50 loc) · 1.57 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import pygame
from Utils import *
from Player import Player
from Brain import Brain
from Population import Population
from Node import Node
import time
# initializing imported module
pygame.init()
print("\n")
population = Population()
p1 = Player()
def main():
t = 0
running = True
while running:
# Sets window at 60 FPS
clock.tick(FPS)
# Check for events
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Mouse click event
if event.type == pygame.MOUSEBUTTONUP:
mousePos = pygame.mouse.get_pos()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q or event.key == pygame.K_ESCAPE:
running = False
if event.key == pygame.K_f:
p1.draw_raycast = not p1.draw_raycast
# Calculations before drawing
keys = pygame.key.get_pressed()
keyPresses(keys, p1)
fillScreen()
surface.blit(road_image, road_rect)
drawWalls()
displayFPS()
# p1.calcSpeed()
# p1.rotatePoints()
# p1.calcRaycast()
# p1.draw()
population.updatePlayersMovement()
population.checkIfPlayersDied()
population.updateAllPlayersBrain()
population.calculateBrainOutput()
population.calculateBestScore()
# Updates the screen
pygame.display.flip()
if __name__ == '__main__':
main()