![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() Getting the latest source codeThe latest source code is held on Sourceforge in a CVS (concurrent versions system) repository. You can get the source and libraries from the downloads page or from the cvs repository. Here we deal with the CVS method. Using the download page's links are simpler but it is more difficult to keep your local copy synchronised with the code under development.CVS vs zipped source fileThere are two options for getting the source code. The simplest is to download the zipped source file. Winzip can be used to extract the files. The zipped source file can be obtained from the download page.The second option is to do a cvs checkout of the source code and then to do updates. The advantage of using cvs is that it is more up to date and it is simpler to merge updates from the cvs repository into your local source files. The zipped source file is a brute force overwrite of what you have, whereas the cvs method merges only the changes into your files and also gives you tools to sync individual files that you have changed that have also been changed in the cvs. What you needTo be able to compile the freeplay code you will need the libraries from the download page as well as the source from this page.Setting up a CVS clientIf you are like me and had never used a CVS before you are probably daunted by this 'barrier'. Don't worry, I will show you the easy steps needed to get the code, it is no more difficult than using a gui ftp client. I have kept the code tree simple, for my own sanity. There are no branches and other complications.There are several options here, from a hard core command line client to native code gui options (WinCVS/MacCVS) to pure Java clients (jCVS). I looked at a few and have settled for SmartCVS. It is a free, pure java client, that in my limited experience seemed to have the best feel. Even though it is pure java, on my windows box it installed, is launched, and runs like a native code program. I will only explain how to use SmartCVS, other programs should be similar. Once you have downloaded SmartCvs and installed it, go to Project->Checkout... Fill in the dialog box as below.
You need to change the 'Checkout into' field.You will be prompted for a password, there is no need to enter one, just keep clicking. My directory structure looks like this. / freeplay : : src freeplay runtime editor images library : com cg theater utilities : :Put the path to the freeplay directory when you checkout the 'src' module.
Everything in the src directory and below will be installed.
Code submissionBecause you have checked the code out of the cvs as an anonymous user you will not be allowed to commit any changes you make back into the cvs. Please email them to me and I will merge them into the code base.If it becomes clear that you are providing regular updates then I will set you up as a member of the Chrongears project on Sourceforge and you can then commit changes directly to the cvs. Unfortunately it is necessary to take these basic precautions to prevent malicious submission of buggy code. Software overviewThe big pictureFreeplay consists of two main sections, the game/lesson authoring program (Freeplay) and the runtime code (runtime). The metaphor used by Freeplay is that of a stage performance. There are scenes, actors, props, directors, scripts and so on. Creating a lesson consists of defining these components and how they interact. Eventually there will be a comprehensive library of components and new lessons can be quickly constructed by selecting the appropriate items from the library.A Freeplay lesson is structured as a tree of nodes where each node has a corresponding java class. This tree structure is what the lesson author works with and it is shown in the Freeplay GUI. The root node represents the play itself. Below that are nodes for each scene, which in turn have nodes representing the props in the scene, the scripts used to control the action in the scene and so on. Below the root node are other nodes that hold global items, such as the actors (who may appear in a number of scenes), sounds and music, messages and the startup script. I'm only going to deal with how Freeplay is extended using java. The jython scripting language can subclass the java classes and and so create new nodes as well, but that is a document for another time. Extending Freeplay consists mainly of creating new nodes that can be placed in the tree. The most common type of node is a 'prop', that is, an object that is added to a scene. A prop is pretty much self contained. It is typically a java class that exposes its properties through getter and setter methods (e.g. getName() and setName()). It may also have other methods for performing actions, such as move(). As the author of a prop class you do not have to worry how it interacts with other props or actors, the jython scripts tie everything together and they are written by the play's author. Freeplay uses the Chronogears package to provide the low level services. These are mainly the sprite based graphics, sound capability and some utility functions, such as a simple image editor. A sprite is the basic graphic object. For example, a chair in a scene would ultimately be represented by a sprite. Sprites are often, but not always, a bitmapped graphic image. Each sprite has its own renderer which determains how it appears. Chronogears defines various renderers each with their own capabilities. For example, static images, animated images, starwars text scrollers etc. Writing a propNote:This information a little vague, on purpose. Some of the details will change and there will be extra requirements, which are not yet specified. Unfortunately this is the disadvantage of using pre-alpha code.Like other nodes in the play's tree a prop has three modes of operation. a) It may be present in the tree but essentially idle, b) the user can double click the node in the tree which possibly displays the cusomization editor for the prop, and c) the prop is in runtime mode. The runtime actions are contained in a separate class. Typically a prop is written by creating two files in the freeplay.library.props directory/package. For example to create a blackboard prop that can be used in a classroom.
BlackboardNode.java
This should extend PropNode. For a very simplistic prop the only methods that must be implemented
are
The
In our example there is a suitable renderer for edit time, ie the CgRectangleRenderer.
But no renderer is suitable for the run time display of a blackboard. It is a design decision
whether the
The BlackboardProp.java
This class should extend Prop. Beside the constructor the only method that must be written is
The It seems that Chronogears could do with a new renderer that is a graphics canvas. The blackboard prop can then simply write onto this canvas to emulate a blackboard. Props in the future could use this renderer as well, for example a graphs prop could draw on the canvas. It could be considered to be a mini screen. An interesting extension would be to show an entire play on the canvas, ie, a play within a play, but that is for the future.
Create a new renderer in the com.cg.theater directory. Call it CgCanvasRenderer and it should
extend CgRenderer. Only two methods are absolutely required.
Easier said than done! Where does the 'required image' come from? One technique would be to create a
All that remains now is for BlackboardProp to provide a few useful methods to write to the image. For
example a
The prop needs to be tested. The way I normally do is to modify the Wizard.java class. In the method
|