Thursday, December 21, 2006

showing a bitmap in XNA

I've seen some crazy complicated samples online for something that should be very simple - showing a bitmap in XNA. I even found one article that suggested using pointers. ha!

here's the simple version that I used to show augmented reality markers on my TV. unfortunately, it seems that the TV scan line is going to prevent this from actually working as an AR demo.

#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;

namespace Xbox360Game1
public class Game1 : Microsoft.Xna.Framework.Game
GraphicsDeviceManager graphics;
ContentManager content;

//Added for bitmap
public static Texture2D SpriteTexture;
public static SpriteBatch SpriteBatch;
public Point Velocity;
public Point Location;
public Point Size;

public Game1()
graphics = new GraphicsDeviceManager(this);
content = new ContentManager(Services);

protected override void Initialize()

//Added for bitmap
SpriteBatch = new SpriteBatch(;

protected override void LoadGraphicsContent(bool loadAllContent)
if (loadAllContent)

//Added for bitmap
SpriteTexture = content.Load("base0_128");



protected override void UnloadGraphicsContent(bool unloadAllContent)
if (unloadAllContent == true)

protected override void Update(GameTime gameTime)
// Allows the default game to exit on Xbox 360 and Windows
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

protected override void Draw(GameTime gameTime)

//Added for bitmap
Location.X = 100;
Location.Y = 100;
Size.X = 512;
Size.Y = 512;
Game1.SpriteBatch.Draw(Game1.SpriteTexture, new Rectangle(Location.X, Location.Y, Size.X, Size.Y), Color.White);


Wednesday, December 20, 2006

'Canada's Best' books

has anyone else seen the "Canada's Best" list that Chapters compiled?

they asked 150,000 irewards members to list their favourite Canadian books of all time (both fiction and non-fiction). however, this is a bit misleading since they don't actually say what the resultant sample size was.

it's clear to me that the entries are heavily biased towards books that were published in the last few years. for example, jPod (#11) is listed ahead of Microserfs (#58). I have a hard time seeing how that could happen unless the people who voted for jPod haven't read Microserfs.

also, some of the best books are clearly missing from the list. for example, Whale Music by Paul Quarrington should obviously be included.

BTW - two authors have ten books each in the list of 100 books: Atwood and Coupland.

here are my favourite book lists:
favourite geek books
favourite fiction books

Wednesday, December 13, 2006

debug xbox 360 without xbox?

it didn't take long for me to realize that the GSE XNA xbox 360 project forces a deployment to the xbox 360 when you debug or build. so how do you work on your xbox 360 game when you're in the coffee shop?

there doesn't seem to be any way to disable the deployment, so - unless you take your xbox with you - it's a bit of an issue. even adding Any CPU as an additional platform in the configuration manager didn't work. I found a forum post about debugging without the xbox 360, and it seems that the current solution is a bit of a hack:

"You can start a new Windows Game and link all the files from the 360 project. It would probably take about 30 seconds to set up. After you create the Windows Game project, right click on the project in the Solution Explorer, select Add Existing Item, select all the files in the dialog, click the arrow on the Add button and select Add As Link. Any changes made in either project will be reflected in the other."

there is a second solution in the post (manually altering the project file), but it isn't recommended.

Monday, December 11, 2006

xbox creators club live!

the xbox 360 creators club is up and running. this option allows game developers to use the XNA game development platform to create and run xbox 360 games.

although the game studio express (GSE) dev environment is free, the creators club requires an xbox live subscription and a creators club membership.

refer to the XNA blog (and the GSE docs) for details about setup. once you have everything installed, you can connect your xbox 360 to your pc and begin to work your magic.

this screenshot shows an xbox 360 project deployed and running on an xbox 360. the project is running in debug mode and a breakpoint has been hit - all while still listening to the iPod connected to the 360... nice.

- debugging an xbox 360 project - click for full-size version