Windows Phone at MS Days

Windows Phone Audience

Did my second session of the day on Windows Phone. This is some of the audience before the start. Thanks for being another great audience folks.  Everything worked, in some cases eventually. My “party piece du-jour” was to start the program on the device rather than the emulator. I did it pretty much every time, in the end the people watching were spotting it before I did.

I got a question about Windows Phone Marketplace during the talk and I said I’d follow up on these pages. As I understand it this is as much a legal as a technical issue, in terms of how the law works in Bulgaria. At the moment you have to go through another publisher I’m afraid, which means people like http://appamundi.com/Publishing/ or http://www.yallaapps.com/.

You can find all the content from the lecture, including slides and demos, here.

After I’d finished I had a wander round and took some pictures of the conference.

Speakers Room

Who knows what goes on behind these doors….

Banner

Nice Banner

Windows Phone Banner

Windows Phone, Bulgarian style

Movie Showings

The conference is being held in a huge cinema multiplex. If you hurry you might make one of the 10:00 showings..

Lights

Nice Lights

Fun at Microsoft Days

Sofia Badge

Got my conference badge this morning, along with a very fancy pin which marks me out as a speaker at the conference. I got in and got set up and then went and watched one of the keynote sessions. The first part was in Bulgarian, which was pretty much lost on me I’m afraid, but the main talk was by Mingfei Yan, who talked about the cloud and how it is going to change everything. I reckon all of our students should see this, lots of food for thought about the way that computing is going.

Mingfei Car Juggling

At one point she showed some augmented reality, where a 3D car model was streamed down onto a marker on a piece of paper. Great fun.

Then it was time for my Micro Framework session.

Micro Framework Audience

Everything worked and I had a great audience. This is some of them as the room filled up. Some great questions and a round of applause at the end. Although it was probably for the robot.

I’ve put all the resources for the talk here.

On now to experts lounge and then the Windows Phone talk.

Hello Bulgaria

Staircase

Flew out to Sofia today to give some sessions at Microsoft Days 2011. The journey out was complicated slightly by a two hour delay on the  flight from Amsterdam to Sofia. They didn’t actually announce “The flight is being held up while we put the seat in front of Rob into the ‘permanently reclined’ position” but I think that is probably what happened.

Anyhoo, I made it in the nick of time for our trip to a local university Damien Caro and myself met up with a bunch of students and, once we managed to make our laptops talk to the projector, we had a great time. I gave a demonstration of my silly robot and a Windows Phone game involving cheese. Damien talked about the Cloud which is going to change our lives.

Students2

I took a picture just as everyone was leaving. Thanks for being a great audience folks.

Opening Up

Starting the speed dating

Then. straight after our lecture, it was time to head off to a trendy city centre bar for some ‘speed dating’ with journalists. This was one of the most intense things I’ve ever done. We had five minutes with each person and we were shouting introductions, questions and answers over each other. Great fun, although I ended up a little hoarse by the end.

Awesome Handbag

One journalist had this amazing handbag.

Sofia Night

After that it was time to head back to the hotel and make sure that my little robot knows his lines for tomorrow.

Three Thing Game Judging Videos

Platform Expo

If you want to see what the teams came up with at the end of the game event, and how well students can function after sleep deprivation and lots of caffeine and sugar, then they are all now available on youtube. Just search for threethinggame These videos are in High Definition, as I’m sure you will spot.

We had Paul Ross from Criterion Games here today (they are the studio behind titles such as Burnout) to give a talk on game development and chat with our students. This was the cue for lots of scrambling for Windows Phone devices so that some of our team members could show him the things they had made during the competition. By all accounts he was very impressed, which is nice.

Anyone who missed out on taking part in the competition this time round needn’t worry. Three Thing Game will be back next semester.

Three Thing Game Judging at Platform Expo

Three Thing Game Finals
Yours truly with “To Be Confirmed”, whose take on “Warrior Koalas on Mars” got them a Windows Phone each. Good work guys. Now put it in the Windows Phone Marketplace.

We put 60 or so bleary eyed students on a double decker bus and drove them down to Platform Expo for the judging.

Three Thing Game Finals

They must be judges, they’ve got clipboards…

All the group watched the judging videos (which will be online soon) and asked a bunch of questions about the entries.  At noon we announced the winners. The students then had an hour or so to explore the expo (or collapse somewhere) and then the trusty bus brought them back to campus.

Every team stayed the course this time, and we had playable content from all of them. Some of the teams did amazing things with some truly tricky starting points and they stuck to their subjects really well. I’m terrifically impressed with all the students, who served as ambassadors for the university at every level. We even had a bunch of volunteers who had given up a chunk of their Sunday to come and demonstrate the 3DS to people at the expo.

Jon and I did talks about 3D displays and Kinect that were well received and well attended (although I’m not sure how coherent we were only having had 3 hours sleep in the last 36).

Great fun, if exhausting. I’ve put a load of pictures up on Flickr (search for the tag threethinggame) and I’ll be uploading the judging videos on Monday.

Three Thing Game Team Videos

I’ve been round all the teams and done brief videos of how they are getting on:

Awesome Source

Bi Winning
Blank
Bottled Games
Brayshaw’s Bandits

CMYK
E for idiots
Fez Productions
Fresh Pot
Left 4 Dev
Pixel Bomb
So Fear
To Be Confirmed
Troll
Two and a Half Life

I’ve also put captions on the pictures on Flickr..

http://www.flickr.com/search/?q=threethinggame

I’ll do this all again later tonight, and see what progress we’ve made.

Three Thing Game Gets Going

Three Thing Games Teams

These are the teams at the start of the competition. I’ll do another of everyone at the end…..

Three Thing Game Prizes

Awesome prizes, I think this explains the good turnout.

We’ve launched the game development competition today. We have over 60 students involved.  They are all busily in the development phase of their games at the moment, just a few hours left now…..

If you want to see what they are up to we have a variety of webcam feeds for you to choose from:

http://www.ustream.tv/channel/twenty-four-hour-game-dev

http://www.ustream.tv/channel/24-hour-game-dev

http://www.ustream.tv/channel/fresh-pot

I’m putting regular picture updates on Flickr and there will be videos later when I’ve been round and chatted to all the teams. And everyone is tweeting as well. The tag threethinggame will get you where you want to be.

Pex for Windows Phone 7

image

I write programs for fun. Seriously. I’ve got games at home still in the box because I’d rather fiddle with some C# on Windows Phone than try to kill demons/drive cars/fly spaceships etc etc.

Pex is a great way to play games while you write programs. I’ve played with the web version before and now I can do that on my phone too. You can download Pex4fun and play along too. If you have any interest in brushing up your C# smarts in a fun (and portable) way then get this on your phone. It’s free too.

Using Vectors to Position Draw actions in XNA

I did a session yesterday for Three Thing Game (work progressing nicely) about positioning objects in XNA using vectors. I said I’d post the content, and here it is.

The basis of the chat was that for maximum object drawing satisfaction you should use vectors to position objects you want to draw  on the screen. I then had all kinds of fun with Visual Studio IntelliSense (bless its cotton socks) trying to be “helpful” as I filled in the more complicated draw calls.

The simplest version of XNA drawing uses a Rectangle to specify the position and size of the item to be drawn. This works well, but it does have some disadvantages, the most notable of which is that you can’t rotate sprites when you draw them this way. Another significant problem is that the position of a rectangle is specified by an integer value, which means that if you want to make something which changing in position by less than one pixel per update (which is often the case) then you can’t just use a rectangle to record its position.  Vectors contain floating point values, which give you much more precise object positioning.

So, my vector powered sprite starts off as two things:

Texture2D logo;
Vector2 logoPosition;

The logo gives the image I want to draw, and the logoPosition says where. I can use a very simple drawing call to draw using this if I like:

spriteBatch.Draw(logo, logoPosition, Color.Red);

This draws the logo using a red light at the position held in the vector. The position is given as the top left hand corner of the texture, so this call works very like the use of a Rectangle to position the texture, where the X and Y properties of the Rectangle give the position of the top left hand corner of the object.  The difference is that with this draw operation the texture is always drawn full size. If you use a Rectangle you can give width and height values that will get XNA to scale and transform your texture when it is drawn. If you want to do this kind of thing you have to use the monster version of Draw, which lets you specify all kinds of fun stuff:

spriteBatch.Draw(
    logo,           // Texture
    logoPosition,   // Position
    null,           // Source area in texture to draw
                    // null for all of it
    Color.Blue,    // draw colour
    logoRotation,   // rotation angle
    new Vector2(logo.Width / 2.0f, logo.Height / 2.0f),
                    // origin of the draw
    1,              // scale value
    SpriteEffects.None, // can flip the sprite
    0);             //  layerdepth

 

This version of Draw lets you do pretty much anything. You still give it a texture and a position but you also give it a whole heap more. We can look at some of these:

Source Area: this is the region of the source texture you want to draw. This lets you have a single sheet of sprites and then pull the particular one you want to draw from that sheet. Alternatively you can have a huge map texture and then just display part of it. If you put null there this means the entire texture is used as the source,  which is what I’ve done.

Rotation Angle: this is really nice. You can rotate your sprites when you draw them. The angle is given in radians - which means that the value 2 * pi (6.28 or so) is a complete revolution.

Origin of the Draw: OK. This bit is fiddly. The origin is given in coordinates relative to the source texture (i.e. if the texture is 100 pixels square the value 50,50 would mean the centre of the sprite). I do a simple sum to get this centre position in my example. This is the point at which the draw and rotation behaviours will act. This means that if you do both draw operations with the position vector holding the same value you get an effect like the one you see below:

image

The red logo is being drawn with the vector giving the top left hand corner of the draw operation. The blue logo is being drawn with the origin set to the middle of the texture as shown above.  To make things even more interesting I’ve rotated the logo a bit. Having  a draw action that works on the middle of the sprite is actually very useful if you want to centre draws around things like touch positions. The thing to remember is that the units for this value are relative to the texture, not the drawing coordinates.

Scale Value: This scales the draw. If you want to stretch the image in X or Y there is another version of Draw where this is given as a vector where you can express different X and Y scale values.

Sprite Effects: You can flip or mirror the sprite with this.

Layer Depth: Normally XNA will layer things in the order they are drawn, in other words new draws will lay on top of older ones. If you want to control the layering of your drawing you can set a layer depth for a draw action.  A depth of 0 means the front and 1 means the back. If you use the simple version of spriteBatch.Begin() these depth values are ignored, they only have an effect if you select an appropriate SpriteSortMode value.

Three Thing Game Gets Started

Audience1

Left hand of the audience

Audience2

Right hand of the audience.

We kick started our “Three Thing Game” game development competition today.  Everyone seemed quite happy, at least until they got their “things”. You can see all the teams and what they ended up with, over at www.threethinggame.com

The students will be showing off the results of their “Red Eye 24 Hour Development Phase” at Platform Expo on Sunday. Come down to the KC Stadium and find out what kind of results you get from “sleep deprived programming”.  The winning team will all get shiny new Windows Phone 7 devices, I just hope they are awake enough to notice they have won.

An Open Blog Post to Adobe and HP

image
This will not print correctly.

I am not normally given to ranting. I consider myself quite a balanced soul really, and where computers are concerned I usually have enough good nature and technical skill to deal with most problems that come my way. But some things are just beyond the pale. I would like to think that to think that computers generally help to make people’s lives easier and when I find something that is so crass, stupid and ignorant as this I feel I have to write something.

The problem is a simple one. I have a brand new copy of Photoshop Elements 9, a recent model HP printer (C7280) and a desire to take a picture out of the former and print it on the latter. So that it fills an A4 page. And appears on the paper as it does on the screen. This does not happen. It does not even seem to be possible. I can get close, but the picture is always cropped or scaled so that it doesn’t fit. I was printing pictures with my Amiga around 20 years ago with fewer problems then I’m having now. I had the same trouble with an older version of Photoshop and in my ignorance I assumed that they would have fixed this by now because someone would have got back to them during their extensive testing to tell them they had made a product that was fundamentally useless in this respect.

I’ve just wasted two pages of expensive paper, and a lot of expensive ink, printing the wrong thing in the wrong place. The reason I wasted the second page was that I asked the printer driver to show me the page before it printed and it ignored me.

Photoshop will let me print collages, albums and all kinds of stuff I don’t want. The HP printer is clever enough to tell me that the ink has run out in a cartridge before it actually has. This technology is state of the art, and it stinks. I’m now reduced to carefully scaling printouts wrong so that they print out right. There is probably a fundamental setting that I’ve missed somewhere that could be adjusted to make all this work, but I’ve not found it yet.  And if there is, why isn’t it set on by default?

Anyone like me who has been unlucky enough to invest in these useless products has my sympathy and an apology on behalf of those of us who have been promoting computers as a way to make things easier.

Red Nose Day Pictures

RedNose

Some of the audience, watching me code under pressure in rhyme

Jamie Wins a Phone

Jamie picks up his winnings. Don’t I have big elbows?

Agnes Picks up her phone

Agnes was the winning bidder of the second phone. This is where the money changed hands….

We’ve done the final tally and it turns out that adding together the sponsorship money, the cash taken on the day and phone auction we ended up raising over 1,260 pounds for Comic Relief. Great stuff. Thanks to everyone who helped. To Microsoft for providing some lovely prizes and an awesome phone, to Adam and Mike for sterling technical support and the audience, for laughing in most of the right places.

You can find a video of most of the event here: I’m trimming the live recording together at the moment, should be available soon. If you have any pictures of the occasion then I’d love to see them. Put them on Flickr tagged Robinrhyme.

Many apologies to the hapless lecturer in the session before mine, who must have been perplexed as to why there was a huge number of students in silly hats waiting outside, and a nervous bloke trying to get in and set up some cameras and stuff…

And now I’ve got a First Year tutorial. Not in rhyme, thank goodness.

Getting a Windows Phone App to Market

Red Nose Game Screenshot
Now you really have to get a copy….

My Red Nose Day application has finally made it to the Windows Phone Marketplace. In spite of my efforts. It is the first fully developed game that I’ve put out there, and getting it out there was quite an experience, especially when it kept failing certification. So that other people can learn from this, and so that I don’t do the same stupid things again, here are some hints for preparing a game for certification.

Consider the Pause and Tombstoning behaviour at the start

I got so carried away with my game ideas that I ended up leaving all the code that dealt with pause and resume, and what happens when the game is tombstoned, until the very end. The plan was to add this in a couple of hours. This did not happen. I spent a lot of time messing around and finally ended up with something that was not correct according to the Marketplace requirements. Foolish me. I had used what I thought was a rather nice fading effect between screens, but this caused me endless grief when I realised that I might get tombstoned during a fade. And the game structure had a huge bearing on what I had to do when the user drops out of a game, something that they can do at any moment on the phone.  Next time I’ll design the gameplay with a view to the fact that my game might get stopped at any instant. 

This should extend to making game objects “tombstone aware”. In other words, don’t try and impose the phone behaviours on objects in your game, make sure that the objects themselves can deal with suddenly having to stop and resume.  This is something that game developers that have not written a lot of mobile games might find new and a bit scary, but it turns out that if the objects are built with this in from the start it makes the game a lot more reliable. My code tried to knock the game engine into a particular state for tombstoning, what I should have done is have states and messages specifically concerned with suspend and resume.

For those that don’t know what “tombstoning” is, it is the recognition of the unpleasant fact that a program on a mobile device is always vulnerable to an interruption that results in the program being stopped or, worst case, removed entirely from memory. Windows Phone programs deal with tombstoning by responding to the various messages that are sent in these situations and the Windows Phone Marketplace has strict standards on proper behaviour.

These are messages are not hard to deal with, but you have to get your head properly around the way they work. You must also not assume (like I did) that Silverlight and XNA tombstone messages are exactly the same.

Make sure the Back button always does something

I made the an assumption that in some screens there was “no need” for a back button, since the player wouldn’t want to go back to the previous screen in that situation. Stupid, stupid, stupid. I tell my students that every time you make an assumption, somewhere a specification fairy dies. I should have read the Application Certification Requirements that state emphatically that the Back button must always do something, either return to a previous screen, exit the app if at the “front page” or pause gameplay.

Make sure that the first page a user arrives at is a sensible one

I was very proud of the way that after a restart my game always went back to the same page it was stopped from. Unfortunately this is wrong. If the user starts a new copy of the game (as opposed to resumes it) then it must go to a starting screen where the Back button can be used to exit the game.  Again, I’d not read the requirements in enough detail to appreciate this.

Make good use of the Testing Reports

The test reports are great. They are actually written by someone who has played your game and will give you a simple sequence of steps that illustrate the broken parts. So work through them carefully. I found that I could  follow their steps and then, having seen the fault, it was quite easy for me to drop into the code and put it right. One tiny thing, when you re-submit an application you lose the reports from the previous run, so if you want to know what you had to fix you should save the pdf files when you have read them.

Keep Moving Towards the Happy Ending

The Marketplace people are great. Don’t think of certification as a bunch of obstacles that you must pass through on the way to getting to market. Instead you should regard the certification team as a bunch of folks who are tying to make you produce a solution that works the same way as all the others on the Windows Phone, and doesn’t do anything stupid.

Anyhoo, search Windows Phone Marketplace for Red Nose Game and let me know what you think…

Kinect and Home Sweet Home

Kinect and Home Sweet Home

Tom and Laurie from Home Sweet Home came into the department so that we could work on our setup for Platform Expo, which is coming up real fast. We had Paul Murphy from BBC Look North along to take some film as well, which was nice. We showed what we had done and most of it worked. To see all of it working you could come along to the Platform Expo a week on Sunday (the 27th) and even drive the music and video yourself.

http://platformexpos.com/

Red Nose Day Streaming Fun

Red Nose Day Streaming

I’ve made a special poster to celebrate…

I’ve sorted out the streaming of the Red Nose Day lecture in rhyme. You should be able to join in the fun and games here:

http://www.ustream.tv/channel/rob-miles-red-nose-day/

The channel will go live on Friday 18th of March at 12:15 GMT.

Be there, join in the fun and win prizes.

And don’t forget to sponsor me:

http://my.rednoseday.com/robmiles

One lucky sponsor will win a Windows Phone device.

Keeping a Cool Lap

image

I’ve never been that bothered about laptop coolers. These tray type things sit underneath the laptop and have fans that help your portable computer nice and cool. However, I picked up a Microsoft one recently and it actually turns out to be quite useful. Not so much for the fan, which I don’t really think a properly designed computer should need, but for the way it keeps the machine off your lap. The Microsoft one also has a foot that you can use to bring a portable to a better angle to use on a desk.

All things considered  there are worse ways to spend 13 pounds or so.