def __init__(self,name='',**kw):
     super(Balrog,self).__init__(name,**kw)
     self.dark = lighting.claim_light()
     lighting.light_colour(self.dark,(-0.1,-0.8,-0.8,1.0))
     x,y,z = self.pos
     lighting.light_position(self.dark,(x,y,1.0,1.0))
     lighting.light_attenuation(self.dark,0.02)
     lighting.light_switch(self.dark,True)
    def build_parts(self):
        view = viewpoint.OrthoView(
            "view",[],
            geom=dict(left=0, right=40, top=40, bottom=0,
                      near=-1.6,
                      vport=(0,0,WIDTH,HEIGHT)),
            style={"ClearColor":(0.2,0.2,0.2,0)})
        self.hexfield = graphics.HexagonField(
            "field",self.level)
        view.append(self.hexfield)
        with view.compile_style():
            glEnable(GL_LIGHTING)
        self.light = lighting.claim_light()
        lighting.light_position(self.light,(10,10,10,0))
        lighting.light_colour(self.light,(1,1,1,1))
        lighting.light_switch(self.light,True)
        lighting.setup()
        tools = viewpoint.OrthoView(
            "tools",[],
            geom=dict(left=0,right=100,top=300,bottom=0,
                      vport=(WIDTH,0,TOOLW,HEIGHT)),
            style={"ClearColor":(0,0,0,0)})

        tools.append(
            ColourBar("red",0,
                      geom=dict(scale=10,pos=(10,10,0))))
        tools.append(
            ColourBar("green",1,
                      geom=dict(scale=10,pos=(25,10,0))))
        tools.append(
            ColourBar("blue",2,
                      geom=dict(scale=10,pos=(40,10,0))))
        tools.append(
            ColourBar("alpha",3,intensity=15,
                      geom=dict(scale=10,pos=(55,10,0))))

        tools.append(
            panel.LabelPanel("cellcode",
                             text=self.cellcode,
                             style={"font_size":10},
                             geom={"pos":(50,250,0)}))
                             
        tools.append(
            MiniBorder("border",bg=self.level.bg,
                       bd=self.level.bd,fg=self.level.fg,
                       geom=dict(scale=40,pos=(10,200,0))))
        self.parts = part.Group("parts",[view,tools])
        for coords,mname in self.level.monsters.items():
            self.add_thing_to_view(coords,monsters,mname)
        for coords,pname in self.level.powerups.items():
            self.add_thing_to_view(coords,graphics,pname)

        self.parts.restyle(True)
 def build_parts(self,**kw):
     level = self.level
     if self.special_ball:
         ammo_name = self.special_ball.__name__
     else:
         ammo_name = None
     border = ScreenBorder(
         "hud",
         title=level.name,
         score=self.score,
         ammo=self.special_ammo,
         ammo_name=ammo_name,
         style=dict(fg=level.fg,bg=level.bg,bd=level.bd))
     ov = OrthoView("frame", [border],
                    _left=0,_right=1024,_bottom=0,_top=768)
     with ov.compile_style():
         glClearColor(0,0,0,0)
         glDisable(GL_LIGHTING)
     if main.options.time:
         ov.append(ClockPart(geom=dict(pos=(50,50,0))))
     if level.story:
         ov.append(StoryPanel("story",level.story[0]))
         self.story_page = 0
     else:
         self.story_page = None
     self.append(ov)
     hf = graphics.HexagonField("hexfield",self.level)
     pu,pv = level.start
     self.player_exit = level.exit
     x,y = graphics.hex_to_world_coords(pu,pv)
     player = Player(name="player",
         geom=dict(pos=(x,y,0),radius=0.49))
     self.player = player
     self.hexfield = hf
     balls = part.Group("balls",[])
     monsters = part.Group("monsters",
                           self.build_monsters(self.level))
     powerups = part.Group("powerups",
                           self.build_powerups(self.level))
     sv = SceneView("scene",[monsters,hf,player,balls,powerups])
     sv.camera.look_at((x,y,1),10)
     sv.camera.look_from_spherical(87,-90,300)
     sv.camera.look_from_spherical(80,-90,50,1000)
     self.camera = sv.camera
     self.camera.step(1)
     with sv.compile_style():
         glEnable(GL_LIGHTING)
     lighting.light_position(self.light,(10,10,10,0))
     lighting.light_colour(self.light,(1,1,1,1))
     lighting.light_switch(self.light,True)
     self.append(sv)
Exemple #4
0
 def build_parts(self, **kw):
     #        menus = OrthoView("menus",[], _vport=(0,0,1024,768))
     #        with menus.compile_style():
     #            glDisable(GL_LIGHTING)
     sv = SceneView("scene", [],
                    _vport=(0.0, 128, 1.0, 1.0),
                    _ClearColor=(0.3, 0.3, 0.3, 1.0),
                    _perspective_angle=30.0)
     hroom = Room("Room", self.room + ".txt")
     outdoors = "outdoors" in hroom.flags
     ppos = hroom.gates.get(self.start, (0, 0, 0))
     sv.append(hroom)
     self.camera = sv.camera
     self.player = Player((ppos[0], ppos[1], 0), ppos[2], 1.2, self.camera)
     with sv.compile_style():
         glEnable(GL_LIGHTING)
     lighting.two_side(True)
     lighting.local_viewer(True)
     lighting.light_position(self.light,
                             (hroom.width / 2, hroom.height / 2, 2, 1))
     lighting.light_colour(self.light, (1, 1, 0.9, 1))
     lighting.light_switch(self.light, True)
     lighting.light_attenuation(self.light, (0, ) if (outdoors) else
                                (0.01, ))
     self.append(sv)
     ov = OrthoView("itembar", [],
                    _vport=(0.0, 0.0, 1.0, 128),
                    _ClearColor=(0.1, 0, 0, 1.0),
                    _left=0,
                    _right=1024,
                    _top=128,
                    _bottom=0)
     speechport = OrthoView("speech", [],
                            _ClearColor=None,
                            _left=0,
                            _right=1024,
                            _top=768,
                            _bottom=0)
     with ov.compile_style():
         glDisable(GL_LIGHTING)
     with speechport.compile_style():
         glDisable(GL_LIGHTING)
     self.append(ov)
     self.append(speechport)
     tpanel = LabelPanel("text",
                         hroom.name,
                         _text_width=1000,
                         _pos=(512, 48, 0))
     ov.append(tpanel)
 def build_parts(self,**kw):
     self.light = lighting.claim_light()
     stylesheet.load(monsters.MonsterStyles)
     stylesheet.load(graphics.BallStyles)
     start_btn = panel.LabelPanel(
         "Start", text=" Start ",
         geom=dict(pos=(512,200,0)),
         style_classes=['button'])
     quit_btn = panel.LabelPanel(
         "Quit", text=" Quit ",
         geom=dict(pos=(512,100,0)),
         style_classes=['button'])
     ov = OrthoView(
         "ortho", [start_btn, quit_btn],
         geom=dict(left=0,right=1024,top=768,bottom=0,far=1000),
         style={"ClearColor":(0,0,0,0)})
     if main.options.time:
         ov.append(ClockPart(geom=dict(pos=(50,50,0))))
     with ov.compile_style():
         glDisable(GL_LIGHTING)
     self.append(ov)
     sv = SceneView("scene")
     self.level = level = levelfile.load_level("title.lev")
     hf = graphics.HexagonField("hexfield",level)
     sv.append(hf)
     for coords, classname in level.monsters.items():
         pos = collision.h_centre(*coords)
         M = getattr(monsters,classname,monsters.Monster)
         m = M(classname, geom=dict(pos=pos,angle=0))
         sv.append(m)
     for coords, classname in level.powerups.items():
         pos = collision.h_centre(*coords)
         M = getattr(graphics,classname,graphics.Ball)
         m = M(classname, geom=dict(pos=pos,angle=0))
         m.duration = float('inf')
         sv.append(m)
     sv.camera.look_at(pos,10)
     sv.camera.look_from_spherical(45,270,70)
     sv.camera.step(1)
     self.camera = sv.camera
     with sv.compile_style():
         glEnable(GL_LIGHTING)
     lighting.light_position(self.light,(10,10,10,0))
     lighting.light_colour(self.light,(1,1,1,1))
     lighting.light_switch(self.light,True)
     self.append(sv)
    def build_parts(self,**kw):
#        menus = OrthoView("menus",[], _vport=(0,0,1024,768))
#        with menus.compile_style():
#            glDisable(GL_LIGHTING)
        sv = SceneView("scene",[],
                       _vport=(0.0, 128, 1.0, 1.0), 
                       _ClearColor=(0.3, 0.3, 0.3, 1.0),
                       _perspective_angle=30.0)
        hroom = Room("Room",self.room+".txt")
        outdoors = "outdoors" in hroom.flags
        ppos = hroom.gates.get(self.start,(0,0,0))
        sv.append(hroom)
        self.camera = sv.camera
        self.player = Player((ppos[0],ppos[1],0),ppos[2], 1.2, self.camera)
        with sv.compile_style():
            glEnable(GL_LIGHTING)
        lighting.two_side(True)
        lighting.local_viewer(True)
        lighting.light_position(self.light,(hroom.width/2, hroom.height/2, 2,1))
        lighting.light_colour(self.light,(1,1,0.9,1))
        lighting.light_switch(self.light,True)
        lighting.light_attenuation(self.light, 
                                   (0,) if (outdoors) else (0.01,))
        self.append(sv)
        ov = OrthoView("itembar", [],
                       _vport=(0.0,0.0,1.0,128),
                       _ClearColor=(0.1, 0, 0, 1.0),
                       _left=0, _right=1024, _top=128, _bottom=0)
        speechport = OrthoView("speech", [],
                               _ClearColor=None,
                               _left=0, _right=1024, _top=768, _bottom=0)
        with ov.compile_style():
            glDisable(GL_LIGHTING)
        with speechport.compile_style():
            glDisable(GL_LIGHTING)
        self.append(ov)
        self.append(speechport)
        tpanel = LabelPanel("text", hroom.name, 
                            _text_width=1000, _pos=(512,48,0))
        ov.append(tpanel)