def input(self, user_input): if user_input == pygame.MOUSEBUTTONUP: print('executing action') if self.attached: #replace gui object saved in field var with text from gui object, convert to number if digit for name, field in self.attached.items(): self.attached[name] = to_num(field.get_text()) self.action(self.attached) else: self.action()
def _load_objects(self): obj_filename = os.path.join('level_data', self._filename) parser = configparser.ConfigParser() if obj_filename not in parser.read(obj_filename): print(obj_filename + 'not found/cant be read') object_list = parser.sections() for objname in object_list: obj_type = parser[objname]['type'] var_dict = {'name': objname} for option in parser[objname]: value = parser[objname][option] var_dict[option] = to_num(value) self.objects.add(ObjFactory(obj_type, var_dict))
def __init__(self, var_dict): LevelObject.__init__(self, var_dict) self.type = BUILD_PROC str_input = var_dict['input'] str_output = var_dict['output'] self.input_items = [x.strip() for x in str_input.split(',')] self.output_items = [x.strip() for x in str_output.split(',')] self.length = to_num(var_dict['time']) self.delay_timer = Timer(5, self._ready) self.build_timer = Timer(self.length, self._finish) self.ready = True self.built = [] # list of output items that need to be spawned into the level self.input_area = self.rect # required input parts must collide with this rect to start build self.output_area = pygame.Rect(self.rect.right, self.rect.bottom, 200, 100) # items with output in this rect