API reference
This page gives an overview of all public pizzoo objects, functions and methods. All classes and functions exposed in pizzoo.* namespace are public.
Pizzoo
Initialize the Pizzoo object with the given renderer. Additional parameters can be passed to the renderer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address |
str
|
The IP address of the Pixoo device, or any renderer that needs an address. |
required |
renderer |
Renderer
|
The renderer to use. Default is Pixoo64Renderer. |
Pixoo64Renderer
|
renderer_params |
dict
|
Additional parameters to pass to the renderer. |
{}
|
debug |
bool
|
Whether to enable debug mode or not. Default is False. |
False
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
add_frame
Adds a new frame to the animation buffer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rgb |
tuple(int, int, int) | int | string
|
The color to fill the frame with. Default is black. |
(0, 0, 0)
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
cls
Clears the current frame with the given color.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rgb |
tuple(int, int, int) | int | string
|
The color to clear the frame with. Default is black. |
(0, 0, 0)
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
draw_circle
Draws a circle on the current frame at the given coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xy |
tuple(int, int
|
The coordinates of the center of the circle. |
required |
radius |
int
|
The radius of the circle. |
required |
color |
tuple(int, int, int) | int | string
|
The color to draw the circle with. |
required |
filled |
bool
|
Whether to fill the circle or not. |
True
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
draw_gif
Draws a gif on the animation buffer, starting on current frame. If the gif is larger than the screen, it will be resized to fit the screen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gif_path |
str
|
The path to the gif file. |
required |
xy |
tuple(int, int
|
The coordinates to start drawing the gif at. |
(0, 0)
|
size |
tuple(int, int) | str
|
The size to resize the gif to. If 'auto' is given, width and height of the gif will be used and resized if needed to fit the screen. |
'auto'
|
loop |
bool
|
Whether to loop the gif or not. |
False
|
resample_method |
Resampling
|
The resample mode to use when resizing the gif to fit the screen. Default is Image.NEAREST. |
NEAREST
|
fill |
tuple(int, int, int) | str
|
The color to fill the screen with before drawing the gif. If 'auto' is given, the color will be black. |
'auto'
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
draw_image
Draws an image on the current frame at the given coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_or_path |
str | Image
|
The path to the image file or the Image object to draw. |
required |
xy |
tuple(int, int
|
The coordinates of the top-left corner of the image. |
(0, 0)
|
size |
tuple(int, int) | str
|
The size to resize the image to. If 'auto' is given, the image will be resized to fit the screen if needed. |
'auto'
|
resample_method |
Resampling
|
The resample mode to use when resizing the image to fit the screen. Default is Image.NEAREST. |
NEAREST
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
draw_line
Draws a line on the current frame from the start to the end coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
tuple(int, int
|
The coordinates of the start of the line. |
required |
end |
tuple(int, int
|
The coordinates of the end of the line. |
required |
color |
tuple(int, int, int) | int | string
|
The color to draw the line with. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
draw_pixel
Draws a single pixel on the current frame at the given coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xy |
tuple(int, int
|
The coordinates to draw the pixel at. |
required |
color |
tuple(int, int, int) | int | string
|
The color to draw the pixel with. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the given coordinates are out of bounds. |
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
draw_rectangle
Draws a rectangle on the current frame at the given coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xy |
tuple(int, int
|
The coordinates of the top-left corner of the rectangle. |
required |
width |
int
|
The width of the rectangle. |
required |
height |
int
|
The height of the rectangle. |
required |
color |
tuple(int, int, int) | int | string
|
The color to draw the rectangle with. |
required |
filled |
bool
|
Whether to fill the rectangle or not. |
True
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
draw_text
draw_text(text, xy=(0, 0), font='default', color='#FFFFFF', align=0, line_width='auto', shadow=None, shadow_rgb=(0, 0, 0))
Draws a text on the current frame at the given coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The text to draw. |
required |
xy |
tuple(int, int
|
The coordinates of the top-left corner of the text. |
(0, 0)
|
font |
str
|
The name of the font to use. Default is 'default'. |
'default'
|
color |
tuple(int, int, int) | int | string
|
The color to draw the text with. |
'#FFFFFF'
|
align |
int
|
The alignment of the text. 0 is left, 1 is center and 2 is right. |
0
|
shadow |
str | tuple | None
|
The type of shadow to add to the text. Values are 'horizontal', 'vertical', 'diagonal', tuple with displacements, or None. |
None
|
shadow_rgb (tuple(int, int, int) | int | string): The color of the shadow. line_width (int): The maximum width of the text. Default is 'auto'.
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
get_settings
Get the current settings from the device.
Returns:
Type | Description |
---|---|
A dict with the current settings of the device. |
load_font
Loads a new font on bdf format to be used on the draw_text method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
font_name |
str
|
The name to identify the font. |
required |
path |
str
|
The path to the font file. |
required |
soft |
bool
|
If True, the font will be loaded when used. If False, the font will be loaded now. |
True
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
load_fonts
Loads multiple fonts at once.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fonts |
dict
|
A dictionary with the font name as key and the font path as value. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
render
Renders the current animation buffer to the Pixoo device. After that it resets the buffer.
Take into account that only a max of 60 frames can be rendered at once. So any buffer with more than 60 frames will be truncated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame_speed |
int
|
The speed in milliseconds per frame. Default is 150. (Only useful if more than 1 frame is being rendered) |
150
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
render_template
Renders an XML template to the given renderer.
This template can have a number of valid tags that are directly supported by the library, but any other renderer can add his own nodes. The template must have a root tag named 'pizzoo' and can have the following tags:
- section - A container for other elements. It can have x, y, width, height and position attributes.
- rectangle - Draws a rectangle. It can have x, y, width, height, color and filled attributes.
- circle - Draws a circle. It can have x, y, radius and color attributes.
- text - Draws a text. It can have x, y, color, wrap, shadow, shadowColor and font attributes.
- pixel - Draws a single pixel. It can have x, y and color attributes.
- image - Draws an image. It can have x, y and src attributes.
- line - Draws a line. It can have x, y, x2, y2 and color attributes. Aside from that, any container as section or rectangle can have a position attribute with the following values:
- static - x and y are relative to last non-absolute parent
- relative - as static, but absolute children are relative to this element
- absolute - x and y are absolute to the last relative element or the screen
Parameters:
Name | Type | Description | Default |
---|---|---|---|
template |
str
|
The XML template to render. |
required |
use_cache |
bool
|
Whether to use the cache or not. Default is False. (Currently not in use) |
False
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\__init__.py
reset_buffer
Resets the animation buffer, removing all frames and adding a new one.
Returns:
Type | Description |
---|---|
And int with the number of items removed from the buffer. |
Source code in pizzoo\__init__.py
set_brightness
Sets the brightness of the device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
brightness |
int
|
The brightness value to set. Must be between 0 and 100. |
required |
Returns:
Type | Description |
---|---|
None |
Renderer
A renderer is an object that is used to render the frames on the device. It can be a real device, an emulator or a static image.
Source code in pizzoo\_renderers.py
compile_node
Compiles an XML node into a command that can be executed on the device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
Element
|
The XML node to compile. |
required |
parent |
Element
|
The parent XML node. |
required |
inherited_props |
dict
|
The properties inherited from the parent node. |
required |
node_props |
dict
|
The properties of the current node. |
required |
Source code in pizzoo\_renderers.py
compile_node_root_options
Compiles the root options of the XML into a list of commands that can be executed on the device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options |
dict
|
The options of the root node. |
required |
get_max_frames
Returns the maximum amount of frames the device buffer can store.
Returns:
Name | Type | Description |
---|---|---|
int |
The maximum amount of frames the device can store. |
get_settings
get_size
render
Renders the buffer on the device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buffer |
list
|
A list of frames to render on the device. |
required |
frame_speed |
int
|
The speed at which the frames should be displayed. |
required |
Source code in pizzoo\_renderers.py
render_template_items
Renders or process a list of items on the device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items |
list
|
A list of items to render on the device. |
required |
use_cache |
bool
|
Whether to use the cache or not. |
True
|
Source code in pizzoo\_renderers.py
set_brightness
Sets the brightness of the device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
brightness |
int
|
The brightness level to set. Between 0 and 100. |
required |
switch
Turns the device on or off.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
on |
bool
|
Whether to turn the device on or off. |
True
|
Pixoo64Renderer
Bases: Renderer
This renderer is used to render the frames on the Divoom Pixoo64 device. It uses the Divoom API to send the frames to the device. Also includes some built-in methods for controlling the device like the buzzer, scoreboard, countdown, etc.
Source code in pizzoo\_renderers.py
buzzer
Plays a sound on the device buzzer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
active |
float
|
The time in seconds the buzzer is active. |
0.5
|
inactive |
float
|
The time in seconds the buzzer is inactive. |
0.5
|
duration |
float
|
The total time in seconds the buzzer will play. |
1
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\_renderers.py
clear_remote_text
set_dial
Sets the dial on the device with the given items. These are networking commands on the pixoo device that manage things like temperature, weather, time, etc. Most of them just auto-update, so it's useful for creating custom dials (Like watchfaces, for example).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items |
list(dict
|
A list of items to display on the dial. Each item should have at least a 'DisplayType' type. |
required |
background |
str
|
The path to an image to use as the background of the dial. Default is None. |
None
|
clear |
bool
|
Whether to send a network clear for the current text on the device or not. Default is True. |
True
|
Returns:
Type | Description |
---|---|
None |
Note: This method is pretty raw and depends on knowing the exact parameters to send to the device. It's recommended to use the higher-level render_template method. If needed additional documentation can be found on the official API.
Source code in pizzoo\_renderers.py
set_scoreboard
Sets the scoreboard on the device for every team.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blue_score |
int
|
The score for the blue team. |
0
|
red_score |
int
|
The score for the red team. |
0
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\_renderers.py
start_countdown
Creates and starts the countdown timer on the device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seconds |
int
|
The amount of seconds to countdown from. |
0
|
Returns:
Type | Description |
---|---|
None |
Source code in pizzoo\_renderers.py
stop_countdown
Stops the countdown timer on the device.
Returns:
Name | Type | Description |
---|---|---|
int |
Elapsed time in seconds |
Source code in pizzoo\_renderers.py
ImageRenderer
Bases: Renderer
This renderer creates a static image or gif with the frames and saves it to the disk. It can be used for debugging or demo purposes.
Source code in pizzoo\_renderers.py
render
The static render creates an image (if one frame) or a gif (if multiple frames) and then shows and returns it.
Source code in pizzoo\_renderers.py
WindowRenderer
Bases: Renderer
This renderer creates a window with a canvas to render the frames on the screen. It can be used for debugging or testing purposes.
Source code in pizzoo\_renderers.py
render
The static render creates an image (if one frame) or a gif (if multiple frames) and then displays it on the window.
Source code in pizzoo\_renderers.py
game
Actor
Actor(x, y, frame_src, game, base_path=None, z_index=0, bounding_box_size=None, visible=True, solid=True)
Creates a new actor object. An actor is an object that can be rendered on the screen and can interact with other objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
the x coordinate of the actor |
required |
y |
int
|
the y coordinate of the actor |
required |
frame_src |
(str, list)
|
Can be a list of paths to images or an iterable of images (like a gif) |
required |
game |
PizzooGame
|
the game object |
required |
base_path |
str
|
the base path to the image files |
None
|
z_index |
int
|
the z index of the actor |
0
|
bounding_box_size |
tuple
|
a tuple with the width and height of the bounding box |
None
|
visible |
bool
|
if True, the actor will be rendered on the screen |
True
|
solid |
bool
|
if True, the actor will collide with other objects |
True
|
Source code in pizzoo\game.py
check_collisions
Checks the collisions of the actor with other objects in the game.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_names |
(list, str)
|
a list of class names or a single class name to filter the collisions |
None
|
Returns:
Type | Description |
---|---|
Collision list (list): a list of objects that collided with the actor |
Source code in pizzoo\game.py
collisions
destroy
on_press
Camera
Creates a new camera object. A camera is a portion of the map that is visible/rendered on the screen, it can be centered on an object or moved manually.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
game |
PizzooGame
|
the game object |
required |
x |
int
|
the x coordinate of the camera |
required |
y |
int
|
the y coordinate of the camera |
required |
center_on |
Actor
|
the object to center the camera on |
None
|
Source code in pizzoo\game.py
center
Centers the camera on a target object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
Actor
|
the object to center the camera on |
required |
Source code in pizzoo\game.py
step
Updates the camera position based on the target object if center_on
is selected, else does nothing by default.
Map
Creates a new map object. A map is a grid of tiles that can be filled with sprites.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tile_size |
int
|
the size of the tiles in pixels |
required |
tiles_width |
int
|
the width of the map in tiles |
required |
tiles_height |
int
|
the height of the map in tiles |
required |
Source code in pizzoo\game.py
add_tile
Adds a tile to the map at a specific position with a span.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tile |
Sprite
|
the tile to add |
required |
x |
int
|
the x index of the tile |
required |
y |
int
|
the y index of the tile |
required |
span |
tuple
|
a tuple with the width and height of the tile in tiles |
(0, 0)
|
Source code in pizzoo\game.py
add_tile_at
Adds a tile to the map at a specific position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tile |
Sprite
|
the tile to add |
required |
x |
int
|
the x index of the tile |
required |
y |
int
|
the y index of the tile |
required |
Source code in pizzoo\game.py
draw
Draws the map on the screen using a cropped image of the map image and a memoization based on the camera position
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pizzoo |
Pizzoo
|
the pizzoo object |
required |
camera |
Camera
|
the camera object |
required |
Source code in pizzoo\game.py
fill
Fills the entire map with a single tile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tile |
Sprite
|
the tile to fill the map with |
required |
Source code in pizzoo\game.py
generate_map_image
Generates a map image based on the tiles in the map. This static image is used to render the map on the screen and is memoized for performance.
Source code in pizzoo\game.py
Path
Source code in pizzoo\game.py
next
Returns the next node in the path, if the path is closed, it will return to the first node when it reaches the end.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
the x coordinate of the object that is following the path |
required |
y |
int
|
the y coordinate of the object that is following the path |
required |
coords |
bool
|
if True, x and y will be treated as coordinates and result will be a tuple of coordinates, otherwise it will return a tuple of tile indexes |
False
|
Returns:
Type | Description |
---|---|
Next node (tuple): a tuple with the x and y indexes of the next node in the path |
Source code in pizzoo\game.py
prev
Returns the previous node in the path, if the path is closed, it will return to the last node when it reaches the beginning.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
the x coordinate of the object that is following the path |
required |
y |
int
|
the y coordinate of the object that is following the path |
required |
coords |
bool
|
if True, x and y will be treated as coordinates and result will be a tuple of coordinates, otherwise it will return a tuple of tile indexes |
False
|
Returns:
Type | Description |
---|---|
Previous node (tuple): a tuple with the x and y indexes of the previous node in the path |
Source code in pizzoo\game.py
PizzooGame
Creates a new game object. A game is a container for maps, instances, cameras, and timers. It also handles the game loop and the rendering of the game.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pizzoo |
Pizzoo
|
the pizzoo object |
required |
frame_limit |
int
|
the frame limit of the game |
5
|
dev |
bool
|
if True, the game will print the FPS on the console |
False
|
Source code in pizzoo\game.py
add_instance
Adds an instance to the game, the instances are sorted by the z_index attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance |
Actor
|
the instance to add |
required |
Source code in pizzoo\game.py
check_collision_point
Checks if a point is inside a bounding box.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
the x coordinate of the point |
required |
y |
int
|
the y coordinate of the point |
required |
object_x |
int
|
the x coordinate of the bounding box |
required |
object_y |
int
|
the y coordinate of the bounding box |
required |
size |
int
|
the size of the bounding box |
required |
Returns:
Name | Type | Description |
---|---|---|
Collision |
bool
|
True if the point is inside the bounding box, False otherwise |
Source code in pizzoo\game.py
check_collisions
Checks the collisions of an object with other objects in the game.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
Actor
|
the object to check the collisions with |
required |
class_names |
(list, str)
|
a list of class names or a single class name to filter the collisions |
None
|
Returns:
Type | Description |
---|---|
Collision list (list): a list of objects that collided with the target |
Source code in pizzoo\game.py
collision
Checks if two objects are colliding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
Actor
|
the first object |
required |
target |
Actor
|
the second object |
required |
Returns:
Name | Type | Description |
---|---|---|
Collision |
bool
|
True if the objects are colliding, False otherwise |
Source code in pizzoo\game.py
create_camera
Creates a new camera object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
the x coordinate of the camera |
0
|
y |
int
|
the y coordinate of the camera |
0
|
center_on |
Actor
|
the object to center the camera on |
None
|
Source code in pizzoo\game.py
create_map
Creates a new map with a tile size and a width and height in tiles
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tile_size |
int
|
the size of the tiles in pixels |
required |
tiles_width |
int
|
the width of the map in tiles |
required |
tiles_height |
int
|
the height of the map in tiles |
required |
Returns:
Name | Type | Description |
---|---|---|
Map |
Map
|
the map object |
Source code in pizzoo\game.py
draw
Draws the game on the screen, rendering the maps, instances, and the UI.
Source code in pizzoo\game.py
draw_ui
on_press
Handles the key press events and forwards them to the instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
the key that was pressed |
required |
Source code in pizzoo\game.py
remove_instance
Removes an instance from the game.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance |
Actor
|
the instance to remove |
required |
Returns:
Name | Type | Description |
---|---|---|
Instance |
Actor
|
the removed instance |
Source code in pizzoo\game.py
remove_timer
Removes a timer from the game.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the name of the timer to remove |
required |
Returns:
Name | Type | Description |
---|---|---|
Timer |
dict
|
the removed timer |
Source code in pizzoo\game.py
run
Runs the game loop, updating the game state and rendering the game on the screen.
Source code in pizzoo\game.py
start
step
Updates the game state, moving the instances, checking the collisions, and updating the camera.
stop
timer
Creates a new timer with a name, a callback function, an interval in seconds, and a repeat flag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the name of the timer |
required |
callback |
function
|
the callback function to execute |
required |
interval |
float
|
the interval in seconds |
required |
repeat |
bool
|
if True, the timer will repeat |
False
|
force |
bool
|
if True, the timer will be created even if it already exists |
False
|
Source code in pizzoo\game.py
timer_exists
Checks if a timer exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the name of the timer |
required |
Returns:
Name | Type | Description |
---|---|---|
Exists |
bool
|
True if the timer exists, False otherwise |
Sprite
Creates a new sprite object. A sprite is a sequence of frames that can be rendered on the screen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame_src |
(str, list)
|
Can be a list of paths to images or an iterable of images (like a gif) |
required |
base_path |
str
|
the base path to the image files |
None
|
current_frame |
int
|
the current frame of the sprite |
0
|
z_index |
int
|
the z index of the sprite |
0
|
offset |
tuple
|
a tuple with the x, y, and size of the offset to crop the image |
(0, 0, 0)
|
Source code in pizzoo\game.py
get_frame
Returns a frame based on an index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
the index of the frame to return |
None
|
Returns:
Name | Type | Description |
---|---|---|
Frame |
Image
|
the frame |
Source code in pizzoo\game.py
next_frame
set_frame
Sets a frame as the current frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
the index of the frame to set as the current frame |
required |
size
Returns the size of the current frame.
Returns:
Name | Type | Description |
---|---|---|
Size |
tuple
|
a tuple with the width and height of the current frame |
coords_to_tile
Returns the indexes of a tile in the map based on the tile size and the coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tile_size |
int
|
the size of the tile in pixels |
required |
x |
int
|
the x coordinate of the tile |
required |
y |
int
|
the y coordinate of the tile |
required |
use_ceil |
bool
|
if True, the indexes will be rounded up, otherwise they will be rounded down |
False
|
Returns:
Type | Description |
---|---|
Tile indexes (tuple): a tuple with the x and y indexes of the tile |
Source code in pizzoo\game.py
distance
Returns the distance between two points in a 2D space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a |
tuple
|
a tuple with the x and y coordinates of the first point |
required |
b |
tuple
|
a tuple with the x and y coordinates of the second point |
required |
Returns:
Name | Type | Description |
---|---|---|
Distance |
float
|
the distance between the two points |
Source code in pizzoo\game.py
tile_to_coords
Returns the coordinates of a tile in the map based on the tile size and the tile indexes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tile_size |
int
|
the size of the tile in pixels |
required |
tile_x |
int
|
the x index of the tile |
required |
tile_y |
int
|
the y index of the tile |
required |
Returns:
Name | Type | Description |
---|---|---|
Coordinates |
tuple
|
a tuple with the x and y coordinates of the tile |