SHARE
TWEET

Untitled

coolbunny1234 Mar 14th, 2013 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Game1.cs
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using Microsoft.Xna.Framework;
  7. using Microsoft.Xna.Framework.Audio;
  8. using Microsoft.Xna.Framework.Content;
  9. using Microsoft.Xna.Framework.GamerServices;
  10. using Microsoft.Xna.Framework.Graphics;
  11. using Microsoft.Xna.Framework.Input;
  12. using Microsoft.Xna.Framework.Media;
  13.  
  14. namespace Xbox360Game1
  15. {
  16.     /// <summary>
  17.     /// This is the main type for your game
  18.     /// </summary>
  19.     public class Game1 : Microsoft.Xna.Framework.Game
  20.     {
  21.         GraphicsDeviceManager graphics;
  22.         SpriteBatch spriteBatch;
  23.  
  24.         public Ship ship;
  25.  
  26.         public Game1()
  27.         {
  28.             graphics = new GraphicsDeviceManager(this);
  29.             Content.RootDirectory = "Content";
  30.  
  31.             graphics.PreferredBackBufferWidth = 880;
  32.             graphics.PreferredBackBufferHeight = 520;
  33.             graphics.PreferMultiSampling = true;
  34.             graphics.ApplyChanges();
  35.         }
  36.  
  37.         protected override void Initialize()
  38.         {
  39.             // TODO: Add your initialization logic here
  40.  
  41.             base.Initialize();
  42.         }
  43.  
  44.  
  45.         protected override void LoadContent()
  46.         {
  47.             spriteBatch = new SpriteBatch(GraphicsDevice);
  48.             ship = new Ship();
  49.             ship.ShipTexture = Content.Load<Texture2D>("RocketShip");
  50.             ship.Rotation = 0.0f;
  51.             ship.Position = new Vector2(
  52.                 graphics.GraphicsDevice.Viewport.Width / 2,
  53.                 graphics.GraphicsDevice.Viewport.Height / 2);
  54.  
  55.         }
  56.  
  57.         protected override void UnloadContent()
  58.         {
  59.             Content.Unload();
  60.             Content.Dispose();
  61.         }
  62.  
  63.         protected override void Update(GameTime gameTime)
  64.         {
  65.             // Allows the game to exit
  66.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  67.                 this.Exit();
  68.  
  69.             // TODO: Add your update logic here
  70.  
  71.             base.Update(gameTime);
  72.         }
  73.  
  74.         protected override void Draw(GameTime gameTime)
  75.         {
  76.             GraphicsDevice.Clear(Color.CornflowerBlue);
  77.             spriteBatch.Begin();
  78.             spriteBatch.Draw(ship.ShipTexture, ship.Position, null, Color.White, ship.Rotation,
  79.                 new Vector2(
  80.                     ship.ShipTexture.Width / 2,
  81.                     ship.ShipTexture.Height / 2), 1.0f, SpriteEffects.None, 0);
  82.             spriteBatch.End();
  83.  
  84.  
  85.             base.Draw(gameTime);
  86.         }
  87.     }
  88. }
  89.  
  90. //Ship.cs
  91.  
  92. using System;
  93. using System.Collections.Generic;
  94. using System.Linq;
  95. using System.Text;
  96. using Microsoft.Xna.Framework.Graphics;
  97. using Microsoft.Xna.Framework;
  98. namespace Xbox360Game1
  99. {
  100.     class Ship
  101.     {
  102.         public Texture2D ShipTexture;
  103.         public Vector2 Position;
  104.         public Single Rotation;
  105.     }
  106. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top