| |||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||
Print This Article REALbasic University: Column 075
Book Review: Learning REALbasic Through Applications
There's a fascinating new REALbasic book out there which you may not have discovered. If you're new to REALbasic or to programming, you might find the unique approach to teaching in Learning REALbasic Through Applications by Clayton E. Crooks II just what you need. Its method of teaching you about REALbasic is similar to that of REALbasic University, in the sense that we build real, practical applications and teach you as part of that process. Learning REALbasic Through Applications is similar, except it's in book format. Each chapter is devoted to creating a different kind of application. There are 22 chapters in the book, though a few cheat and just have you build a demo instead of a real program. Among the lessons you build an MP3 player, a calcuator, a screen saver, a movie database, a slot machine game, and an encryption program. You also create programs that use sprites, OpenGL and 3D graphics, text-to-speech, and others. The book comes with a CD that includes demos of REALbasic and all the book's projects, so you don't have to type in any code. The broad variety of programs is excellent: you almost certainly will find a project here that's similar to something you're wanting to do. For instance, if you haven't worked with 3D graphics before, you could experiment with the 3D graphics project and learn some techniques you could use in your own programs. However, the majority of the projects are rather basic. Most have minimal interfaces and are of the "takes ten minutes to create" variety. There's very little here you'd want to use in real life: these are just samples of things you can do with REAlbasic. For example, here's what the MP3 player looks like: ![]() This is the fancy (sarcasm alert) music playing program: ![]() The graphics of the sprite example make my woeful Shooting Gallery project seem sophisticated: Still, I like the step-by-step teaching style and feel the approach is excellent for REALbasic beginners. Intermediate users might find some projects helpful, especially in areas they're unfamiliar with, but some will wish for more advanced tips and solutions to more complicated problems. Advanced users will find little here they do not already know. The book is 304 pages plus about 50 pages of appendixes and the index. Some of the appendixes are helpful, such as the ASCII chart, internet references, REALbasic quick reference, and a list of text encodings values. The index is competent, but not great (it's only 7 pages). I prefer a more comprehensive index, with duplicates, as my brain apparently stores stuff in the wrong manner and most indexes don't list the term under the one I look up. (For example, REALbasic University isn't listed under "R" but under "A" as Applelinks REALbasic University. That's fine, but why not do both? After all, if I remember RBU is on Applelinks, I can probably find the site without looking it up in the book.) For new programmers or those new to REALbasic, this book is an excellent starter, though you'll grow out of it quickly. It's also a little expensive. Since it's not a reference book, you'll rarely need to go back to it again, unless there are projects you skipped the first time that you later need. It goes well as a companion book to Matt Neuburg's REALbasic: The Definitive Guide. I'd love to see a similar book geared toward advanced users with much more complicated applications.
Next WeekSomething new!
LettersToday we've got a question from Rob involving animating graphics with the timer control:
Good question, Rob! I believe this is simply a limitation of the Timer control. It's well known that Timers aren't super reliable: they give a lot of time to operating system and if the system is busy, they may not execute exactly on time. To test this, I wrote a little application in which a circle and a square race each other across a canvas. (This actually turns out to be a fun game! Try to predict which object will win.) ![]() Within this application, I use two different methods of animation. For the first, I use a timer control. There's a slider control that lets you set the speed of the animation. At its fastest setting, a Timer's period (how often it executes) is set to 1, which should mean that the timer is run every millisecond (1,000th of a second). However, if you try this, you'll see that even at that setting timer animation is slow. If you click on the second button ("Race with Non-Timer Animation"), we use a tight loop to control the speed of animation:
When you use this method, the racers run at a blur -- much faster than the timer method. And yet you'll see, we've included a delay within the main loop so that even here the animation can't happen faster than 1000 frames per second. Theoretically, the two methods should produce animation of similar speeds, but they do not. On my 500-mhz PowerBook G4, I had to change the 1000 in the while microseconds - tt < 1000 line to 100,000 before it was slower than the timer method! This just says to me that timers are lower priority controls. They're useful, but not reliable if you need exact timing. Even with the second method there is no guarantee that you'll actually be able to do timing's exactly, but it's certainly faster than using a timer. My recommendation is that you create your own timer-like system using the microseconds function to fire the animation as often as you'd like (such as 60 frames per second). However, the disadvantage to this approach is that your routine would be a CPU-hog, not giving time to the system or other aspects of your program. Depending on what you are doing, that might be okay. If not, perhaps you could spin it off in a thread. If you want the source for this racing demo, you can grab it here. About the Column REALbasic University is a weekly instructional column on programming with REALbasic and is brought to you by REALbasic Developer, the magazine for REALbasic programmers. Each week we answer select reader questions, and we're always open to ideas for future columns. Send your questions to . (Keep your questions simple and specific. General queries like "How do I write my own web browser?" will be neglected.) Your question won't be answered immediately, but will be answered in a future column. (If you don't want your correspondence published, just be sure to indicate that when you write. Otherwise it's fair game.) About the Author See the REALbasic University Archives
REALbasic University contents ©2001-2004 by Marc Zeedar and REALbasic Developer. All Rights Reserved.
| |||||||||||||||||||||||||||||||||||