def __init__(self, var_dict): LevelObject.__init__(self, var_dict) self.type = PLATFORM self.recipe_list = var_dict["recipe"] self.state = READY self.good_file = var_dict["good"] self.bad_file = var_dict["bad"] self.bad_anim = pyganim.PygAnimation([(os.path.join(self.bad_file), 1)]) self.good_anim = pyganim.PygAnimation([(os.path.join(self.good_file), 1)])
def __init__(self, var_dict): try: var_dict['file1'] = Part.lookup_image(var_dict['name']) var_dict['behavior0'] = 'pickup' LevelObject.__init__(self, var_dict) self.type = PART self.quality = var_dict['quality'] except KeyError: print('invalid/missing keys sent to part __init__') raise KeyError
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
def __init__(self, var_dict): LevelObject.__init__(self, var_dict) self.type = CRANE_OBJECT #list of tuples representing coordinates and wait time ie dest[0] = (x,y,wait) #Contains coordinates and wait time for each destination self.dests = [] self.cur_dest = 0 self.arm = None self.arm_name = var_dict['arm'] self.moving = False #These variables' values will be set in self.__setup_vars(var_dict) self.name = var_dict['name'] self.xmin = var_dict['xmin'] self.xmax = var_dict['xmax'] self.ymin = var_dict['ymin'] self.ymax = var_dict['ymax'] self.xhome = var_dict['xhome'] self.yhome = var_dict['yhome'] self.xspeed = var_dict['xspeed'] self.yspeed = var_dict['yspeed'] #Create home destination self.add_dest(self.xhome, self.yhome, 500) self.add_dest(820, 250, 5000, PICKUP) self.add_dest(100, 250, 5000, PLACE) self._waiting = False self._power = False self.state = OFF #These x and y values represent the crane's position when telling it to move somewhere (claw) self.claw_x = 0 self.claw_y = 0 #Objects that are possible to pick up and held objects self.pos_pickup = [] self.held_objects = [] #Area of the crane that objects can be picked up from pickup_w = 60 pickup_h = 30 pickup_x = self.claw_x - pickup_w pickup_y = self.claw_y - pickup_h self.pickup_area = pygame.Rect(pickup_x, pickup_y, pickup_w, pickup_h)