|
1-24-02
REALbasic Merlin Simulator - Part 3 by
Erick Tejkowsi
Back in the late 1970's, Parker Brothers introduced a great handheld electronic game machine called Merlin.
This week we continue with Part 3 of our Merlin Simulator project and continue
adding functionality to the simulator.
Interface
If you'd like to start where we left off last week, download the project. Then, launch REALbasic
and open Window1. Drag a Timer control from the toolbar and add it to your Window1 interface.
It doesn't matter where you drag it to in the interface, since it will be invisible when the application executes.
Change the properties of the Timer to match the following image:
Add the Code
Next, double click Window1 to open its Code Editor and make sure you have all of the following properties
Then, add a new method to Window1 as follows:
Method Name:PlayGameEcho
Parameters:indx as integer
To this new method, add this code:
This method takes of the game play for the next game we are implementing for Merlin. This week's game is game number 3: Echo.
In this game, Merlin plays you a certain number of sounds, which you must replay to him. At the end of the game,
Merlin tells you how many errors you entered before repeating the exact sequence.
Now, you need to "wire" the game into the interface. This is accomplished
with the MouseUp events of the NumButton and UtilButton control arrays. Expand the NumButton
control array in the Code Editor and add this code to it:
Next, expand the UtilButton
control array in the Code Editor and add this code:
Finally, add these two lines of code to the GameThreeTimer:
numButton(0).ButtonOff
numButton(10).ButtonOff
As you probably can guess, this code turns off numButton(0) and numButton(10). Why do this? Well, Merlin momentarily
lights these two lights at the start of the game to show which keys are not allowed for a game level choice. Since they get turned on
at game startup, we use the Timer to turn them off a certain amount of time later.
Conclusion
Well, that's it for this week. Select Debug-Run to test your work. If you encounter any
difficulties with the code or don't feel like entering it all, you can
download the completed project.
See you next week!
1-22-02
REALbasic News
by Erick Tejkowsi
New Multimedia Classes
BEST Software Design has released a new suite of multimedia related classes for REALbasic. Broken up into three classes, the whole
package helps you do the following in REALbasic:
- Record audio files with Classic or Carbon Mac OS
- Play SoundFont and DLS files from your REALbasic application. This includes lots of neat features like pan, modulation, pitch bend, and even reverb.
- Navigate QTVR movies programmatically.
The three classes include demo projects that work in the REALbasic IDE. Registered users can use them in built applications as well. At 10 bucks a pop,
these classes offer some great new features for RB developers at a very low cost. Check them out! And, don't forget about our ResExcellence SoundFont and DLS tutorial.
Can We Get a Hand?
Erik Barzeski (of Cocoa Dev Central fame) is looking for some REALbasic help to convert Expression to REALbasic 4.
He says that most of the hard work is done, so if you're good at REALbasic and are wanting to dive into a quick project, contact him.
OS X Utilties
OS X Utilties has been upgraded to v1.2. This version fixes some bugs and reimplements some
functionality from past releases. It's a very handy tool for OS X developers, so don't miss it!
Sort, Sort, Sort
SortLibrary 1.6 is now available.
SortLibrary implements optimized
versions of several sorting algorithms for use by REALbasic developers.
Version 1.6 adds an ArraySorter class containing the same sorting
methods as in the module. Instead of using a Comparator object as with
global functions, ArraySorter has a Compare event which you implement in
subclasses. It turns out that this results in running time improvements
of about 5-10%, even including the cost of object creation, over the use
of global functions.
Also included in this version is improved validity checking for heapsort
and quicksort, and a few other miscellaneous improvements.
SortLibrary works on all platforms for which REALbasic compiles.
New Processes Plugin
Paul Mitchum has announced a new REALbasic plugin for your plugging enjoyment!
MacAppProcess is free and works with 68k, PPC, and Carbon.
It extends the Application class with three properties and a method:
- App.MacCreator: The creator code of your app, as reported by the Process Manager.
- App.MacFolderItem: The FolderItem used to launch your app.
- App.MacName: Your app's name, as reported by the Process Manager.
- App.MacSendToFront: Makes your app the frontmost.
|