diff --git a/Interface/grid_draw.py b/Interface/grid_draw.py index ca0b7fd..10a87aa 100644 --- a/Interface/grid_draw.py +++ b/Interface/grid_draw.py @@ -1,20 +1,24 @@ import sys import pygame -class Colors(): + +class Colors: BLACK = 0, 0, 0 WHITE = 255, 255, 255 RED = 255, 0, 0 GREEN = 0, 255, 0 + DEFAULT_COLOR = Colors.WHITE -def default_color(func): + +def default_color(func): def wrap(*args, **kwargs): - if 'color' not in kwargs: - kwargs['color'] = DEFAULT_COLOR + if "color" not in kwargs: + kwargs["color"] = DEFAULT_COLOR result = func(*args, **kwargs) return result + return wrap class GridDraw(): @@ -56,9 +60,9 @@ class GridDraw(): pygame.time.delay(delay) @default_color - def line(self, x_1, y_1, x_2, y_2, color = None): + def line(self, x_1, y_1, x_2, y_2, color=None): pygame.draw.line(self.screen, color, (x_1, y_1), (x_2, y_2)) - + @default_color def board(self, tiles_x = None, tiles_y = None, color = None): tiles_x = tiles_x if tiles_x != None else self.tiles_x diff --git a/Interface/movement.py b/Interface/movement.py new file mode 100644 index 0000000..546c8f5 --- /dev/null +++ b/Interface/movement.py @@ -0,0 +1,25 @@ +import pygame +import sys + + +def robot_movement(grid_width, grid_height, tile_width, tile_height, x, y): + for event in pygame.event.get(): + if event.type == pygame.QUIT: + sys.exit() + if event.type == pygame.KEYDOWN: + # go left + if event.key == pygame.K_LEFT and x > (tile_width / 2): + x -= tile_width + + # go right + if event.key == pygame.K_RIGHT and x < (grid_width - (tile_width / 2)): + x += tile_width + + # go up + if event.key == pygame.K_UP and y > (tile_height / 2): + y -= tile_height + + # go down + if event.key == pygame.K_DOWN and y < (grid_height - (tile_height / 2)): + y += tile_height + return (x, y) diff --git a/Interface/vacuum_render.py b/Interface/vacuum_render.py index c64e984..9f5e70c 100644 --- a/Interface/vacuum_render.py +++ b/Interface/vacuum_render.py @@ -8,6 +8,9 @@ GRID_SIZE_Y = 10 # dummy function def initial_draw(): + # window name + pygame.display.set_caption("AI Vacuum Cleaner") + grid = GridDraw(800, 800, GRID_SIZE_X, GRID_SIZE_Y) x = 2 @@ -22,7 +25,6 @@ def initial_draw(): while True: grid.start_draw() - # grid.draw_vacuum(x, y) grid.fill_grid_with_sprite('TILE') grid.board() @@ -46,5 +48,3 @@ def initial_draw(): y = (y + 1 + GRID_SIZE_Y) % GRID_SIZE_Y grid.end_draw(delay=10) - - diff --git a/main.py b/main.py index 45c51de..a857b41 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,3 @@ from Interface.vacuum_render import initial_draw -initial_draw() \ No newline at end of file +initial_draw()