-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathui.py
More file actions
28 lines (27 loc) · 778 Bytes
/
ui.py
File metadata and controls
28 lines (27 loc) · 778 Bytes
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
import utils
import globals
import engine
class ButtonUI:
def __init__(self, keyCode, text, x, y):
self.keyCode = keyCode
self.text = text
self.x = x
self.y = y
self.pressed = False
self.on = False
self.timer = 20
def update(self, inputStream):
self.pressed = inputStream.isPressed(self.keyCode)
if self.pressed:
self.on = True
if self.on:
self.timer -= 1
if self.timer <= 0:
self.on = False
self.timer = 20
def draw(self, screen, alpha=255):
if self.on:
colour = engine.GREEN
else:
colour = engine.WHITE
utils.drawText(screen, self.text, self.x, self.y, colour, alpha)