Gamepad not working in snakegame

Apr 22, 2009 at 5:04 PM
Edited Apr 22, 2009 at 8:22 PM
hi, im running your snakegame but its not responding to the dpad on my xbox controller. my game isnt responding to input either. is there something i have to enable somehwere to get it to work?

heres a link to a screenshot of my game currently

should the silverlight be scaling everything automatically like it does on the xbox? i ran into a spritebatch.Draw problem when i was converting my game. are all your draw overloads correct?

I added the following lines to your snakegame and it still isnt accepting input from the keyboard, please help!!

KeyboardState ks = Keyboard.GetState();
            if (ks.IsKeyDown(Keys.A))
                newVelocity = new Vector2(-1, 0);
            else if (ks.IsKeyDown(Keys.D))
                newVelocity = new Vector2(1, 0);
            else if (ks.IsKeyDown(Keys.W))
                newVelocity = new Vector2(0, -1);
            else if (ks.IsKeyDown(Keys.S))
                newVelocity = new Vector2(0, 1);
Apr 23, 2009 at 1:50 PM
The game pad isn't supported by Silverlight so I map gamepad to the keyboard. You need to get focus on the Silverlight control before the keyboard will work, that's why you always see a "click to start" on the first screen of Flash and Silverlight games. It sounds like this may be the same problem you're having with your game. There is no automatic scaling built in, but I was thinking about adding that. You can use the ViewBox control in the Silverlight Toolkit to scale your game automatically for now.

The latest code in the source tree should have support for all of the draw methods, I'll be doing a new release this weekend with a source code release and a binary release as well. So until then please get the code from source control, it is stable and most likely won't change before the release.
Apr 23, 2009 at 5:12 PM
your snakegame isnt responding to keyboard input either though. im looking on internet for how to give focus right now.
Apr 23, 2009 at 6:35 PM
Keyboard works for me in snake game once I click on it. I've researched a cross browser way of ensuing the control gets focus and didn't find anything except people saying there wasn't a way to make sure it gets focus in all browsers.
Apr 23, 2009 at 7:03 PM
lol, ok snakegame responds to input. ill try to get my game working now.