From edc78b91039e8d482496f5e4ea0404dc179a52cb Mon Sep 17 00:00:00 2001 From: countingthedots Date: Sun, 12 Mar 2023 18:19:28 +0100 Subject: [PATCH 2/2] Moving circle added --- Interface/grid_draw.py | 2 -- Interface/interface.py | 40 -------------------------------------- Interface/vacuum_render.py | 29 +++++++++++++++++++++------ 3 files changed, 23 insertions(+), 48 deletions(-) delete mode 100644 Interface/interface.py diff --git a/Interface/grid_draw.py b/Interface/grid_draw.py index 92471f9..0f74e86 100644 --- a/Interface/grid_draw.py +++ b/Interface/grid_draw.py @@ -32,8 +32,6 @@ class GridDraw(): self.screen = pygame.display.set_mode((self.width, self.height)) def start_draw(self): - for event in pygame.event.get(): - if event.type == pygame.QUIT: sys.exit() self.screen.fill(Colors.BLACK) def end_draw(self): diff --git a/Interface/interface.py b/Interface/interface.py deleted file mode 100644 index 8fc8971..0000000 --- a/Interface/interface.py +++ /dev/null @@ -1,40 +0,0 @@ -import sys -import pygame -from .helpers import * - - -def initialize_interface(tiles_x, tiles_y): - - size = width, height = 600, 600 - screen = create_screen(size) - pygame.display.set_caption('Epic AI Vacuum Cleaner') - tile_width = width / tiles_x - tile_height = height / tiles_y - x = tile_width / 2 - y = tile_height / 2 - radius = 15 - - while True: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - sys.exit() - userInput = pygame.key.get_pressed() - if event.type == pygame.KEYDOWN: - if event.key == pygame.K_LEFT: - x -= tile_width - if event.key == pygame.K_RIGHT: - x += tile_width - if event.key == pygame.K_UP: - y -= tile_height - if event.key == pygame.K_DOWN: - y += tile_height - - pygame.time.delay(10) - pygame.display.update() - screen.fill(BLACK) - # rect(screen, WHITE, 50,50,90,90) - - draw_board(screen, WHITE, width, height, tiles_x, tiles_y) - pygame.draw.circle(screen, (178, 172, 136), (int(x), int(y)), radius) - - pygame.display.flip() diff --git a/Interface/vacuum_render.py b/Interface/vacuum_render.py index 29f1b52..3732c3e 100644 --- a/Interface/vacuum_render.py +++ b/Interface/vacuum_render.py @@ -1,14 +1,31 @@ from Interface.grid_draw import GridDraw, Colors +import sys +import pygame # dummy function def initial_draw(): grid = GridDraw(500, 500) - + tile_width = 500 / 10 + tile_height = 500 / 10 + x = tile_width / 2 + y = tile_height / 2 + radius = 15 while True: grid.start_draw() - grid.board(10, 10) - grid.circle(75, 75, 20, color=Colors.RED) - grid.circle(225, 175, 20, color=Colors.GREEN) - - grid.end_draw() + for event in pygame.event.get(): + if event.type == pygame.QUIT: + sys.exit() + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT: + x -= tile_width + if event.key == pygame.K_RIGHT: + x += tile_width + if event.key == pygame.K_UP: + y -= tile_height + if event.key == pygame.K_DOWN: + y += tile_height + grid.circle(x, y, 20, color=Colors.RED) + grid.end_draw() + pygame.time.delay(10) +