-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.py
31 lines (28 loc) · 1.06 KB
/
process.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pygame
import sys
def move(player):
keys = pygame.key.get_pressed()
if keys[player.player_controls['left']]:
player.image = player.left_faced
player.set_direction('left')
player.velocity['horizontal'] = -player.speed
player.velocity['vertical'] = 0
elif keys[player.player_controls['right']]:
player.image = player.right_faced
player.position['right'] = True
player.set_direction('right')
player.velocity['horizontal'] = player.speed
player.velocity['vertical'] = 0
elif keys[player.player_controls['down']]:
player.image = player.down_faced
player.set_direction('down')
player.velocity['vertical'] = player.speed
player.velocity['horizontal'] = 0
elif keys[player.player_controls['up']]:
player.set_direction('up')
player.image = player.up_faced
player.velocity['vertical'] = - player.speed
player.velocity['horizontal'] = 0
else:
player.velocity['vertical'] = 0
player.velocity['horizontal'] = 0