public Game1() { XnaUtility.UtilityMethods.CurrentGame = this; graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; atlasHandler = new AtlasHandler(this, "MASTER GAIDEN SHEET", "MASTER GAIDEN SHEET DICT"); Components.Add(atlasHandler); Services.AddService(typeof(AtlasHandler), atlasHandler); Services.AddService(typeof(Random),random); watch = new XnaWatch(this,Color.White); Components.Add(watch); Services.AddService(typeof(XnaWatch), watch); graphics.PreferredBackBufferHeight = 750; graphics.PreferredBackBufferWidth = 900; this.IsMouseVisible = true; graphics.ApplyChanges(); Width = graphics.PreferredBackBufferWidth; Height = graphics.PreferredBackBufferHeight; }
public static Color[] TextureTo1DArray(AtlasHandler handler, Rectangle frameOfSpriteInAtlas) { Color[] atlas1D = handler.TexAsColorArray; var width = frameOfSpriteInAtlas.Width; var height = frameOfSpriteInAtlas.Height; Color[] colors1D = new Color[width * height]; for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) colors1D[x + y * width] = atlas1D[(x + frameOfSpriteInAtlas.X) + (y + frameOfSpriteInAtlas.Y) * handler.Texture.Width]; return colors1D; }
public static Color[,] TextureTo2DArray(AtlasHandler handler, Rectangle frameOfSpriteInAtlas) { Color[] colors1D = handler.TexAsColorArray; Color[,] colors2D = new Color[frameOfSpriteInAtlas.Width, frameOfSpriteInAtlas.Height]; for (int x = 0; x < frameOfSpriteInAtlas.Width; x++) for (int y = 0; y < frameOfSpriteInAtlas.Height; y++) colors2D[x, y] = colors1D[(x + frameOfSpriteInAtlas.X) + (y + frameOfSpriteInAtlas.Y) * handler.Texture.Width]; return colors2D; }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { atlasHandler = (AtlasHandler)Game.Services.GetService(typeof(AtlasHandler)); spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); base.Initialize(); }