Tuesday, 22 September 2009

Birdie Music

I spent a whole day looking for royalty free music for the birdie game. Everything was either copyrighted or unsuitable, so decided to attempt writing some new music for it instead. I had the notion of using the keyboard to write something so I did a search on Google and eventually found an amazing program called the Tune Smithy.
I wrote a piece of music and uploaded it but it was over 6MBs and bits of it had my hubby climbing the walls. Maybe it was the high pitched flute part... anyway it was taking too long to load so I edited it down to an 18 second loop. I think it works better and I like the way the bird tweets take up the melody.
I started on the ending animation (hence the flock of birdies) when my niece, who has a 5 year old, suggested I let the child tidy the leaves up as they like to feel they are doing something. Thinking it over, this made sense, so I implemented it. I would have liked to add a sweeping brush cursor but you can't change the cursor in a Processing applet online. I suppose I could have just added an image next to the cursor...
So now I need to add a dialog and an ending for when the leaves have been picked up.

Monday, 14 September 2009

State, Activity, Bird Class and Minim

I'm recovering from a bout of flu and finding it even harder than usual, to concentrate on the logic needed to control the workflow.
At the moment I'm using booleans to control the states in the Birdie game but its getting very unwieldy and I'm beginning to think I need to factor out the bird animation into a new Bird class.
I will need to add a sound file of a bird going tweet. This should improve feedback when the birdie is clicked. The weather today is awful so I don't rate my chances of recording this today as very high. How on earth do I record this on my laptop? Does it have its own built in mike? Do I even have Audacity installed to edit the sound if I ever succeed in capturing it? Can Minim be used for the sound in the Processing applet without causing Out of Memory errors?
So my task for the week is to make a Bird class and add sound.
As I now use Processing 1.0.6 Minim is one of the standard libraries available so I didn't even need to download and unzip it.
I used the RecordPad Sound Recorder in Windows Vista and said "tweet tweet". Then I used some of the effects available to make the sound not sound like me going "tweet tweet". This produced a very strange tweety sound but lets face it, this is one very strange bird anyway!
I added my sound file to the sketch and edited the code provided by the Minim Quick Start Instructions. It worked first time and needed no more research! Thanks to the Minim team, when I remember the cartwheels I had to perform with threading and preloading to provide the sound in Solundria... this is a very welcome feature!
That Bird class really needs to be created now, as the sound is only playing the first time the birdie is clicked. I think the birdie state needs more work.
...
I added a Birdie class and this made handling the states in the game easier. I used the rewind function, after each play, so the sound now works fine. There's now a kinda score thing for each time the birdie is found.
Next week's tasks will be to add an endgame scene. I will need to find some suitable music too. The Birdie Song or Rockin Robin would've been nice but are likely copyrighted.
Latest version of Catch the Birdie. Use refresh to see latest version or start new game. feedback welcome...

Saturday, 5 September 2009

Catch The Birdie

I've started to write a game applet for Solundria using Processing.
My two year old grandson, Ally came up to visit for a week and so I decided to make a game for him.
He is a cheerful little fellow but sometimes quite fearless. He somehow managed to go diving out the backdoor, giving himself quite a nasty black eye. Then he took the doorstop and dropped it on his foot! My glasses went missing for days and then he heroically picked them up from behind a chair and handed them to me.
He went out to play in the back garden and was shouting at the birds to come down, so he could play with them, and so I thought granny would help with that.
One of the problems with writing an applet is that you don't know the size available to the game in the client's browser. I couldn't find an easy way of implementing this, so I just set the size to a default size of 800. I set the height to be 100 pixels smaller than an actual height of 600 to allow for toolbars etc.

Folder Permissions

One of the annoyances of working in Vista is the stifling user permissions. Although I have tried to set the permissions of the processing folder to be not read only, numerous times, it keeps changing them back. This means that every time I export I have to remember to untick read only both in the project folder and the applet folder. If this isn't done I get errors about the images not being found and not being able to delete the applet folder.

Applet Index Page

Every time the project was exported the index page was being overwritten again. This made the background colour, text, width and height of the applet reset to their default values. This was really annoying as I suspect the jar file had a different id number every time it was exported which caused other errors to occur. I was so peeved about having to edit the file every time that I did a search on the Processing site. There I found some great info that means I dont have to do this anymore. There is a file called applet.html in the lib folder of processing. You just need to copy this to your project's root folder and edit it with your preferred values. Now when I export as an applet the index file has the my preferred values and this has saved me a mountain of time!

GifAnimation Library

I made a stop frame animated gif of a birdie using Draw Plus X2. I also made three leaf images, although I'm not very pleased with them. I added these to the sketch folder using Sketch-Add File. I downloaded the Gif Animation library and unzipped it to Processing's Library folder. To use it you just add import gifAnimation.*; to the top of the sketch. I declared it globally as Gif myAnimation; Then to set it with the animated gif and start it off I used:
myAnimation = new Gif(this, "birdie.gif");
myAnimation.loop();
Now it can be drawn anywhere using:
image(myAnimation, xPos , yPos);

The Leaf Class

Adding the Font and Text Dialogs

Mouse Control and State

To be continued....