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


Python Population.addCreatureKraken方法代码示例

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


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

示例1: Game

# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import addCreatureKraken [as 别名]
class Game():

    def __init__(self):
        
        self.running = True
        self.clock = pygame.time.Clock()
        
        self.initializeScreen()
        
        self.viewPositionX = 0
        self.viewPositionY = 0
        
        self.terrain = Terrain(40,40)
        self.population = Population(self.terrain)
        self.buildingPopulation = BuildingPopulation(self.terrain)
        self.powers = PowerPopulation()
        
        self.explosionTimer = 0;
        
        
    def initializeScreen(self):
        
        #Initialize Everything
        pygame.init()
        self.screen = pygame.display.set_mode((1024, 768))
        pygame.display.set_caption('Release the Kraken!')
        pygame.mouse.set_visible(1)
    
        #Create The Background
        self.background = pygame.Surface(self.screen.get_size())
        self.background = self.background.convert()
        self.background.fill((250, 250, 250))
        
    def handleInput(self):
            
        kraken = 0    
            
        for event in pygame.event.get():
            if event.type == QUIT:
                self.running = False
                
        self.explosionTimer += TIME_QUANTUM
            
        if(pygame.mouse.get_pressed()[0] and self.explosionTimer > 500):
            self.powers.addPower(Explosion((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30))
            self.explosionTimer = 0
                
        if(pygame.key.get_pressed()[K_k]):
            self.population.addCreatureKraken((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, Kraken((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30), self.terrain)  
            phaser_sound = pygame.mixer.Sound("art/release.ogg")
            channel = phaser_sound.play()    
           
            if kraken < 1:
                pygame.mixer.music.load("sfx/carmina.ogg")
                pygame.mixer.music.play()
                kraken += 1
                
       
        if(pygame.key.get_pressed()[K_q]):
            self.population.addCreature((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, Peasant((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, 0), self.terrain)
        if(pygame.key.get_pressed()[K_w]):
            self.population.addCreature((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, Swordsman((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, 0), self.terrain)
        if(pygame.key.get_pressed()[K_e]):
            self.population.addCreature((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, Archer((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, 0), self.terrain)
        if(pygame.key.get_pressed()[K_r]):
            self.population.addCreature((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, Wizard((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, 0), self.terrain)
       
        if(pygame.key.get_pressed()[K_a]):
            self.population.addCreature((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, Peasant((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, 1), self.terrain)
        if(pygame.key.get_pressed()[K_s]):
            self.population.addCreature((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, Swordsman((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, 1), self.terrain)
        if(pygame.key.get_pressed()[K_d]):
            self.population.addCreature((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, Archer((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, 1), self.terrain)
        if(pygame.key.get_pressed()[K_f]):
            self.population.addCreature((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, Wizard((-self.viewPositionX + pygame.mouse.get_pos()[0])/30, (-self.viewPositionY + pygame.mouse.get_pos()[1])/30, 1), self.terrain)
       
       
        if(pygame.key.get_pressed()[K_UP]):
            self.viewPositionY+=8
        if(pygame.key.get_pressed()[K_DOWN]):
            self.viewPositionY-=8
        if(pygame.key.get_pressed()[K_LEFT]):
            self.viewPositionX+=8
        if(pygame.key.get_pressed()[K_RIGHT]):
            self.viewPositionX-=8

            
        
    def run(self):
            
        time = pygame.time.get_ticks()
        pygame.mixer.music.load("art/rose.ogg")
        pygame.mixer.music.play()
        
        while self.running:
                           
            while(time < pygame.time.get_ticks()):   
                            
                self.handleInput()
                
#.........这里部分代码省略.........
开发者ID:osgcc,项目名称:osgcc4-ReleaseTheKraken,代码行数:103,代码来源:Game.py


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