Machine_learning_2023/Interface/movement.py
2023-03-16 20:33:22 +01:00

26 lines
784 B
Python

import pygame
import sys
def moving_cleaner(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)