From 63912b9b246712ee0c14b110044d2d523652b1e8 Mon Sep 17 00:00:00 2001 From: countingthedots Date: Sun, 12 Mar 2023 20:10:18 +0100 Subject: [PATCH] movement as a seperate function --- Interface/vacuum_render.py | 22 ++++++---------------- main.py | 2 +- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/Interface/vacuum_render.py b/Interface/vacuum_render.py index 3732c3e..e19baac 100644 --- a/Interface/vacuum_render.py +++ b/Interface/vacuum_render.py @@ -1,30 +1,20 @@ from Interface.grid_draw import GridDraw, Colors import sys import pygame +from Interface.movement import moving_cleaner # dummy function -def initial_draw(): - grid = GridDraw(500, 500) - tile_width = 500 / 10 - tile_height = 500 / 10 +def initial_draw(grid_width, grid_height): + grid = GridDraw(grid_width, grid_height) + tile_width = grid_width / 10 + tile_height = grid_height / 10 x = tile_width / 2 y = tile_height / 2 radius = 15 while True: grid.start_draw() grid.board(10, 10) - 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 + (x,y) = moving_cleaner(grid_width,grid_height,tile_width,tile_height, x, y) grid.circle(x, y, 20, color=Colors.RED) grid.end_draw() pygame.time.delay(10) diff --git a/main.py b/main.py index a857b41..2b8ee4a 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,3 @@ from Interface.vacuum_render import initial_draw -initial_draw() +initial_draw(500, 500)