Minor comments
[4DMemory.git] / 4DMemory / Game4D.cs
blob9c795756edf7b3f49ee4938d7cc0ed231e8f54b6
1 using System;
2 using System.Collections.Generic;
3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Audio;
5 using Microsoft.Xna.Framework.Content;
6 using Microsoft.Xna.Framework.GamerServices;
7 using Microsoft.Xna.Framework.Graphics;
8 using Microsoft.Xna.Framework.Input;
9 using Microsoft.Xna.Framework.Net;
10 using Microsoft.Xna.Framework.Storage;
12 namespace Memory
14 /// <summary>
15 /// This is the main type for your game
16 /// </summary>
17 public class Game4D : Microsoft.Xna.Framework.Game
19 GraphicsDeviceManager graphics;
21 SpriteBatch spriteBatch;
22 Texture2D tx2CardBack;
24 Rectangle titleSafeArea;
26 public Game4D()
28 graphics = new GraphicsDeviceManager(this);
29 Content.RootDirectory = "Content";
32 /// <summary>
33 /// Allows the game to perform any initialization it needs to before starting to run.
34 /// This is where it can query for any required services and load any nongraphic
35 /// related content. Calling base.Initialize will enumerate through any components
36 /// and initialize them as well.
37 /// </summary>
38 protected override void Initialize()
40 // TODO: Add your initialization logic here
42 base.Initialize();
45 /// <summary>
46 /// LoadContent will be called once per game and is the place to load
47 /// all of your content.
48 /// </summary>
49 protected override void LoadContent()
51 // Calculate the area that is visible on screen for sure
52 titleSafeArea = GetTitleSafeArea(.80f);
54 // Create a new SpriteBatch, which can be used to draw textures.
55 spriteBatch = new SpriteBatch(GraphicsDevice);
57 // TODO: use this.Content to load your game content here
59 tx2CardBack = this.Content.Load<Texture2D>("Textures/logo08");
61 System.Diagnostics.Debug.WriteLine("Loaded All Game4D Content");
64 /// <summary>
65 /// UnloadContent will be called once per game and is the place to unload
66 /// all content.
67 /// </summary>
68 protected override void UnloadContent()
70 // TODO: Unload any non ContentManager content here
72 System.Diagnostics.Debug.WriteLine("Unloaded All Game4D Non-ContentManager Content");
75 /// <summary>
76 /// Allows the game to run logic such as updating the world,
77 /// checking for collisions, gathering input, and playing audio.
78 /// </summary>
79 /// <param name="gameTime">Provides a snapshot of timing values.</param>
80 protected override void Update(GameTime gameTime)
82 // Allows the game to exit
83 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
84 this.Exit();
86 // TODO: Add your update logic here
88 base.Update(gameTime);
91 /// <summary>
92 /// This is called when the game should draw itself.
93 /// </summary>
94 /// <param name="gameTime">Provides a snapshot of timing values.</param>
95 protected override void Draw(GameTime gameTime)
97 graphics.GraphicsDevice.Clear(Color.WhiteSmoke);
99 // TODO: Add your drawing code here
101 spriteBatch.Begin();
103 spriteBatch.Draw(tx2CardBack, new Vector2(titleSafeArea.X, titleSafeArea.Y), Color.White);
105 spriteBatch.End();
107 base.Draw(gameTime);
110 private Rectangle GetTitleSafeArea(float percent)
112 Rectangle retval = new Rectangle(
113 graphics.GraphicsDevice.Viewport.X,
114 graphics.GraphicsDevice.Viewport.Y,
115 graphics.GraphicsDevice.Viewport.Width,
116 graphics.GraphicsDevice.Viewport.Height
118 #if XBOX360
119 float border = (1 - percent) / 2;
120 retval.X = (int)(border * retval.Width);
121 retval.Y = (int)(border * retval.Height);
122 retval.Width = (int)(percent * retval.Width);
123 retval.Height = (int)(percent * retval.Height);
124 #endif
125 return retval;