def draw_message(self): if event.message != self.current_message: self.current_message = event.message self.message_label.text = event.message self.message_label.font_size = event.message_size xa = self.message_label.content_width // 2 + 20 ya = self.message_label.content_height // 2 + 5 gl.glLineWidth(3.0) gl.glPointSize(1.0) draw.set_color(0, 0, 0, 0.8) draw.rect( self.message_label.x - xa, self.message_label.y - ya, self.message_label.x + xa, self.message_label.y + ya ) draw.set_color(0, 0, 0, 1) draw.rect_outline( self.message_label.x - xa, self.message_label.y - ya, self.message_label.x + xa, self.message_label.y + ya ) draw.points( ( self.message_label.x - xa, self.message_label.y - ya, self.message_label.x + xa, self.message_label.y - ya, self.message_label.x + xa, self.message_label.y + ya, self.message_label.x - xa, self.message_label.y + ya, ) ) self.message_label.draw()
def draw(self, dt=0): if self.blackout: draw.set_color(0,0,0,1) draw.rect(0, 0, gamestate.norm_w, gamestate.norm_h) return self.env.behind.blit(0,0,0) with camera.apply_camera(self.camera): if self.main_group: self.main_group.x = self.x_offset self.main_group.y = self.y_offset with pushmatrix(pyglet.gl.glTranslatef, self.x_offset, self.y_offset, 0): self.env.draw() self.shadow.draw() self.batch.draw() self.env.draw_overlay() self.convo.draw() convos_to_remove = set() for c in self.background_convos: c.draw() if not c.active: convos_to_remove.add(c) for c in convos_to_remove: c.delete() self.background_convos.remove(c)
def draw(self, dt=0): if self.blackout: draw.set_color(0, 0, 0, 1) draw.rect(0, 0, gamestate.norm_w, gamestate.norm_h) return self.env.behind.blit(0, 0, 0) with camera.apply_camera(self.camera): if self.main_group: self.main_group.x = self.x_offset self.main_group.y = self.y_offset with pushmatrix(pyglet.gl.glTranslatef, self.x_offset, self.y_offset, 0): self.env.draw() self.shadow.draw() self.batch.draw() self.env.draw_overlay() self.convo.draw() convos_to_remove = set() for c in self.background_convos: c.draw() if not c.active: convos_to_remove.add(c) for c in convos_to_remove: c.delete() self.background_convos.remove(c)
def draw(self): """Draw dialogue box and text""" if self.convo_label: draw.set_color(0,0,0,1) pyglet.graphics.draw(9, pyglet.gl.GL_TRIANGLES,('v2f', self.vertices_fill)) draw.set_color(*map(lambda c:c/255.0, self.text_color)) pyglet.graphics.draw(len(self.vertices_outline)/2, pyglet.gl.GL_LINE_LOOP, ('v2f', self.vertices_outline)) self.convo_label.draw()
def draw_at(self, x, y): draw.set_color(1,1,1,1) for unit in self.units: ix, iy = x-unit.offset[1], y+unit.offset[0] gl.glPushMatrix() gl.glTranslatef(ix,iy,0) gl.glRotatef(unit.local_angle-90,0,0,-1) unit.image.blit(0,0) gl.glPopMatrix()
def draw(self): """Draw dialogue box and text""" if self.convo_label: draw.set_color(0, 0, 0, 1) pyglet.graphics.draw(9, pyglet.gl.GL_TRIANGLES, ('v2f', self.vertices_fill)) draw.set_color(*map(lambda c: c / 255.0, self.text_color)) pyglet.graphics.draw( len(self.vertices_outline) / 2, pyglet.gl.GL_LINE_LOOP, ('v2f', self.vertices_outline)) self.convo_label.draw()
def draw(self): if self.selected: draw.set_color(0, 1, 0, 1) x1, y1 = self.x - 5, self.y + 13 x2 = self.lineto_x + player_position[0] y2 = self.lineto_y + player_position[1] draw.rect_outline( x2 - physics.default_radius * 1.3, y2 - physics.default_radius * 1.3, x2 + physics.default_radius * 1.3, y2 + physics.default_radius * 1.3, ) super(UnitProxyButton, self).draw()
def draw_ai_message(self): if event.ai_message != self.current_ai_message: self.current_ai_message = event.ai_message self.ai_message_label.text = event.ai_message w = self.ai_message_label.content_width mx = self.ai_message_label.x my = self.ai_message_label.y gl.glLineWidth(3.0) gl.glPointSize(1.0) draw.set_color(0, 0, 0, 0.8) draw.rect(mx - 80, 10, mx + w + 10, 100) self.ai_message_label.draw() draw.set_color(1, 1, 1, 1) if event.ai_head != None: event.ai_head.blit(mx - 80, 17)
def draw_level(self): draw.clear(0, 0, 0, 1) draw.set_color(1, 1, 1, 1) level.background_image.blit_tiled(0, 0, 0, level.width, level.height) gl.glLineWidth(3.0) env.batch.draw() particle.draw() if debug_draw: draw.set_color(1, 0, 0, 1) gl.glLineWidth(1.0) for body in physics.body_update_list: if hasattr(body, "draw_collisions"): body.draw_collisions() for unit in physics.unit_update_list: if hasattr(unit, "draw_collisions"): unit.draw_collisions()
def load(self): # Loading currently just consists of reading a list of formations and adding them to # the scene according to their offsets. formation_list = util.load_yaml("levels", self.name)["formations"] # Load each formation. For now, we only care about positioning options. for form, form_options in ((fd.keys()[0], fd.values()[0]) for fd in formation_list): self.load_formation(form, form_options) self.player = player.Player(self, 1) self.actors["player_1"] = self.player.actor if draw_paths: for a in self.actors.itervalues(): if a.path: a.path.instantiate(self.batch, color=[255, 0, 0, 255]) elif draw_player_path: draw.set_color(1, 0, 0, 1) draw.line_loop(list(itertools.chain(*self.player.actor.path)))
def draw_hud(self): if event.message_countdown > 0: self.draw_message() if event.ai_message_countdown > 0: self.draw_ai_message() if event.active_countdown > 0: self.draw_countdown() self.fps_display.draw() if self.fade_countdown > 0: draw.set_color(1, 1, 1, self.fade_countdown / 0.5) draw.rect(0, 0, env.norm_w, env.norm_h) self.fade_countdown -= env.dt if self.fade_countdown < 0: self.fade_countdown = 0 if event.fade_out_countdown != -100 or event.stay_black: draw.set_color(0, 0, 0, min(1, event.fade_out_countdown * 2)) if event.stay_black: draw.set_color(0, 0, 0, 1) draw.rect(0, 0, env.norm_w, env.norm_h)