Level Window¶
HelpPageWidget¶
Constructor
HelpPageWidget (panel, point1, point2, title, ...) |
Methods
flashButton () |
|
getClickedButton (x, y) |
|
setButtonsInvisible ([buttonDisplayNames]) |
|
setButtonsVisible ([buttonDisplayNames, ...]) |
Details
LevelWindow¶
The level window is the parent for all Scribbler Adventure levels.
The level window is the object on which you can build a Scribbler Adventure level. To create a level you’ll need to overwrite the create level function, and add statements to it that will build your level.
Constructor
LevelWindow ([levelName, gameData, parent, debug]) |
The level window is the parent for all Scribbler Adventure levels. |
Instance Attributes
conversation |
The conversation object that manages all conversations. |
debug |
Turns on debug messages |
endEvents |
The events that need to be triggered when the robot reaches the end pad. |
interactContactList |
List keeping track of all the interactable object the robot is |
levelName |
Name used in panel and window |
levelScore |
Holds current user score for the level |
maxTime |
MaxTime is 60 seconds or one minute |
parent |
Application that launched this level |
pickupContactList |
List keeping track of all the objects you can pickup that the robot is currenlty in contact with to speed-up pickup. |
printTags |
Need to iterate over calico.tags to access the keys |
queue |
Event queue that blocks the conversation |
robots |
List for storing robots |
startEvents |
The events that need to be triggered when the robot leaves the |
statusBoxHideEvent |
A singular handle to the status box hide event, such that later hide event can overwrite older ones. |
stepEvents |
The event queue |
toAdd |
The “events to add” queue to avoid concurrency issues |
vX |
X origin of viewPort |
vY |
Y origin of viewPort |
viewH |
Heigth of the updated screen area (level + ui) |
viewW |
Width of the updated screen area (level + ui) |
Methods
addActor (actor) |
Adds an actor to the world. |
addBriefShape (s[, text]) |
Adds a shape to the list of briefing shapes. |
addDecor (posOrOb[, ob, vis]) |
|
addEndEvent (event) |
Add an event to the end events. |
addEntryObject (e) |
Adds an entry object for the window to keep track of.Entry object focused considered during mouse down and key press |
addMouseDown (f) |
It’s assumed the developer knows what they are doing and are adding a proper function ‘f’ |
addObstacle (ob[, vis]) |
Helper function for adding static obstacles. |
addResponse ([portrait, text, action, sticky]) |
Convenience functions for adding responses to the conversation object. |
addStartEvent (event) |
Add an event to the start events. |
addStepEvent (event) |
Add an event to the level thread. |
addThread (thread) |
|
briefScreenClick (obj, event) |
Callback for when a briefscreen is clicked. |
buildBriefing () |
Function to be overwritten to build the briefing |
burnEvidence () |
Method for clearing the output and history. |
checkFocus () |
Helper function that iterates through the list of entry objects that could be added to this window. |
checkPassword (testPass) |
Checks if the incoming string matches the password. |
checkVariableValue () |
|
clearBriefList () |
Clears the list of briefscreens. |
clearEntryObject (e) |
Clears list of entry objects. |
clearObjectiveText () |
Sets the objective text to the empty string. |
clearResponses () |
Clears all responses from the conversation object. |
clearStepEvents () |
Clears all events. |
confirmDebugCommand (success, message) |
|
convEvent (action) |
|
convPause () |
|
convStart () |
|
convUnpause () |
|
createBriefScreen () |
Creates the briefscreen. |
createEndPad (x, y[, locked]) |
Creates an end-pad at the indicated location. |
createFog () |
Creates a ‘fog-of-war’ for the simulator. |
createLevel () |
Virtual function that should overwritten to create a level. |
createRobot (x, y, rotation) |
Creates a robot at the indicated location. |
createRobotStart (x, y, a) |
|
createStartPad (x, y) |
Creates a start-pad at the indicated location. |
deathCollide (myfixture, otherfixture, contact) |
Convience collision function you can install on custom hazards. |
debugConsole () |
Launches and an input dialog box where you can enter commands that can be used |
dismiss () |
Function that performs same action as the Dismiss button or pressing ‘b’. |
endCollide (myfixture, otherfixture, contact) |
Callback for one the robot reaches the end-pad. |
exists ([name]) |
Function to check if a variable is in scope |
flashObjective () |
|
gameThread () |
This is the main function passed to Myro |
getBriefObject () |
Function returns a Shape with text and buttons drawn on it. |
getHelpPageButtonInfo (helpWidgetIndex, ...) |
|
getI (buttonName) |
|
getR (buttonName) |
|
getScopeVariable ([name]) |
Function to retrieve variables in scope |
gotoNextLevel () |
Transitions to the next level, if possible. |
gotoPrevLevel () |
Transitions to the previous level, if possible. |
helpPageEvents (clickedPanel, event) |
Defunked function. |
hidePanel1 ([p]) |
Hide the shape that is currently set to panel 1. |
interactCollide (myfixture, otherfixture, contact) |
Collision function for objects that want to be able to interact. |
interactSeparate (myfixture, otherfixture) |
The separation function for object that want to be able to interact. |
isVisiblePanel1 () |
Checks whether panel 1 is visible. |
keyPressed (obj, event) |
Callback function for when a key is pressed. |
launchBriefScreen (index) |
Will display the indicated briefscreen on top of the game area. |
launchEndEvents () |
Called when the level ends, for whathever reason. |
launchStartEvents () |
Called when the robot leaves the starting plate. |
levelThread () |
Experiment with an event based level thread. |
levelTransition () |
All the steps required for a level transition (quit, menu, next, |
lockEndPad () |
Helper function that unlocks the end pad through the self.endPadLocked variable. |
loseGame () |
The player loses the game. |
mouseDown (obj, event) |
Callback function for when the window is clicked. |
onEndPad () |
|
onStartLevel () |
Called right before the player gains control. |
outputPrint (message[, tagNo]) |
Method for printing colored text to the output. |
panel1Click (obj, event) |
Callback for when panel 1 is clicked. |
panel2Click (obj, event) |
Callback for when panel 2 is clicked. |
panel3Click (obj, event) |
Callback for when panel 3 is clicked. |
pauseRobot (value[, index]) |
Helper function to stop the robot. |
pickup () |
Function for picking up items from the game world. |
pickupCollide (myfixture, otherfixture, contact) |
Collision function for objects that want to be able to picked up. |
pickupSeparate (myfixture, otherfixture) |
The separation function for object that want to be able to be picked up. |
printToSpeechBox (text[, portrait, ...]) |
Prints a message directly to the speech box. |
quickActor (x, y, base, \*\*kwargs) |
Convenience function for adding an actor to the world. |
quickItem (x, y, base[, description]) |
Convenience function that sets a description and pickup equal to True. |
quickLock (x, y, base, key, action[, failMsg]) |
Convenience function creates a lock, based on a key and an action. |
quitGame () |
Saves statistics and exits the game |
restartGame () |
Stops all scripts and restarts the level. |
restartGameNoStopScript () |
Version of restartGame that doesn’t stop scripts used for the restart() user command may cause calico to crash if used improperly. |
safeMove (x, y, a) |
|
safeMoveBlock (x, y, a) |
|
saveStats () |
Saves the currenlty recorded statistics to a file (I guess?) |
setBackground (back) |
Sets a background image. |
setButtonsInvisible ([buttonList]) |
|
setButtonsVisible (helpWidgetIndex[, ...]) |
|
setErrorCallback (callback) |
Adds a callback that is called whenever an error is thrown in Calico |
setForeground (fore) |
Sets a foreground image. |
setGameOver (value) |
Indicates that the game is over, for better or worse. |
setImagePanel1 (imageFileName[, show]) |
Directly set an image as the contents of panel 1. |
setObjectiveText (message[, numFlashes]) |
Sets the current objective text. |
setResponse ([portrait, text, action, sticky]) |
Convenience functions for setting responses to the conversation object. |
setShapePanel1 (s[, show, offX, offY]) |
Directly set a shape as the contents of panel 1. |
setup ([runSimulator]) |
Creates the window and starts the level. |
showPanel1 ([p]) |
Show the shape that is currently set to panel 1. |
skip () |
Function to skip dialogue. |
startRingCollideSep (myfixture, otherfixture) |
Callback for one the robot leaves the starting pad. |
stopScript () |
Stops the current script from running, if any. |
talk () |
Function for talking. |
unlockEndPad () |
Helper function that locks the end pad through the self.endPadLocked variable. |
updateClock () |
Callback that updates the clock |
use (items) |
Attempts to use the items passed by the user. |
waitForStep () |
Blocks until one iteration of events has been processed. |
winGame () |
The player wins the game. |
Details
-
class
LevelWindow
(levelName='levelName', gameData=None, parent=None, debug=False)[source]¶ Bases:
Myro.LevelObject
Creates a LevelWindow object.
Parameters: - levelName – The name of the level.
- gameData – Data that should be provided by the parent portal window.
- parent – A reference to the parent window (the calico app).
- debug – Set to True to enable certain debug statements.
Instance Attributes
-
conversation
¶ The conversation object that manages all conversations.
-
debug
¶ Turns on debug messages
-
endEvents
¶ The events that need to be triggered when the robot reaches the end pad.
-
interactContactList
¶ List keeping track of all the interactable object the robot is currenlty in contact with to speed-up interactions
-
levelName
¶ Name used in panel and window
-
levelScore
¶ Holds current user score for the level
-
maxTime
¶ MaxTime is 60 seconds or one minute
-
parent
¶ Application that launched this level
-
pickupContactList
¶ List keeping track of all the objects you can pickup that the robot is currenlty in contact with to speed-up pickup.
-
printTags
¶ Need to iterate over calico.tags to access the keys
-
queue
¶ Event queue that blocks the conversation
-
robots
¶ List for storing robots
-
startEvents
¶ The events that need to be triggered when the robot leaves the starting pad
-
statusBoxHideEvent
¶ A singular handle to the status box hide event, such that later hide event can overwrite older ones.
-
stepEvents
¶ The event queue
-
toAdd
¶ The “events to add” queue to avoid concurrency issues
-
vX
¶ X origin of viewPort
-
vY
¶ Y origin of viewPort
-
viewH
¶ Heigth of the updated screen area (level + ui)
-
viewW
¶ Width of the updated screen area (level + ui)
Methods
-
addActor
(actor)[source]¶ Adds an actor to the world.
Parameters: actor – The actor to be added. Returns: A reference to the added actor.
-
addBriefShape
(s, text=None)[source]¶ Adds a shape to the list of briefing shapes.
Parameters: - s – A reference to the shape to be added.
- text – Sets the text of the button associated with this briefing.
-
addEntryObject
(e)[source]¶ Adds an entry object for the window to keep track of.Entry object focused considered during mouse down and key press
-
addMouseDown
(f)[source]¶ It’s assumed the developer knows what they are doing and are adding a proper function ‘f’ with that has the fields (obj,event)
-
addObstacle
(ob, vis=True)[source]¶ Helper function for adding static obstacles.
Parameters: ob – Shape to be added as a static objec to the simulator. Returns: A reference to the added shape.
-
addResponse
(portrait=None, text='', action=None, sticky=False)[source]¶ Convenience functions for adding responses to the conversation object.
Parameters: - portrait – The portrait to be show with the string. Can be a Calico Picture object or a string representing the location of an image file to be loaded. A default Scribbler image is shown if None is passed.
- text – The text to be printed (str).
- sticky – Whether this text should be repeated when there is no more conversation left.
-
briefScreenClick
(obj, event)[source]¶ Callback for when a briefscreen is clicked.
Should probably not be overwritten, as it handles basic button presses.
Parameters: - obj – A pointer to the level window object.
- event – The event triggering this callback. Can be read to discover which button was clicked, and where the mouse pointer was.
-
burnEvidence
()[source]¶ Method for clearing the output and history. Useful when someone enters a password and you want to clear you’re tracks.
-
checkFocus
()[source]¶ Helper function that iterates through the list of entry objects that could be added to this window. If any of the foucs for the entries are true than the focus for the main window is set to False. Mainly used to prevent the mouse and key presses from interrupting the text entries
-
checkPassword
(testPass)[source]¶ Checks if the incoming string matches the password. Ends the game if password is correct. Launches an incorrect password message if incorrect.”
-
clearBriefList
()[source]¶ Clears the list of briefscreens.
Should probably not be called from within a level.
-
clearEntryObject
(e)[source]¶ Clears list of entry objects. Entry object focused considered during mouse down and key press
-
createEndPad
(x, y, locked=False)[source]¶ Creates an end-pad at the indicated location.
Parameters: - x – The x-coordinate of the end-pad.
- y – The y-coordinate of the end-pad.
Returns: A reference to the end pad.
-
createFog
()[source]¶ Creates a ‘fog-of-war’ for the simulator.
Returns: A reference to the fog-of-war image.
-
createRobot
(x, y, rotation)[source]¶ Creates a robot at the indicated location.
Parameters: - x – The x-coordinate of the robot.
- y – The y-coordinate of the robot.
- rotation – The rotation of the robot.
-
createStartPad
(x, y)[source]¶ Creates a start-pad at the indicated location.
Parameters: - x – The x-coordinate of the start-pad.
- y – The y-coordinate of the start-pad.
Returns: A reference to the start pad.
-
deathCollide
(myfixture, otherfixture, contact)[source]¶ Convience collision function you can install on custom hazards.
Parameters: - myfixture – The object that registered the collision callback.
- otherfixture – The object that collided with us.
- contact – The Farseer Contact holding contact information.
Returns: True. Returning anything else may cause weird bugs.
-
debugConsole
()[source]¶ Launches and an input dialog box where you can enter commands that can be used to debug and quickly move around the levels
-
dismiss
()[source]¶ Function that performs same action as the Dismiss button or pressing ‘b’. Dismisses/hides whatever is on Panel1
-
endCollide
(myfixture, otherfixture, contact)[source]¶ Callback for one the robot reaches the end-pad.
Parameters: - myfixture – Should be the end-pad.
- otherfixture – Should be the robot.
- contact – The Farseer Contact holding contact information.
Returns: True. Returning anything else may cause weird bugs.
-
gameThread
()[source]¶ This is the main function passed to Myro it calls the update clock and a another virtual function that can be used in different levels
-
helpPageEvents
(clickedPanel, event)[source]¶ Defunked function. Kept around for examples of code. RV.
Callback for when panel 3 is clicked.
Should probably not be overwritten, as it handles basic button presses.
Parameters: - clickedPanel – A pointer to the panel that was clicked.
- event – The event triggering this callback. Can be read to discover which button was clicked, and where the mouse pointer was.
-
hidePanel1
(p=None)[source]¶ Hide the shape that is currently set to panel 1.
Parameters: p – Optional pointer to the shape currently displayed in panel 1. Providing this pointer slighlty increases performance.
-
interactCollide
(myfixture, otherfixture, contact)[source]¶ Collision function for objects that want to be able to interact.
Parameters: - myfixture – The object that registered the collision callback.
- otherfixture – The object that collided with us.
- contact – The Farseer Contact holding contact information.
Returns: True. Returning anything else may cause weird bugs.
-
interactSeparate
(myfixture, otherfixture)[source]¶ The separation function for object that want to be able to interact.
While not as important as the collision function, registering the seperation callback OnSeperation, can speed up the simulation by throwing away unnecessary contacts.
Parameters: - myfixture – The object that registered the separation callback.
- otherfixture – The object that separated from us.
-
isVisiblePanel1
()[source]¶ Checks whether panel 1 is visible.
Returns: True if panel 1 is visible, and False otherwise.
-
keyPressed
(obj, event)[source]¶ Callback function for when a key is pressed.
This function can be overwritten to implement custom keystrokes, but do not forget to call this function at the end (LevelWindow.keyPressed), otherwise basic keystrokes like closing the window or restarting the level will no longer work.
Parameters: - obj – A pointer to the level window object.
- event – The event triggering this callback. Can be read to discover which key was pressed.
-
launchBriefScreen
(index)[source]¶ Will display the indicated briefscreen on top of the game area.
Parameters: index – Integer indicating the index of the briefscreen to be shown.
-
levelTransition
()[source]¶ All the steps required for a level transition (quit, menu, next, prev, and restart) that have to be done to save data and to prevent crashing
-
lockEndPad
()[source]¶ Helper function that unlocks the end pad through the self.endPadLocked variable. This variable can be used to lock the end pad until the user accomplishes some task in the level.
-
loseGame
()[source]¶ The player loses the game.
Short for setGameOver(-1). This can be easier to use than setGameOver(-1) because it does not require a lambda when used in a callback function.
-
mouseDown
(obj, event)[source]¶ Callback function for when the window is clicked.
Overwrite this function to execute a specific action when the user clicks the screen.
Parameters: - obj – A pointer to the screen being clicked on, which should be the level window itself.
- event – The event triggering this callback. Can be read to discover which button was clicked, and where the mouse pointer was.
-
outputPrint
(message, tagNo=0)[source]¶ Method for printing colored text to the output.
Parameters: - message – String containing the message to be displayed.
- tagNo – Integer indicating in which of the predetermined colors the text will be printed.
-
panel1Click
(obj, event)[source]¶ Callback for when panel 1 is clicked.
Can be overwritten to launch a cusomt event when the game area is clicked.
Parameters: - obj – A pointer to the level window object.
- event – The event triggering this callback. Can be read to discover which button was clicked, and where the mouse pointer was.
-
panel2Click
(obj, event)[source]¶ Callback for when panel 2 is clicked.
Should probably not be overwritten, as it handles basic button presses.
Parameters: - obj – A pointer to the level window object.
- event – The event triggering this callback. Can be read to discover which button was clicked, and where the mouse pointer was.
-
panel3Click
(obj, event)[source]¶ Callback for when panel 3 is clicked.
Should probably not be overwritten, as it handles basic button presses.
Parameters: - obj – A pointer to the level window object.
- event – The event triggering this callback. Can be read to discover which button was clicked, and where the mouse pointer was.
-
pauseRobot
(value, index=None)[source]¶ Helper function to stop the robot.
Parameters: - value – True to pause the robot, False to unpause.
- index – The index of the robot to be paused. If no index is provided all robots are paused.
-
pickup
()[source]¶ Function for picking up items from the game world.
Returns: The item that was picked up, or a string containing an error message if the pickup failed.
-
pickupCollide
(myfixture, otherfixture, contact)[source]¶ Collision function for objects that want to be able to picked up.
Parameters: - myfixture – The object that registered the collision callback.
- otherfixture – The object that collided with us.
- contact – The Farseer Contact holding contact information.
Returns: True. Returning anything else may cause weird bugs.
-
pickupSeparate
(myfixture, otherfixture)[source]¶ The separation function for object that want to be able to be picked up.
While not as important as the collision function, registering the seperation callback OnSeperation, can speed up the simulation by throwing away unnecessary contacts.
Parameters: - myfixture – The object that registered the separation callback.
- otherfixture – The object that separated from us.
-
printToSpeechBox
(text, portrait=None, closeOnMove=True, closeOnTime=0, hasNext=False)[source]¶ Prints a message directly to the speech box.
Parameters: - text – The text to be printed (str)
- portrait – The portrait to be show with the string. Can be a Calico Picture object or a string representing the location of an image file to be loaded. A default Scribbler image is shown if None is passed.
- closeOnMove – If true, an on move event will be scheduled that closes the box as soon as the robot moves.
- closeOnTime – If true, a timed event will be scheduled that closes the box after a certain number of ticks. Can not be used with ‘closeOnMove’. If both options are true, only the onMoveEvent will be scheduled.
- hasNext – Boolean the will tell the speechbox if there is more conversation left. Should be false if this is a one-of message.
-
quickActor
(x, y, base, **kwargs)[source]¶ Convenience function for adding an actor to the world.
QuickActor will create an actor based on the ‘base’ that is passed to the function. If the base is a string, it is assumed that you wish to create a picture actor, with the string being a directory and filename. If the base is a list, it is assumed you want to create a Sprite actor, where every element in the list is a string pointing to a directory and filename, each becoming a frame for the Sprite. If the base is a shape, it is assumed you want to create a Shape actor, with the Shape being the body of the actor.
Parameters: - x – The x position for the actor.
- y – The y position for the actor.
- base – The base on which the actor should be created.
- kwargs – Keyword arguments passed direclty to the actor.
Returns: A reference to the created actor.
-
quickItem
(x, y, base, description=None, **kwargs)[source]¶ Convenience function that sets a description and pickup equal to True.
Parameters: - x – The x position for the actor.
- y – The y position for the actor.
- base – The base on which the actor should be created.
- description – The description that is returned when the item is printed.
- kwargs – Keyword arguments passed direclty to the actor.
Returns: A reference to the created actor.
-
quickLock
(x, y, base, key, action, failMsg='The key does not fit.', **kwargs)[source]¶ Convenience function creates a lock, based on a key and an action.
Parameters: - x – The x position for the actor.
- y – The y position for the actor.
- base – The base on which the actor should be created.
- key – The key necessary to use this lock.
- action – The action that is executed whent he key fits the lock.
- failMsg – The message that is displayed when the key does not fit the lock.
- kwargs – Keyword arguments passed direclty to the actor.
Returns: A reference to the created actor.
-
restartGameNoStopScript
()[source]¶ Version of restartGame that doesn’t stop scripts used for the restart() user command may cause calico to crash if used improperly. RV.
-
setBackground
(back)[source]¶ Sets a background image.
Parameters: back – String pointing towards an image file (jpg, png). Returns: A reference to the background image, or None if the function was unsuccessful.
-
setErrorCallback
(callback)[source]¶ Adds a callback that is called whenever an error is thrown in Calico The callback must have an argument for the exception thrown and the initial command Exp: def expCallback(e,command):
-
setForeground
(fore)[source]¶ Sets a foreground image.
Should probably not be used, as it may severly hurt performance.
Parameters: fore – String pointing towards an image file (jpg, png). Returns: A reference to the foreground image, or None if the function was unsuccessful.
-
setGameOver
(value)[source]¶ Indicates that the game is over, for better or worse.
Parameters: value – 1 indicates that the player has won the game, -1 indicates that the player has lost the game.
-
setImagePanel1
(imageFileName, show=True)[source]¶ Directly set an image as the contents of panel 1.
Parameters: - imageFileName – The name of an image file (png, jpg)
- show – If True, the image will be displayed immediately
-
setObjectiveText
(message, numFlashes=0)[source]¶ Sets the current objective text.
Parameters: message – A string containing the message to be displayed.
-
setResponse
(portrait=None, text='', action=None, sticky=False)[source]¶ Convenience functions for setting responses to the conversation object.
The only difference between adding and setting responses for the conversation object is that, if you set a response for the conversation object, it will immedidiately become the next response, skipping all other responses, whereas if you add a response, a use will have to go through all previous responses before getting the new one.
Parameters: - portrait – The portrait to be show with the string. Can be a Calico Picture object or a string representing the location of an image file to be loaded. A default Scribbler image is shown if None is passed.
- text – The text to be printed (str).
- sticky – Whether this text should be repeated when there is no more conversation left.
-
setShapePanel1
(s, show=True, offX=None, offY=None)[source]¶ Directly set a shape as the contents of panel 1.
Parameters: - imageFileName – The name of an image file (png, jpg)
- show – If True, the shape will be displayed immediately
-
setup
(runSimulator=True)[source]¶ Creates the window and starts the level.
Parameters: runSimulator – if true, the simulator is started.
-
showPanel1
(p=None)[source]¶ Show the shape that is currently set to panel 1.
Parameters: p – Optional pointer to the shape currently displayed in panel 1. Providing this pointer slighlty increases performance.
-
startRingCollideSep
(myfixture, otherfixture)[source]¶ Callback for one the robot leaves the starting pad.
Parameters: - myfixture – Should be the starting pad.
- otherfixture – Should be the robot.
-
talk
()[source]¶ Function for talking.
Returns: Whatever is set to be returned, which is usually a string containing the spoken text.
-
unlockEndPad
()[source]¶ Helper function that locks the end pad through the self.endPadLocked variable. This variable can be used to lock the end pad until the user accomplishes some task in the level.
-
use
(items)[source]¶ Attempts to use the items passed by the user.
Parameters: items – The items passed by the used, which can literaly be anything. Returns: This function may return arbitrary objects based on whatever the use function did or did not accomplish. If the use function failed, a string containing an error message is returned.