Skip to content

Tairitsu.Attributes

Attributes of the game.

Attributes

Classes

Collidable

Collidable()

A class representing a collidable object.

ATTRIBUTE DESCRIPTION
collidingWith

A dictionary indicating whether the object is colliding with different types of objects.

TYPE: dict

collidingObject

A dictionary storing the colliding object for each type of collision.

TYPE: dict

Examples:

>>> collidable = Collidable()
>>> collidable.collidingWith["obstacle"] # The object is not colliding with any obstacle.
False
>>> collidable.collidingWith["obstacle"] = True # The object is colliding with an obstacle.
>>> collidable.collidingObject["npc"] # The object is not colliding with any npc.
None
>>> collidable.is_colliding() # Check if the object is colliding with any other object.
True
Source code in Tairitsu/Attributes.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def __init__(self):
    self.collidingWith = {
        "obstacle": False, 
        "npc": False, 
        "monster": False, 
        "portal": False, 
        "boss": False, 
    }
    self.collidingObject = {
        "obstacle": [], 
        "npc": None, 
        "monster": None, 
        "portal": None, 
        "boss": None, 
    }
Attributes
collidingObject instance-attribute
collidingObject = {'obstacle': [], 'npc': None, 'monster': None, 'portal': None, 'boss': None}
collidingWith instance-attribute
collidingWith = {'obstacle': False, 'npc': False, 'monster': False, 'portal': False, 'boss': False}
Functions
is_colliding
is_colliding()

Check if the object is colliding with any other object.

RETURNS DESCRIPTION
bool

True if the object is colliding, False otherwise.

Source code in Tairitsu/Attributes.py
38
39
40
41
42
43
44
45
46
47
48
49
def is_colliding(self):
    """
    Check if the object is colliding with any other object.

    Returns:
        bool: True if the object is colliding, False otherwise.
    """
    return (self.collidingWith["obstacle"] or 
            self.collidingWith["npc"] or 
            self.collidingWith["monster"] or
            self.collidingWith["portal"] or 
            self.collidingWith["boss"])

Exchange