-
Notifications
You must be signed in to change notification settings - Fork 1
/
InputHandler.py
52 lines (43 loc) · 1.14 KB
/
InputHandler.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pyglet
from pyglet.window import Window
from pyglet import app
from pyglet.gl import *
class MouseInput:
x = y = button = None
def __init__(this, x, y, button):
this.x = x
this.y = y
this.button = button
def getX(this):
return this.x
def getY(this):
return this.y
def getButton(this):
return this.button
class KeyInput:
key = None
def __init__(this, key):
this.key = key
def getKey(this):
return this.key
class RecentInputs:
mouseInputs = []
keyInputs = []
def __init__(this):
this.mouseInputs = []
this.keyInputs = []
def addMouseInput(this, x, y, button):
this.mouseInputs.append(MouseInput(x, y, button))
def addKeyInput(this, key):
this.keyInputs.append(KeyInput(key))
def clearInputs(this):
this.mouseInputs.clear()
this.keyInputs.clear()
def popMouseInputs(this):
temp = this.mouseInputs.copy()
this.mouseInputs.clear()
return temp
def popKeyInputs(this):
temp = this.keyInputs.copy()
this.keyInputs.clear()
return temp