Coder Profile - Show off your skills, get a coder profile.
 
 
 
code pin board XNA Examples Download Source Code
Author Details Code Information
shadytyrant ( Travus )

Pinned 5 Codes
Posted 5 Coding Articles

Send A Message
View Coders Profile
Language C# (C Sharp)
Expires Never
Length 1,136 Characters (38 Lines)
Password no password
Description

a few snippets of things in xna
  1. public void LeftThumbStickMove(GamePadState gamePad)
  2. {
  3.     position.X += gamePad.ThumbSticks.Left.X * speed;
  4.     position.Y -= gamePad.ThumbSticks.Left.Y * speed;
  5. }
  6.  
  7. public void RightThumbStickMove(GamePadState gamePad)
  8. {
  9.     position.X += gamePad.ThumbSticks.Right.X * speed;
  10.     position.Y -= gamePad.ThumbSticks.Right.Y * speed;
  11. }
  12.  
  13. public void DPadMove(GamePadState gamePad)
  14. {
  15.     if (gamePad.DPad.Right == ButtonState.Pressed)
  16.     {
  17.         position.X += speed;
  18.     }
  19.     if (gamePad.DPad.Left == ButtonState.Pressed)
  20.     {
  21.         position.X -= speed;
  22.     }
  23.     if (gamePad.DPad.Up == ButtonState.Pressed)
  24.     {
  25.         position.Y -= speed;
  26.     }
  27.     if (gamePad.DPad.Down == ButtonState.Pressed)
  28.     {
  29.          position.Y += speed;
  30.     }
  31. }
  32.  
  33. // Bounds checking
  34. sprite.position.X = MathHelper.Clamp(sprite.position.X, 0, GraphicsDevice.Viewport.Width - sprite.width);
  35. sprite.position.Y = MathHelper.Clamp(sprite.position.Y, 0, GraphicsDevice.Viewport.Height - sprite.height);
  36.  
  37. // Draw text to screen
  38. spriteBatch.DrawString(font, "Some text here", new Vector2(20, 45), Color.White);
code pin board Back To Code Pin Board Post New Code
Please login to post comments.
Page 1 of 1
 
 
Latest News About Coder Profile
Coder Profile Poll
If you made money from keeping your profile up to date, say $30 and up, per month. What extra time would you spend on your profile?

No extra time
A few hours at weekends
A whole day each week
Every minute i can get free


please login to cast your vote
and see the results of this poll
Latest Coder Profile Changes
Coder Profile was last updated
3.49 Years Ago
Official Blog :: Make A Donation :: Credits :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents :: Wallpapers
Version 1.46.00
Copyright © 2007 - 2012, Scott Thompson, All Rights Reserved