movement as a seperate function
This commit is contained in:
parent
63912b9b24
commit
9db0cc3cfd
17
Interface/movement.py
Normal file
17
Interface/movement.py
Normal file
@ -0,0 +1,17 @@
|
||||
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)
|
Loading…
Reference in New Issue
Block a user