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 __init__(self, name="", room="Chapter1", start="begin", **kw): self.light = lighting.claim_light() self.room = room self.start = start self.speaking = False self.options = None self.quit_after_fade_out = None super(GameState, self).__init__(name, **kw) story.action_for_object(self, room, "begin")
def __init__(self,name="",room="Chapter1",start="begin",**kw): self.light = lighting.claim_light() self.room = room self.start = start self.speaking = False self.options = None self.quit_after_fade_out = None super(GameState,self).__init__(name,**kw) story.action_for_object(self, room, "begin")
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): 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 __init__(self,name="",level=None,levelnum=1,score=0, ammo=0,special=None, **kw): if not level: level = self.find_level(levelnum) self.level = level self.levelnum = levelnum self.score = score self.light = lighting.claim_light() stylesheet.load(monsters.MonsterStyles) stylesheet.load(graphics.BallStyles) if level.music: self.music = level.music self.special_ammo = ammo self.special_ball = special super(GameScreen,self).__init__(name,**kw) self.set_mode("story" if self.story_page is not None else "playing") Sin60 = collision.Sin60 self.movekeys = { # Gamer keys pygletkey.A: Vec(-1,0), pygletkey.D: Vec(1,0), pygletkey.W: Vec(0,1), pygletkey.S: Vec(0,-1), # Hexagon around J pygletkey.H: Vec(-1,0), pygletkey.U: Vec(-0.5,Sin60), pygletkey.I: Vec(0.5,Sin60), pygletkey.K: Vec(1,0), pygletkey.M: Vec(0.5,-Sin60), pygletkey.N: Vec(-0.5,-Sin60), } self.keysdown = set() self.first_person = False vport = (GLint*4)() glGetIntegerv(GL_VIEWPORT, vport) self.vport = tuple(vport) self.reload = 0 sounds.play(self.level.sound)