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


Python Monster.create方法代码示例

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


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

示例1: Necro

# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import create [as 别名]
class Necro():
    def __init__(self):
        #window setup
        pygame.display.set_caption('Necromonster')
        path = ['rec', 'misc', 'icon.png']
        os.path.sep.join(path)
        pygame.display.set_icon(pygame.image.load(os.path.sep.join(path)))
        #pygame.display.set_icon(pygame.image.load('rec\\misc\\icon.png'))
        self.main_path = os.getcwd()

        # initiate the clock and screen
        self.clock = pygame.time.Clock()
        self.last_tick = pygame.time.get_ticks()
        self.screen_res = [900, 650]
        self.screen = pygame.display.set_mode(self.screen_res, pygame.HWSURFACE, 32)
        self.DEBUG = 1

        #Init custom game classes
        self.Player = Player(self)
        self.Monsters = Monster(self)
        self.ItemHandler = Item(self)
        self.Invent = Invent(self)
        self.HUD = HUD(self)

        # load fonts, create font list
        self.text_list = []
        self.default_font = pygame.font.SysFont(None, 20)

        # get the map that you are on
        self.blit_list = mapLoader.load('home', self)

        self.Monsters.create('goop', [300, 300], 2, 'neutral')

        while 1:
            self.Loop()

    def Loop(self):
        # main game loop
        self.eventLoop()
        if pygame.time.get_ticks() - self.last_tick > 20:
            self.Tick()
            self.Draw()
        pygame.display.update()

    def eventLoop(self):
        # the main event loop, detects keypresses
        for event in pygame.event.get():
            if event.type == QUIT:
                sys.exit()
            elif event.type == KEYDOWN:
                if event.key == K_e:
                    self.Invent.toggleView()
            elif event.type == MOUSEBUTTONDOWN:
                if self.Invent.in_hand:
                    self.Invent.testThrow(pygame.mouse.get_pos())
                if self.Invent.shown:
                    self.Invent.inventClick(pygame.mouse.get_pos())

    def Tick(self):
        # updates to player location and animation frame
        self.keys_pressed = pygame.key.get_pressed()
        self.clock.tick()
        self.Player.update()
        self.Monsters.update()
        self.ItemHandler.update()
        self.Invent.update()
        for index, text in enumerate(self.text_list):
            if text[2] < time():
                self.text_list.pop(index)

        self.last_tick = pygame.time.get_ticks()

    def off(self, coords):
        newx = coords[0] - self.Player.player_r.x + 450
        newy = coords[1] - self.Player.player_r.y + 325
        return [newx, newy]

    def Draw(self):
        #Responsible for calling all functions that draw to the screen
        tile_width = self.tile[1][0]
        tile_height = self.tile[1][1]
        tile_extrax = self.Player.player_r.x % tile_width
        tile_extray = self.Player.player_r.y % tile_height
        y = 0

        for i in xrange(self.screen_res[1] / tile_height + 3):
            for i in xrange(self.screen_res[0] / tile_width + 3):
                self.screen.blit(self.tile[0], [i * tile_width - tile_width - tile_extrax, y - tile_height - tile_extray])
            y += self.tile[1][1]
        for surf in self.blit_list:
            if 'player' in surf:
                self.Player.blitPlayer()
                self.Monsters.blitMonsters()
            else:
                self.screen.blit(surf[0], self.off(surf[1]))
        for text in self.text_list:
            self.screen.blit(text[0], text[1])
        self.ItemHandler.blitItems()
        if self.Invent.shown:
            self.Invent.draw()
#.........这里部分代码省略.........
开发者ID:metulburr,项目名称:Necromonster,代码行数:103,代码来源:Necromonster.py


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