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
;
15 /// This is the main type for your game
17 public class Game4D
: Microsoft
.Xna
.Framework
.Game
19 GraphicsDeviceManager graphics
;
21 SpriteBatch spriteBatch
;
22 Texture2D tx2CardBack
;
24 Rectangle titleSafeArea
;
28 graphics
= new GraphicsDeviceManager(this);
29 Content
.RootDirectory
= "Content";
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.
38 protected override void Initialize()
40 // TODO: Add your initialization logic here
46 /// LoadContent will be called once per game and is the place to load
47 /// all of your content.
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");
65 /// UnloadContent will be called once per game and is the place to unload
68 protected override void UnloadContent()
70 // TODO: Unload any non ContentManager content here
72 System
.Diagnostics
.Debug
.WriteLine("Unloaded All Game4D Non-ContentManager Content");
76 /// Allows the game to run logic such as updating the world,
77 /// checking for collisions, gathering input, and playing audio.
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
)
86 // TODO: Add your update logic here
88 base.Update(gameTime
);
92 /// This is called when the game should draw itself.
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
103 spriteBatch
.Draw(tx2CardBack
, new Vector2(titleSafeArea
.X
, titleSafeArea
.Y
), Color
.White
);
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
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
);