当前位置: 首页>>代码示例>>Python>>正文


Python Animation.setup方法代码示例

本文整理汇总了Python中animation.Animation.setup方法的典型用法代码示例。如果您正苦于以下问题:Python Animation.setup方法的具体用法?Python Animation.setup怎么用?Python Animation.setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在animation.Animation的用法示例。


在下文中一共展示了Animation.setup方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Medbay

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import setup [as 别名]
class Medbay(Building):
    def __init__(self):
        self.ico_pic = pygame.image.load("sprites/generator_ico.png")
        self.image = Animation()
        self.image.setup("medbay")
        self.ico_medic = pygame.image.load("sprites/icons/mup.png")
        self.ico_medshop = pygame.image.load("sprites/icons/mup.png")
        self.size = 50

    def draw_hud(self, target):        
        target.screen.blit(self.ico_pic, (230, 500))
        target.draw_hudbuttons(2)
        target.screen.blit(self.ico_medic, target.hud.all_coords[0])
        target.screen.blit(self.ico_medshop, target.hud.all_coords[1])
        
    def detectact(self, target, curpos):
        if curpos.get_distance(vec2d(646, 456)) <= 15:
            if target.buildings[0].inventory[1][1] > 20000:
                target.buildings[0].inventory[1][1] -= 20000

                print("Medic ready for duty!")

            else:
                print("You need 20 000 ore to buy this unit!")
        if curpos.get_distance(vec2d(696, 456)) <= 15:
            if target.buildings[0].inventory[1][1] > 40000:
                target.buildings[0].inventory[1][1] -= 40000

                print("Battery truck ready for duty!")

            else:
                print("You need 40 000 ore to buy this unit!")
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:34,代码来源:buildings.py

示例2: UpgradeFactory

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import setup [as 别名]
class UpgradeFactory(Building):
    def __init__(self):
        self.ico_pic = pygame.image.load("sprites/factory_ico.png")
        self.image = Animation()
        self.image.setup("factory")
        self.supic = pygame.image.load("sprites/icons/spu.png")
        self.mupic = pygame.image.load("sprites/icons/mup.png")
        self.size = 50
        
    def draw_hud(self, target):
        target.screen.blit(self.ico_pic, (230, 500))
        target.draw_hudbuttons(2)
        target.screen.blit(self.supic, target.hud.all_coords[0])
        target.screen.blit(self.mupic, target.hud.all_coords[1])
        
    def detectact(self, target, curpos):
        if curpos.get_distance(vec2d(646, 456)) <= 15:
            if target.buildings[0].inventory[1][1] > 40000:
                target.buildings[0].inventory[1][1] -= 40000
                Drone.speed = 6
                print("Drone speed upgraded by 20%.")
                for drone in target.drones:
                    drone.speed = 6
            else:
                print("You need 40 000 ore to buy speed upgrade!")
        if curpos.get_distance(vec2d(696, 456)) <= 15:
            if target.buildings[0].inventory[1][1] > 40000:
                target.buildings[0].inventory[1][1] -= 40000
                Drone.mining_speed = 2
                print("Drone mining speed increased by 100%")
                for drone in target.drones:
                    drone.mining_speed = 2
            else:
                print("You need 40 000 ore to buy mining speed upgrade!")
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:36,代码来源:buildings.py

示例3: upgrade

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import setup [as 别名]
 def upgrade(self):
     self.level = 1
     self.target = self.pos
     self.fire_target = self.pos
     tempimage = Animation()
     tempimage.setup("upoutpost")
     self.image = tempimage
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:9,代码来源:buildings.py

示例4: Outpost

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import setup [as 别名]
class Outpost(Building):
    def __init__(self):
        self.ico_pic = pygame.image.load("sprites/generator_ico.png")
        self.up_ico = pygame.image.load("sprites/icons/up_ico.png")
        self.image = Animation()
        self.image.setup("outpost")
        self.size = 35
        self.level = 0
        self.target = vec2d(0, 0)
        self.fire_target = vec2d(0, 0)
        
    def draw_hud(self, target):
        target.screen.blit(self.ico_pic, (230, 500))
        target.draw_hudbuttons(1)
        target.screen.blit(self.up_ico, target.hud.all_coords[0])

    def detectact(self, target, curpos):
        if curpos.get_distance(vec2d(646, 456)) <= 15:
            self.upgrade()
            
    def upgrade(self):
        self.level = 1
        self.target = self.pos
        self.fire_target = self.pos
        tempimage = Animation()
        tempimage.setup("upoutpost")
        self.image = tempimage
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:29,代码来源:buildings.py

示例5: __init__

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import setup [as 别名]
class Drone:
    '''Class for workers!'''
    def __init__(self):
        self.pos = vec2d(0, 0)
        self.target = []
        self.single_t = True
        self.image = Animation()
        self.image.setup("drone")
        self.def_pic = pygame.image.load("sprites/icons/bat_ico.png")
        self.ico_pic = pygame.image.load("sprites/bot_ico.png")
        self.generator_ico = pygame.image.load("sprites/icons/gico.png")
        self.factory_ico = pygame.image.load("sprites/icons/faico.png")
        self.medbay_ico = pygame.image.load("sprites/icons/med_ico.png")
        self.outpost_ico = pygame.image.load("sprites/icons/out_ico.png")
        self.stockpile_ico = pygame.image.load("sprites/icons/sto_ico.png")
        self.power = 255
        self.inventory = [["battery", 0], ["iron ore", 0]]
        self.task = 0
        self.speed = 5
        self.mining_speed = 1
        
    def update(self):
        dir = self.target[0] - self.pos      
        self.power -= 0.1
        if dir.length >= self.speed:
            dir.length = self.speed
            self.pos = vec2d(int(self.pos[0] + dir[0]), int(self.pos[1] + dir[1]))
        else:
            if len(self.target) > 1:
                temptargets = self.target[1:]
                self.target = temptargets
                
    def draw_hud(self, target):
        if self.single_t == 1:
            target.screen.blit(target.hud.sing_dir, (280, 427))
        else:
            target.screen.blit(target.hud.mul_dir, (280, 427))
            
        target.screen.blit(self.ico_pic, (230, 505))
        target.drawbattery(cap = 1)
            
        target.screen.blit(target.ores[0].ico, (380, 505))
        pygame.draw.rect(target.screen, (75, 75, 75), (380, 505, 25, 25 - int(self.inventory[1][1] / 40)))
        pygame.draw.rect(target.screen, (0, 0, 0), (380, 505, 25, 25), 2)
            
        target.draw_hudbuttons(5)
        target.screen.blit(self.factory_ico, target.hud.all_coords[0])
        target.screen.blit(self.generator_ico, target.hud.all_coords[1])
        target.screen.blit(self.medbay_ico, target.hud.all_coords[2])
        target.screen.blit(self.outpost_ico, target.hud.all_coords[3])
        target.screen.blit(self.stockpile_ico, target.hud.all_coords[4])
        
    def detectact(self, target, curpos):
        ''' `buttons` contains button coords and building instructions '''
        button = [((646, 456), (6000, 1)), ((696, 456), (5000, 2)), ((746, 456), (5000, 3)), ((646, 506), (5000, 4)), ((696, 506), (5000, 5)),]
        for build_button in button:
            if curpos.get_distance(vec2d(*build_button[0])) <= 15:
                target.startbuild(*build_button[1]) 
       
    def colider (self, odrone, targ):
        dist = self.pos.get_distance(odrone.pos)
        if dist < 56:
            overlap = 56 - dist
            ndir = odrone.pos - self.pos
            ndir.length = overlap
            if self.task == 2 and odrone.power < 1:
                self.inventory[0][1] -= 1
                odrone.power = 150
                self.task = 0    
            if self == targ.selected:
                odrone.pos = odrone.pos + ndir
            elif odrone == targ.selected:
                self.pos = self.pos - ndir
            else:
                ndir.length =  ndir.length / 2
                odrone.pos = odrone.pos + ndir
                self.pos = self.pos - ndir
                
    def droneaction(self, target, pos):
        def helpdrone(target, pos):
            for drone in target.drones:
                if drone.pos.get_distance(vec2d(pos[0] + target.hud.pos[0], pos[1] + target.hud.pos[1])) < 20 and drone.power < 1:
                    if drone is not target.selected:
                        target.selected.target.append(target.buildings[0].pos)
                        target.selected.task = 2
                        target.selected.target.append(vec2d(int(drone.pos[0]), int(drone.pos[1])))
                        print("Going to charge another drone!")
                        return 1
            return 0
        
        def visitbuilding(target, pos):
            for building in target.buildings:
                if building.pos.get_distance(vec2d(pos[0] + target.hud.pos[0], pos[1] + target.hud.pos[1])) < building.size:
                    target.selected.target.append(building.pos)
                    return 1
            return 0
            
        def builddata(target, pos):
            if target.hud.build_mode == 1:
                permit = True
#.........这里部分代码省略.........
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:103,代码来源:drone.py

示例6: MainBase

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import setup [as 别名]
class MainBase(Building):
    def __init__(self):
        self.size = 140
        self.storepic = pygame.image.load("sprites/main_store.png")
        self.image = Animation()
        self.image.setup("main")
        self.ico_pic = pygame.image.load("sprites/main_ico.png")
        self.bat_ico = pygame.image.load("sprites/icons/bat_ico.png")
        self.dro_ico = pygame.image.load("sprites/icons/dro_ico.png")
        self.inventory = [["battery", 2], ["iron ore", 500000]]
        self.powergain = 5
        self.target = vec2d(0, 0)
        self.power = 100000
        self.inv = 1000000
        
    def request(self, requester, caller):
        if self.power > 255:
            self.power -= int(255 - requester.power)
            requester.power = 255
        if requester.task == 1:
            self.inventory[1][1] += requester.inventory[1][1]
            requester.inventory[1][1] = 0
            print("Main stock is: ", self.inventory, "Power: ", self.power)
            requester.task = 0
            print("Drone returns to mining duty.")
        elif requester.task == 2:
            if self.inventory[0][1] > 0:
                print("Drone took one battery from store.We have ", self.inventory[0][1]," left!")
                self.inventory[0][1] -= 1
                requester.inventory[0][1] += 1
        requester.target.insert(1, caller.target)
               
    def buy_drone(self):
        if self.inventory[1][1] > 10000:
            self.inventory[1][1] -= 10000
            tempdrone = Drone()
            tempdrone.pos = self.pos
            target = self.pos
            tempdrone.target.append(target)
            print("New drone is waiting for orders!")
            return tempdrone
        else:
            print("You need 10 000 ore to buy this!")
            
    def buy_battery(self):
        if self.inventory[1][1] > 5000:
            self.inventory[1][1] -= 5000
            self.inventory[0][1] += 1
            print("Another battery added to storage!")
        else:
            print("You need 5000 to buy a battery!")
            
    def update (self):
        if self.power < 255000:
            self.power += self.powergain
            
    def draw_hud(self, target):
        target.screen.blit(self.ico_pic, (230, 500))
        target.drawbattery(cap = 1000)       
        target.screen.blit(self.storepic, (381, 501))
        pygame.draw.rect(target.screen, (85, 85, 85), (381, 501, 201, 51 - int(self.inventory[1][1] / (self.inv / 50))))
        pygame.draw.rect(target.screen, (0, 0, 0), (380, 500, 202, 52), 2)  
        target.draw_hudbuttons(2)
        target.screen.blit(self.dro_ico, target.hud.all_coords[0])
        target.screen.blit(self.bat_ico, target.hud.all_coords[1])
            
    def detectact(self, target, curpos):
        if curpos.get_distance(vec2d(646, 456)) <= 15:
            new_drone = self.buy_drone()
            if new_drone: 
                target.drones.append(new_drone)
        if curpos.get_distance(vec2d(696, 456)) <= 15:
            self.buy_battery()
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:75,代码来源:buildings.py

示例7: Whearhouse

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import setup [as 别名]
class Whearhouse(Building):
    def __init__(self):
        self.ico_pic = pygame.image.load("sprites/generator_ico.png")
        self.image = Animation()
        self.image.setup("stockpile")
        self.size = 50    
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:8,代码来源:buildings.py

示例8: Generator

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import setup [as 别名]
class Generator(Building):
    def __init__(self):
        self.ico_pic = pygame.image.load("sprites/generator_ico.png")
        self.image = Animation()
        self.image.setup("generator")
        self.size = 50    
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:8,代码来源:buildings.py


注:本文中的animation.Animation.setup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。