本文整理汇总了Python中hero.Hero.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Hero.draw方法的具体用法?Python Hero.draw怎么用?Python Hero.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hero.Hero
的用法示例。
在下文中一共展示了Hero.draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import draw [as 别名]
def main():
open_canvas()
global mainback
mainback = Mainback()
global start
start = False
while(start == False):
handle_events()
clear_canvas()
mainback.draw()
update_canvas()
delay(0.08)
#클래스 선언
global hero
hero = Hero()
rabbit = Rabbit()
rabbit_group = [Rabbit() for i in range(600)]
land = Land()
wood = Wood()
global torch
torch = Torch()
global fire
fire = Fire()
eskimo = Eskimo()
attack_fire = Attack_fire()
attack_fire_group = [Attack_fire() for i in range(100)]
background = BackGround()
global ui
ui = Ui()
firewood = Firewood()
firewood_group = [Firewood() for i in range(600)]
#변수 선언
rabbit_group_counter = 0
rabbit_group_collision_counter = 0
attack_group_counter = 0
attack_group_update_counter = 0
attack_group_collision_counter = 0
rabbit_alive_counter = 0
attack_group_alive_check = False
attack_group_alive_counter = 0
attack_group_limit = 20
rabbit_group_draw_counter = 0
firewood_num_counter = 0
firewood_num_update_counter = 0
firewood_collide_counter = 0
rabbit_group_counter2 = 0
rabbit_jump = False
rabbit_num = 10
firewood_num = 10
rack_block = 0
eskimo_counter = 0
global running
running = True
while running:
#핸들 이벤트
handle_events()
#업데이트
hero.update()
background.update()
land.update()
wood.update()
fire.update()
torch.update()
eskimo.update()
ui.update(hero.x, hero.y, hero.ability)
for rabbit in rabbit_group: # 토끼 업데이트
if(rabbit_group_counter == rabbit_num):
rabbit_group_counter = 0
break
if(rabbit.alive):
rabbit.update()
rabbit_group_counter += 1
# for rabbit in rabbit_group: # 토끼 업데이트
# if(rabbit_group_counter2 == 1):
# print("%d" % rabbit.x)
# break
# rabbit_group_counter2 += 1
for attack_fire in attack_fire_group: # 공격불 업데이트
if(attack_group_update_counter == hero.attack_num):
attack_fire.init_direction()
attack_fire.alive = True # 공격불이 활성화 됨
attack_fire.init_fire()
attack_group_update_counter = 0
break
if(attack_fire.alive):
attack_fire.update()
attack_group_update_counter += 1
#.........这里部分代码省略.........
示例2: Level
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import draw [as 别名]
class Level(object):
'''TwistedMold level'''
def __init__(self, screen, father, level, total_points):
self.screen = screen
self.father = father
self.level = level
self.background = utils.load_image(levels[level]['background'])
#parameters
self.energy_leap = levels[level]['energy_leap']
self.mold_density = levels[level]['mold_density']
self.mold_velocity = levels[level]['mold_velocity']
self.max_time = levels[level]['max_time']
#menu control
self.options = [("Yes", self.father),("No", None)]
self.exit = False
#Create the game clock
self.clock = pygame.time.Clock()
self.mm = MoldsManager(self.mold_density, self.mold_velocity)
self.bm = BottleManager(*levels[self.level]['bottle_density'])
self.bm.mm = self.mm
self.total_points = total_points
self.pointsCounter = Points(self.total_points)
self.levelIndicator = LevelIndicator(self.level)
self.mm.level = self
self.tics = 0
self.snow_slim = pygame.sprite.Group()
self.snow_fat = pygame.sprite.Group()
for x in range(75):
sprite = Wheather(1,2)
self.snow_slim.add(sprite)
for x in range(75):
sprite = Wheather(3,5)
self.snow_fat.add(sprite)
self.energy_bar = EnergyBar(self.energy_leap)
self.bm.energy_bar = self.energy_bar
self.mm.energy_bar = self.energy_bar
self.level_time = LevelTime(self.max_time)
self.gadgets = pygame.sprite.RenderUpdates()
self.gadgets.add(self.pointsCounter)
self.gadgets.add(self.energy_bar)
self.gadgets.add(self.level_time)
self.gadgets.add(self.levelIndicator)
self.hero = Hero()
self.bm.hero=self.hero
self.mm.hero=self.hero
self.explotion = Explotion()
self.control_down = -1
self.control_up = -1
self.control_left = -1
self.control_right = -1
self.control_tiempo = 5
self.next_scream = random.randrange(400,500)
#Show level image
Visual(self.screen, [utils.load_image(levels[self.level]['img'])], [2], None).loop()
def loop(self):
music.play_music(PLAYMUSIC)
while not self.finish():
self.tics += 1
if not self.next_scream:
music.play_random_scream()
self.next_scream = random.randrange(400,500)
else:
self.next_scream -= 1
self.screen.blit(self.background, (-(self.tics % 700),0))
self.update()
self.draw()
#Control
for event in pygame.event.get():
self.control(event)
self.clock.tick(CLOCK_TICS)
if self.control_down == 0: self.hero.down()
if self.control_up == 0: self.hero.up()
if self.control_right == 0: self.hero.right()
if self.control_left == 0: self.hero.left()
if self.control_down >= 0:
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import draw [as 别名]
#.........这里部分代码省略.........
if self.core.getState() == 0:
if self.menu_play_button.getState() == 0:
self.menu_exit_log.handle( event )
#HANDLE IF AUTHOR BUTTON == OFF AND SCORE BUTTON == OFF
if self.menu_author_log.getState() == 0 and self.menu_score_log.getState() == 0:
self.menu_play_button.handle( event )
self.menu_git_button.handle( event )
self.menu_google_button.handle( event )
self.menu_music_button.handle( event )
self.menu_chunk_button.handle( event )
if self.menu_score_log.getState() == 0:
self.menu_author_log.handle( event )
if self.menu_author_log.getState() == 0:
self.menu_score_log.handle( event )
#-------------------------------------------------------------------------------------------------------
if self.core.getState() == 1:
self.menu_log.handle( event )
#HANDLE IF MENU_LOG == OFF
if self.menu_log.getState() == 0:
self.hero.handle( event )
#-------------------------------------------------------------------------------------------------------
def states( self ):
#-------------------------------------------------------------------------------------------------------STATE -1
if self.core.getState() == -1:
self.intro.draw( self.core.getWindow() )
if self.intro.getQuit():
self.intro.free()
del self.intro
self.menu_music.play()#MENU MUSIC
self.core.setState( 0 )
#-------------------------------------------------------------------------------------------------------STATE 0
if self.core.getState() == 0:
#FADE IN
if self.menu_play_button.getState() != 1 and self.menu_exit_log.getState() == 0:
self.menu_background.fadein( 5 )
self.menu_title.fadein( 5 )
self.menu_play_button.fadein( 5 )
self.menu_git_button.fadein( 5 )
self.menu_google_button.fadein( 5 )
self.menu_facebook_button.fadein( 5 )
self.menu_twitter_button.fadein( 5 )
self.menu_music_button.fadein( 5 )
self.menu_chunk_button.fadein( 5 )
self.menu_author_log.fadein( 5 )
self.menu_game_log.fadein( 5 )
self.menu_settings_log.fadein( 5 )
self.menu_score_log.fadein( 5 )
self.menu_music.setVolume( 1.0 )
#DRAW ALWAYS IN MENU STATE
self.menu_background.draw( self.core.getWindow() )
self.menu_title.draw( self.core.getWindow() )
self.menu_exit_log.draw( self.core.getWindow() )