My PhotoBruno Brás Silva

09, April 1986

info@brunosilva.net

Sintra Lisbon Portugal

Category: Programming

Multiplatform Games in XNA - Preprocessor Directives

Posted on 7:25pm 6/22/2008 by Bruno Silva in .NET, Programming, Visual Studio, XBox 360, XNA

You probably already know that developing a game that runs both in XBox 360 and Windows is possible and pretty manageable using XNA Game Studio. If you start developing your game for Windows (which is great to compile/debug your code more quickly), you can then duplicate that project as an XBox 360 game. The same files will be used, but during compilation, the assemblies of XNA Framework that are used are chosen based on the target platform.

Create Copy of Project fot XBox 360

Developing a game for both platforms isn’t that trivial. There are a lot of functionalities that are exclusive to each platform. For instance, the Gamercard integration that I talked about in an earlier post, only works in XBox 360. In the other hand, since XNA games targeting Windows are pure .NET managed code, you can use whatever .NET libraries you want (such as WiimoteLib :) )

If you have a game that you want to compile to both platforms, but which has slight differences, you can use the C# Preprocessor Directives. When you create an XBox 360 project, the XBOX and XBOX360 conditional compilation symbols are used by the preprocessor.

XBox 360 Project Properties

Those symbols can be used to create conditions that make the preprocessor able to choose which lines of code of a file to compile. The example bellow is pretty self-explanatory.

Preprocessor Directives

If you compile this game targeting the XBox 360 you’ll get a blue background, otherwise you’ll get a red background.

This is not a XNA or XNA Game Studio feature, but this was the first time I needed to use such feature. More information about C# Preprocessor Directives are available at MSDN.

XNA - Getting GamerCard Info in Xbox 360

Posted on 5:30pm 6/12/2008 by Bruno Silva in .NET, Programming, XBox 360, XNA

Xbox 360 - GamerCard

One nice XNA feature is the ability to manage Xbox 360 users gamer data. This way you can access your gamercard information which include your name, avatar, achievements, played games and list of friend among other things. How can you do that?

In the Initialize method of your game you must add a specific component into the game, in order to prepare the game to access the data.

XNA Gamercard Manipulation

Since while the Initialize and LoadContent methods are executed, the gamer data is not available yet, you must access it in the Update method. There you can check if a variable is set, and if it is not, you load the gamercard information. Be careful, you must not load the gamer data in every iterations of the game loop. Your Xbox will hang if you do that… It is an expensive operation. Try to load this data only one time or so during the game lifetime.

XNA Gamercard Manipulation

This example show your gamer picture in the screen, followed by some of your informations such as your gamer tag.

XNA Gamercard Manipulation

You can download the full source code and deploy it into your Xbox 360 console and give it a try. (I’ve written before about how to get a free XNA Creators Club Membership in order to allow XNA deploying).

Xbox 360 Wireless Gaming Receiver + Wireless GamePad + Guitar Hero

Posted on 9:07pm 6/11/2008 by Bruno Silva in Games, Programming, Software, Utilities, XBox 360, XNA

A equipa PizzaShoot continua o intrincado processo de desenvolvimento de um jogo de elevado nível! :-P

Temos disponível mais um vídeo. Desta vez demonstramos com é possível ligar acessórios wireless da Xbox 360 ao PC através do Wireless Gaming Receiver for Windows. Demonstramos também como utilizar o Input Reporter (disponível no XNA Creators Club) para testar o input não só do gamepad wireless, como também da guitarra que acompanha o Guitar Hero 3! Isto porque a guitarra não passa de um comando com uma disposição diferente dos botões (e com um acelerómetro mapeado nos triggers do comando normal).

Os developers de jogos em XNA ficam então com um leque de possibilidades ainda mais abrangente.


Video: Connect X360 Wireless devices to PC

———————– ENGLISH VERSION ———————–

Although the video is in Portuguese, I want to leave the main message to all the potential worldwide readers of this blog. If you connect your Xbox 360 guitar to your PC (a wireless or wired guitar) you can use it as a X-Box 360 gamepad. Use Input Reporter to find out the correspondence between each device buttons. Wireless Gaming Receiver for Windows it the accessory that you need to connect Xbox 360 wireless accessories to your PC.

Deploy de XNA na Xbox 360

Posted on 9:49pm 6/10/2008 by Bruno Silva in Games, Programming, Web, XBox 360, XNA

Um pequeno vídeo caseiro só para dar a ideia do processo. Gravado durante uma tarde de desenvolvimento e testes do PizzaShoot! :)


Video: XNA Game Studio Deploy X-Box 360

Dream Build Play - Free XNA Creators Club Membership!

Posted on 4:48pm 6/09/2008 by Bruno Silva in Events, Games, Programming, Web, XBox 360, XNA

Dream Build Play

Great news!!! For all the Portuguese folks, it is a nice resource for XNA Pizza Night! Now you can deploy your XNA game on your Xbox 360 for free.

Don’t forget that XNA Pizza Night is getting closer! Register in Microsoft Portugal website, and get your game ready until 24th June.

BizTalk Business Rules Engine - Vocabulary Get and Set

Posted on 2:57pm 5/22/2008 by Bruno Silva in Programming

During the last couple of days I’ve been exploring BizTalk 2006 Business Rules Engine for a college assignment.

The objective is calculating the total cost of a travel. The input is the number of days the customer was staying in the destination, and the number of touristic spots he wanted to visit. The business rules defined the price per night of the stay and the price per visit. These values added to the flight cost gives us the total cost of the travel.

There is a nice tutorial about the BizTalk 2004 version of the rule composer which is quite similar to the 2006 version (at least in the UI). After some search I was unable to find an answer to my particular problem (was it that obvious?… read further and tell me).

I wanted to calculate the cost per visit and cost per night within the policy (I wanted to set these values) and I also wanted to calculate the total cost of the travel based on those variables (by getting their values).

(I am using an XML file as input which has the elements I talked about before)

When you create a definition in your vocabulary (which you use do define rules in your policy) you must select the operation you want to do over the element: Get or Set. You can choose only one of them…

BizTalk Vocabulary Definition

So, what’s the trick to perform both actions? Create two definitions of the same element, one as Get and the other as Set.

When a rule uses the Set definition of the element, all the rules that use the Get definition of that XML element read the updated value.

Works great! Just be careful about rules priority. Make sure that rules that read the element value are called after a rule that sets it’s value.

© Bruno Silva | Powered by Wordpress