Advertisement
Guest User

game class

a guest
Jun 8th, 2013
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.82 KB | None | 0 0
  1.     public class Game1 : Microsoft.Xna.Framework.Game
  2.     {
  3.         GraphicsDeviceManager graphics;
  4.         SpriteBatch spriteBatch;
  5.  
  6.         Model terrain;
  7.  
  8.         Player myPlayer;
  9.         Camera3rdPerson cam;
  10.  
  11.         public Game1()
  12.         {
  13.             graphics = new GraphicsDeviceManager(this);
  14.             Content.RootDirectory = "Content";
  15.         }
  16.  
  17.         /// <summary>
  18.         /// Allows the game to perform any initialization it needs to before starting to run.
  19.         /// This is where it can query for any required services and load any non-graphic
  20.         /// related content.  Calling base.Initialize will enumerate through any components
  21.         /// and initialize them as well.
  22.         /// </summary>
  23.         protected override void Initialize()
  24.         {
  25.  
  26.  
  27.  
  28.             base.Initialize();
  29.         }
  30.  
  31.         /// <summary>
  32.         /// LoadContent will be called once per game and is the place to load
  33.         /// all of your content.
  34.         /// </summary>
  35.         protected override void LoadContent()
  36.         {
  37.             // Create a new SpriteBatch, which can be used to draw textures.
  38.             spriteBatch = new SpriteBatch(GraphicsDevice);
  39.             terrain = Content.Load<Model>("terrain");
  40.             myPlayer = new Player();
  41.             myPlayer.LoadContent(Content);
  42.  
  43.             cam = new Camera3rdPerson();
  44.         }
  45.  
  46.         /// <summary>
  47.         /// UnloadContent will be called once per game and is the place to unload
  48.         /// all content.
  49.         /// </summary>
  50.         protected override void UnloadContent()
  51.         {
  52.             // TODO: Unload any non ContentManager content here
  53.         }
  54.  
  55.         /// <summary>
  56.         /// Allows the game to run logic such as updating the world,
  57.         /// checking for collisions, gathering input, and playing audio.
  58.         /// </summary>
  59.         /// <param name="gameTime">Provides a snapshot of timing values.</param>
  60.         protected override void Update(GameTime gameTime)
  61.         {
  62.             // Allows the game to exit
  63.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  64.                 this.Exit();
  65.             float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
  66.  
  67.             myPlayer.Update(dt);
  68.  
  69.             cam.Update(myPlayer.playerWorld);
  70.  
  71.             base.Update(gameTime);
  72.         }
  73.  
  74.         /// <summary>
  75.         /// This is called when the game should draw itself.
  76.         /// </summary>
  77.         /// <param name="gameTime">Provides a snapshot of timing values.</param>
  78.         protected override void Draw(GameTime gameTime)
  79.         {
  80.             GraphicsDevice.Clear(Color.CornflowerBlue);
  81.             terrain.Draw(Matrix.Identity, cam.view, cam.proj);
  82.  
  83.             myPlayer.Draw(cam);
  84.            
  85.  
  86.             base.Draw(gameTime);
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement