pellet

Defines the Pellet class.

class pyskool.pellet.Pellet(pellet_id, command_list_id, pellet_range, hit_zone, hit_xy)

A catapult pellet.

Parameters:
  • pellet_id – The ID of the pellet.
  • command_list_id – The ID of the command list the pellet will use.
  • pellet_range – The maximum distance the pellet will travel after launch.
  • hit_zone – The size of the portion at the end of the pellet’s journey in which it can hit things.
  • hit_xy – The coordinates of the pellet within its sprite (used for collision detection).
get_command_list_id(lesson_id)

Return the ID of the command list used by the pellet.

Parameters:lesson_id – The ID of the current lesson (ignored - pellets do not follow a timetable).
get_hit_coords()

Return the coordinates of the pellet adjusted for comparison with the coordinates of a cup, shield or conker.

get_victim()

Return whoever has been hit by this pellet, or None if no one was hit.

hit_conker()

Check whether the pellet hit a conker in the tree, and make the conker fall if so.

Returns:True if the pellet hit a conker, False otherwise.
hit_cup()

Check whether the pellet hit a cup, and spill its contents if so.

Returns:True if the pellet hit a cup containing water, sherry or a frog, False otherwise.
hit_shield()

Check whether the pellet hit a shield, and make the shield flash or unflash as appropriate if so.

Returns:True if the pellet hit a shield, False otherwise.
impeded(bottom_y, top_y)

Return whether the pellet is blocked by an object (such as a wall).

Parameters:
  • bottom_y – The y-coordinate of the bottom of the object.
  • top_y – The y-coordinate of the top of the object.
launch(x, y, direction)

Launch the pellet from a starting point.

Parameters:
  • x – The x-coordinate of the starting point.
  • y – The y-coordinate of the starting point.
  • direction – The direction the pellet will travel.

Previous topic

mutable

Next topic

plant