Пример #1
0
def startEngine(options):
    """Start the main engine"""
    engine = serge.engine.Engine(width=G('screen-width'), height=G('screen-height'), 
        title=G('screen-title'), fullscreen=options.fullscreen)
    serge.blocks.utils.createVirtualLayersForEngine(engine, ['background', 'foreground', 'foam', 'main', 
        'ropes', 'smoke', 'actors', 'trees', 'light', 'ui-back', 'ui-highlight', 'ui', 'overlay'])
    serge.blocks.utils.createWorldsForEngine(engine, ['start-screen', 'name-screen', 
        'main-screen', 'credits-screen', 'help-screen', 'collection-screen'])
    #
    if options.engine_profile:
        engine.profilingOn()
    #
    # The layers which don't move with the camera
    for layer in ('ui', 'ui-back', 'ui-highlight'):
        engine.getRenderer().getLayer(layer).setStatic(True)
    #
    # For the start screen we want to isolate the rope from the cave since they move independently so
    # we create two zones. 
    world = engine.getWorld('start-screen')
    rope_zone = serge.zone.TagIncludeZone(['player', 'rope', 'rope-anchor', 'rope-link'])
    none_rope_zone = serge.zone.TagExcludeZone(['player', 'rope', 'rope-anchor', 'rope-link'])
    rope_zone.active = none_rope_zone.active = True
    rope_zone.physics_stepsize = 1.0
    world.clearZones()
    world.addZone(rope_zone)
    world.addZone(none_rope_zone)
    #
    engine.setCurrentWorldByName('start-screen' if not options.skip else 'main-screen')
    return engine
Пример #2
0
 def clickAddWorld(self, arg):
     """Add a new world"""
     name = 'World %d' % (len(self.view_worlds.model) + 1)
     self.view_worlds.model.append((name, ))
     world = serge.world.World(name)
     zone = serge.zone.Zone()
     zone.setSpatial(0, 0, 20000, 20000)
     zone.active = True
     world.addZone(zone)
     self.engine.addWorld(world)
Пример #3
0
 def clickAddWorld(self, arg):
     """Add a new world"""
     name = 'World %d' % (len(self.view_worlds.model)+1)
     self.view_worlds.model.append((name,))
     world = serge.world.World(name)
     zone = serge.zone.Zone()
     zone.setSpatial(0, 0, 20000, 20000)
     zone.active = True
     world.addZone(zone)
     self.engine.addWorld(world)
Пример #4
0
def createWorldsForEngine(engine, worlds):
    """Add a numer of worlds to the engine
    
    The words parameter is a list of names of the worlds to create.
    Each world is created with a single active zone which is quite
    large.
    
    """
    for name in worlds:
        world = serge.world.World(name)
        zone = serge.zone.Zone()
        zone.active = True
        zone.setSpatial(-2000, -2000, 4000, 4000)
        world.addZone(zone)
        engine.addWorld(world)
Пример #5
0
def createWorldsForEngine(engine, worlds):
    """Add a numer of worlds to the engine
    
    The words parameter is a list of names of the worlds to create.
    Each world is created with a single active zone which is quite
    large.
    
    """
    for name in worlds:
        world = serge.world.World(name)
        zone = serge.zone.Zone()
        zone.active = True
        zone.setSpatial(-2000, -2000, 4000, 4000)
        world.addZone(zone)
        engine.addWorld(world)
Пример #6
0
    def scaleBy(self, factor):
        """Scale the image by a factor"""
        self.zoom *= factor
    
engine = serge.engine.Engine()
renderer = engine.getRenderer()
layer = serge.render.Layer('base', 0)
renderer.addLayer(layer)
camera = renderer.getCamera()
camera.setSpatial(0, 0, 600, 600)

world = serge.world.World('surface')
main = serge.zone.Zone()
main.setSpatial(-6000, -6000, 12000, 12000)
main.active = True
world.addZone(main)

engine.addWorld(world)
engine.setCurrentWorld(world)

gc = [(0, i, 0, i) for i in range(255)] + \
     [(i, 255, 0, 255) for i in range(255)] + \
     [(255, 255, 0, 255-i) for i in range(255)]
     
for i in range(20):
    grass = Plant(gc, random.randint(10, 50), 0.01, 0.001/10.0, 10, 100)
    grass.setSpatial(random.randint(200, 400), random.randint(100, 300), random.randint(1, 5), 20)
    grass.setLayerName('base')
    world.addActor(grass)

#engine.run(60)