Skip to content

Tairitsu.Maps

Generate maps and blocks on a map.

Maps

Classes

Block

Block(image: pygame.Surface, x=0, y=0, width=SceneSettings.tileWidth, height=SceneSettings.tileHeight)

Bases: pygame.sprite.Sprite

A block in the map

PARAMETER DESCRIPTION
image

The image of the block.

TYPE: pygame.Surface

x

The x coordinate of the block.

TYPE: int DEFAULT: 0

y

The y coordinate of the block.

TYPE: int DEFAULT: 0

width

The width of the block.

TYPE: int DEFAULT: SceneSettings.tileWidth

height

The height of the block.

TYPE: int DEFAULT: SceneSettings.tileHeight

Source code in Tairitsu/Maps.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def __init__(self, image: pygame.Surface, x=0, y=0, width=SceneSettings.tileWidth, height=SceneSettings.tileHeight):
    """
    A block in the map

    Args:
        image (pygame.Surface): The image of the block.
        x (int): The x coordinate of the block.
        y (int): The y coordinate of the block.
        width (int): The width of the block.
        height (int): The height of the block.
    """

    super().__init__()
    self.image = pygame.transform.scale(image, (SceneSettings.tileWidth, SceneSettings.tileHeight))
    self.rect = self.image.get_rect()
    self.rect.topleft = (x, y)
    self.actualRect = self.rect.copy()
Attributes
actualRect instance-attribute
actualRect = self.rect.copy()
image instance-attribute
image = pygame.transform.scale(image, (SceneSettings.tileWidth, SceneSettings.tileHeight))
rect instance-attribute
rect = self.image.get_rect()
Functions
draw
draw(window: pygame.surface, dx=0, dy=0)

draw the block on the window

Source code in Tairitsu/Maps.py
27
28
29
30
31
def draw(self, window: pygame.surface, dx=0, dy=0):
    """
    draw the block on the window
    """
    window.blit(self.image, (self.rect.x + dx, self.rect.y + dy))