Genesis
Every application starts somewhere whether from a blank template or a sample, in this case I was inspired by the Datagram sample for Windows 8
This sample demonstrates the basics of the DatagramSocket class using the networking features provided by the Windows Runtime. The client component of the sample creates a UDP socket, uses the socket to send and receive data, and closes the socket. The server component of the sample creates a UDP socket to listen for incoming network packets, receives incoming UDP packets from the client, sends data to the client, and closes the socket.
|
I wanted to create a game, many of my apps are apps, I keep saying I want to make more games, and then a bunch more apps come out somehow, i want to make a game. I'm going to make a game. Yeah.
Communication Breakdown
Once I saw text travel across the network from phone to PC I knew I could easily use this to make Windows Phone the controller of game pieces in a game running on Windows 8. In practice however, the problem is UDP has been pretty flaky and I’m going to need to make the communication channel more robust. We’re not talking the occasional lost packet, it can be mass chaos! For whatever reason UDP messages are sometimes not received or sent by any or all of the devices in various combinations including nothing at all, and working perfectly. Sometimes temporarily or permanently failing or working. By changing the port and address of the UDP channel it can most times help. So before I release this I need to make an optimal channel finding algorithm or otherwise solve this issue. I brought my own wireless router to the hackathon to run my game on, and rightly so since it wasn’t working as well on the Microsoft guest wireless. It seems to work better on unsecure wifi than secure but I don't really know what the cause is yet. Point being, If the network failed, that would have been the end of my demo.
Currently I am supporting up to 16 players but I've yet to do that in practice. I might make it open to more players or less depending on how I find things are working under those loads. Still learning what the limits of UDP will be.
Currently I am supporting up to 16 players but I've yet to do that in practice. I might make it open to more players or less depending on how I find things are working under those loads. Still learning what the limits of UDP will be.
Chosen Path to the Game Loop
Developing games for Windows 8 starts with a choice among 3 paths for Windows 8 Game development:
· HTML5/JS/CSS3
· C++,C#,VB/XAML
· C++ w/ DirectX
I chose to use C#/XAML for Run and Shoot. I am very familiar with web programming but I use my Windows Phone and Windows 8 endeavors to stretch my limits. I’m not totally unfamiliar though, I have used C#/XAML for many Windows Phone Apps and I have a few Silverlight/XNA games on that platform as well. I used the CompositionTarget.Rendering event to manage my Game Loop.
Game Board, Battle Grids, and Player Controls
Run and Shoot has a 20 by 11 grid of tiles that follow the silhouette and spacing of Windows 8. Thus allowing pixel perfect scaling across the entire range of device resolutions with fixed layout scaling and the Viewbox control. I’m considering the adaptive layout scaling for the future to add more tiles to the game board on larger resolutions. Check out the Guidelines for scaling for more information on Fixed vs Adaptive layouts on Windows 8.
The player control commands are sent over UDP from Windows Phone to Windows 8 by a companion controller app . When a player launches the app on their phone and clicks Play, a join message is sent via UDP and a response is broadcast with the assigned player ID information. At this point the Windows Phone app presents game controller buttons to the player in the same color of their game piece and can begin moving and shooting. Sound Effects are emitted from the phone when the player moves or shoots, and additional sound effects will be played from the Windows 8 game board this creates a pretty fun gaming environment as you hear "Pew Pew Pew" coming from all over the place.
The controllers are a work in progress they are currently just buttons so there is no multitouch. I play to implement multitouch so you can run and shoot simultaneously and let people hold down the buttons as well for continuous shooting or movement. Vibrations will also be introduced for some added impact.
Settings, Privacy Policy, About, and How To Play
You can’t talk about Windows 8 without Charms so we’ll start with the games offerings in the Settings charm. Music Settings will allow for the selection of background music for gameplay from a set of default offerings. Voice settings will allow for the accent selection on the voice-over game announcer, where you can make it sound British, Canadian, American, Japanese etc. as it makes the play by play call of the game action. Privacy Policy is important for any application which accesses the internet and your app will not pass certification without it. Be sure to check the Certification Requirements and the changelog at the bottom before submitting your app. Windows Store requirements are still changing so be aware. Make sure you offer some branding of your Privacy Policy such as your logo, so that it is clear what application is offering this policy. Many of the features available via Charms are system offerings so you want to make sure that your users have clarity, so include your logo. An About page is just as important in establishing confidence among the users of your application, it gives you a great place to advertise your greatness or just let people know what they need to know. I also included a How To Play page on the Settings charm, I’ll probably bring this off somewhere else as I get more complex instructions for my game.
Belly On Up to the App Bar
The App Bar is a great way to keep controls and chrome off screen and keep the focus on the content, in this case the game play. When playing my game the App Bar can be collapsed and kept off screen, but come back easily to allow the players to complete some common tasks. I have pause/play button which allows for time outs. Battle Grids can be selected by a group of buttons in the App Bar that position obstacles on the game board that players will need to run and shoot around. Currently we have an open battle grid with no obstacles, a solid wall, a x shape, and a series of poles. Finally there is a Pin button in the app Bar that allows Battle grids to be pinned to the Start Screen as Secondary Tiles.
Speaking of Tiles
The primary app tile supports both the square and wide configurations allowing the user the most control and flexibility the display of their start screen. As mention, Secondary Tiles are available for quick access to a specific battle grid. Both the Primary and Secondary tiles are Live Tiles , again in square and wide format, that will be populated with the picture of the last winner and a short message from them in which they can boast of their winnings or more generic leaderboard information. This makes Run and Shoot feel connected and alive, encouraging players to come back for more lest they be stuck with their opponents boasting on their start screen!
Share To Contract Target
I implemented this Share To contract in my app without fully thinking through the use case. Part of the hackathon criteria is the Windows 8 features it uses so i was trying to hit as many as possible. I started thinking that players would be able to pass url’s of MP3’s they would want to listen to, however that is more sharing from PC to PC than sharing within one PC app to app as the Share To contract enables. So it’s not PC to PC but this still enables you to share the MP3 URL from the internet with Run and Shoot, which can then be used as background music. This led me to consider the File Picker contract as a way of leveraging a users local music library as I'm not sure this Share To use case I implemented is a good experience. Wait, yes I am, it is not a good experience.
File Picker Contract, Game Developers Delight?
So why would a game developer be excited about the filepicker contract in Windows 8? As a game developer it is my responsibility to secure licensing for any music and images I use in my games. With the File Picker Contract I can allow my user to select a music file(s) to play as the background music for gameplay. Ever wondered how Pink Floyd’s the wall matched up with that one level in Zelda? Shoot it up in Halo with Skrillex and DeadMou5 playing in the background. This won’t be right for every game, but it’s an exciting thought to give your players the choice & open up entire music libraries for use in your games, royalty free.
Play To contract
This is my favorite contract in Windows 8. Someone who has seen a lot of apps told me this was the first app they had seen using DLNA, but so far all 4 apps I’ve made for Windows 8 make use of Play To. It is very simple to implement, I have done it with HTML/JS and with C#/XAML and with either one you get an awesome feature that lets you escape the bounds of the PC for just a few lines of code. For my game I allow the game background music to be played on any DLNA enabled audio device on the network. The user needs to select the target audio device via the Devices charm and then the background music plays on that device until disconnected. If you have a killer stereo in the room, you don’t need to sit there and listen to the game music coming off a tablet. Get that rich gaming experience. This is a no brainer to me, if your app displays pictures, plays video, or has audio you simply must consider implementing Play To!!! Audio,Video, and Pictures can be sent via DLNA to devices that will accept the content bounded only by your imagination.
Stay tuned, I plan to blog about PlayTo and share the secrets I have learned about it, I did say it was my favorite. If there is anything bad I have to say about PlayTo is that DLNA devices seem to be hard to come by, I hope the Windows 8 launch is accompanied by Nokia play 360 style speakers with DLNA or something.
Fast and Fluid
Wherever I may Roam
This is Hackathon
Competing in Hackathons is pretty fun stuff, I enjoy seeing other peoples creations and the little bit of competition. There were 3 winners of this Hackathon and I was one of them! Woo hoo! So I get $500 and a Windows tablet, likely a Samsung Series 7 Slate that I will promptly install Windows 8 upon. They tallied up the stats and the three winners had 124, 121, and 121 points so the competition was very close. I have to say I was also really impressed with the 2 other winners apps and was proud to be among them. Even among the apps that weren't winners there was hardly a dud among them, there were a few non-developers making their first apps, a number of people coming from other platforms, plus there were several personal stories of inspiration for apps where developers whose lives had been touched were looking for ways to make that experience somehow easier or more surmountable for everyone else going forward. That's amazing and so are these folks.
One of the winners was a Course organization app for Educators which would allow them to manage their courses, students, and projects. It really made use of Windows 8 to take what could be pretty some pretty complex sets of info and he had it making groups and organizing the info in some really great views – awesome information architecture that’s going shine on Windows 8. The other winner was a github client of sorts for Windows 8 that was done a young developer probably somewhere in the 14-16 year old range. DreamSpark, BizSpark, Express Editions, all sorts of programs reaching out, I think Microsoft is doing a great job investing in the future. There are so many opportunities for young (and old) developers and the information has never been more available. I’ve seen a couple instances of some young developers creating some really cool stuff, the future is bright!
At the end of the day somebody made some comment and I learned the guy I was sitting next to, an hour and a half away from my house, lives just a couple of blocks away from me. It’s a small world after all! He’s been looking to revive the NJ User group community which has pretty much floundered over the years. Despite being the most densely populated state in the country, our community leaks out into NYC and Philadelphia areas and NJ itself gets no play. But this is how it is in everything see: NY Giants, NY Jets, Brooklyn Nets.
How can I develop for Windows 8?
If I've got you all excited and you are ready to build your own Windows 8 apps there is a great upcoming opportunity in NYC called 30 to launch. Many of you may have seen the online 30 to launch programs or the programs for Windows Phone. This is different. This is a 4 week in-person event that i participated in back in June/July that they are doing again starting each Thursday starting October 4th. You can earn a chance to win an XBOX/Kinect bundle and better yet build an app for Windows Store. Don't worry, if you're not in the NYC area there are plenty of Windows 8 events going on around the world. There is also plenty of material available online http://www.windowsuserexperiencetraining.com