Archive for April, 2008
Silverlight MP3 problem
Posted by Joshua Smyth (Admin) in Silverlight, Software Development, WebDevelopment on April 29, 2008
I came across this odd bug in silverlight 2.0 Beta. For some reason some of my MP3 files were playing fine and some of my MP3 files were not playing at all. I was stumped for nearly an hour as to why this might be the case. The only difference between the files was the sample rate.
It seems that silverlight 2.0 doesn’t like playing MP3 files that used to be 22khz wav files. Changing the sample rate on my wavs to 44hz before using LAME to encode them to MP3s allowed me to playback the sound files as normal.
A little strange, guess I should report this bug to Microsoft – Maybe with broadband no one uses 22khz audio samples anymore.
Attack of the Meeplings 2.0 Released!
Posted by Joshua Smyth (Admin) in Meeplings, myProjects on April 28, 2008
I’ve just finished a new version of Attack of the Meeplings – Play it here!
So Whats New?
Added an ‘Easy’ difficulty level for those who are not quite experts at playing these types of games. The downside to playing on easy is that your score will not be included in the highscore table. But it should be enough to train yourself for the normal difficulty.
Heat seeking enemies now have turning arcs so they don’t change direction instantly.
And finally – Improved the performance of the game / Fixed some minor bugs.
Edit – Forgot to add that pressing A will toggle autofire on/off
Crappy Laptop Keyboard
Posted by Joshua Smyth (Admin) in Meeplings, myProjects on April 25, 2008
Apparently computer manufacturers are always looking at ways to cut costs. My Laptop keyboard cannot register if I press the left arrow+down arrow+z keys at the same time – This makes playing Attack of the Meeplings very difficult!
However, I’m planning to release version 2.0 of AOTM within the next week, it will have an autofire option, instead of holding down the z key – Just press A once to enable autofire mode, c’mon you pretty much fire all the time anyway, so why not have that automated for you.
Version 2.0 will also feature a much needed easy difficulty mode
I’m not sure if I should build a separate highscore table for easy mode, or just not allow posting highscores if you play on easy…
The other improvement to the game will be to get rid of the occasional random pause that happens sometimes. It looks like I’m making the java garbage collector do too much work with adding/removing hundreds of enemies/bullets/particles etc into and out of ArrayLists – As you can imagine the memory manager has a bit of a hard time keeping up.
Look for Attack of the Meeplings 2.0 coming soon!
How to play sound files in Silverlight 2.0
Posted by Joshua Smyth (Admin) in Silverlight, WebDevelopment on April 24, 2008
I finally got around to installing Visual Studio 2008 and the Silverlight 2.0 add-ons. My inital impressions were running high as I started a new project and mucked around with the XAML to create the obligatory Hello World App. I even managed to deploy my hello world app on my webserver – Yes, Apache can host Silverlight projects, pretty cool huh!
Everything was going fine until I tried to play some audio files. Since my project is heavily based around playing audio this would not do, not until I solved the problem of playing sound files that is!
First of all Silverlight doesn’t seem to support .wav files. But it will happily play .MP3s and .WMAs – Guess they figured .wavs were outdated and no one uses them anymore?
The class that plays audio files (and video files) is called a MediaElement, which takes a URI and points it towards a sound or video file. However, I found that the MediaElement would not start downloading the file until .play() was called – Which added a bit of delay the first time the file was played – I wanted to pre-load my sound files and here is the best way I found to do it:
Note: Silverlight 2.0 is still in Beta as I’m writing this, so things may change before final release.
Part 1 – Add the sound file as a resource
First of all add the file you want as a resource in your project. In Visual Studio 2008 right click on your Silverlight Project->Add->Existing Item
Then Select your file and under the Build Action property set it to ‘Resource’ - If you have a web project along with your silverlight project make sure you add the resource in your SL project and not to your web project.
If you do this when you build the project your file will be incorporated into your Silverlight application.
Part 2 – Play the Resource File
In order to play your newly added resource first include the line:
using System.Windows.Resources;
You will now be able to access streams to your resources. Use this code to create a MediaElement and get it to play an audio file.
MediaElement m = new MediaElement();
StreamResourceInfo sri = Application.getResourceStream(new Uri(“applicationName;component/myMp3.mp3″));
// Where applicationName = the name of your project and myMp3 is the name of the resource file you added
m.SetSource(sri.Stream); // Sets the MediaElement to point at the added resource
LayoutRoot.Children.Add(m); // Adds the MediaElement to the canvas, if you don’t do this then the sound seems to only play once (possible bug in silverlight?)
m.Play(); // Plays the sound
m.Position = System.TimeSpan.FromSeconds(0); // Reset the position of the sound so it is ready to play again
New Laptop
Posted by Joshua Smyth (Admin) in Offtopic / Real Life on April 13, 2008
I got myself a new laptop last week. I’ve never owned a laptop before and it’s taken a little getting used to (I refuse to use that silly mouse pad thingy and instead plug an external USB mouse in.) But at least now I have something to use between my (sometimes very large) gaps between classes.
I’ve also been in bed tied up with the flu, which means that I have a whole week worth of uni to catch up on. Its mid-semester break at the moment, so I at least have the opportunity, It just means that my Silverlight project has to be delayed
My laptop is an Acer Aspire 5520 which has an AMD Turion 2.0 ghz 64×2 cpu with 2GB of RAM a 160GB Harddrive and a Geforce 7000M videocard and Windows Vista Home Premium.
Some observations…
First of all Windows Vista is really cool. I don’t understand why people have been dissing it. (Actually I do, its more than likely the high system requirements) But it runs like a dream with 2GB of ram, multi-tasks extremely well and it looks really pretty.
Secondly the word laptop is a bit of a misnomer, while you can sit in bed and type with it on your lap – It’s just not that comfortable, a desk is still recommended. Also, the thing eats through its battery life faster than cookie monster in a biscuit factory – esp when trying to play games. I try to keep it plugged in as much as possible.
Thirdly, the Geforce 7000M supports graphics shader 3 – Which means that I can play some of the newer games that I’ve missed out on. Being a laptop graphics card its no where near as powerful as its desktop counterpart, but it does the job. I bought a copy of Civ IV Completete Edition to go with my laptop. Hey, theres no point in buying a new toy if you don’t get to see what it can do. Unfortunately theres that whole catching up on missed uni lectures thing that I have to do…
Monthly Projects
Posted by Joshua Smyth (Admin) in myProjects on April 3, 2008
A little while ago I decided to start doing monthly projects. Attack of the Meeplings was the first of such projects.
I’ve got another idea for another game that I could do in around a month, a sort of maze based shooter. But because I’m about to finish uni in June, I have decided that I need to add something to my portfolio that isn’t a game. I’m getting a new laptop soon, which means that I can work on things during my (sometimes very long) intervals between lectures.
So I’m going to have a go at learning Silverlight, Microsofts new browser technology. I’ve got an idea for a fairly short but pretty cool project to do, so once I get my laptop setup with Visual Studio 2008 I’m going to get started down that path.
I’ll be blogging about what I discover and my progress with the project, so others who might be thinking about trying out Silverlight can get a little insight into what it might involve, and what features are present (and perhaps missing) at this stage in the Silverlight life cycle.