Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tickedObject import TickedObject
- def extract(obj, prop):
- return (obj.__dict__[prop][0]).__dict__[obj.__dict__[prop][1]]
- def setup(obj, prop, default):
- obj.__dict__[f'std_{prop}'] = default
- obj.__dict__[prop] = (obj, f'std_{prop}')
- def launch(cdict):
- varlist = {key: cdict[key] for key in cdict}
- ticked = [varlist[key] for key in varlist if isinstance(varlist[key], TickedObject)]
- return ticked
- class Printer(TickedObject):
- def __init__(self):
- self.std_message = 'No Print Set'
- self.message = (self, 'std_message')
- def update(self):
- print((self.message[0]).__dict__[self.message[1]])
- class Counter(TickedObject):
- def __init__(self):
- self.i = 0
- self.std_increment = 1
- self.increment = (self, 'std_increment')
- def update(self):
- self.i += (self.increment[0]).__dict__[self.increment[1]]
- import timeit
- class FPSCounter(TickedObject):
- def __init__(self):
- self.frames = 0
- self.fps = 0
- self.last_frame = 0
- self.last_frames = []
- def update(self):
- self.last_frame = timeit.default_timer()
- self.last_frames.append(self.last_frame)
- if len(self.last_frames) > 5:
- self.last_frames = self.last_frames[1:]
- framediffs = []
- for i, frame_time in enumerate(self.last_frames):
- if i != len(self.last_frames)-1:
- framediffs.append((self.last_frames[i+1])-frame_time)
- if len(framediffs): self.fps = round(1/(sum(framediffs)/len(framediffs)),2)
- import os
- class Clearer(TickedObject):
- def __init__(self):
- pass
- def update(self):
- os.system('cls')
- import math
- class Operator(TickedObject):
- def __init__(self):
- self.std_operation = lambda x : x**2
- self.operation = (self, 'std_operation')
- self.std_operand = 5
- self.operand = (self, 'std_operand')
- self.last_value = 0
- def update(self):
- op = (self.operation[0]).__dict__[self.operation[1]]
- self.last_value = op((self.operand[0]).__dict__[self.operand[1]])
- class Difer(TickedObject):
- def __init__(self):
- self.previous_value = 0
- self.current_value = 0
- self.difference = 0
- self.value = setup(self, 'value', 0)
- def update(self):
- self.current_value = extract(self, 'value')
- self.difference = self.current_value-self.previous_value
- self.previous_value = self.current_value
- class Concator(TickedObject):
- def __init__(self):
- setup(self, 'one', 'Hello')
- setup(self, 'two', ' World!')
- self.out = ''
- def update(self):
- self.out = str(extract(self, 'one')) + str(extract(self, 'two'))
- import UI
- class Canvas(TickedObject):
- def __init__(self):
- self.objects = []
- def update(self):
- canvas = UI.Canvas()
- for obj in self.objects:
- canvas.objects.append(obj.load())
- canvas.draw()
- class CanvasRect(TickedObject):
- def __init__(self):
- setup(self, 'x', 0)
- setup(self, 'y', 0)
- setup(self, 'width', 20)
- setup(self, 'height', 10)
- setup(self, 'text', '')
- def load(self):
- return UI.Square(extract(self, 'x'), extract(self, 'y'), extract(self, 'width'), extract(self, 'height'), extract(self, 'text'))
- def update(self):
- pass
Add Comment
Please, Sign In to add comment