-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteraction.py
32 lines (24 loc) · 983 Bytes
/
interaction.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
32
import pygame
import sys
from Classes import Tile
from Classes import Body
def interaction(screen, head):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
head.velx = 0
head.vely = 0
if event.key == pygame.K_w or event.key == pygame.K_UP:
head.velx = 0
head.vely -= head.height
if event.key == pygame.K_s or event.key == pygame.K_DOWN:
head.velx = 0
head.vely += head.height
if event.key == pygame.K_a or event.key == pygame.K_LEFT:
head.velx -= head.width
head.vely = 0
if event.key == pygame.K_d or event.key == pygame.K_RIGHT:
head.velx += head.width
head.vely = 0