本文整理汇总了Python中Map.loadMap方法的典型用法代码示例。如果您正苦于以下问题:Python Map.loadMap方法的具体用法?Python Map.loadMap怎么用?Python Map.loadMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.loadMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LoadGame
# 需要导入模块: import Map [as 别名]
# 或者: from Map import loadMap [as 别名]
def LoadGame():
if not reloadGame:
loadHolder = maps.load()
maps.new_blocks = loadHolder[0]
player.rect = loadHolder[1]
objects.all_objects = loadHolder[2]
else:
maps.loadMap()
示例2: main
# 需要导入模块: import Map [as 别名]
# 或者: from Map import loadMap [as 别名]
def main():
gameRunning = True
im = Image.open("graphics/map4.png", "r")
pixels = list(im.getdata())
myMap = Map(Globals.gTileSize)
# create a map from the image
myMap.loadMap(pixels, im.size[0], im.size[1])
graphicsMgr = GraphicsManager(myMap)
myPathfinder = Pathfinder(myMap)
path = None
startCoord = (0, 0)
endCoord = (0, 0)
ninja1 = Entity("ninja", myPathfinder)
ninja2 = Entity("ninja", myPathfinder)
ninja1.setPosition((0, 6))
ninja2.setPosition((5, 0))
ninjas = [ninja1, ninja2]
Globals.gEntities = [ninja1, ninja2]
ninja1.setPath( myPathfinder.findPath( ninja1.getTilePos(), (9, 0) ) )
ninja2.setPath( myPathfinder.findPath( ninja2.getTilePos(), (2, 10) ) )
ninja1.ChangeState(Globals.gStates["MoveAlongPath"])
ninja2.ChangeState(Globals.gStates["MoveAlongPath"])
selectedNinja = ninja1
ninja1.select()
Globals.gDeltaTime = time.clock() - Globals.gDeltaTime
while(gameRunning):
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
mouseTilePos = getTileCoords(event.pos, Globals.gTileSize)
if event.button == 3:
# set end pos
startCoord = selectedNinja.getTilePos()
endCoord = mouseTilePos
path = myPathfinder.findPath(startCoord, endCoord)
if( not path ):
print "no path"
else:
selectedNinja.setPath(path)
selectedNinja.ChangeState(Globals.gStates["MoveAlongPath"])
elif event.button == 1:
print "mouse coord: ", mouseTilePos
# select ninja
for ninja in ninjas:
ninja.unselect()
ninjaPos = ninja.getTilePos()
if ninjaPos[0] == mouseTilePos[0] and ninjaPos[1] == mouseTilePos[1]:
selectedNinja = ninja
ninja.select()
for ninja in ninjas:
ninja.update()
graphicsMgr.render(myMap, path, ninjas)