public Viewport(WorldMap WorldMap, Rectangle Screen, Vector2 FieldSize, Vector2 Camera) { this.WorldMap = WorldMap; this.Camera = Camera; this.FieldSize = FieldSize; this.Screen = Screen; // new Rectangle((int)ScreenPos.X, (int)ScreenPos.Y, Camera.Width, Camera.Height); this.Zoom = 1; }
public void getFieldTest() { int width = 2; int height = 2; Game1 Game = new Game1(); WorldMap target = new WorldMap(width, height, Game); // TODO: Initialize to an appropriate value iField actual; // Element istniejacy actual = target.getField(0,0); Assert.AreEqual(0, actual.X); Assert.AreEqual(0, actual.Y); // Element 'poza mapa' - gorna granica actual = target.getField(width+2,height+2); Assert.AreEqual(width-1, actual.X); Assert.AreEqual(height-1, actual.Y); // Element 'poza mapa' - dolna granica actual = target.getField(-1, -1); Assert.AreEqual(0, actual.X); Assert.AreEqual(0, actual.Y); }
/// <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() { this.DisplayFps = new Element.DisplayFps(); int size = 100; this.WorldMap = new WorldMap(size, size, this); this.Viewport = new Viewport[1]; Rectangle Screen = new Rectangle(0, 0, 400, 300); Screen.Width = graphics.PreferredBackBufferWidth; Screen.Height = graphics.PreferredBackBufferHeight; if (this.debugViewport == true) { Screen.X = 200; Screen.Y = 200; Screen.Width = 400; Screen.Height = 300; } this.Viewport[0] = new Viewport(this.WorldMap, Screen, new Vector2(100, 50), new Vector2(0, 0)); this.LastkeyState = Keyboard.GetState(); this.OldField = this.WorldMap.getField(0, 0); this.Player = new Player(new Vector2(100, 100), 10); base.Initialize(); this.UpdateTitle(); }