Game1.cs dla liczenia min. update timu
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
WindowsGame5
{
/// <summary>
/// This is the main type
for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Interface1 interface1;
Interface1 Interface1
{
get
{
if (interface1 == null)
interface1 = (Interface1)Services.GetService(typeof(Interface1));
return interface1;
}
}
#region checking_time_vars
/*
double
elapsed;
double
minElapsed;
*/
#endregion
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
//IsMouseVisible = true;
graphics.SynchronizeWithVerticalRetrace = false;
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
graphics.IsFullScreen = true;
graphics.PreferredBackBufferHeight = 600;
graphics.PreferredBackBufferWidth = 800;
graphics.ApplyChanges();
GameComponent1 game_com = new
GameComponent1(this);
Components.Add(game_com);
Services.AddService(typeof(Interface1), game_com);
IsFixedTimeStep = true;
TargetElapsedTime = TimeSpan.FromTicks(460);
#region checking_time_vars_set
//elapsed = 0;
//minElapsed = 0;
#endregion
base.Initialize();
}
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw
textures.
spriteBatch
= new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
}
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
protected override void Update(GameTime
gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
KeyboardState key = Keyboard.GetState();
MouseState mouse = Mouse.GetState();
if (mouse.LeftButton == ButtonState.Pressed)
{
Interface1.Add(mouse.X, mouse.Y, 0, Color.Black);
}
if (key.IsKeyDown(Keys.Escape))
this.Exit();
if (Keyboard.GetState().IsKeyDown(Keys.F1))
{
graphics.ToggleFullScreen();
}
#region checking_time
/*
elapsed = gameTime.ElapsedGameTime.TotalMilliseconds;
if
(graphics.IsFullScreen == true)
{
if
(minElapsed == 0)
minElapsed = elapsed;
else
if (elapsed < minElapsed)
minElapsed = elapsed;
}
*/
#endregion
base.Update(gameTime);
}
protected override void Draw(GameTime
gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
#region checking_time2
/*
string currentMinElapsedTime =
minElapsed.ToString();
Window.Title = "minElapsed: " + minElapsed;
*/
#endregion
base.Draw(gameTime);
}
}
}
|