Exemplo n.º 1
0
 def __init__(self, fielddata):
     BaseModel.__init__(self)
     self.footholds = []
     self.footholds_count = 0
     self.background_img = pygame.image.load(
         get_file_path(fielddata['background_img'])).convert()
     self.tiles_img = pygame.image.load(
         get_file_path(fielddata['tiles_img'])).convert_alpha()
     for fh in fielddata['footholds']:
         tmp = {
             'pos': fh['pos'], 'width': fh['size'][0],
             'image': pygame.Surface(fh['size'], SRCALPHA)}
         x = 0
         for t in fh['tiles']:
             repeat, sub_pos, rand_tile = 1, (0, 0), False
             if 'repeat' in t:
                 repeat = t['repeat']
             if isinstance(t['sub_pos'], list):
                 rand_tile = True
             for _ in range(repeat):
                 sub_pos = t['sub_pos'][randindex(len(t['sub_pos']))] if\
                     rand_tile else t['sub_pos']
                 x = self._build_image(tmp['image'], x, sub_pos, t['size'])
         self.footholds.append(tmp)
         self.footholds_count += 1
Exemplo n.º 2
0
    def __init__(self, env, handle, attack_handle, *args, **kwargs):
        BaseModel.__init__(self, env, handle)

        self.attack_channel = env.get_channel(attack_handle)
        self.attack_base, self.view2attack = env.get_view2attack(handle)

        print("attack_channel", self.attack_channel)
        print("view2attack", self.view2attack)
Exemplo n.º 3
0
    def __init__(self, env, handle, *args, **kwargs):
        BaseModel.__init__(self, env, handle)

        self.env = env
        self.handle = handle
        self.n_action = env.get_action_space(handle)
        self.view_size = env.get_view_space(handle)
        self.attack_base, self.view2attack = env.get_view2attack(handle)
Exemplo n.º 4
0
 def __init__(self):
     BaseModel.__init__(self)
     # load save file
     self.level = 10
     self.critical_chance = 10
     self.damage = 10
     self.hit_num = 5
     self.critical_power = 50
Exemplo n.º 5
0
    def __init__(self, env, handle, away_handle, *args, **kwargs):
        BaseModel.__init__(self, env, handle)

        self.away_channel = env.get_channel(away_handle)
        self.attack_base, _ = env.get_view2attack(handle)
        self.move_back = 4

        print("attack base", self.attack_base, "away", self.away_channel)
Exemplo n.º 6
0
    def __init__(self, env, handle, name, subclass_name):
        """init a model

        Parameters
        ----------
        env: magent.Environment
        handle: handle (ctypes.c_int32)
        name: str
        subclass_name: str
            name of subclass
        """
        BaseModel.__init__(self, env, handle)
        self.name = name
        self.subclass_name = subclass_name
Exemplo n.º 7
0
 def __init__(self):
     Group.__init__(self)
     BaseModel.__init__(self)
     # load image
     _money_image = pygame.image.load(
         get_file_path('img/item/money.png')).convert_alpha()
     _subsurface_data = [(25, 24), (25, 24), (33, 30), (32, 31)]
     _y = 0
     self.money_images = []
     for _sub_data in _subsurface_data:
         _tmp_list = [_money_image.subsurface(
             (i*_sub_data[0], _y), _sub_data) for i in range(4)]
         _y += _sub_data[1]
         self.money_images.append(_tmp_list)
     _item_rare_image = pygame.image.load(
         get_file_path('img/item/rare_42x44.png')).convert_alpha()
     self.item_rare_images = [_item_rare_image.subsurface(
         (i*ITEM_RARE_SIZE[0], 0), ITEM_RARE_SIZE) for i in range(6)]
     # load icons, but now only load one image
     self.item_icons = pygame.image.load(
         get_file_path('img/item/04000019.png')).convert_alpha()
Exemplo n.º 8
0
    def __init__(self, env, handle, *args, **kwargs):
        BaseModel.__init__(self, env, handle)

        self.env = env
        self.handle = handle
        self.n_action = env.get_action_space(handle)[0]