本文整理汇总了Python中monster.Monster.update方法的典型用法代码示例。如果您正苦于以下问题:Python Monster.update方法的具体用法?Python Monster.update怎么用?Python Monster.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monster.Monster
的用法示例。
在下文中一共展示了Monster.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: and
# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import update [as 别名]
last_time = time.time()*1000
elif event.type == pygame.KEYDOWN:
#print(event.key)
key_monitor.key_down(event)
elif event.type == pygame.KEYUP:
key_monitor.key_up(event)
# Game loop
if game.started() and (time.time()*1000.0)-last_time > FRAME_TIME:
last_time = time.time()*1000.0
game.tick()
key_monitor.tick()
witch.update()
zombie.update()
monster.update()
skeleton.update()
witch.move(SPEED)
zombie.move(SPEED)
monster.move(SPEED)
skeleton.move(SPEED)
screen.fill(black)
game.check_piece([witch,zombie,monster,skeleton], key_monitor)
game.draw_background(screen)
screen.blit(witch.get_image(), witch.get_rect())
screen.blit(zombie.get_image(), zombie.get_rect())
示例2: Necro
# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import update [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()
#.........这里部分代码省略.........