// A very quick test to see how much my TV screen shows (or loses) using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; using Microsoft.Xna.Framework.Net; using Microsoft.Xna.Framework.Storage; namespace TestScreenSize { public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; SpriteFont spriteFont; Texture2D textureWhite; GamePadState prevGamePadState, currGamePadState; int x, y, w, h; int current; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // go to 1280 x 720 graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; } protected override void Initialize() { // initial values x = 50; y = 50; w = 1180; h = 620; current = 0; base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); spriteFont = Content.Load("SpriteFont1"); // create my own white pixel textureWhite = new Texture2D(GraphicsDevice, 1, 1, 1, TextureUsage.None, SurfaceFormat.Color); textureWhite.SetData(new Color[] { Color.White }); } protected override void UnloadContent() { } protected override void Update(GameTime gameTime) { prevGamePadState = currGamePadState; currGamePadState = GamePad.GetState(PlayerIndex.One); if (wasButtonPressed(Buttons.Back)) { Exit(); } if (wasButtonPressed(Buttons.DPadDown)) { current++; if (current > 3) current = 3; } if (wasButtonPressed(Buttons.DPadUp)) { current--; if (current < 0) current = 0; } if (wasButtonPressed(Buttons.DPadLeft)) { if (current == 0) x--; if (current == 1) y--; if (current == 2) w--; if (current == 3) h--; } if (wasButtonPressed(Buttons.DPadRight)) { if (current == 0) x++; if (current == 1) y++; if (current == 2) w++; if (current == 3) h++; } base.Update(gameTime); } private bool wasButtonPressed(Buttons button) { return (currGamePadState.IsButtonDown(button) && prevGamePadState.IsButtonUp(button)); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); spriteBatch.Draw(textureWhite, new Rectangle(x, y, w, h), Color.Red); spriteBatch.Draw(textureWhite, new Rectangle(x + 2, y + 2, w - 4, h - 4), Color.CornflowerBlue); int tx = 100; int ty = 80; int tyd = 44; String s = "x = " + x; Color c = Color.Black; if (current == 0) c = Color.Red; spriteBatch.DrawString(spriteFont, s, new Vector2(tx, ty), c); ty += tyd; s = "y = " + y; c = Color.Black; if (current == 1) c = Color.Red; spriteBatch.DrawString(spriteFont, s, new Vector2(tx, ty), c); ty += tyd; s = "w = " + w + " which is "+(w*100.0/1280.0)+"%"; c = Color.Black; if (current == 2) c = Color.Red; spriteBatch.DrawString(spriteFont, s, new Vector2(tx, ty), c); ty += tyd; s = "h = " + h + " which is "+(h*100.0/720.0)+"%";; c = Color.Black; if (current == 3) c = Color.Red; spriteBatch.DrawString(spriteFont, s, new Vector2(tx, ty), c); ty += tyd; ty += tyd; ty += tyd; s = "DPad Up/Down to select a dimensional attribute."; spriteBatch.DrawString(spriteFont, s, new Vector2(tx, ty), Color.Black); ty += tyd; s = "DPad Left/Right to decrease/increase that attribute."; spriteBatch.DrawString(spriteFont, s, new Vector2(tx, ty), Color.Black); ty += tyd; s = "Get the red border to the edge of your TV screen"; spriteBatch.DrawString(spriteFont, s, new Vector2(tx, ty), Color.Black); spriteBatch.End(); base.Draw(gameTime); } } }