Machine_learning_2023/Interface/vacuum_render.py

39 lines
1010 B
Python
Raw Normal View History

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-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-12 19:33:57 +01:00
grid = GridDraw(500, 500, GRID_SIZE_X, GRID_SIZE_Y)
x = 2
y = 2
2023-03-12 16:22:51 +01:00
while True:
grid.start_draw()
2023-03-12 19:33:57 +01:00
grid.board()
grid.draw_wall(0, 0)
grid.draw_vacuum(x, y)
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)
2023-03-12 18:19:28 +01:00