def __init__(self,fname=None,**kw): super(EditorWindow,self).__init__(**kw) self.level = None if fname: self.level = levelfile.load_level(fname) else: fname = "untitled.lev" self.fname = fname if not self.level: self.level = levelfile.Level() if options.name: self.level.name = options.name self.set_caption("{0} - {1}".format(fname,self.level.name)) if options.story: with open(options.story,"ru") as f: self.level.story = f.read().split("\n\n") if options.sound: self.level.sound = options.sound if options.music: self.level.music = options.music if options.no_music: self.level.music = "No Music" self.cellcode = "#" self.rgba = [1,1,1,1] stylesheet.load(monsters.MonsterStyles) stylesheet.load(graphics.BallStyles) self.get_monster_list() self.get_balls_list() self.build_parts()
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 find_level(self,levelnum): fname = "level{0:02}.lev".format(levelnum) return levelfile.load_level(fname)