2023-03-12 16:22:51 +01:00
|
|
|
from Interface.grid_draw import GridDraw, Colors
|
2023-03-12 18:19:28 +01:00
|
|
|
import sys
|
|
|
|
import pygame
|
2023-03-21 20:29:35 +01:00
|
|
|
from random import randint
|
2023-03-11 19:31:43 +01:00
|
|
|
|
2023-03-12 19:33:57 +01:00
|
|
|
GRID_SIZE_X = 10
|
|
|
|
GRID_SIZE_Y = 10
|
|
|
|
|
2023-03-12 16:22:51 +01:00
|
|
|
# dummy function
|
|
|
|
def initial_draw():
|
2023-03-16 21:38:42 +01:00
|
|
|
# window name
|
|
|
|
pygame.display.set_caption("AI Vacuum Cleaner")
|
|
|
|
|
2023-03-21 20:29:35 +01:00
|
|
|
grid = GridDraw(800, 800, GRID_SIZE_X, GRID_SIZE_Y)
|
2023-03-12 19:33:57 +01:00
|
|
|
|
|
|
|
x = 2
|
|
|
|
y = 2
|
|
|
|
|
2023-03-21 20:29:35 +01:00
|
|
|
peels = []
|
|
|
|
for _ in range(10):
|
|
|
|
temp_x = randint(0, GRID_SIZE_X)
|
|
|
|
temp_y = randint(0, GRID_SIZE_Y)
|
|
|
|
peels.append((temp_x, temp_y))
|
|
|
|
|
|
|
|
|
2023-03-12 16:22:51 +01:00
|
|
|
while True:
|
|
|
|
grid.start_draw()
|
2023-03-21 20:29:35 +01:00
|
|
|
grid.fill_grid_with_sprite('TILE')
|
2023-03-12 19:33:57 +01:00
|
|
|
grid.board()
|
|
|
|
|
2023-03-21 20:29:35 +01:00
|
|
|
for peel in peels:
|
|
|
|
grid.draw_sprite(peel[0], peel[1], "PEEL")
|
|
|
|
|
|
|
|
grid.draw_sprite(x, y, "VACUUM")
|
2023-03-12 19:33:57 +01:00
|
|
|
|
2023-03-12 18:19:28 +01:00
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
sys.exit()
|
|
|
|
if event.type == pygame.KEYDOWN:
|
2023-03-12 19:33:57 +01:00
|
|
|
match event.key:
|
|
|
|
case pygame.K_LEFT:
|
|
|
|
x = (x - 1 + GRID_SIZE_X) % GRID_SIZE_X
|
|
|
|
case pygame.K_RIGHT:
|
|
|
|
x = (x + 1 + GRID_SIZE_X) % GRID_SIZE_X
|
|
|
|
case pygame.K_UP:
|
|
|
|
y = (y - 1 + GRID_SIZE_Y) % GRID_SIZE_Y
|
|
|
|
case pygame.K_DOWN:
|
|
|
|
y = (y + 1 + GRID_SIZE_Y) % GRID_SIZE_Y
|
|
|
|
|
|
|
|
grid.end_draw(delay=10)
|