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


Python Entity._Add_Component方法代码示例

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


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

示例1: Assemble_Text_Box

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import _Add_Component [as 别名]
def Assemble_Text_Box(sEntityName, sEntityType, iDrawPriority, attribDict):
    """This assembles a box with text in it!"""
    entity = Entity(sEntityName, sEntityType, iDrawPriority, {})

    #The first argument represents the ID of the component with respect to its type (multiple components of a single type need to have different IDs.)
    entity._Add_Component(getClass("Box")({'componentID': '0', 'x': attribDict['x'], 'y': attribDict['y'], 'width': attribDict['width'], 'height': attribDict['height']}))
    entity._Add_Component(getClass("Text_Line")({'componentID': "0", 'x': attribDict['x'], 'y': attribDict['y'], 'width': attribDict['width'], 'height': attribDict['height'], 'text': attribDict['text'], 'font': attribDict["Font"]["Asman"]}))

    return entity
开发者ID:WaffleTime,项目名称:TileGame,代码行数:11,代码来源:Assemble_Text_Box.py

示例2: Assemble_Player

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import _Add_Component [as 别名]
def Assemble_Player(sEntityName, sEntityType, iDrawPriority, attribDict):
    entity = Entity(sEntityName, sEntityType, iDrawPriority, {})

    entity._Add_Component(
        getClass("Animated_Sprite")(
            {
                "componentID": "main",
                "FrameWidth": attribDict["FrameWidth"],
                "FrameHeight": attribDict["FrameHeight"],
                "Delay": attribDict["Delay"],
                "WindPos": attribDict["WindPos"],
                "Texture": attribDict["Texture"],
            }
        )
    )

    lWindPos = attribDict["WindPos"].split(",")

    # print lWindPos

    entity._Add_Component(
        getClass("Position")({"componentID": "LastPos", "positionX": lWindPos[0], "positionY": lWindPos[1]})
    )

    entity._Add_Component(
        getClass("Collision_Body")(
            {
                "componentID": "main",
                "dependentComponentID": "STATE_ANIMATIONS:main",
                "static": "UPRIGHT",
                "mass": attribDict["mass"],
                "height": attribDict["FrameHeight"],
                "xOffset": lWindPos[0],
                "yOffset": lWindPos[1],
                "CollisionShape": attribDict["CollisionBody"]["body"],
            }
        )
    )

    """
    entity._Add_Component(getClass("Tile_Collision_Body")({"componentID":"anchor",                          \
                                                           "dependentComponentID":None,                     \
                                                           "width":int(attribDict["FrameWidth"]),                \
                                                           "height":int(attribDict["FrameHeight"]),              \
                                                           "xOffset":int(lWindPos[0]),                           \
                                                           "yOffset":int(lWindPos[1]),                           \
                                                           "friction":0.0,                                  \
                                                           "staticBody":pymunk.Body(pymunk.inf, pymunk.inf)}))
    
    entity._Add_Component(getClass("Collision_Constraint")({"componentID":"anchor",                         \
                                                            "type":"gearJoint",                             \
                                                            "body1":entity._Get_Component("CBODY:main"),    \
                                                            "body2":entity._Get_Component("CTILEBODY:anchor"),  \
                                                            "phase":"0.0",                                    \
                                                            "ratio":"0.0"}))
    """

    return entity
开发者ID:WaffleTime,项目名称:TileGame,代码行数:60,代码来源:Assemble_Player.py

示例3: __init__

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import _Add_Component [as 别名]
    def __init__(self, sName, sType, iDrawPriority, dAttribs):

        Entity.__init__(self, sName, sType, iDrawPriority, {})

        #This takes all of the entities out of the dComponents
        dEntities = dAttribs.pop("entity", {})

        #"These are the entities that are being loaded into the Entity_PQueue"
        #print dEntities

        #This orders the entities so that the ones with the highes t draw
        #   priority will be first in the list (highest priority is 0.)
        self._pqEntities = PQ()

        #This is Pymunk's Space() class basically. But it's in a component.
        #   It will contain the collidable object for Entities.
        Entity._Add_Component( self, getClass("Collision_Space")( {"componentID":"EntityPool",     \
                                                                 "gravity":dAttribs["gravity"].split(",")} ) )

        #This will insert the entities into the PriorityQueue through the proper method.
        for entity in dEntities.values():

            self._Add_Entity(entity)
开发者ID:WaffleTime,项目名称:TileGame,代码行数:25,代码来源:Entity_PQueue.py

示例4: Assemble_Button

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import _Add_Component [as 别名]
def Assemble_Button(sEntityName, sEntityType, iDrawPriority, attribDict):
    """This assembles a box with text in it! And sets up some other
    components that'll store important information we might need later."""
    entity = Entity(sEntityName, sEntityType, iDrawPriority, {})

    entity._Add_Component(getClass("Box")({'componentID': '0', 'x': attribDict['x'], 'y': attribDict['y'], 'width': attribDict['width'], 'height': attribDict['height']}))
    entity._Add_Component(getClass("Text_Line")({'componentID': '0', 'x': attribDict['x'], 'y': attribDict['y'], 'width': attribDict['width'], 'height': attribDict['height'], 'text': attribDict['text'], 'font': attribDict['Font']["Asman"]}))
    entity._Add_Component(getClass("Flag")({'componentID': '0', 'flag': False}))

    return entity
开发者ID:WaffleTime,项目名称:TileGame,代码行数:12,代码来源:Assemble_Button.py

示例5: Assemble_MCData_Storage

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import _Add_Component [as 别名]
def Assemble_MCData_Storage(sEntityName, sEntityType, iDrawPriority, attribDict):
    """This is for storing the Markov Chain data for the maps made in the tile editor.
    This essentially is just temporary storage until the map is fully iterated over. Then
    this data will have to be saved to a number of xml files (one for each tile relation
    that will be compatible.)"""

    #This mostly should store a List of Lists of Lists of Lists. The first depth is the layer
    #   that the target tile exists on. The second depth is the tile relation.
    #   The third depth is the relative tile's tile type (on the GROUND layer.) And
    #   the last depth is the target tile's tile type (on the layer specified by the first depth.)

    #So I'm thinking that some more reasonable numbers may look like 8*6*25*25 (30000.)
    #   Since that number is still much larger than the amount of tiles we have loaded in memory at
    #   more points in time (6912,) that's probably what I'm going to shoot for at the most.
    #Note that those numbers are only for a single layer (which there are three of currently.)
    #   So I'm going to figure out the minimum number of tile types that should be available
    #   for the generation. Then all the rest of the tile types would have to be obtained through
    #   chests or crafting.

    entity = Entity(sEntityName, sEntityType, iDrawPriority, {})

    List = getClass("List")
    Counter = getClass("Counter")
	
    #This will be what stores the Markov Chain data for the map generation.
    #   But after the data is all gathered and converted, it will be saved to
    #   some xml files.
    MCData = List({"componentID":"MCData"})

    for layer in xrange(config.CHUNK_LAYERS):

        tileLayer = List({"componentID":"TileLayer%d"%layer})

        for y in xrange(config.TILE_YRELATION_MIN,config.TILE_YRELATION_MAX+1):
            
            yRelation = List({"componentID":"YRelation%d"%(y)})
            
            for x in xrange(config.TILE_XRELATION_MIN,config.TILE_XRELATION_MAX+1):

                if y == 0 and x == 0:
                    continue
                
                xRelation = List({"componentID":"XRelation%d"%(x)})

                for r in xrange(config.GROUND_TILE_TYPES):

                    relativeTile = List({"componentID":"RelativeTileType%d"%r})

                    if layer == 0:

                        for t in xrange(config.FOREGROUND_TILE_TYPES):

                            relativeTile._Add(Counter({"componentID":"TargetTileType%d"%t}))

                    if layer == 1:

                        for t in xrange(config.GROUND_TILE_TYPES):

                            relativeTile._Add(Counter({"componentID":"TargetTileType%d"%t}))

                    if layer == 2:

                        for t in xrange(config.BACKGROUND_TILE_TYPES):

                            relativeTile._Add(Counter({"componentID":"TargetTileType%d"%t}))

                    xRelation._Add(relativeTile)

                yRelation._Add(xRelation)

            tileLayer._Add(yRelation)

        MCData._Add(tileLayer)

    entity._Add_Component(MCData)

    return entity
开发者ID:WaffleTime,项目名称:TileGame,代码行数:79,代码来源:Assemble_MCData_Storage.py

示例6: Assemble_Chunk_Manager

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import _Add_Component [as 别名]
def Assemble_Chunk_Manager(sEntityName, sEntityType, iDrawPriority, attribDict):
    """This will return an Entity object that contains a list of lists of lists of tiles,
    some world coordinates, the number of chunks in the screen, and all that stuff that is
    needed in order to manager a chunks of tiles (except for the textures, those are already
    taken care of.)"""
    entity = Entity(sEntityName, sEntityType, iDrawPriority, {})

    if attribDict["ChunkDataDir"] == "SavedGame":
        #Notice that the ChunkDataDir is prefixed by the directory that this file is in.
        entity._Add_Component(getClass("Misc")({"componentID":"ChunkDataDir", "storage":os.getcwd()+config.Saved_Game_Directory}))

    elif attribDict["ChunkDataDir"] == "MapEdi":
        #Notice that the ChunkDataDir is prefixed by the directory that this file is in.
        entity._Add_Component(getClass("Misc")({"componentID":"ChunkDataDir", "storage":os.getcwd()+config.Map_Data_Directory}))    

    else:
        #Notice that the ChunkDataDir is prefixed by the directory that this file is in.
        entity._Add_Component(getClass("Misc")({"componentID":"ChunkDataDir", "storage":os.getcwd()+attribDict["ChunkDataDir"]}))

    entity._Add_Component(getClass("Position")({"componentID":"WorldPos", "positionX":attribDict["WorldPos"].split(',')[0], "positionY":attribDict["WorldPos"].split(',')[1]}))
    entity._Add_Component(getClass("Position")({"componentID":"ChunksInWind", "positionX":attribDict["ChunksInWind"].split(",")[0], "positionY":attribDict["ChunksInWind"].split(",")[1]}))
    entity._Add_Component(getClass("Flag")({"componentID":"VisibilityUpdate", "flag":False}))

    entity._Add_Component(getClass("Dictionary")({"componentID":"ChunkDict"}))

    List = getClass("List")

    entity._Add_Component(List({"componentID":"LoadList"}))
    entity._Add_Component(List({"componentID":"RebuildList"}))
    entity._Add_Component(List({"componentID":"UnloadList"}))
    entity._Add_Component(List({"componentID":"FlagList"}))
    entity._Add_Component(getClass("Render_List")({"componentID":"RenderList"}))

    #This is so that new chunks can be given a pointer to the tile atlas' for the tiles' textures.
    entity._Add_Component(getClass("Misc")({"componentID":"TileAtlas", "storage":attribDict["RenderState"].items()}))

    lWorldPos = attribDict["WorldPos"].split(",")

    lChunksInWindow = attribDict["ChunksInWind"].split(",")

    Assemble_Chunk = getClass("Assemble_Chunk")


    #This will strictly assemble the chunks around the outside of the chunks on the screen (the first items in the loadList get loaded last, so we add these first!)
    #This only will loop through the chunks to the left and right of the screen.
    for i in xrange( int(lWorldPos[0])-1, int(lWorldPos[0]) + int(lChunksInWindow[0])+1 ):
        for j in xrange( int(lWorldPos[1])-1, int(lWorldPos[1]) + int(lChunksInWindow[1])+1, int(lChunksInWindow[1])+1 ):

            dChunkData = {"WorldPos":"%d,%d"%(i,j), \
                          "WindowPos":str(i - int(lWorldPos[0]))+","+str(j - int(lWorldPos[1]))}

            #print "(%d,%d) is the chunk being added"

            #Iterating through the dictionary of Texture items within
            #   an element of the attribDict. These textures are
            #   the tileAtlas' and are for the Chunks Mesh component.
            for (attribName, attrib) in attribDict["RenderState"].items():
                
                #This checks to see if the current item is
                #   for the Mesh component.
                if attribName[0:9] == "TileAtlas":
                    #This will add in the Texture objects
                    #   defined by SFMl. This Texture object
                    #   points to a Texture object within
                    #   the AssetManager.
                    dChunkData[attribName] = attrib
                          
                else:
                    print "The TileAtlas' were given an incorrect name within the xml for the Chunk Manager entity."


            entity._Get_Component("DICT:ChunkDict")._Add( "%d,%d"%(i,j),                        \
                                                          Assemble_Chunk( "%s,%s" % (i, j),     \
                                                                          "Chunk",              \
                                                                          iDrawPriority,        \
                                                                          dChunkData ) )

            pChunk = entity._Get_Component("DICT:ChunkDict")._Get("%d,%d"%(i,j))

            #print "(%d,%d) is being added to the loadlist"%(i,j)

            entity._Get_Component("LIST:LoadList")._Add(pChunk)

    #This does the same thing as the previous loop, but with different chunks (above the screen and below the screen.)
    for i in xrange( int(lWorldPos[0])-1, int(lWorldPos[0]) + int(lChunksInWindow[0])+1, int(lChunksInWindow[0])+1 ):
        for j in xrange( int(lWorldPos[1]), int(lWorldPos[1]) + int(lChunksInWindow[1])):

            dChunkData = {"WorldPos":"%d,%d"%(i,j), \
                          "WindowPos":str(i - int(lWorldPos[0]))+","+str(j - int(lWorldPos[1]))}

            #Iterating through the dictionary of Texture items within
            #   an element of the attribDict. These textures are
            #   the tileAtlas' and are for the Chunks Mesh component.
            for (attribName, attrib) in attribDict["RenderState"].items():
                #This checks to see if the current item is
                #   for the Mesh component.
                if attribName[0:9] == "TileAtlas":
                    #This will add in the Texture objects
                    #   defined by SFMl. This Texture object
                    #   points to a Texture object within
#.........这里部分代码省略.........
开发者ID:WaffleTime,项目名称:TileGame,代码行数:103,代码来源:Assemble_Chunk_Manager.py


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