Skip to content

Tairitsu.Portal

Protal to transfer player.

Portal

Classes

Portal

Portal(x, y, GOTO: SceneType)

Bases: pygame.sprite.Sprite

Initializes a Portal object.

PARAMETER DESCRIPTION
x

The x-coordinate of the portal's top-left corner.

TYPE: int

y

The y-coordinate of the portal's top-left corner.

TYPE: int

GOTO

The scene type to which the portal leads.

TYPE: SceneType

Source code in Tairitsu/Portal.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def __init__(self, x, y, GOTO : SceneType):
    """
    Initializes a Portal object.

    Args:
        x (int): The x-coordinate of the portal's top-left corner.
        y (int): The y-coordinate of the portal's top-left corner.
        GOTO (SceneType): The scene type to which the portal leads.
    """
    super().__init__()
    self.image = pygame.image.load(GamePath.portal)
    self.image = pygame.transform.scale(self.image,
                        (PortalSettings.width, 
                         PortalSettings.height))
    self.rect = self.image.get_rect()
    self.rect.topleft = (x, y)
    self.actualRect = self.rect.copy()

    self.directionType = GOTO
Attributes
actualRect instance-attribute
actualRect = self.rect.copy()
directionType instance-attribute
directionType = GOTO
image instance-attribute
image = pygame.transform.scale(self.image, (PortalSettings.width, PortalSettings.height))
rect instance-attribute
rect = self.image.get_rect()
Functions
draw
draw(window, dx=0, dy=0)

Draws the portal on the specified window.

PARAMETER DESCRIPTION
window

The window surface on which to draw the portal.

TYPE: pygame.Surface

dx

The x-offset for drawing the portal. Defaults to 0.

TYPE: int DEFAULT: 0

dy

The y-offset for drawing the portal. Defaults to 0.

TYPE: int DEFAULT: 0

Source code in Tairitsu/Portal.py
28
29
30
31
32
33
34
35
36
37
def draw(self, window, dx=0, dy=0):
    """
    Draws the portal on the specified window.

    Args:
        window (pygame.Surface): The window surface on which to draw the portal.
        dx (int, optional): The x-offset for drawing the portal. Defaults to 0.
        dy (int, optional): The y-offset for drawing the portal. Defaults to 0.
    """
    window.blit(self.image, self.rect)