Interactables

ClippedFrame

Frame object that will only draw items within a certain bounding box.

Constructor

ClippedFrame(x, y) Frame object that will only draw items within a certain bounding box.

Methods

render(context) Overwite of the render method.
updateFromPhysics() Updates all shapes after a step of the physics simulator.

Details

class ClippedFrame(x, y)[source]

Bases: Graphics.Frame

Constructs a ClippedFrame object.

Parameters:
  • x – The x coordinate of the frame.
  • y – The y coordinate of the frame.

Methods

render(context)[source]

Overwite of the render method.

By overwriting the render method, we can restrict the drawing to a particular box.

Parameters:context – The Cairo painting context.
updateFromPhysics()[source]

Updates all shapes after a step of the physics simulator.

Necessary, otherwise objects added to the frame won’t appear in the correct location of the screen.

DoubleDoor

A double door object that can be opened.

The double door can be drawn like a rectangle, and will then be plit in two such that it opens in the direction in which the door is longest. As such, it is impossible to make a door that is really narrow but thick with this object.

Constructor

DoubleDoor(x, y, w, h[, c]) A double door object that can be opened.

Methods

close() Schedules the close event to the levelThread.
closeEvent() Executes one iteration of closing the door.
draw(levelWindow) Draw the door to the level window.
open() Schedules the open event to the levelThread.
openEvent() Executes one iteration of opening the door.
update() Draw the two parts of the door in the correction location depending on the value of the pOpen attribute.

Details

class DoubleDoor(x, y, w, h, c=None)[source]

Bases: actors.baseActor.BaseActor

Constructs a DoubleDoor object.

Parameters:
  • x – The x coordinate of the door.
  • y – The y coordinate of the door.
  • w – The width of the door.
  • h – The height of the door.
  • c – The color of the door. If c is set to 1, a rusted gate sprite is drawn instead of a solid color.

Methods

close()[source]

Schedules the close event to the levelThread.

closeEvent()[source]

Executes one iteration of closing the door.

This method should be scheduled to the levelThread in order to close the door.

Return: False when the door has finished closing, True otherwise.

draw(levelWindow)[source]

Draw the door to the level window.

Parameters:levelWidow – The LevelWindow to draw to.
open()[source]

Schedules the open event to the levelThread.

openEvent()[source]

Executes one iteration of opening the door.

This method should be scheduled to the levelThread in order to open the door.

Return: False when the door has finished opening, True otherwise.

update()[source]

Draw the two parts of the door in the correction location depending on the value of the pOpen attribute.

EventPad

A non-obstructing physics object that triggers an event when touched.

The EventPad covers a rectangular area of custom size.

Constructor

EventPad(start, width, height[, ...]) A non-obstructing physics object that triggers an event when touched.

Methods

collideActionLauncher(myfixture, ...) The default onCollision() callback for the event pad.
draw(levelWindow) Adds this object to the level window, and thus the world.

Details

class EventPad(start, width, height, collisionAction=None, collision=None, avatar=None, separation=None, use=None, interact=None, scale=1, debug=False)[source]

Bases: actors.spriteActor.SpriteActor

Constructs an EventPad object.

Parameters:
  • start – The position (center) of the pad.
  • width – The width of the pad.
  • height – The height of the pad.
  • collisionActioncallbackFunction() called when the event pad is hit.
  • collisiononCollision() callback called when the event pad is hit by anything.
  • avatar – filename or Shape object used a the visual representation of the pad.
  • separationonSeparation() callback called when something leaves the event pad.
  • use – Function called when this pad is used after being picked up.
  • interact – Function called when the player calls use when on top of this pad.
  • scale – The scale of the visual representation of the pad.
  • debug – If True, shows the hitbox of the pad.

Methods

collideActionLauncher(myfixture, otherfixture, contact)[source]

The default onCollision() callback for the event pad.

Calls the collisionAction, or all function in collisionAction is collisionAction is a list or tuple.

Parameters:
  • myFixture – The Fixture of the object on which this collision function is installed.
  • otherFixture – The Fixture of the object colliding with the object on which this collision function was installed.
  • contact – The Contact object associated with this collision.
draw(levelWindow)[source]

Adds this object to the level window, and thus the world.

Parameters:levelWindow – A LevelWindow object.

Lantern

A latern object that reveals the fog-of-war in a limited area around the player.

Constructor

Lantern(start, working[, scale, debug, ...]) A latern object that reveals the fog-of-war in a limited area around the player.

Details

class Lantern(start, working, scale=1, debug=False, onPickup=None, use=None)[source]

Bases: actors.spriteActor.SpriteActor

Constructs a Latern object.

Parameters:
  • start – The position of the lantern.
  • working – If False, this lantern doesn’t actually work.
  • scale – The scale of the visual representation of the lantern.
  • debug – If True, shows the hitbox of the lantern.
  • onPickup – Function called when this item is picked-up.
  • use – Function called when thus item is used.

Platform

A circular platform for attaching collision or separation callbacks.

Constructor

Platform(position, radius, picture[, ...]) A circular platform for attaching collision or separation callbacks.

Details

class Platform(position, radius, picture, collision=None, separation=None, debug=False)[source]

Bases: actors.spriteActor.SpriteActor

Constructs a Platform object.

Parameters:
  • position – The position (center) of the pad.
  • radius – The radius of the platform.
  • picture – String or Shape used a the visual representation of the platform.
  • collisiononCollision() collision called when the event pad is hit by anything.
  • separationonSeparation() callback called when something leaves the event pad.
  • debug – If True, shows the hitbox of the pad.

Portal

A pair of portals that teleports robots from one end to the other.

Constructor

Portal(start, end, endAngle, costume[, ...]) A pair of portals that teleports robots from one end to the other.

Methods

onInteract(items) Implementation of the actorOnInteract() callback function for the portal.
teleportStep() The event that will actually teleport the robot.

Details

class Portal(start, end, endAngle, costume, debug=False, scale=1, useDeath=False, additionalAction=None)[source]

Bases: actors.spriteActor.SpriteActor

Constructs a Portal object.

Parameters:
  • start – The position of the portal
  • end – The position the portal will teleport its user to.
  • endAngle – The direction the user will be facing after passing through the portal
  • costume – Integer indicating wich costume to use. Customes are: 0) blue portal, 1) orange portal, 2) broken portal.
  • debug – If True, shows the hitbox of the portal.
  • scale – The scale of the visual representation of the portal.
  • useDeath – If True, use of the portal will kill the user, rather than teleporting them.
  • additionalActioncallbackFunction() called after the portal is used.

Methods

onInteract(items)[source]

Implementation of the actorOnInteract() callback function for the portal.

Parameters:items – The list of items that passed to the use function when the user interacted with this Actor.
teleportStep()[source]

The event that will actually teleport the robot.

The robot will have to be teleport in an event scheduled to the levelThread, rather than being teleported immediately, to avoid race conditions that can crash Calico.

Return: Always returns False.

Sample

A sample object that can be compared to other samples

Constructor

Sample(x, y, fileName[, code, scale]) A sample object that can be compared to other samples

Details

class Sample(x, y, fileName, code=-1, scale=0.25, **kwargs)[source]

Bases: actors.spriteActor.SpriteActor

Constructs a Sample object.

Parameters:
  • x – The x coordinate of the sample.
  • y – The y coordinate of the sample.
  • fileName – String pointing to an image to be used as the visual representation of the sample.
  • code – The value of this particular sample when tested.
  • scale – The scale of the visual representation of the sample.
  • **kwargs – See SpriteActor for the keyword arguments.

SimpleMovingNPC

Simple NPC that just moves along wayPoints.

Constructor

SimpleMovingNPC(wayPoints[, filename, ...]) Simple NPC that just moves along wayPoints.

Methods

step() Executes one step of the NPC movement.

Details

class SimpleMovingNPC(wayPoints, filename=None, visible=True, debug=False, endAction=None)[source]

Bases: actors.spriteActor.SpriteActor

Constructs a SimpleMovingNPC object.

wayPoints: List of waypoints the NPC will follow. fimename: String pointing to the file an image to be used for this NPC. visible: Whether the NPC will be visible or not. debug: If True, shows the hitbox of the NPC. endAction: callbackFunction() called when the NPC is done moving.

Methods

step()[source]

Executes one step of the NPC movement.

This function is supposed to be added to the levelThread to make the NPC move. The movement can be stopped or started by changing the value of the run attribute.

Return: Returns False when the movement is finished, True otherwise.

TestKeyPad

Test key pad object.

Constructor

TestKeyPad(loc[, wayPoints, touchAction, ...]) Test key pad object.

Methods

checkCode(foo, code) Default actorOnInteract() callback called when the user calls use when standing on the key pad.
resetTestCases() Causes all test cases to go to their default positions.
setTestCase(case) Sets the test case for the key pad.
touchCodePad(myfixture, otherfixture, contact) Default onCollision() callback called when the key pad is hit.

Details

class TestKeyPad(loc, wayPoints=None, touchAction=None, wrongCodeAction=None, correctCodeAction=None, testType=0)[source]

Constructs a TestKeyPad object.

Parameters:
  • loc – The position of the key pad.
  • waypoint – Waypoints for the key pad.
  • touchActioncallbackFunction() called when the pad is touched.
  • wrongCodeActioncallbackFunction() called when the wrong codes is provided to the key pad.
  • correctCodeActioncallbackFunction() called when the wrong codes is provided to the key pad.
  • testType – Integer indicating the type of test.

Methods

checkCode(foo, code)[source]

Default actorOnInteract() callback called when the user calls use when standing on the key pad.

Function checks if the code intered by the user is correct. If it is, it executes the correctCodeAction. Otherwise, it will call the wrongCodeAction.

Parameters:
  • foo – The actor of which the use action is called. Not used by this function.
  • code – The code passed by the user (as a list).
resetTestCases()[source]

Causes all test cases to go to their default positions.

setTestCase(case)[source]

Sets the test case for the key pad.

Parameters:case – Interger indicating the index of the case to set.
touchCodePad(myfixture, otherfixture, contact)[source]

Default onCollision() callback called when the key pad is hit.

Calls the touchAction callback if present.

Parameters:
  • myFixture – The Fixture of the object on which this collision function is installed.
  • otherFixture – The Fixture of the object colliding with the object on which this collision function was installed.
  • contact – The Contact object associated with this collision.

TestRow

Object for controlling multiple TestWall and Portal objects.

Will create a row of 5 portals: 1 entry portal and 4 exit portals.

Constructor

TestRow(position, safeEnd[, useAction]) Object for controlling multiple TestWall and Portal objects.

Methods

resetWalls() Resets the walls.
setSafePortal(safeIndex) Species which of the portals is the ‘safe’ portal that won’t kill you.

Details

class TestRow(position, safeEnd, useAction=None)[source]

Bases: object

Constructs a TestRow object.

Parameters:
  • position – The position og the test row.
  • safeEnd – Position that the portal will take the robot if the robot chooses the right portal.
  • useActioncallbackFunction() called when one of the portals is used.

Methods

resetWalls()[source]

Resets the walls.

Return: True if wall 3 is atEnd, but walls 4 and 5 are not at end.

setSafePortal(safeIndex)[source]

Species which of the portals is the ‘safe’ portal that won’t kill you.

Parameters:safeIndex – Integer index of the safe portal.

TestWall

A special wall for testing robot sensors.

Constructor

TestWall(wayPoints, width, height[, speed]) A special wall for testing robot sensors.

Methods

gotoPoint(p1, p2) Sets speed and direction of this wall for moving from waypoint p1 to waypoint p2.
step() Executes one iteration of movement for the wall.

Details

class TestWall(wayPoints, width, height, speed=10)[source]

Bases: actors.spriteActor.SpriteActor

Constructs a TestWall object.

Parameters:
  • wayPoints – List of points the wall may visit.
  • width – The widht of the wall.
  • height – The height of the wall.
  • speed – The speed with which the wall moves.

Methods

gotoPoint(p1, p2)[source]

Sets speed and direction of this wall for moving from waypoint p1 to waypoint p2.

Parameters:
  • p1 – Integer index of the first waypoint.
  • p2 – Integer index of the second waypoint.
step()[source]

Executes one iteration of movement for the wall.

This method should be scheduled to the levelThread to enable the wall to move. One scheduled, movement of the wall can be controlled with the gotoPoint() method.

Return: Always returns True.

TimerDisplay

Display showing a time counting down.

Constructor

TimerDisplay(loc[, width, height]) Display showing a time counting down.

Methods

updateTimerDisplay(e) Updates the timer display.

Details

class TimerDisplay(loc, width=75, height=50)[source]

Constructs a TimerDisplay object.

Parameters:
  • loc – The position of the timer display.
  • width – The width of the timer display.
  • height – The height of the timer display.

Methods

updateTimerDisplay(e)[source]

Updates the timer display.

Parameters:e – Event causing the timer to be updated.

TrollCompare

This is troll object that will return false for equality less than, and greater than

Constructor

TrollCompare() This is troll object that will return false for equality

Details

class TrollCompare[source]

Bases: object

This is troll object that will return false for equality less than, and greater than