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


Python World.process方法代码示例

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


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

示例1: run

# 需要导入模块: import World [as 别名]
# 或者: from World import process [as 别名]
def run():

    pygame.init()
    settings = Settings()
    screen = pygame.display.set_mode(settings.SCREEN_SIZE, 0, 32)

    world = World()

    w, h = settings.WORLD_SIZE

    camera = Camera(0, 0)

    world.add_camera(camera)

    clock = pygame.time.Clock()

    hero_img = pygame.image.load("pictures\Top_Down_Survivor_2\Top_Down_Survivor/flashlight\idle\survivor-idle_flashlight_0.png").convert_alpha()
    hero = Hero(world, hero_img)
    world.add_entity(hero)

    Move_Left = False
    Move_Right = False
    Move_Down = False
    Move_Up = False

    while True:

        for event in pygame.event.get():
            if event.type == QUIT:
                return
            if event.type == KEYDOWN:
                if event.key == K_UP:
                    Move_Down = True
                    Move_Up = False
                elif event.key == K_LEFT:
                    Move_Right = True
                    Move_Left = False
                elif event.key == K_RIGHT:
                    Move_Left = True
                    Move_Right = False
                elif event.key == K_DOWN:
                    Move_Up = True
                    Move_Down = False

            elif event.type == KEYUP:
                if event.key == K_UP:
                    Move_Down = False
                elif event.key == K_LEFT:
                    Move_Right = False
                elif event.key == K_RIGHT:
                    Move_Left = False
                elif event.key == K_DOWN:
                    Move_Up = False

            #elif event.type == MOUSEMOTION:
                #pos = pygame.mouse.get_pos()
                #hero.rotatewithcursor(pos)

        camera.moveCamera(Move_Left, Move_Right, Move_Up, Move_Down)

        time_passed = clock.tick(30)

        world.process(time_passed)
        world.render(screen)

        pygame.display.update()
开发者ID:jsanyika,项目名称:Bang-Bang-,代码行数:68,代码来源:main.py

示例2: run

# 需要导入模块: import World [as 别名]
# 或者: from World import process [as 别名]

#.........这里部分代码省略.........
                held = 0
                draw = False
                    
            if event.type == KEYDOWN:
                if event.key == K_F2:
                    str1 =  str(datetime.now())
                    str1 = str1.split(".")
                    str2 = str1[0]+str1[1]
                    str2 = str2.split(":")
                    str1 = ""
                    for i in str2:
                        str1+=i
                    pygame.image.save(screen, "Images/Screenshots/SCREENSHOT%s.png"%str1)
                    
            if event.type == VIDEORESIZE:
                Owidth, Oheight = event.size
                    
            
                
        #------------------Keys Below--------------------------------------------------
        pressed_keys = pygame.key.get_pressed()
        if pressed_keys[K_ESCAPE]:  #quits the game
            pygame.quit() 
            exit()
            
        if pressed_keys[K_SPACE]:   #Resets wood
            world.wood = 0
        
        if pressed_keys[K_d]:   #Fast-forward-esk functionability
            world.clock_degree+=5
            
        if pressed_keys[K_l]:   #Test to see what the first entity's state is
            print world.entities[0].brain.active_state, world.degree
            
        #--------------Keys Above----------------------------------------
        #--------------Mouse Below---------------------------------------
        
        if int(pos.x) <= 15:
            pygame.mouse.set_pos((15, pos.y))
            world.background_pos.x+=500*time_passed_seconds
            
        elif int(pos.x) >= Owidth-16:
            pygame.mouse.set_pos((Owidth-16, pos.y))
            world.background_pos.x-=500*time_passed_seconds
            
        if int(pos.y) <= 15:
            pygame.mouse.set_pos((pos.x, 15))
            world.background_pos.y+=500*time_passed_seconds
            
        elif int(pos.y) >= Oheight-16:
            pygame.mouse.set_pos((pos.x, Oheight-16))
            world.background_pos.y-=500*time_passed_seconds
            
        if pygame.mouse.get_pressed()[0]:
            if pos.x > clip.minimap_rect.x and pos.y > clip.minimap_rect.y:
                world.background_pos.x = (-1*(pos.x-clip.minimap_rect.x)*clip.a)+(clip.rect_view_w*clip.a)/2
                world.background_pos.y = (-1*(pos.y-clip.minimap_rect.y)*clip.b)+(clip.rect_view_h*clip.b)/2
            

            
        #--------------Mouse Above---------------------------------------
        #--------------Process below-------------------------------------
        
        world.process(time_passed_seconds)
        
        if selected_building == "House":
            selected_img = placing_house_img
        elif selected_building == "LumberYard":
            selected_img = placing_lumberyard_img
        elif selected_building == "Dock":
            selected_img = placing_dock_img
        elif selected_building == "Manor":
            selected_img = placing_manor_img
        
        #--------------Process above-------------------------------------
        #--------------Render Below------------------------
        
        screen.fill((0,0,0))
        clip.render(screen, time_passed_seconds, pos)
        
        all_sprites.clear(screen, world.background)
        all_sprites.update()
        all_sprites.draw(screen)
        
        if fade.trans_value == 0:
            all_sprites.remove(fade)

        if selected_building!=None:
            if ( pos.x > clip.minimap_rect.x and pos.y > clip.minimap_rect.y ) or ( pos.x < clip.side.w + 32 ):
                pass
            else:
                if not world.test_buildable(selected_building, pos):
                    selected_img = bad_lumberyard_img
                blit_pos = world.get_tile_pos(pos-world.background_pos)*32
                screen.blit(selected_img, ((blit_pos.x-(selected_img.get_width()-32))+world.background_pos.x, (blit_pos.y-(selected_img.get_height()-32))+world.background_pos.y))
        
        #--------------Render Above------------------------

        
        pygame.display.flip()
开发者ID:wazzup771,项目名称:AICivGame,代码行数:104,代码来源:NewVillagerSim.py


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