Initialize grid and node classes. Initialize main window.

This commit is contained in:
nlitkowski 2019-04-07 16:58:08 +02:00
parent c57b341381
commit fe7cc509fd
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,34 @@
import pygame
class Grid:
def __init__(self, game):
self.game = game
self.length = self.game.screen_res[0]/15
self.width = (self.game.screen_res[1]/15)-3
self.nodes = [[Node(self, [row, col + 3])
for row in xrange(self.length)]
for col in xrange(self.width)]
class Node:
def __init__(self, grid, pos):
self.grid = grid
self.game = self.grid.game
self.pos = pos
self.blit_pos = [i*15 for i in self.pos]
self.color = [0, 0, 0]
self.image = pygame.Surface((15, 15))
self.rect = self.image.get_rect(topleft=self.blit_pos)
self.solid = 0
self.in_path = False
self.checked = False
def fill(self, screen):
self.image.fill(self.color)
screen.blit(self.image, self.rect)

12
main.py
View File

@ -1,2 +1,12 @@
import pygame
def main():
pygame.init()
# Define screen size tuple
size = width, height = 1200, 900
screen = pygame.display.set_mode(size)
if __name__ == "__main__":
pass
main()