Machine_learning_2023/Interface/vacuum_render.py

39 lines
1.2 KiB
Python
Raw Normal View History

2023-03-12 16:22:51 +01:00
from Interface.grid_draw import GridDraw, Colors
2023-03-12 18:11:31 +01:00
import sys
import pygame
2023-03-16 21:55:05 +01:00
from Interface.movement import robot_movement
2023-03-11 19:31:43 +01:00
2023-03-16 20:33:22 +01:00
2023-03-19 22:00:10 +01:00
# window_dimensions says how many pixels window have
# board_size says how many lines board have
def initial_draw(window_dimensions, board_size):
2023-03-16 21:38:42 +01:00
# window name
pygame.display.set_caption("AI Vacuum Cleaner")
# define array for grid
2023-03-19 22:00:10 +01:00
board_array = [["" for j in range(board_size)] for i in range(board_size)]
board_render(board_array)
2023-03-16 21:38:42 +01:00
# set window dimension
2023-03-19 22:00:10 +01:00
window_width = window_dimensions
window_height = window_dimensions
2023-03-16 21:38:42 +01:00
# FIXME @countingthedots: please tell me what is going on there and why???
2023-03-19 22:00:10 +01:00
#
grid = GridDraw(window_width, window_height)
tile_width = window_width / board_size
tile_height = window_height / board_size
2023-03-12 18:11:31 +01:00
x = tile_width / 2
y = tile_height / 2
2023-03-16 20:33:22 +01:00
# rendering loop
2023-03-12 16:22:51 +01:00
while True:
grid.start_draw()
2023-03-16 21:38:42 +01:00
grid.board(board_size, board_size)
2023-03-19 22:00:10 +01:00
(x, y) = robot_movement(
window_width, window_height, tile_width, tile_height, x, y
)
grid.circle(x, y, tile_height, color=Colors.RED)
2023-03-16 20:33:22 +01:00
grid.end_draw()
pygame.time.delay(10)