radius Fix

This commit is contained in:
Mateusz Dokowicz 2023-03-19 22:00:10 +01:00
parent 4ec034d548
commit 101136b0b7
2 changed files with 19 additions and 15 deletions

View File

@ -10,6 +10,7 @@ class Colors:
DEFAULT_COLOR = Colors.WHITE
RADIUS_SIZE_COEFFICIENT = 3
def default_color(func):
@ -53,7 +54,6 @@ class GridDraw:
self.line(0, tiles_height * i, self.width, tiles_height * i, color=color)
@default_color
def circle(self, x, y, radius, color=None):
pygame.draw.circle(
self.screen, color, (x, y), radius
) # TODO calculate radius (now 20) in terms of window size.
def circle(self, x, y, tile_height, color=None):
radius = tile_height / RADIUS_SIZE_COEFFICIENT
pygame.draw.circle(self.screen, color, (x, y), radius)

View File

@ -4,31 +4,35 @@ import pygame
from Interface.movement import robot_movement
def initial_draw(grid_dimensions, board_size):
# 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
border_array = [["" for j in range(board_size)] for i in range(board_size)]
board_array = [["" for j in range(board_size)] for i in range(board_size)]
board_render(board_array)
# set window dimension
grid_width = grid_dimensions
grid_height = grid_dimensions
window_width = window_dimensions
window_height = window_dimensions
# FIXME @countingthedots: please tell me what is going on there and why???
#
grid = GridDraw(grid_width, grid_height)
tile_width = grid_width / board_size
tile_height = grid_height / board_size
#
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
radius = tile_height/3
# rendering loop
while True:
grid.start_draw()
grid.board(board_size, board_size)
(x, y) = robot_movement(grid_width, grid_height, tile_width, tile_height, x, y)
grid.circle(x, y, radius, color=Colors.RED)
(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)