-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.py
55 lines (42 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
51
52
53
54
55
import pygame
import time
import random
import numpy as np
import os
import grid
os.environ["SDL_VIDEO_CENTERED"]='1'
#resolution
width, height = 1920,1080
size = (width, height)
pygame.init()
pygame.display.set_caption("CONWAY'S GAME OF LIFE")
screen = pygame.display.set_mode(size)
clock = pygame.time.Clock()
fps = 30
black = (0, 0, 0)
blue = (0, 121, 150)
blue1 = (0,14,71)
white = (255, 255, 255)
scaler = 30
offset = 1
Grid = grid.Grid(width,height, scaler, offset)
Grid.random2d_array()
pause = False
run = True
while run:
clock.tick(fps)
screen.fill(black)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if event.type == pygame.KEYUP:
if event.key == pygame.K_ESCAPE:
run = False
if event.key == pygame.K_SPACE:
pause = not pause
Grid.Conway(off_color=white, on_color=blue1, surface=screen, pause=pause)
if pygame.mouse.get_pressed()[0]:
mouseX, mouseY = pygame.mouse.get_pos()
Grid.HandleMouse(mouseX, mouseY)
pygame.display.update()
pygame.quit()