changed state singleton to behave like an singleton

This commit is contained in:
CiscoTheWolf 2023-06-05 22:17:15 +02:00
parent 6781c53cfd
commit 9abfdab767

View file

@ -7,24 +7,25 @@ class StateSingleton:
def __new__(cls):
if not cls._instance:
cls._instance = super(StateSingleton, cls).__new__(cls)
cls._instance.states = {
0: "open",
1: "blink",
2: "owo",
3: "angry"}
cls._instance.matrix = False
cls._instance.current_expression = cls._instance.states[0]
cls._instance.desired_expression = cls._instance.states[0]
cls._instance.new_desired_expression = cls._instance.states[0]
cls._instance.transition_steps = 10 # Number of steps to transition between states
cls._instance.transition_count = 0 # Counter to keep track of transition progress
cls._instance.animations_ready = False
cls._instance.blink_animation_FrameCanvases = []
cls._instance.angry_animation_FrameCanvases = []
return cls._instance
def __init__(self):
self.states = {
0: "open",
1: "blink",
2: "owo",
3: "angry"
}
self.matrix = False
self.current_expression = self.states[0]
self.desired_expression = self.states[0]
self.new_desired_expression = self.states[0]
self.transition_steps = 10 # Number of steps to transition between states
self.transition_count = 0 # Counter to keep track of transition progress
self.animations_ready = False
self.blink_animation_FrameCanvases = []
self.angry_animation_FrameCanvases = []
def set_blink_animation_frames(self, blink_animation_FrameCanvases):
self.blink_animation_FrameCanvases = blink_animation_FrameCanvases