pgz¶
pgz.actor¶
pgz uses the pgzero.actor.Actor
implementation a sprite representation.
More inforamation can be found here
pgz.application¶
Application¶
class Application()
The idea and the original code was taken from EzPyGame
A simple wrapper around pygame
for running games easily.
Also makes scene management seamless together with the Scene
class.
__init__¶
| __init__(title: Optional[str], resolution: Optional[Tuple[int, int]], update_rate: Optional[int] = None)
Create an instance of the pgz.Application
Arguments:
title
Optional[str] - title to display in the window’s title barresolution
Optional[Tuple[int, int]] - resolution of the game windowupdate_rate
Optional[int], optional - how many times per second to update. Defaults to None.
If any parameters are left to None
, these settings must be
defined either manually through application.<setting> = value
or via Scene
‘s class variable settings.
Examples:
class Menu(pgz.Scene):
...
class Game(pgz.Scene):
...
app = pgz.Application(
title='My First Application',
resolution=(1280, 720),
update_rate=60,
)
main_menu = Menu()
app.run(main_menu)
title¶
| @property
| title() -> str
Get application title
Returns:
str
- application title
title¶
| @title.setter
| title(value: str) -> None
Change application title
Arguments:
value
str - application title to set
resolution¶
| @property
| resolution() -> Tuple[int, int]
Get application screen resolution
Returns:
Tuple[int, int]: application screen resolution
resolution¶
| @resolution.setter
| resolution(value: Tuple[int, int]) -> None
Change application screen resolution
Arguments:
value
Tuple[int, int] - application screen resolution to use
update_rate¶
| @property
| update_rate() -> int
Get application update rate
Returns:
int
- application update rate
update_rate¶
| @update_rate.setter
| update_rate(value: int) -> None
Change application update rate
Arguments:
value
int - application update rate to set
screen¶
| @property
| screen() -> Screen
Get application screen object
Returns:
Screen
- application screen object
keyboard¶
| @property
| keyboard() -> Keyboard
Get Keyboard
object.
Returns:
Keyboard
- keyboard object
clock¶
| @property
| clock() -> Clock
Get Clock
object.
Actually returns the global clock object.
Returns:
Clock
- clock object
active_scene¶
| @property
| active_scene() -> Optional[Scene]
Get currently active scene.
Can be None
.
Returns:
Optional[Scene]
- currently active scene
change_scene¶
| change_scene(scene: Optional[Scene]) -> None
Change the currently active scene.
This will invoke Scene.on_exit
and
Scene.on_enter
methods on the switching scenes.
If None
is provided, the application’s execution will end.
Arguments:
scene
Optional[Scene] - the scene to change into
run¶
| run(scene: Optional[Scene] = None) -> None
Execute the application.
Arguments:
scene
Optional[Scene], optional - scene to start the execution from. Defaults to None.
pgz.clock¶
pgz uses the pgzero.clock.Clock
implementation for scheduling game events.
More inforamation can be found here
pgz.keyboard¶
pgz uses the pgzero.keyboard.Keyboard
implementation for tracking the keyboard state.
More inforamation can be found here
Keyboard¶
class Keyboard()
The current state of the keyboard.
Each attribute represents a key. For example,
keyboard.a
is True if the ‘A’ key is depressed, and False otherwise.
pgz.loaders¶
pgz uses the pgzero.loaders
module implementation for the source managemens.
More inforamation can be found here
The extension was provided by pgz is the MapLoader
resource loader, which loads TMX tiled maps in the same manner as all other resources are loaded
Examples:
The example of default.tmx file loading is shown below:
tmx = pgz.maps.default
pgz.multiplayer¶
Set of tools for converting you singleplayer game to the multiplayer one.
pgz.multiplayer.multiplayer_scene¶
MultiplayerSceneServer¶
class MultiplayerSceneServer()
Scene server implementation.
MultiplayerSceneServer opens a WebSocket server and instantiate a pgz.Scene per connected player(client):
tmx = pgz.maps.default
map = pgz.ScrollMap((1280, 720), tmx, ["Islands"])
# Build and start game server
self.server = pgz.MultiplayerSceneServer(map, GameScene)
self.server.start_server(port=self.port)
All the scenes will share the map object and collision detector object. So, the communication between different players scenes is done with collision detection. If one scene shoots the cannon ball (by implementing the CannonBall actor and adding its instance to the map):
def on_mouse_down(self, pos, button):
start_point = self.calc_cannon_ball_start_pos(pos)
if start_point:
ball = CannonBall(pos=start_point, target=pos)
self.add_actor(ball, group_name="cannon_balls")
Another player(scene) might be harmed by the cannon ball using the collision detection:
def update(self, dt):
super().update(dt)
cannon_ball = self.collide_group(self.ship, "cannon_balls")
if cannon_ball:
# pgz.sounds.arrr.play()
self.ship.health -= cannon_ball.hit_rate * dt
__init__¶
| __init__(map: ScrollMap, HeadlessSceneClass: Scene)
Create MultiplayerSceneServer instance.
Arguments:
map
ScrollMap - apgz.ScrollMap
object. Will be shared across all the scenes in the serverHeadlessSceneClass
Callable - a scene class. HeadlessSceneClass will be used as a scene object factory.
update¶
| update(dt: float) -> None
Update method similar to the pgz.scene.Scene.update
method.
Arguments:
dt
float - time in milliseconds since the last update
start_server¶
| start_server(host: str = "localhost", port: int = 8765) -> None
Start the scene server.
Arguments:
host
str, optional - host name. Defaults to “localhost”.port
int, optional - port number for listeting of a incoming WebSocket connections. Defaults to 8765.
stop_server¶
| stop_server() -> None
Stop the server and disconnect all the clients
RemoteSceneClient¶
class RemoteSceneClient(MapScene)
pgz.RemoteSceneClient allows to communicate with pgz.MultiplayerSceneServer and render the remote scene locally:
data = self.menu.get_input_data()
server_url = data["server_url"]
tmx = pgz.maps.default
map = pgz.ScrollMap(app.resolution, tmx, ["Islands"])
game = pgz.RemoteSceneClient(map, server_url, client_data={"name": data["name"]})
Pay attention that client process needs to have access to the same external resources (like map files, images,…) as the game server.
Pay attention that the RemoteSceneClient
uses pgz.RPCScreenClient
instead of pgz.Screen
.
__init__¶
| __init__(map: ScrollMap, server_url: str, client_data: JSON = {}) -> None
Create a remote scene client object.
client_data
will be send to the remote scene object. The common usage - remote scene configuration.
For example the used select the players avatar image: the image name should be a part of the client_data object.
So the remote scene will be able to load a correct sprite and the actor’s state with other clients.
Arguments:
map
ScrollMap - map object will be used for actors management and renderingserver_url
str - remote server URLclient_data
JSON, optional - data will be sent to the remote scene object. Defaults to {}.
on_exit¶
| on_exit(next_scene: Optional[Scene]) -> None
Overriden deinitialization method
Arguments:
next_scene
Optional[Scene] - next scene to run
on_enter¶
| on_enter(previous_scene: Optional[Scene]) -> None
Overriden initialization method
Arguments:
previous_scene
Optional[Scene] - previous scene was running
update¶
| update(dt: float) -> None
Overriden update method
Arguments:
dt
float - time in milliseconds since the last update
draw¶
| draw(screen: Screen) -> None
Overriden rendering method
Arguments:
screen
Screen - screen to draw the scene on
handle_event¶
| handle_event(event: pygame.event.Event) -> None
Overriden event handler
Events will be accumulated internally and flushed all together to the remote scene.
Arguments:
event
pygame.event.Event - pygame event object
connect_to_server¶
| async connect_to_server(attempts: int = 10) -> bool
Connect to the remote scene server.
Arguments:
attempts
int, optional - number of attempts to connect. Defaults to 10.
Returns:
bool
- True if connected successfully
pgz.multiplayer.rpc¶
pgz.multiplayer.screen_rpc¶
RPCSurfacePainter¶
class RPCSurfacePainter()
Interface to pygame.draw that is bound to a surface.
line¶
| line(start: Tuple[Any, Any], end: Tuple[Any, Any], color: Any, width: int = 1) -> None
Draw a line from start to end.
circle¶
| circle(pos: Tuple[Any, Any], radius: float, color: Any, width: int = 1) -> None
Draw a circle.
filled_circle¶
| filled_circle(pos: Tuple[Any, Any], radius: float, color: Any) -> None
Draw a filled circle.
polygon¶
| polygon(points: List[Tuple[Any, Any]], color: Any) -> None
Draw a polygon.
filled_polygon¶
| filled_polygon(points: List[Tuple[Any, Any]], color: Any) -> None
Draw a filled polygon.
rect¶
| rect(rect: ZRect, color: Any, width: int = 1) -> None
Draw a rectangle.
filled_rect¶
| filled_rect(rect: ZRect, color: Any) -> None
Draw a filled rectangle.
text¶
| text(*args: Any, **kwargs: Any) -> None
Draw text to the screen.
textbox¶
| textbox(*args: Any, **kwargs: Any) -> None
Draw text to the screen, wrapped to fit a box
RPCScreenServer¶
class RPCScreenServer()
bounds¶
| bounds() -> ZRect
Return a Rect representing the bounds of the screen.
clear¶
| clear() -> None
Clear the screen to black.
pgz.rect¶
pgz uses the pgzero.rect.ZRect
implementation for a rectangle representation.
More inforamation can be found here
pgz.scene¶
Scene¶
class Scene(EventDispatcher)
The idea and the original code was taken from EzPyGame
An isolated scene which can be ran by an application.
Create your own scene by subclassing and overriding any methods.
Example:
class Menu(Scene):
def __init__(self):
self.font = pygame.font.Font(...)
def on_enter(self, previous_scene):
self.title = 'Main Menu'
self.resolution = (640, 480)
self.update_rate = 30
def draw(self, screen):
pygame.draw.rect(...)
text = self.font.render(...)
screen.blit(text, ...)
def handle_event(self, event):
if event.type == pygame.MOUSEBUTTONUP:
if event.button == 1:
game_size = self._get_game_size(event.pos)
self.change_scene(Game(game_size))
def _get_game_size(self, mouse_pos_upon_click):
...
class Game(pgz.Scene):
title = 'The Game!'
resolution = (1280, 720)
update_rate = 60
def __init__(self, size):
super().__init__()
self.size = size
self.player = ...
...
def on_enter(self, previous_scene):
super().on_enter(previous_scene)
self.previous_scene = previous_scene
def draw(self, screen):
self.player.draw(screen)
for enemy in self.enemies:
...
def update(self, dt):
self.player.move(dt)
...
if self.player.is_dead():
self.change_scene(self.previous_scene)
elif self.player_won():
self.change_scene(...)
def handle_event(self, event):
... # Player movement etc.
The above two classes use different approaches for changing the application’s settings when the scene is entered:
- Manually set them in
on_enter
, as seen inMenu
- Use class variables, as I did with
Game
When using class variables (2), you can leave out any setting
(defaults to None
) to not override that particular setting.
If you override on_enter
in the subclass, you must call
super().on_enter(previous_scene)
to use the class variables.
These settings can further be overridden in individual instances:
my_scene0 = MyScene()
my_scene0.resolution = (1280, 720)
my_scene1 = MyScene(title='My Second Awesome Scene')
Example:
Shortcuts foe event gandling while Scene
subclassing.
def on_mouse_up(self, pos, button):
# Override this for easier events handling.
pass
def on_mouse_down(self, pos, button):
# Override this for easier events handling.
pass
def on_mouse_move(self, pos):
# Override this for easier events handling.
pass
def on_key_down(self, key):
# Override this for easier events handling.
pass
def on_key_up(self, key):
# Override this for easier events handling.
pass
scene_uuid¶
| @property
| scene_uuid() -> str
Get scene UUID.
client_data¶
| @property
| client_data() -> Dict[str, Any]
Get data provided by client side.
title¶
| @property
| title() -> str
Get application title
Returns:
str
- application title
title¶
| @title.setter
| title(value: str) -> None
Change application title
Arguments:
value
str - application title to set
resolution¶
| @property
| resolution() -> Tuple[int, int]
Get application screen resolution
Returns:
Tuple[int, int]: application screen resolution
resolution¶
| @resolution.setter
| resolution(value: Tuple[int, int]) -> None
Change application screen resolution
Arguments:
value
Tuple[int, int] - application screen resolution to use
update_rate¶
| @property
| update_rate() -> int
Get application update rate
Returns:
int
- application update rate
update_rate¶
| @update_rate.setter
| update_rate(value: int) -> None
Change application update rate
Arguments:
value
int - application update rate to set
clock¶
| @property
| clock() -> Clock
Get Clock
object.
Actually returns the global clock object.
Returns:
Clock
- clock object
keyboard¶
| @property
| keyboard() -> Keyboard
Get Keyboard
object.
Returns:
Keyboard
- keyboard object
draw¶
| draw(screen: Screen) -> None
Override this with the scene drawing.
Arguments:
screen
Screen - screen to draw the scene on
update¶
| update(dt: float) -> None
Override this with the scene update tick.
Arguments:
dt
float - time in milliseconds since the last update
handle_event¶
| handle_event(event: pygame.event.Event) -> None
Override this to handle an event in the scene.
All of pygame
‘s events are sent here, so filtering
should be applied manually in the subclass.
Arguments:
event
pygame.event.Event - event to handle
on_enter¶
| on_enter(previous_scene: Optional["Scene"]) -> None
Override this to initialize upon scene entering.
If you override this method and want to use class variables
to change the application’s settings, you must call
super().on_enter(previous_scene)
in the subclass.
Arguments:
previous_scene
Optional[Scene] - previous scene was running
on_exit¶
| on_exit(next_scene: Optional["Scene"]) -> None
Override this to deinitialize upon scene exiting.
Arguments:
next_scene
Optional[Scene] - next scene to run
pgz.scenes¶
pgz provides an implementation of a few tipical scene classes subclassed from the pgz.Scene
.
pgz.MenuScene
- implements game menu rendering as a pgz.Scene subclasspgz.ActorScene
- implements the basic actors managements, updates, rendering logic and actors collision detection.pgz.MapScene
- extends pgz.ActorScene for games based on the tiled maps. It also implements the tiles collision detection.pgz.RemoteSceneClient
- allows to render the view of remote pgz.MapScene or pgz.ActorScene using WebSocket connection. It might be useful handy for building of a multiplayer game
pgz.scenes.actor_scene¶
ActorScene¶
class ActorScene(Scene)
Scene implementation for management of multiple actors.
Actors also can be added to different collision groups, which allows easily identify collision of an actor with a specific actor group.
__init__¶
| __init__() -> None
Create an ActorScene object
set_collision_detector¶
| set_collision_detector(collision_detector: CollisionDetector)
Set external collsinion detector object.
The default collision detector can be use in the most of the cases. This method in used by multiplayer.
add_actor¶
| add_actor(actor: Actor, group_name: str = "") -> None
Add actor to the scene and add the actor to the collision group.
Arguments:
actor
Actor - actor to addgroup_name
str, optional - Collision group name. Defaults to “”.
remove_actor¶
| remove_actor(actor: Actor) -> None
Remove actor from the scene.
Actor also will be removed from the associated collision detector
Arguments:
actor
Actor - Actor to be removed
remove_actors¶
| remove_actors() -> None
Remove all actors from the scene and the associated collision detector
get_actor¶
| get_actor(uuid: str) -> Actor
Get actor object by its UUID
Arguments:
uuid
str - UUID of the actor to be retrieved
Returns:
Actor
- Actor associated with the UUID
get_actors¶
| get_actors() -> List[Actor]
Get list of actors
Returns:
List[Actor]
- The list of actors on the scene
collide_group¶
| collide_group(actor: Actor, group_name: str = "") -> Optional[Actor]
Detect collision of a ginen actor with the actors in requested collsion group.
Arguments:
actor
Actor - actor to detect collisions withgroup_name
str, optional - Collision group name. Defaults to “”.
Returns:
Optional[Actor]
- A collins actor in the specified collision group
draw¶
| draw(surface: Screen) -> None
Overriden rendering method
Implementation of the update method for the ActorScene.
The ActorScene implementation renders all the actorts attached to the scene.
Arguments:
screen
Screen - screen to draw the scene on
update¶
| update(dt: float) -> None
Overriden update method
Implementation of the update method for the ActorScene.
This method updates all the actors attached to the scene.
Arguments:
dt
float - time in milliseconds since the last update
pgz.scenes.map_scene¶
MapScene¶
class MapScene(ActorScene)
Scene implementation for Tiled map management.
Extends functionality ActorScene, but in case of MapScene actors are placed on a map. The implementation is based on pyscroll. A tiled map can be created and modified with wonderful Tiled maps editor.
The maps loading and usage is backed by PyTMX
Actors also can be added to different collision groups, which allows easily identify collision of an actor with a specific actor group
__init__¶
| __init__(map: Optional[ScrollMap] = None)
Create a MapScene object
The map object loading is done with the map loader (a-la pgzero resource loaders). So for loading a map from “default.tmx” file of the resource directory:
tmx = pgz.maps.default
map = pgz.ScrollMap(app.resolution, tmx, ["Islands"])
Arguments:
map
Optional[ScrollMap], optional - Loaded map object. Defaults to None.
map¶
| @property
| map() -> ScrollMap
Get map object
Returns:
ScrollMap
- the map object used by the scene
set_map¶
| set_map(map)
Set map object
Arguments:
map
[type] - map object to set
dispatch_event¶
| dispatch_event(event: pygame.event.Event) -> None
Overriden events dispatch method Used for mouse cursor position transformation into map “world coordinates”
Arguments:
event
pygame.event.Event - pygame Event object
update¶
| update(dt: float) -> None
Overriden update method Implementation of the update method for the MapScene.
This method updates all the actors attached to the scene.
Arguments:
dt
float - time in milliseconds since the last update
draw¶
| draw(screen: Screen) -> None
Overriden rendering method Implementation of the update method for the MapScene.
The ActorScene implementation renders all the actorts attached to the scene.
Arguments:
screen
Screen - screen to draw the scene on
add_actor¶
| add_actor(actor: Actor, central_actor: bool = False, group_name: str = "") -> None
Overriden add_actor method Implementation of the add_actor method for the MapScene.
The ActorScene implementation renders all the actorts attached to the scene.
Arguments:
actor
Actor - actor to addcentral_actor
bool, optional - Sets the actor to be central actor for the scene. The map view will be centered on the actor. Defaults to False.group_name
str, optional - Collision group name. Defaults to “”.
remove_actor¶
| remove_actor(actor: Actor) -> None
Overriden remove_actor method Implementation of the remove_actor method for the MapScene.
Arguments:
actor
Actor - actor to be removed
handle_event¶
| handle_event(event: pygame.event.Event) -> None
Overriden event handler Implementation of the event handler method for the MapScene.
Arguments:
event
pygame.event.Event - pygame event object
collide_map¶
| collide_map(actor: Actor) -> bool
Detect collision with tiles in the map object used by the scene
Arguments:
actor
Actor - actor for collision detection
Returns:
bool
- True if the collision with map tiles is detected
pgz.scenes.menu_scene¶
MenuScene¶
class MenuScene(Scene)
Base class for a scenes showing menu.
MenuScene uses pygame_menu.Menu
internally, for the additional information follow the link pygame-menu.
Examples:
class Menu(pgz.MenuScene):
def __init__(self):
super().__init__()
import pygame_menu
self.menu = pygame_menu.Menu(300, 400, "Welcome", theme=pygame_menu.themes.THEME_BLUE)
self.menu.add_text_input("Name :", textinput_id="name", default="John Doe")
self.menu.add_selector('Difficulty :', [('Hard', 1), ('Easy', 2)], onchange=set_difficulty)
self.menu.add_button("Play", self.start_the_game)
self.menu.add_button("Quit", pygame_menu.events.EXIT)
def start_the_game(self):
data = self.menu.get_input_data()
scene = GameScene()
tmx = pgz.maps.default
map = pgz.ScrollMap(app.resolution, tmx, ["Islands"])
scene.set_map(map)
scene.set_client_data({"name": data["name"]})
self.change_scene(scene)
__init__¶
| __init__(menu: Optional[pygame_menu.Menu] = None)
Create MenuScene
Receives a menu object as argument or creates its own menu object.
Arguments:
menu
Optional[pygame_menu.Menu], optional - menu object. Defaults to None.
menu¶
| @property
| menu() -> pygame_menu.Menu
Get the internal pygame_menu.Menu
object.
Returns:
pygame_menu.Menu
- internal menu object.
draw¶
| draw(screen: Screen) -> None
Overriden rendering method Implementation of the update method for the ActorScene.
The ActorScene implementation renders all the actorts attached to the scene.
Arguments:
screen
Screen - screen to draw the scene on
on_exit¶
| on_exit(next_scene: Optional[Scene]) -> None
Overriden deinitialization method
Arguments:
next_scene
Optional[Scene] - next scene to run
handle_event¶
| handle_event(event: pygame.event.Event) -> None
Overriden event handling method method
All of pygame
‘s events are sent here, so filtering
should be applied manually in the subclass.
Arguments:
event
pygame.event.Event - event to handle
pgz.screen¶
pgz uses the pgzero.screen.Screen
implementation for the screen object representation and rendering.
More inforamation can be found here.
pgz.utils¶
pgz.utils.collision_detector¶
CollisionDetector¶
class CollisionDetector(object)
Class helper for easier collision detection
The class manages multiple collision groups and can detect a collsion with each one of groups independently.
__init__¶
| __init__() -> None
Create a collision detecor
add_actor¶
| add_actor(actor: Actor, group_name: str = "") -> None
Add an actor to the detector
Arguments:
actor
Actor - actor to addgroup_name
str, optional - collision group to use. Defaults to “”.
remove_actor¶
| remove_actor(actor: Actor) -> None
Remore an actor from the detector and all collision groups
Arguments:
actor
Actor - actor to remove
get_actor¶
| get_actor(uuid: str) -> Actor
Get actor by UUID
Arguments:
uuid
str - UUID of the actor
Returns:
Actor
- actor associated with the UUID
get_actors¶
| get_actors() -> List[Actor]
Get list of all the known actors.
Returns:
List[Actor]
- list of actors
collide_group¶
| collide_group(sprite: pygame.sprite.Sprite, group_name: str = "") -> Optional[pygame.sprite.Sprite]
Detect a collision of an actor with a specified collsion group.
Arguments:
sprite
pygame.sprite.Sprite - actor to use for collision detection.group_name
str, optional - collision group name. Defaults to “”.
Returns:
Optional[pygame.sprite.Sprite]
- actor was found in the collsion group.
pgz.utils.event_dispatcher¶
EventDispatcher¶
class EventDispatcher()
Adapt a pgzero game’s raw handler function to take a Pygame Event.
Returns a one-argument function of the form handler(event)
.
This will ensure that the correct arguments are passed to the raw
handler based on its argument spec.
The wrapped handler will also map certain parameter values using callables from EVENT_PARAM_MAPPERS; this ensures that the value of ‘button’ inside the handler is a real instance of constants.mouse, which means (among other things) that it will print as a symbolic value rather than a naive integer.
handle_event¶
| handle_event(event: pygame.event.Event) -> None
Override me
pgz.utils.fps_calc¶
pgz.utils.scroll_map¶
ScrollMap¶
class ScrollMap(object)
Scroll Map object.
The implementation is based on pyscroll
This class provides functionality: - create and manage a pyscroll group - load a collision layers - manage sprites added to the map - allows to detect collisions with loaded collision layers - render the map and the sprites on top
__init__¶
| __init__(screen_size: Tuple[int, int], tmx: pytmx.TiledMap, collision_layers: List[str] = []) -> None
Create scroll map object.
Arguments:
screen_size
Tuple[int, int] - screen resolution will be used to the map renderingtmx
pytmx.TiledMap - loadedpytmx.TiledMap
objectcollision_layers
List[str], optional - List ofpytmx.TiledMap
layer names will be used for tiles collision detection. Defaults to [].
add_collision_layers¶
| add_collision_layers(collision_layers: List[str]) -> None
Load pytmx.TiledMap
layer tiles for collision detection.
Some layer in the pytmx.TiledMap
might be be used for collision detection.
For example: the layer includes “island tiles” might be used for collision detection with a “ship” actor.
Arguments:
collision_layers
List[str] - List ofpytmx.TiledMap
layer names will be used for tiles collision detection.
draw¶
| draw(screen: Screen) -> None
Draw method similar to the pgz.scene.Scene.draw
method.
Will draw the map and all actors on top.
Arguments:
dt
float - time in milliseconds since the last update
update¶
| update(dt: float) -> None
Update method similar to the pgz.scene.Scene.update
method.
All the actors attached to the map will be updated.
Arguments:
dt
float - time in milliseconds since the last update
add_sprite¶
| add_sprite(sprite: pygame.sprite.Sprite) -> None
Add actor/sprite to the map
Arguments:
sprite
pygame.sprite.Sprite - sprite object to add
remove_sprite¶
| remove_sprite(sprite: pygame.sprite.Sprite) -> None
Remove sprite/actor from the map.
Arguments:
sprite
pygame.sprite.Sprite - sprite object to remove
collide_map¶
| collide_map(sprite: pygame.sprite.Sprite) -> bool
Detect a collision with tiles on the map
Arguments:
sprite
pygame.sprite.Sprite - sprite/actor for detection
Returns:
bool
- True is the collision with the colision layers was detected