Monday, November 10, 2014

Memory Game Built Using LiveCode



How good is your memory?

Here is a little LiveCode example project based on the old memory game that requires that you repeat a specific pattern. The game begins by clicking the start button and will continue incrementing up until you make a mistake. How high can you go? I pretty much bomb out at 7 or 8 steps.

This LiveCode example works both as a desktop application or as a iOS mobile application. The scripts/code for this project live in the “Start” button, the Card script, and the colorful game buttons: one, two, three, and four. The card script contains the CheckProgress command which determines whether the player is correct or incorrect. It also contains, essentially, a matching series of code that the desktop version of the Start button uses, but incorporates the iOS specific commands for mobile. If you compare the iOS code in the Card script, and the desktop app code within the Start button, you will notice some similarities.

The musical notes were created in Apple’s Garageband and saved as mp3 and wav files. The mp3 files are referenced from within the iOS package (they are included as individual files in the apps sandbox) in order to play and the wav files are imbedded into the application for playback in the desktop version. (MP3 files were converted to wav files using the OSX terminial application afconvert.) You will notice differences between the desktop code and the iOS mobile code.

Finally, to address different screen resolutions on both an iPad and an iPhone, it uses the “fullScreenMode function within LiveCode, a relatively new addition to the development tool, to make adjusting screen resolutions automatic. The application will automatically resize itself to fit within the devices screen resolution. It is one line of code within a preOpenStack call: set the fullScreenMode of this stack to “ExactFit.” That’s it.

The Memory Game project file is available here: Download .

Here is a short YouTube video explaining more about the process of creating the memory game example with LiveCode and a peak at the code:



No comments: