Machine_learning_2023/Interface/vacuum_render.py

39 lines
1.2 KiB
Python

from Interface.grid_draw import GridDraw, Colors
import sys
import pygame
from Interface.movement import robot_movement
# window_dimensions says how many pixels window have
# board_size says how many lines board have
def initial_draw(window_dimensions, board_size):
# window name
pygame.display.set_caption("AI Vacuum Cleaner")
# define array for grid
board_array = [["" for j in range(board_size)] for i in range(board_size)]
board_render(board_array)
# set window dimension
window_width = window_dimensions
window_height = window_dimensions
# FIXME @countingthedots: please tell me what is going on there and why???
#
grid = GridDraw(window_width, window_height)
tile_width = window_width / board_size
tile_height = window_height / board_size
x = tile_width / 2
y = tile_height / 2
# rendering loop
while True:
grid.start_draw()
grid.board(board_size, board_size)
(x, y) = robot_movement(
window_width, window_height, tile_width, tile_height, x, y
)
grid.circle(x, y, tile_height, color=Colors.RED)
grid.end_draw()
pygame.time.delay(10)