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


Python Map.Map类代码示例

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


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

示例1: testPolylineSerialize

    def testPolylineSerialize(self):
        map = Map()
        map.open(os.path.join(self.testdatadir, "00map.ini"))

        streets = map.getLayerByName("00_Streets")
        streets.open("r")

        cell = streets.getCell(1)

        street = cell.getCellElements()[0]

        expected = getCellElementRawData(streets, 1, 0)


        actual = street.serialize(cell)

        if actual != expected:
            print "Expected:", dump(expected)
            print "Actual:  ", dump(actual)

        outstreet = CellElementPolyline(streets)
        outstreet.deSerialize(cell, actual)

        self.assertEqual(street,outstreet)
        self.assertEqual(len(actual), len(expected))
        self.assertEqual(actual, expected)
开发者ID:codingforfun,项目名称:pymagellan,代码行数:26,代码来源:cell.py

示例2: newTak

def newTak():
	name = getValue(request, "name", None)
	uid = getValue(request, "userid", None)
	lat = getValue(request, "lat", None)
	lng = getValue(request, "lng", None)
	if not ( name and lat and lng and uid):
		return json_response(code=400)
	mapid = getValue(request, "mapid", None)
	map = None
	if uid is not None:
		user = Account.get_by_id(int(uid))
		if user is None:
			return json_response(code=400)
	if mapid is not None:
		map = Map.get_by_id(int(mapid))
	if map is None:
		map = Map(creator=user.name,creatorId=int(uid),name='Untitled',adminIds=[int(uid)])
		key = map.put()
		mapid = key.id()
		account = Account.get_by_id(int(uid))
		account.adminMaps.append(int(mapid))
		account.put()
	tak  = Tak(lng=lng,lat=lat, creator=user.name, name=name,mapId=int(mapid),creatorId=int(uid))
	key = tak.put()
	map.takIds.append(key.integer_id())
	map.put();
	return json_success(tak.Get())
开发者ID:kylepotts,项目名称:droptak-web,代码行数:27,代码来源:app.py

示例3: Game

class Game(object):

    def __init__(self):
        self.TITLE = "TEST (by zeeisl)"
        self.WIDTH = 800
        self.HEIGHT = 600
        
        self.controller = Controller()
        
        # game things
        self.char = Player("res//hero.png")
        self.map = Map()
        
        self.char1 = Character("res//hero.png", 100, 100, 32, 32)
        
    def key_input(self, event):
        self.controller.getButtonStates(event)
        self.char.key_input(event)
    
    def update(self, delta):
        self.map.update()
        self.char.update(self.char1)
        self.char1.update()
    
    def render(self, screen):
        self.map.render(screen)
        self.char.render(screen)
        self.char1.render(screen)
开发者ID:gia2api,项目名称:froscon,代码行数:28,代码来源:Game.py

示例4: main

def main():
    # initialize map
    map = Map()

    player = AIPlayer(map)
    map.setPlayer(player)

    map.mapLoop() # map's main loop event
开发者ID:beekill95,项目名称:unblockme,代码行数:8,代码来源:main.py

示例5: OpenAnt

class OpenAnt(QApplication):
    
    def __init__(self):
        QApplication.__init__(self, sys.argv)
        
        # Set the default background color to a darker grey.
        self.setPalette(QPalette(self.palette().button().color(), QColor(192, 192, 192)))
    
        self.window = MainWindow()
        self.window.show()
        self.window.start()
        self.window.setWindowTitle('OpenAnt')
        
        # Game timer, used in the gameloop FPS calculations.
        self.game_timer = QTime()
        self.game_timer.start()
        
        # Draw map, set view to ground.
        self.map = Map()
        Globals.view = self.map.generateMap()
        self.map.spawnAnts()
        
        # Start the main loop.
        self.gameLoop()
        
    def gameLoop(self):
        TICKS_PER_SECOND = 20
        SKIP_TICKS = 1000 / TICKS_PER_SECOND
        MAX_FRAMESKIP = 5
        
        next_game_tick = self.getTickCount()
        Globals.game_is_running = True
        while Globals.game_is_running:
            loops = 0
            while self.getTickCount() > next_game_tick and loops < MAX_FRAMESKIP:
                self.updateGame()
                next_game_tick += SKIP_TICKS
                loops += 1
            interpolation = float(self.getTickCount() + SKIP_TICKS - next_game_tick) / float(SKIP_TICKS)
            self.updateDisplay(interpolation)

    def updateDisplay(self, interpolation):
       
        #lerp away
        if not 'nolerp' in sys.argv:
            if self.map.yellowAnt.moving:
                self.map.yellowAnt.lerpMoveSimple(interpolation)

        Globals.glwidget.updateGL()
        self.processEvents() # Let Qt process its events.

    def getTickCount(self):
        return self.game_timer.elapsed()

    def updateGame(self):
        self.map.update()
开发者ID:HideTheMess,项目名称:OpenAnt,代码行数:56,代码来源:main.py

示例6: main

def main():
    print ("Main called")
    c1 = Coordinate(0,0,0)
    c2 = Coordinate(10,10,10)
    m = Map()
    print ("begin mapping")
    carl = m.map_1D_space(c1,c2,5)
    print ("endin mapping")
    for index, item in enumerate(carl):
        print (''+str(index)+' '+str(item.coordinate.x)+' '+str(item.coordinate.y)+' '+str(item.coordinate.z))
开发者ID:buckbaskin,项目名称:SpaceWarp,代码行数:10,代码来源:1DTest.py

示例7: testSimple

    def testSimple(self):
        map = Map(MapDirectory(self.testdatadir), maptype=MapTypeImage)
        map.open("r")

        poigroup = map.getPOIGroup()
        poigroup.open("r")

        f = poigroup.getFeatureByIndex(0)
        aux = f.getAuxAsDict(poigroup)
        print f, aux
开发者ID:codingforfun,项目名称:pymagellan,代码行数:10,代码来源:test_poi.py

示例8: api_taks

def api_taks(id=-1):
	if request.method == 'GET':
		map = Map.get_by_id(id)
		if map is None:
			return json_success({})
		else:
			return json_success(map.Get())
	if request.method == 'DELETE':
		map = Map.get_by_id(id)
		if map is None:
			return json_response(code=400, message="Map does not exist")
		map.Delete()
		return json_response(code=200,message="Success")
开发者ID:kylepotts,项目名称:droptak-web,代码行数:13,代码来源:app.py

示例9: testCategories

    def testCategories(self):
        map = Map(MapDirectory(self.testdatadir), maptype=MapTypeImage)
        map.open("a")

        poigroup = map.getPOIGroup()

        poigroup.open("a")

        catman = poigroup.getCategoryManager()

        print catman.getCategories()

        poigroup.close()
开发者ID:codingforfun,项目名称:pymagellan,代码行数:13,代码来源:test_poi.py

示例10: loadMap

    def loadMap(self, filename):        
        with open(filename, "r") as map_file:
            parts = map_file.readline().split(",")
            width = int(parts[0])
            height = int(parts[1])
            
            m = Map(width, height)
            r = 0
            for line in map_file:
                row = [TileTypes()[t] for t in line.strip('\n').split(",")]
                m.set_row(r, row)
                r = r + 1

        return m
开发者ID:DaveTCode,项目名称:MapForgetfulSearch,代码行数:14,代码来源:MapLoader.py

示例11: api_map

def api_map():
	if request.method == 'POST':
		userName = request.args.get("username","")
		mapName = request.args.get("mapname","")
		userId = request.args.get("userId","")
		userId = str(userId.encode('utf-8').decode('ascii', 'ignore'))
		uid = int(userId)
		ownMap =Map(creator=userName,creatorId=uid,name=mapName)
		key = ownMap.put()
		return json_success({"mapId":key.integer_id()}) 

	if request.method == 'GET':
		id = request.args.get("id","")
		ownMap = Map.get_by_id(int(id))
		return json_success({"creator":ownMap.creator,"name":ownMap.name,"creatorId":ownMap.creatorId,"id":int(id)})
开发者ID:kylepotts,项目名称:droptak-web,代码行数:15,代码来源:app.py

示例12: run

    def run(self):
        newMap = None
        if self.fileName:
            try:
                newMap = Map.readFromFile(self.fileName)
            except Exception as e:
                self.mapGenerationFailed.emit(e)
                return
        else:
            try:
                newMap = Map.generateCNN(self.citiesCount, self.connectionsCount)
            except Exception as e:
                self.mapGenerationFailed.emit(e)
                return

        self.mapGenerated.emit(newMap)
开发者ID:akkenoth,项目名称:TSPGen,代码行数:16,代码来源:MapGenerator.py

示例13: __init__

 def __init__(self):
     self.map = Map()
     self.numUnits = 1
     self.numPlayers = 1
     self.playerIndex = -1 
     self.turn = 1
     self.players = []
开发者ID:Temppa,项目名称:Vuoropohjainen-peli,代码行数:7,代码来源:application.py

示例14: favorite_mapsForUser

def favorite_mapsForUser(userid = -1):
	if userid <= 0:
		return json_response(code=400)
	user = Account.get_by_id(userid)
	if user is None:
		return json_response(code=400)

	if request.method == 'GET': # done
		#	GET: returns json array of information about user's map objects
		return json_success(user.getFavorites())

	mapid = getValue(request, "mapid", "")
	if not mapid:
		return json_response(code=400)
	map = Map.get_by_id(int(mapid))
	if map is None:
		return json_response(code=400)
	if request.method == 'POST':
		if not map.key.integer_id() in user.favoriteMaps:
			user.favoriteMaps.append(map.key.integer_id())
			user.put()
		return json_response(code=200)
	
	if request.method == 'DELETE':
		if map.key.integer_id() in user.favoriteMaps:
			user.favoriteMaps.remove(map.key.integer_id())
			user.put()
		return json_response(code=200)
开发者ID:kylepotts,项目名称:droptak-web,代码行数:28,代码来源:app.py

示例15: download_map

 def download_map(self, filename):
     """
     Download a map.
     @param filename Name of the map.
     @return Map object on success, None on error.
     """
     # [0]filename, [1]title, [2]filesize, [3]map_data
     map_data = self.database.do_query(Procedures.get_map(), filename);
     map = Map(self.reporter);
     try:
         if not map.read_map(map_data[0][3]):
             raise Exception, "Unknown corruption error." % filename;
     except Exception, e:
         self.report("Map file %s is corrupted (%s). Discarding." % (filename, str(e)));
         Log.quick_log("The map %s is corrupted: %s." % (filename, str(e)));
         return None;
开发者ID:summer-of-software,项目名称:vtank,代码行数:16,代码来源:Map_Manager.py


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