Compare commits

...

15 Commits

Author SHA1 Message Date
7809879c7c merge 2023-03-21 20:43:10 +01:00
4ec034d548 Merge pull request 'Fixed radius value' (#6) from radiusFixed into main
Reviewed-on: #6
2023-03-19 20:05:12 +01:00
countingthedots
8d9c4146a4 Fixed radius value 2023-03-19 19:53:54 +01:00
ef2e1a1fb7 Merge pull request 'optimization' (#5) from optimization into main
Reviewed-on: #5
2023-03-16 22:13:59 +01:00
Mateusz Dokowicz
2200cf15d7 typo 15->20 2023-03-16 22:08:47 +01:00
Mateusz Dokowicz
9b7bb1a62c rename movingCleaner to robot_movement 2023-03-16 21:55:05 +01:00
Mateusz Dokowicz
a5e38a707b calculate radius prep 2023-03-16 21:50:27 +01:00
Mateusz Dokowicz
257f0f7d1d TODO calculate radius 2023-03-16 21:49:06 +01:00
Mateusz Dokowicz
3696636245 Code readability 2023-03-16 21:38:42 +01:00
Mateusz Dokowicz
d080b04763 formatting and comments 2023-03-16 20:33:22 +01:00
9ac833550c Merge pull request 'Refactor' (#4) from Refactor into main
Reviewed-on: #4
2023-03-12 20:15:06 +01:00
countingthedots
9db0cc3cfd movement as a seperate function 2023-03-12 20:13:00 +01:00
countingthedots
63912b9b24 movement as a seperate function 2023-03-12 20:10:18 +01:00
countingthedots
997bd72a97 Merge branch 'main' of https://git.wmi.amu.edu.pl/s473601/Machine_learning_2023 2023-03-12 19:40:43 +01:00
countingthedots
6f31a587b9 Moving circle added 2023-03-12 18:11:31 +01:00
4 changed files with 39 additions and 10 deletions

View File

@ -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 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():

25
Interface/movement.py Normal file
View File

@ -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)

View File

@ -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)