ThatSnail

Untitled

Mar 23rd, 2012
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.Xna.Framework;
  5. using Microsoft.Xna.Framework.Audio;
  6. using Microsoft.Xna.Framework.Content;
  7. using Microsoft.Xna.Framework.GamerServices;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Input;
  10. using Microsoft.Xna.Framework.Media;
  11.  
  12. namespace Engine
  13. {
  14.     /// <summary>
  15.     /// This is the main type for your game
  16.     /// </summary>
  17.     public class Game1 : Microsoft.Xna.Framework.Game
  18.     {
  19.         #region Fields
  20.         GraphicsDeviceManager graphics;
  21.         public static SpriteBatch spriteBatch;
  22.  
  23.         public static Color bkgColor;
  24.  
  25.         public static const int VIEW_WIDTH = 800;
  26.         public static const int VIEW_HEIGHT = 600;
  27.  
  28.         private static RoomCont roomCont;
  29.         public static RoomCont hRoomCont
  30.         {
  31.             get
  32.             {
  33.                 return roomCont;
  34.             }
  35.             set
  36.             {
  37.                 roomCont = value;
  38.             }
  39.         }
  40.         private static ObjCont objCont;
  41.         public static ObjCont hObjCont
  42.         {
  43.             get
  44.             {
  45.                 return objCont;
  46.             }
  47.             set
  48.             {
  49.                 objCont = value;
  50.             }
  51.         }
  52.         #endregion
  53.  
  54.         Texture2D texGameBase;
  55.  
  56.         public Game1()
  57.         {
  58.             graphics = new GraphicsDeviceManager(this);
  59.             graphics.PreferredBackBufferWidth = VIEW_WIDTH;
  60.             graphics.PreferredBackBufferHeight = VIEW_HEIGHT;
  61.             Content.RootDirectory = "Content";
  62.         }
  63.  
  64.         /// <summary>
  65.         /// Allows the game to perform any initialization it needs to before starting to run.
  66.         /// This is where it can query for any required services and load any non-graphic
  67.         /// related content.  Calling base.Initialize will enumerate through any components
  68.         /// and initialize them as well.
  69.         /// </summary>
  70.         protected override void Initialize()
  71.         {
  72.             bkgColor = new Color(140, 255, 128);
  73.             // TODO: Add your initialization logic here
  74.             base.Initialize();
  75.  
  76.             roomCont = new RoomCont();
  77.             objCont = new ObjCont();
  78.  
  79.             roomCont.Init();
  80.             objCont.Init();
  81.         }
  82.  
  83.         /// <summary>
  84.         /// LoadContent will be called once per game and is the place to load
  85.         /// all of your content.
  86.         /// </summary>
  87.         protected override void LoadContent()
  88.         {
  89.             // Create a new SpriteBatch, which can be used to draw textures.
  90.             spriteBatch = new SpriteBatch(GraphicsDevice);
  91.  
  92.             // TODO: use this.Content to load your game content here
  93.             texGameBase = Content.Load<Texture2D>("sGameBase");
  94.         }
  95.  
  96.         /// <summary>
  97.         /// UnloadContent will be called once per game and is the place to unload
  98.         /// all content.
  99.         /// </summary>
  100.         protected override void UnloadContent()
  101.         {
  102.             // TODO: Unload any non ContentManager content here
  103.             texGameBase.Dispose();
  104.             texGameBase = null;
  105.         }
  106.  
  107.         /// <summary>
  108.         /// Allows the game to run logic such as updating the world,
  109.         /// checking for collisions, gathering input, and playing audio.
  110.         /// </summary>
  111.         /// <param name="gameTime">Provides a snapshot of timing values.</param>
  112.         protected override void Update(GameTime gameTime)
  113.         {
  114.             // Allows the game to exit
  115.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  116.                 this.Exit();
  117.  
  118.             // TODO: Add your update logic here
  119.             roomCont.Update();
  120.             objCont.Update();
  121.  
  122.             base.Update(gameTime);
  123.         }
  124.  
  125.         /// <summary>
  126.         /// This is called when the game should draw itself.
  127.         /// </summary>
  128.         /// <param name="gameTime">Provides a snapshot of timing values.</param>
  129.         protected override void Draw(GameTime gameTime)
  130.         {
  131.             GraphicsDevice.Clear(bkgColor);
  132.  
  133.             // TODO: Add your drawing code here
  134.             objCont.Draw(spriteBatch);
  135.  
  136.             base.Draw(gameTime);
  137.         }
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment