def draw(self, screen, camera): pos = vfloor(camera.cam(self.pos - np.array((0.0, self.TITLE_OFFSET)))) title_pos = (pos[0] - self.title.get_width() // 2, pos[1] - self.title.get_height() // 2) r = screen.blit(self.title, title_pos) cut = int(self.model.tech * self.ENLIGHTENMENT_STATUS_FULL.width) if self.status_surface: return r.union( screen.blit(self.status_surface, (pos[0] - self.status_surface.get_width() // 2, pos[1] - self.status_surface.get_height() // 2 + self.title.get_height() // 2))) else: status_pos = (pos[0] - self.ENLIGHTENMENT_STATUS_FULL.width // 2, pos[1] + self.STATUS_OFFSET_BELOW_TITLE) screen.blit( self.ui_sheet, status_pos, Rect(self.ENLIGHTENMENT_STATUS_FULL.topleft, (cut, self.ENLIGHTENMENT_STATUS_FULL.height)), ) screen.blit( self.ui_sheet, (status_pos[0] + cut, status_pos[1]), Rect((self.ENLIGHTENMENT_STATUS_EMPTY.left + cut, self.ENLIGHTENMENT_STATUS_EMPTY.top), (self.ENLIGHTENMENT_STATUS_FULL.width - cut, self.ENLIGHTENMENT_STATUS_FULL.height)), ) return r.union(self.ENLIGHTENMENT_STATUS_FULL.move(status_pos))
def draw(self, screen, camera): rotated_sprite = pygame.transform.rotozoom( self.sheet.subsurface(self.rect), self.theta * 180 / np.pi, camera.zoom) pos = vfloor( camera.cam(self.pos) - vfloat(rotated_sprite.get_size()) / 2) return screen.blit(rotated_sprite, pos)
def draw(self, screen, camera): axis = np.array((np.cos(self.angle), np.sin(self.angle))) * camera.zoom pos = camera.cam(self.pos) postfix = "_glow" if self.thrusting else "" rotated_U = pygame.transform.rotozoom(self.sprites["U" + postfix], -self.angle * (180 / np.pi) - 90, camera.zoom) scaled_orb_small = pygame.transform.rotozoom( self.sprites["orb_small" + postfix], 0, camera.zoom) scaled_orb_large = pygame.transform.rotozoom( self.sprites["orb_large" + postfix], 0, camera.zoom) r = screen.blit( scaled_orb_small, vfloor(pos - vfloat(scaled_orb_small.get_size()) / 2 - axis * 28)) r = r.union( screen.blit( scaled_orb_large, vfloor(pos - vfloat(scaled_orb_large.get_size()) / 2 - axis * 3))) return r.union( screen.blit(rotated_U, vfloor(pos - vfloat(rotated_U.get_size()) / 2)))
def draw(self, surface, camera): if not self.visible: return None pos = vfloor(camera.cam(self.pos) + self.offset) empty_sprite = self.empty_sprite full_sprite = self.full_sprite cut = int(self.value * (full_sprite.get_width() - self.early_cut)) full_pos = pos full_rect = Rect((0, 0), (cut, full_sprite.get_height())) empty_pos = (pos[0] + cut, pos[1]) empty_rect = Rect( (cut, 0), (empty_sprite.get_width() - cut, empty_sprite.get_height())) r = surface.blit(full_sprite, full_pos, full_rect) return r.union(surface.blit(empty_sprite, empty_pos, empty_rect))
def draw(self, surface, camera): angle = self.theta * 180 / np.pi scale = camera.zoom * self.scale pos = vfloor(camera.cam(self.pos)) if pos[0] < -self.CANVAS_SIZE[0]//2 or \ pos[0] > surface.get_width()+self.CANVAS_SIZE[0]//2 or \ pos[1] < -self.CANVAS_SIZE[1]//2 or \ pos[1] > surface.get_height()+self.CANVAS_SIZE[1]//2: return None day = pygame.transform.rotozoom(self.day_canvas, angle, scale) night = pygame.transform.rotozoom(self.night_canvas, angle, scale) clouds = pygame.transform.rotozoom(self.clouds, self.cloud_theta * 180 / np.pi, scale) clouds_night = pygame.transform.rotozoom( self.clouds_night, self.cloud_theta * 180 / np.pi, scale) r = self.atmosphere.draw_at(surface, pos, scale, self.parameters[0], self.parameters[1], self.parameters[3]) r = r.union( surface.blit( clouds_night, (pos[0] - clouds.get_width() // 2, pos[1] - clouds.get_height() // 2), pygame.Rect(0, 0, clouds_night.get_width() // 2, clouds_night.get_height()))) r = r.union( surface.blit( clouds, (pos[0], pos[1] - clouds.get_height() // 2), pygame.Rect(clouds.get_width() // 2, 0, night.get_width() // 2, clouds_night.get_height()))) r = r.union( surface.blit( day, (pos[0], pos[1] - night.get_height() // 2), pygame.Rect(day.get_width() // 2, 0, day.get_width() // 2, day.get_height()))) r = r.union( surface.blit( night, (pos[0] - night.get_width() // 2, pos[1] - night.get_height() // 2), pygame.Rect(0, 0, night.get_width() // 2, night.get_height()))) return r.union( surface.blit(camera.scaled_shadow, (pos[0] - camera.scaled_shadow.get_width() // 2, pos[1] - camera.scaled_shadow.get_height() // 2)))
def contains(self, pos): rel_pos = vfloor( self.ui.universe.uncam(vfloat(pos)) - self.pos - self.offset) return self.sprite_contains(rel_pos)