• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python map.Map类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: endCapture

    def endCapture(self):
        if (self.mBrushBehavior != BrushBehavior.Capture):
            return
        self.mBrushBehavior = BrushBehavior.Free
        tileLayer = self.currentTileLayer()
        # Intersect with the layer and translate to layer coordinates
        captured = self.capturedArea()
        captured &= QRect(tileLayer.x(), tileLayer.y(),
                          tileLayer.width(), tileLayer.height())
        if (captured.isValid()):
            captured.translate(-tileLayer.x(), -tileLayer.y())
            map = tileLayer.map()
            capture = tileLayer.copy(captured)
            
            stamp = Map(map.orientation(),
                             capture.width(),
                             capture.height(),
                             map.tileWidth(),
                             map.tileHeight())
            # Add tileset references to map
            for tileset in capture.usedTilesets():
                stamp.addTileset(tileset)

            stamp.addLayer(capture)

            self.stampCaptured.emit(TileStamp(stamp))
        else:
            self.updatePreview()
开发者ID:theall,项目名称:Python-Tiled,代码行数:28,代码来源:stampbrush.py


示例2: testParticleFilter

def testParticleFilter():
    print 'Testing the ParticleFilter class ...'

    # Read map
    map = Map()
    map.readMap('../data/map/wean.dat')

    # basic tests
    filter = ParticleFilter()
    filter.initParticles(map)

    X = [Particle(0,0,0, 0.1), Particle(0,0,0, 0.1), Particle(0,0,0, 0.1)]
  
    print 'X after resampling', filter._resample(X)

    # test for update function
    pos = filter._update((5.0, 6.0, 0.0), (1, 2, 0.0), (2, 2, 0.0))
    print pos # this should print something close to (6, 6, 0)

    '''
    ind = weighted_choice([0.4, 0, 0])
    if ind != 0:
        print 'FAILED weighted_choice test.'

    ind = weighted_choice([0.4, .6, 0.2])
    print 'ind = ', ind
    '''

    return
开发者ID:ehuang3,项目名称:pf,代码行数:29,代码来源:particleFilter.py


示例3: build

	def build(self):
		#create window
		root = Widget()
		root.size = Window.size
		root.center = Window.center

		#create map
		Map.tileSet = TileFactory
		board = Map(size=(504,504))
		root.add_widget(board.getDisplayRoot())

		#add starting tile
		tile_fact = TileFactory()
		for i in range(1):
			btn = tile_fact.newTile(board)
			board.addPiece(btn,(i*126,i*126))

		#create players
		CurrentTile.map = board
		CurrentTile.tile_size = TileFactory.size

		playerTile = CurrentTile()
	
		newTile = tile_fact.newTile(board)
		root.add_widget(playerTile)

		playerTile.resetTile(newTile)

		return root
开发者ID:ianhook,项目名称:Carcassonne,代码行数:29,代码来源:carcassonne.py


示例4: Game

class Game(object):

    def __init__(self):
        pygame.init()
        self.window = pygame.display.set_mode((640, 480))
        self.player = Player(x=100, y=100, width=640, height=480)
        self.plupp = Plupp(window_width=640, window_height=480)
        self.clock = pygame.time.Clock()
        self.map = Map()

        while True:
            CollisionHandler.handle_plupp_collisions(player=self.player, plupp=self.plupp)
            CollisionHandler.handle_player_collisions(player=self.player, map=self.map)

            EventHandler.handle_events(player=self.player, plupp=self.plupp)
            self.clock.tick(15)
            self.update()
            self.draw()

    def update(self):
        self.player.update()

    def draw(self):
        self.window.fill((0, 0, 255))
        self.player.draw(self.window)
        self.plupp.draw(self.window)
        self.map.draw(self.window)
        pygame.display.flip()
开发者ID:itggot,项目名称:Nibbles,代码行数:28,代码来源:nibbles.py


示例5: __init__

class GameState:
    def __init__(self):
        self.controller = Controller(self)
        
        self.side = PlayerSide(self)
        self.map = Map(self)
        self.gui = GameStateGUI(self)
    
    def handleEvents(self,events):
        self.controller.handleEvents(events)
    
    def tick(self):
        self.map.tick()
        self.side.tick()
    
    def blit(self,screen):
        screen.fill((0,0,0))
        self.map.blit(screen)
        self.side.blit(screen)
        
        self.gui.blit(screen)
        
        if self.controller.action[0] == PLACEOBJECT:
            screen.blit(R.IMAGES[R.buildings[self.controller.action[1]]["image"]],(pygame.mouse.get_pos()[0]/20*20+self.map.offset[0]%20,
                                                                                   pygame.mouse.get_pos()[1]/20*20+self.map.offset[1]%20))
开发者ID:unnheulu,项目名称:Luna-Pyweek,代码行数:25,代码来源:gamestate.py


示例6: test

def test():
    the_map = Map()
    tic = time.clock()
    the_map.discretize_map()
    print time.clock() - tic
    #obstacle = Polygon([(40,15), (45,15), (45,20), (40,20)], safety_region_length=4.0)
    #the_map.add_obstacles([obstacle])

    tend = 10
    dT = 1
    h  = 0.05
    N  = int(tend/h)  + 1
    N2 = int(tend/dT) + 1

    x0 = np.array([10, 10, 0.0, 3.0, 0, 0])
    xg = np.array([50, 50, 0])

    myDynWnd = DynamicWindow(dT, N2)

    v = Vessel(x0, xg, h, dT, N, [myDynWnd], is_main_vessel=True, vesseltype='viknes')
    v.current_goal = np.array([50, 50])

    world = World([v], the_map)

    myDynWnd.the_world = world
    
    world.update_world(0,0)

    fig = plt.figure()
    ax  = fig.add_subplot(111, aspect='equal', autoscale_on=False,
                          xlim=(-10, 160), ylim=(-10, 160))
    
    world.visualize(ax, 0, 0)
    
    plt.show()
开发者ID:thomsten,项目名称:project-thesis-simulator,代码行数:35,代码来源:ctrl_DWA.py


示例7: test_all_trips_3

 def test_all_trips_3(self):
     map = Map(1, 2, 3)
     map.append(1, 3, 1)
     map.append(3, 1, 1)
     accept_func = lambda step, distance: True
     trim_func   = lambda step, distance: step > 5
     self.assertEqual(map.all_trips(1, 3, accept_func, trim_func), 3)
开发者ID:dmitryv,项目名称:trains,代码行数:7,代码来源:test.py


示例8: update_pos_by_dist_and_dir

    def update_pos_by_dist_and_dir(self, distance, direction):
        """
        params:
        distance - distance went through
        direction - angles relative to the west (clockwise)
        """
        dirRelativeNorth = Map.get_direction_relative_north(self.building, self.level, direction)
        northAt = Map.get_north_at(self.building, self.level)
        userDir = dirRelativeNorth + northAt  # relative to map
        userDir = userDir % 360
        if not self.nextLoc:
            self.nextLoc = self.get_next_location(self.pos[0], self.pos[1])
        movingDir = Map.get_direction(self.pos[0], self.nextLoc["x"],
                                      self.pos[1], self.nextLoc["y"])  # relative to map
        relativeDir = movingDir - userDir
        # if relativeDir > 0, it's at user's rhs, else lhs
        if relativeDir > 180:
            relativeDir -= 360
        if relativeDir < -180:
            relativeDir += 360
        (x, y, newDir) = Map.get_direction_details(self.building, self.level, distance, direction + relativeDir)

        vec1X = self.pos[0] - float(self.nextLoc["x"])
        vec1Y = self.pos[1] - float(self.nextLoc["y"])
        vec2X = self.pos[0] + x - float(self.nextLoc["x"])
        vec2Y = self.pos[1] + y - float(self.nextLoc["y"])
        isSameDirection = (vec1X * vec2X + vec1Y * vec2Y > 0)
        isReachNextLoc = self.is_reach_node(self.nextLoc, self.pos[0] + x, self.pos[1] + y)
        isWentPass = not isSameDirection and not isReachNextLoc
        if isWentPass:
            self.reachedLoc.append(self.nextLoc["nodeName"])
        self.update_pos(x, y)
开发者ID:kai33,项目名称:NaviCane,代码行数:32,代码来源:navigation.py


示例9: TestMainSimulation

class TestMainSimulation(unittest.TestCase):
    def setUp(self):
        self.map=Map('data/londontubes.txt')
        self.map.initialise_map()
    def test_create_random_target_stations_returns_correct_number(self):
        self.target_stations=main.create_random_target_stations(self.map, 800)
        self.assertEquals(800, len(self.target_stations))
开发者ID:Winterflower,项目名称:london-underground-simulation,代码行数:7,代码来源:test_main.py


示例10: new_map

def new_map():
    map = Map(join(MAIN_PATH, 'templates', 'Seoul_districts.svg'))
    if request.method == 'POST':
        req_dict = json.loads(request.data)
        print(req_dict)
        map.change_color(req_dict)
        return redirect('/map')
开发者ID:outtoin,项目名称:cs408e_http2,代码行数:7,代码来源:http2.py


示例11: get_next_location_details

    def get_next_location_details(self, direction, x, y):
        """
        params:
        current user's direction (relative to north 0~360d), current x & y pos
        return:
        distance to next loc, direction to next loc (relative to user) & next loc's node
        """
        nextLocNode = self.get_next_location(x, y)
        if self.nextLoc and self.nextLoc['nodeName'] in self.reachedLoc:
            self.prevLoc = self.nextLoc
        self.nextLoc = nextLocNode
        dist = Map.get_distance(nextLocNode["x"], x, nextLocNode["y"], y)

        northAt = Map.get_north_at(self.building, self.level)
        userDir = direction + northAt  # relative to map
        userDir = userDir % 360
        movingDir = Map.get_direction(x, nextLocNode["x"],
                                      y, nextLocNode["y"])  # relative to map
        relativeDir = movingDir - userDir
        # if relativeDir > 0, it's at user's rhs, else lhs
        if relativeDir > 180:
            relativeDir -= 360
        if relativeDir < -180:
            relativeDir += 360

        return relativeDir, dist, nextLocNode
开发者ID:kai33,项目名称:NaviCane,代码行数:26,代码来源:navigation.py


示例12: do_upload_from_app

def do_upload_from_app():
  picture = request.forms.get('picture')
  lat = request.forms.get('latitude')
  lng = request.forms.get('longitude')

  raw = decodestring(picture)
  now = datetime.now()
  date_filename = now.strftime("%Y%m%d-%H%M%S") + '.jpg'
  print date_filename
  grid_db = connection['grid_files']
  fs = gridfs.GridFS(grid_db)
  fs.put(raw, filename=date_filename)
  # Insert the filename and other data in the pictures db
  hack_db = connection['hackathon']
  hack_db.pictures.insert_one(
      {'filename': date_filename,
       'datetime': now,
       'latitude': lat,
       'longitude': lng,
       'disaster': 0}
  )
  m = Map(hack_db)
  map_id = m.get_map_id(now, [float(lng), float(lat)])
  hack_db.pictures.update_one({"filename": date_filename}, {"$set": {"disaster": map_id}})
  # Get the image back out
  image = fs.get_last_version(filename=date_filename)
  bottle.response.content_type = 'image/jpeg'
  return image
开发者ID:tash1207,项目名称:DisasterMap,代码行数:28,代码来源:server.py


示例13: enter

def enter():
    global timer, player, map, Player_missile, FirstEnemys, SecondEnemys, enemy_missile, enemy_explosion, bomb, bomb_explosion, item, boss, boss_missile
    global angle, ui
    global score
    score = Score()
    timer = Timer()
    player = Player()
    player.kind = 2
    map = Map()
    map.kind = 2

    ui = UI()
    bomb = []
    FirstEnemys = []
    SecondEnemys = []
    Player_missile = []
    enemy_missile = []
    enemy_explosion = []
    bomb_explosion = []
    item = []
    boss = []
    boss_missile = [Boss_missile(10,10 ) for i in range(72)]
    for member in boss_missile:
        angle += 10
        if angle >360 :
            member.y +=400
        member.angle = angle
开发者ID:yeodo,项目名称:yeodohyun,代码行数:27,代码来源:player2_main_state.py


示例14: __init__

class Game:
    def __init__(self, config_filename):
        data = json.load(open(config_filename, 'r'))

        # init map
        self.map = Map(data)

        # init player
        self.player = Player(data['player'])

    def get_current_location_name(self):
        return self.map.get_current_location_name()

    def get_action(self):
        return self.get_action_dic().keys()

    def get_action_dic(self):
        return self.map.get_current_action()

    def play_action(self, action):
        action_dic = self.get_action_dic()
        action_dic[action](self.player)

    def get_player(self):
        return self.player

    def get_status(self):
        status = self.player.get_status()
        status['current_location'] = self.get_current_location_name()
        return status
开发者ID:chaiso-krit,项目名称:reinforcement_learning,代码行数:30,代码来源:game.py


示例15: read

 def read(self, fileName):
     uncompressed = QByteArray()
     # Read data
     f = QFile(fileName)
     if (f.open(QIODevice.ReadOnly)) :
         compressed = f.readAll()
         f.close()
         uncompressed, length = decompress(compressed, 48 * 48)
     
     # Check the data
     if (uncompressed.count() != 48 * 48) :
         self.mError = self.tr("This is not a valid Droidcraft map file!")
         return None
     
     uncompressed = uncompressed.data()
     # Build 48 x 48 map
     # Create a Map -> Create a Tileset -> Add Tileset to map
     # -> Create a TileLayer -> Fill layer -> Add TileLayer to Map
     map = Map(Map.Orientation.Orthogonal, 48, 48, 32, 32)
     mapTileset = Tileset.create("tileset", 32, 32)
     mapTileset.loadFromImage(QImage(":/tileset.png"), "tileset.png")
     map.addTileset(mapTileset)
     # Fill layer
     mapLayer =  TileLayer("map", 0, 0, 48, 48)
     # Load
     for i in range(0, 48 * 48):
         tileFile = int(uncompressed[i])&0xff
         y = int(i / 48)
         x = i - (48 * y)
         tile = mapTileset.tileAt(tileFile)
         mapLayer.setCell(x, y, Cell(tile))
     
     map.addLayer(mapLayer)
     return map
开发者ID:theall,项目名称:Python-Tiled,代码行数:34,代码来源:droidcraftplugin.py


示例16: load_binary

def load_binary(sender, instance, **kwargs):
    if not instance.stage_data:
        file = instance.stage_file
        print instance._get_upload_path(file.name)
        map = Map(file.read(), True)
        instance.title = map.get_name()
        instance.stage_data = map.dump_to_json()
        print instance.stage_data
开发者ID:giginet,项目名称:LeDA,代码行数:8,代码来源:models.py


示例17: test_existing_map

	def test_existing_map(self):
		db = MongoClient().geo_example
		db.drop_collection('disasters')
		db.disasters.create_index([("loc", GEOSPHERE)])
		result = db.disasters.insert_many([{"loc": { 'type': "Point", 'coordinates': [ -73, 40 ] }, "name": "blah1.44", "start_datetime": datetime.now()}])		
		print result.inserted_ids
		m = Map(db)
		m.get_map_id(datetime.now(), [0, 0])
开发者ID:tash1207,项目名称:DisasterMap,代码行数:8,代码来源:map_test.py


示例18: __init__

class PyAction:
    def __init__(self, type=1):
        pygame.init()
        screen = pygame.display.set_mode(SCR_RECT.size)
        pygame.display.set_caption("ROCKMAN WORLD 5")
        
        # load images
        Block.images = split_image(load_image("plute_map.png"), 16, 16, 16)
        Block.image = Block.images[0] #初期化

        # music
#        pygame.mixer.music.load("data/mars.nsf")
#        pygame.mixer.music.play(-1) 
        
        # loading map
        self.map = Map("data/plute.map")
        
        # main loop
        clock = pygame.time.Clock()
        while True:
            clock.tick(60)
            self.update()
            self.draw(screen)
            pygame.display.update()
            self.key_handler()

    def update(self):
        self.map.update()
    
    def draw(self, screen):
        self.map.draw()
        
        # draw part of map by offset
        offsetx, offsety = self.map.calc_offset()
        
        # 端ではスクロールしない
        if offsetx < 0:
            offsetx = 0
        elif offsetx > self.map.width - SCR_RECT.width:
            offsetx = self.map.width - SCR_RECT.width
        
        if offsety < 0:
            offsety = 0
        elif offsety > self.map.height - SCR_RECT.height:
            offsety = self.map.height - SCR_RECT.height
        
        # マップの一部を画面に描画
        screen.blit(self.map.surface, (0,0), (offsetx, offsety, SCR_RECT.width, SCR_RECT.height))
    
    def key_handler(self):
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                pygame.quit()
                sys.exit()
开发者ID:flameDH,项目名称:Megaman-World-5-in-FC,代码行数:57,代码来源:rockmanwld5.py


示例19: enter

def enter():
    global map,pica,enemy1,dino
    open_canvas(800,400)
    game_framework.reset_time()
    map = Map()
    pica = Pica()
    map.set_center_object(pica)
    pica.set_background(map)
    enemy1 = Enemy()
开发者ID:poket1121,项目名称:2dGam,代码行数:9,代码来源:main_state.py


示例20: WorldScreen

class WorldScreen(Screen):
    """The main game screen with a world to wander around."""

    def __init__(self, map_name):
        Screen.__init__(self)
        self.load_screen = LoadScreen()
        self.load_screen.draw()
        self.camera = pygame.Rect((0,0), CAMERA_SIZE)
        self.map = Map(map_name)
        self.party = PartyManager(self)
        self.npcs = NPCManager(self)
        self.gui = StatsWindow(self.party.sprites)
        self.party.add("hero")
        self.npcs.add("npc")
        self.dialog_text = "Sample dialog text."
        self.map.scroll(self.camera, self.party.chars['hero'])

    def add_sprites(self):
        self.chars = pygame.sprite.Group([
            self.party.sprites ])
        self.all_sprites = pygame.sprite.OrderedUpdates([
            self.map.layers['terrain'],
            self.chars,
            self.map.layers['foreground'],
            self.gui ])

        self.layers = pygame.sprite.LayeredDirty()
        for sprite in self.all_sprites:
            self.layers.add(sprite)
        # critical line to make the npc appear!
        # only took 50 mins to find this!    
        self.layers.add(self.npcs.sprites)

    def draw(self):
        """Draws the sprites to the screen and updates the window."""

        self.layers.update()
        rects = self.layers.draw(self.window)
        pygame.display.update(rects)

        if random.random() < 0.01:
            sounds.sounds.FEAR.play()            

        if random.random() < 0.003:
            sounds.sounds.BABY.play()            


    def destroy(self):
        """Destroy the current screen."""

        for sprite in self.all_sprites:
            sprite.kill()

        self.map = None
        self.party = None
        self.gui = None
开发者ID:tomviner,项目名称:crawlr,代码行数:56,代码来源:screens.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mapbox_vector_tile.decode函数代码示例发布时间:2022-05-27
下一篇:
Python functions.mainWindow函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap