18 lines
677 B
Python
18 lines
677 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:
|
|
if event.key == pygame.K_LEFT and x>(tile_width / 2):
|
|
x -= tile_width
|
|
if event.key == pygame.K_RIGHT and x<(grid_width-(tile_width / 2)):
|
|
x += tile_width
|
|
if event.key == pygame.K_UP and y>(tile_height / 2):
|
|
y -= tile_height
|
|
if event.key == pygame.K_DOWN and y<(grid_height-(tile_height / 2)):
|
|
y += tile_height
|
|
return(x,y)
|