Sunday, November 19, 2006

Getting Keyboard Input for the XNA 3D Tutorial

If you tried out the 3D tutorial, you will notice that it is geared towards the Xbox. The tutorial introduces the framework's support for Xbox controllers.

That's ok, except that I am trying to learn how to use XNA to develop Windows games and applications. It turns out that there is support for keyboard and mouse as well.

I have added the following lines of code into the beginning of the Update() method of the Game1.cs class file.



KeyboardState keyState = Keyboard.GetState();
if (keyState.IsKeyDown(Keys.Escape))
this.Exit();


Now, you can terminate the runtime window by hitting the Escape key.

3 comments:

Anonymous said...

Hi there to every one, the contents present at this
website are really amazing for people experience, well, keep up the nice work
fellows.

My website ... Vimax Results

Anonymous said...

Generally I don't learn post on blogs, but I would like to say that this write-up very forced me to check out and do it! Your writing style has been amazed me. Thank you, quite great article.


corexin ()

Anonymous said...

Have you ever considered writing an ebook or guest authoring on other websites?
I have a blog based on the same information you discuss and would love to have
you share some stories/information. I know my visitors would appreciate your work.
If you're even remotely interested, feel free to shoot me an e mail.

My homepage Home Income Kit Online