Machine_learning_2023/Interface/helpers.py

32 lines
794 B
Python
Raw Normal View History

2023-03-11 19:31:43 +01:00
import pygame
BLACK = 0, 0, 0
WHITE = 255, 255, 255
2023-03-12 01:39:08 +01:00
2023-03-11 19:31:43 +01:00
def rect(screen, color, position_x, position_y, size_x, size_y):
2023-03-12 01:39:08 +01:00
pygame.draw.rect(screen, color, (position_x, position_y, size_x, size_y))
2023-03-11 19:31:43 +01:00
def line(screen, color, x_1, y_1, x_2, y_2):
2023-03-12 01:39:08 +01:00
pygame.draw.line(screen, color, (x_1, y_1), (x_2, y_2))
2023-03-11 19:31:43 +01:00
def create_screen(size):
2023-03-12 01:39:08 +01:00
return pygame.display.set_mode(size)
2023-03-11 19:31:43 +01:00
def draw_board(screen, color, width, height, tiles_x, tiles_y):
tiles_width = width / tiles_x
tiles_height = height / tiles_y
temp_x = tiles_width
for i in range(tiles_x-1):
line(screen, color, temp_x, 0, temp_x, height)
temp_x += tiles_width
temp_y = tiles_height
for i in range(tiles_y-1):
line(screen, color, 0, temp_y, width, temp_y)
temp_y += tiles_height