-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModifier_class.py
More file actions
38 lines (30 loc) · 1.43 KB
/
Copy pathModifier_class.py
File metadata and controls
38 lines (30 loc) · 1.43 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
import os, sys, math, time, copy, pygame, random, colorsys
import visual_functions as visual
class Modifier:
def __init__(self, value, visual):
self.value = self.default = value[0]
self.scaling = {"type": value[1],
"amount": value[2],
"bounds": value[3]}
self.name, self.unit, self.dp = visual
def bump(self, bump_type, bump_magnitude):
amount = self.scaling["amount"][bump_magnitude]
identity = (1,-1)[bump_type == "dec"]
if self.scaling["type"] == "lin":
self.value += amount * identity
elif self.scaling["type"] == "geo":
self.value *= (1+amount) ** identity
elif self.scaling["type"] == "mod":
modulo = self.scaling["bounds"][1] - self.scaling["bounds"][0] + 1
self.value = (self.value + amount * identity) % modulo
if self.scaling["bounds"][0] != None:
self.value = max(self.scaling["bounds"][0], self.value)
elif self.scaling["bounds"][1] != None:
self.value = min(self.scaling["bounds"][1], self.value)
def display(self, P_xp, P_yp, marked=False):
marker = ("", ">> ")[marked]
num_value = str(round(self.value, self.dp)) + self.unit
visual.draw_text(marker + "{}: {}".format(self.name, num_value),
(P_xp, P_yp), "bottomright")
def default(self):
self.value = self.default