protected override void Initialize() { base.Initialize(); RandomSeed = new Random(); //Sony's localization decisions be damned... InputManager.JapaneseButtonSwap = true; // What exactly does distinationRect represent? /* * The destinationRect defines the area of the screen * that the rendertarget gets rendered to. * In the Draw() loop, the rendertarget is drawn with destinationRect as its * rectangle. This means that the "game window" can be any size within the * "program window." * * The below code centers it and sets it to fill the height of the screen * while scaling width to match the intended aspect ratio. */ ScaleFactorX = (((int)ScreenResolution.Y / (int)AspectRatio.Y) * (int)AspectRatio.X); destinationRect.X = ((int)ScreenResolution.X / 2); destinationRect.Y = ((int)ScreenResolution.Y / 2); destinationRect.Height = (int)ScreenResolution.Y; destinationRect.Width = (ScaleFactorX); Camera.X = 0; Camera.Y = 0; mapDisplayDevice = new XnaDisplayDevice( this.Content, this.GraphicsDevice); viewport = new xTile.Dimensions.Rectangle(new Size ( (int)TempResolution.X, (int) TempResolution.Y) ); ///For one-axis map wrapping viewportNorth = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) ); viewportSouth = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) ); viewportEast = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) ); viewportWest = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) ); renderTarget = new RenderTarget2D(GraphicsDevice, (int)TempResolution.X, (int)TempResolution.Y, false, SurfaceFormat.Color, 0); ///Initialize Objects //Characters mapCharacter = new MapCharacter[255]; for (int i = 0; i < 255; i++) mapCharacter[i] = new MapCharacter(Content.Load<Texture2D>("Texture//Character//00"), 9, 8, 6, RandomSeed.Next()); mapCharacter[0].Visible = true; mapCharacter[1].Visible = true; mapCharacter[1].IsWandering = true; for (int i = 2; i < 14; i++) { mapCharacter[i].Visible = true; mapCharacter[i].IsWandering = true; } //Maps GameMap.LoadTileSheets(mapDisplayDevice); GlobalVariables.TileMapWidth = (GameMap.Layers[0].LayerWidth); GlobalVariables.TileMapHeight = (GameMap.Layers[0].LayerHeight); GlobalVariables.TileMapResolutionX = (GlobalVariables.TileMapWidth * GlobalVariables.TileSize); GlobalVariables.TileMapResolutionY = (GlobalVariables.TileMapHeight * GlobalVariables.TileSize); }
public static void FollowCharacter(MapCharacter mapCharacter, Vector2 Offset) { X = (mapCharacter.X - (int)Offset.X + 8); Y = (mapCharacter.Y - (int)Offset.Y + 8); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { ScaleFactorX = (((int)ScreenResolution.Y / (int)AspectRatio.Y) * (int)AspectRatio.X); //destinationRect.X = ((int)ScreenResolution.X / 2); //destinationRect.Y = ((int)ScreenResolution.Y / 2); //destinationRect.Height = (int)ScreenResolution.Y; //destinationRect.Width = (ScaleFactorX); Camera.X = 0; Camera.Y = 0; mapDisplayDevice = new XnaDisplayDevice( this.Content, this.GraphicsDevice); viewport = new xTile.Dimensions.Rectangle(new Size((int)TempResolution.X, (int)TempResolution.Y)); //viewportL = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) ); //viewportR = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) ); renderTarget = new RenderTarget2D(GraphicsDevice, (int)TempResolution.X, (int)TempResolution.Y, false, SurfaceFormat.Color, 0); ///Initialize Objects //Characters mapCharacter = new MapCharacter[255]; for (int i = 0; i < 255; i++) mapCharacter[i] = new MapCharacter(Content.Load<Texture2D>("Texture//Character//00"), 9, 0, 0); mapCharacter[0].Visible = true; mapCharacter[1].Visible = true; //Maps GameMap.LoadTileSheets(mapDisplayDevice); }