|
/*
* TextOutput Sample Application
*
* System to display a list of text output in a single sprite batch output for XNA.
*
* Author: Kurt Wesner, Bob Bradley
* Place: University of Tennessee at Martin
* Date: July 02 2007
*
*/
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using UTM.CSIS.Xedge;
#endregion
namespace TextOutputDemo
{
/// <summary>
/// This is a demo for TextOutput.
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
ContentManager content;
TextOutput textOutput;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
content = new ContentManager(Services);
this.Window.AllowUserResizing = true;
this.Components.Add(textOutput = new TextOutput(this));
}
protected override void Initialize()
{
base.Initialize();
}
protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
}
this.IsMouseVisible = true;
}
protected override void UnloadGraphicsContent(bool unloadAllContent)
{
if (unloadAllContent)
{
content.Unload();
}
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.Black);
MouseState currentMouseState = Mouse.GetState();
textOutput.WriteAt(0, 0, "Demonstration of XNA TextOutput component.");
textOutput.FontRotation = MathHelper.ToRadians((float)currentMouseState.X);
textOutput.writeAtMouse("Mouse is at \r\n X: " + currentMouseState.X + " Y: " + currentMouseState.Y, Color.Yellow);
textOutput.FontRotation = 0;//reset font rotation to 0 or else everything would be rotated.
textOutput.WriteAt(50, 50, "Hello World!");
textOutput.WriteAt(100, 100, "Game Time: " + gameTime.TotalRealTime.ToString(), Color.Red);
base.Draw(gameTime);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Bob Bradley is a full time Computer Science instructor at the University of Tennessee at Martin. He has been preoccupied with computers since his first Commodore Vic-20. He is currently interested in XNA/XBox-360 programming!
Currently a senior at the University of Tennessee at Martin: Computer Science.