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


Python Graphics.create_pyglet_line_batch方法代码示例

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


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

示例1: Simulation

# 需要导入模块: from graphics import Graphics [as 别名]
# 或者: from graphics.Graphics import create_pyglet_line_batch [as 别名]
class Simulation(object):
    """Just a Container for object lists and other global stuff"""
    def __init__(self):

        ''' 
        input the scenario here. make sure the configuration files 
        are in the correct folder! 
        '''
        self.scenario = "default"

        ''' time management '''
        self.start_time = 3600 * 5
        self.current_time = self.start_time + 0
        self.speed = 5
        self.timestring = str(datetime.timedelta(seconds=math.floor(self.current_time)))

        self.debugbatch = pyglet.graphics.Batch()
        
        ''' setup, check and clear resources '''
        self.resources = ResourceSetup(self.scenario)
        self.spatial_db = self.resources.mongo_connection['spatial_db']
        
        ''' 
        import static geodata directly (every other import is done 
        via the appropriate manager classes
        '''
        self.importer = Importer("thesis_db", "thesis", "thesis")
        self.extent = self.importer.set_global_extent("street_network")
        self.roads = self.importer.read_line_layer("street_network")
        self.buildings_footprint = self.importer.read_line_layer("buildings_line")

        ''' create building centroids '''
        self.building_manager = BuildingManager(self, 
            self.importer.read_point_layer(
            "buildings_centroid", attributes=["building_id"]), 
            "config/"+self.scenario+"/building_attributes.json")

        ''' create actor manager '''
        self.actor_manager = ActorManager(self)

        ''' create routable network (coarse routing and between vectors as edge attributes) '''
        self.router = Router(self)
        self.router.create_routable_network_from_line_data(self.roads)
        self.router.create_lane_collsion_data()

        ''' create parking lots via the lot manager. initial config is provided via config json '''
        self.lots = self.importer.read_line_layer("parking_lots", attributes=["lot_permis", "lot_type", "lot_tech"])
        self.lot_manager = LotManager(self, self.lots, 
            "config/"+self.scenario+"/lot_init_fill.json", 
            "config/"+self.scenario+"/actor_attributes.json")

        ''' create spawners from config json file. See config for details'''
        self.spawner = Spawner(self, "config/"+self.scenario+"/actor_spawn.json", 
            "config/"+self.scenario+"/actor_attributes.json", 
            "config/"+self.scenario+"/exit_nodes.json")

        ''' display objects '''
        self.window = pyglet.window.Window(width=1000, height=600)
        self.window.set_location(10, 10)
        self.camera = Camera((200, 500), 50, 0, 1000)
        self.graphics = Graphics()
        self.fps_display = pyglet.clock.ClockDisplay()

        ''' create displayable batches '''
        self.buildings_footprint_batch = self.graphics.create_pyglet_line_batch(
            self.buildings_footprint, (200, 200, 200))
        self.router.create_pyglet_batch_from_network()

        ''' debug options '''
        self.debug_layer = None
        self.click_debug = None
        self.stop = False

        ''' GUI '''
        #self.gui = Frame(Theme('/Users/anresources/gui/'), w=1000, h=600)
        #self.window.push_handlers(self.gui)
        self.current_actor = None

        ''' mouse management '''
        self.mouse = []
 
    def change_speed(self, speed_change):
        if self.speed + speed_change != 0:
            self.speed += speed_change

    def trigger_stop(self):
        self.stop = (not self.stop)
开发者ID:chriserik,项目名称:ipasum,代码行数:89,代码来源:main.py


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