def project_cursor(self): if (not sge.game.grab_input and self.visible and self.sprite is not None): img = s_get_image(self.sprite, self.image_index, self.image_xscale, self.image_yscale, self.image_rotation, self.image_alpha, self.image_blend) x = sge.mouse.get_x() y = sge.mouse.get_y() if x is not None and y is not None: x -= self.image_origin_x y -= self.image_origin_y r.game_window_projections.append((img, x, y, self.z, None))
def mask_y(self): if self.collision_precise: if self.image_rotation % 180: origin_y = self.image_origin_y i = ("o_mask_y_offset", self, self.sprite, self.image_origin_x, origin_y, self.image_xscale, self.image_yscale, self.image_rotation) offset = r.cache.get(i) if offset is None: height = s_get_image(self.sprite, self.image_index, self.image_xscale, self.image_yscale, self.image_rotation).get_height() normal_height = s_get_image( self.sprite, self.image_index, self.image_xscale, self.image_yscale).get_height() offset = (height - normal_height) / 2 r.cache.add(i, offset) return self.y - (origin_y + offset) else: return self.y - self.image_origin_y else: return self.bbox_top
def mask_x(self): if self.collision_precise: if self.image_rotation % 180: origin_x = self.image_origin_x i = ("o_mask_x_offset", self, self.sprite, origin_x, self.image_origin_y, self.image_xscale, self.image_yscale, self.image_rotation) offset = r.cache.get(i) if offset is None: width = s_get_image(self.sprite, self.image_index, self.image_xscale, self.image_yscale, self.image_rotation).get_width() normal_width = s_get_image(self.sprite, self.image_index, self.image_xscale, self.image_yscale).get_width() offset = (width - normal_width) / 2 r.cache.add(i, offset) return self.x - (origin_x + offset) else: return self.x - self.image_origin_x else: return self.bbox_left
def render(self, text, antialias, color, background=None): w = (self.width + self.hsep) * len(text) h = self.height + self.vsep xscale = (self.width / self.sprite.width if self.sprite.width > 0 else 1) yscale = (self.height / self.sprite.height if self.sprite.height > 0 else 1) surf = pygame.Surface((w, h), pygame.SRCALPHA) surf.fill(pygame.Color(0, 0, 0, 0)) if not isinstance(color, pygame.Color): color = pygame.Color(color) sge_color = sge.Color((color.r, color.g, color.b, color.a)) for i in six.moves.range(len(text)): if text[i] in self.chars: cimg = s_get_image(self.sprite, self.chars[text[i]], xscale=xscale, yscale=yscale, blend=sge_color) surf.blit(cimg, (i * (self.width + self.hsep), 0)) elif text[i].swapcase() in self.chars: cimg = s_get_image(self.sprite, self.chars[text[i].swapcase()], xscale=xscale, yscale=yscale, blend=sge_color) surf.blit(cimg, (i * (self.width + self.hsep), 0)) if background is None: return surf else: rsurf = pygame.Surface((w, h), pygame.SRCALPHA) rsurf.fill(background) rsurf.blit(surf, (0, 0)) return rsurf
def project_sprite(self, sprite, image, x, y, z, blend_mode=None): """ Project a sprite onto the room. Arguments: - ``x`` -- The horizontal location relative to the room to project ``sprite``. - ``y`` -- The vertical location relative to the room to project ``sprite``. - ``z`` -- The Z-axis position of the projection in the room. See the documentation for :meth:`sge.Sprite.draw_sprite` for more information. """ img = s_get_image(sprite, image) x -= sprite.origin_x y -= sprite.origin_y self.rd["projections"].append((img, x, y, z, blend_mode))