예제 #1
0
 def build_parts(self,**kw):
     pn = StoryPanel("the_end", text=self.victory_text)
     ok_btn = panel.LabelPanel(
         "ok", text=" Finally! ",
         geom=dict(pos=(512,100,0)),
         style_classes=['button'])
     ov = OrthoView(
         "ortho", [pn,ok_btn],
         geom=dict(left=0,right=1024,top=768,bottom=0))
     with ov.compile_style():
         glClearColor(0.1,0.6,0.1,0)
         glDisable(GL_LIGHTING)
     self.append(ov)
예제 #2
0
 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)
예제 #3
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)
예제 #4
0
 def build_parts(self,**kw):
     pn = panel.LabelPanel(
         "finalscore", text="Your Score: {0}".format(self.score),
         geom=dict(pos=(512,600,0)))
     ov = OrthoView(
         "ortho", [pn],
         geom=dict(left=0,right=1024,top=768,bottom=0))
     if self.levelnum is None:
         quit_btn = panel.LabelPanel(
             "ok", text=" OK ",
             geom=dict(pos=(512,100,0)),
             style_classes=['button'])
         ov.append(quit_btn)
     else:            
         retry_btn = panel.LabelPanel(
             "retry", text=" Try Again ",
             geom=dict(pos=(412,100,0)),
             style_classes=['button'])
         quit_btn = panel.LabelPanel(
             "ok", text=" Give Up ",
             geom=dict(pos=(712,100,0)),
             style_classes=['button'])
         ov.append(retry_btn)
         ov.append(quit_btn)
     if self.died_of:
         text = ("CORONER'S REPORT\n"
                 "----------------\n"
                 "Cause of death: {0}").format(self.died_of)
         CoD = panel.LabelPanel(
             "coroners_report",
             text=text,
             geom=dict(pos=(512,300,0),
                       text_width=280))
         ov.append(CoD)
     with ov.compile_style():
         glClearColor(0.1,0,0.1,0)
         glDisable(GL_LIGHTING)
     self.append(ov)
예제 #5
0
 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)
예제 #6
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)