-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_handler.py
More file actions
57 lines (45 loc) · 1.59 KB
/
Copy pathinput_handler.py
File metadata and controls
57 lines (45 loc) · 1.59 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from settings import *
from enum import IntEnum, auto
from pyray import is_key_down, is_key_pressed, KeyboardKey
class Key(IntEnum):
#
FORWARD = KeyboardKey.KEY_W
BACK = KeyboardKey.KEY_S
STRAFE_LEFT = KeyboardKey.KEY_A
STRAFE_RIGHT = KeyboardKey.KEY_D
UP = KeyboardKey.KEY_Q
DOWN = KeyboardKey.KEY_E
MAP = KeyboardKey.KEY_M
SCREEN_SHOT = KeyboardKey.KEY_O
ATTACK = KeyboardKey.KEY_SPACE
class InputHandler:
def __init__(self, engine):
self.engine = engine
self.player = engine.player
def update(self):
self.player.handle_input()
if is_key_pressed(Key.ATTACK):
self.player.attack()
# ------------ camera control ------------- #
#if is_key_down(Key.FORWARD):
#self.player.handle_input()
#
#elif is_key_down(Key.BACK):
#self.player.handle_input()
#if is_key_down(Key.STRAFE_RIGHT):
#self.player.handle_input()
#
#elif is_key_down(Key.STRAFE_LEFT):
#self.player.handle_input()
#
#if is_key_down(Key.UP):
#self.player.handle_input()
#
#elif is_key_down(Key.DOWN):
#self.player.handle_input()
# ------------ --------------- ------------- #
if is_key_pressed(Key.MAP):
self.engine.map_renderer.should_draw = not self.engine.map_renderer.should_draw
self.engine.view_renderer.update_screen_tint()
if is_key_pressed(Key.SCREEN_SHOT):
take_screenshot('screen_shot.png')