Actor

class gamegridp.actor.Actor(grid, location: list = (0, 0), color: tuple = (0, 0, 255), title: str = 'Actor', img_path: str = None, size: tuple = (40, 40), img_action: str = None)[Quellcode]
act()[Quellcode]

The method should be overwritten in subclasses

add_image(img_path: str, img_action: str = None, size=None)[Quellcode]

adds an image to the actor :param img_path: The path of the image relative to the actual path :param img_action: The image action (scale, do_nothing, crop) :param size: scale/crop : Size as 2-Tuple

animate(animation: str = '')[Quellcode]

Starts an animation :param animation: Type of animation (not implemented)

bounding_box(location: tuple = None)[Quellcode]
Rückgabe:The surrounding Rectangle if actor is placed at location
direction

Gets the direction of actor

draw()[Quellcode]

Draws the actor to the grid

flip_x()[Quellcode]

Mirrors image over y-axis. x-Coordinates are flipped. Actor is turned by 180 degrees. is_rotatable should be False.

get_actor_at_location(class_name, location=None) → list[Quellcode]

Get all actors at a specific location

get_actor_in_front(class_name, location=None) → list[Quellcode]

Get all actors at a specific location

get_location() → list[Quellcode]

Returns the location of actor :return: the location as tuple

get_neighbour_cells() → list[Quellcode]
Rückgabetyp:all neighbour cells in a list.
get_x()[Quellcode]
Parameter:x – the x-coordinate
get_y()[Quellcode]
Parameter:y – the y-coordinate
has_image

Checks if actor has an image :return: true if actor has an image, else false

image

Gets the actual image of the actor.

image_next()[Quellcode]

switches to the next image by image_index

image_rect
Rückgabe:The surrounding Rectangle used for redrawing and image manipulation
is_blocking(value: bool = None)[Quellcode]

Checks if actor blocks a field for other actors :type value: true: is blocked, false: is not blocked :return : true if actor blocks a field

is_rotatable

: return true if actor-image is rotatable, else false

is_valid_target(target: tuple = None)[Quellcode]

Checks is a move to a specific target is valid :return true if move is legal, else false

listen(key, data)[Quellcode]

Should be overwritten in child-classes

location

returns the location of object

look_back(distance: int = 1) → tuple[Quellcode]

looks x steps back :param distance : Number of steps to look forward :return location : Location as tuple (x_cell, y_cell)

look_down(distance: int = 1) → tuple[Quellcode]

looks x steps down :param distance : Number of steps to look forward :return location : Location as tuple (x_cell, y_cell)

look_forward(distance: int = 1) → tuple[Quellcode]

looks x steps forward :param distance : Number of steps to look forward :return location : Location as tuple (x_cell, y_cell)

look_left(distance: int = 1) → tuple[Quellcode]

looks x steps left :param distance : Number of steps to look forward :return location : Location as tuple (x_cell, y_cell)

look_right(distance: int = 1) → tuple[Quellcode]

looks x steps right :param distance : Number of steps to look forward :return location : Location as tuple (x_cell, y_cell)

look_up(distance: int = 1) → tuple[Quellcode]

looks x steps up :param distance : Number of steps to look forward :return location : Location as tuple (x_cell, y_cell)

move(distance: int = 1, move: bool = True)[Quellcode]

Moves actor by x steps :param distance : number of steps the actor should step forward.

move_back(distance: int = 1, move: bool = True)[Quellcode]

Moves actor by x steps :param distance : number of steps the actor should step forward.

move_down(distance=1, move: bool = True)[Quellcode]

Moves the actor one step down Sets the direction to 170° (South) :type move: object

move_left(distance=1, move: bool = True)[Quellcode]

Moves the actor one step left Sets the direction to 180° (West)

move_right(distance=1, move: bool = True)[Quellcode]

Moves the actor one step right Sets the direction to 0° (East)

move_up(distance=1, move: bool = True)[Quellcode]

Moves the actor one step down Sets the direction to 170° (South)

next_sprite()[Quellcode]

Loads the next sprite in the current animation

remove()[Quellcode]

removes the actor from grid

set_direction(degrees: int)[Quellcode]

Sets the direction of actor

set_image(img_path: str, img_action: str = None, size=None)[Quellcode]

Adds an single image to an actor, deletes all other images :param img_path: The path of the image relative to the actual path :param img_action: The image action (scale, do_nothing, crop) :param size: scale/crop : Size as 2-Tuple

set_rotatable()[Quellcode]

Sets the actor-image rotatable.

set_unblocked()[Quellcode]

Unsets the blocked-status of actor. If blocked is true, the field can’t be passed by another actor

set_x(x)[Quellcode]
Parameter:x – the x-coordinate
set_y(y)[Quellcode]
Parameter:y – the y-coordinate
setup()[Quellcode]

Should be overwritten by child-classes

stop()[Quellcode]

Stops all animations

turn_left(degrees: int = 90)[Quellcode]

Turns the actor left by x degress

turn_right(degrees: int = 90)[Quellcode]

Turns the actor right by x degress