Werks
This commit is contained in:
28
drawing.py
Normal file
28
drawing.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import pygame
|
||||
from pygame.locals import *
|
||||
|
||||
from consts import *
|
||||
|
||||
|
||||
def draw_cell(display, position, color):
|
||||
position = (position[0] * CELL_SIZE + PADDING, position[1] * CELL_SIZE + PADDING)
|
||||
rect = pygame.Rect(position, (40, 40))
|
||||
pygame.draw.rect(display, color, rect)
|
||||
|
||||
|
||||
def gridtoscreen(pos):
|
||||
return (pos[0] * CELL_SIZE, pos[1] * CELL_SIZE)
|
||||
|
||||
|
||||
def center_line(pos):
|
||||
return (pos[0] + CELL_SIZE / 2, pos[1] + CELL_SIZE / 2)
|
||||
|
||||
|
||||
def draw_path(display, color, path):
|
||||
if path is None:
|
||||
return
|
||||
|
||||
for i in range(0, len(path)-1):
|
||||
n1 = center_line(gridtoscreen(path[i].g_pos()))
|
||||
n2 = center_line(gridtoscreen(path[i + 1].g_pos()))
|
||||
pygame.draw.line(display, color, n1, n2, 4)
|
||||
Reference in New Issue
Block a user