public Camera2D(ResolutionRenderer irr) { Irr = irr; _zoom = 0.1f; _rotation = 0.0f; _position = Vector2.Zero; MinZoom = 0.1f; MaxZoom = 999f; }
public static void BeginResolution(this SpriteBatch mBatch, ResolutionRenderer renderer) { mBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, DepthStencilState.Default, RasterizerState.CullNone, null, renderer.GetTransformationMatrix()); }
/// <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() { //set virtual screen resolution _irr = new ResolutionRenderer(this, VIRTUAL_RESOLUTION_WIDTH, VIRTUAL_RESOLUTION_HEIGHT, _gfx.PreferredBackBufferWidth, _gfx.PreferredBackBufferHeight); _input = new InputHelper(this); _camera = new Camera2D(_irr) { MaxZoom = 10f, MinZoom = .4f, Zoom = 1f }; _camera.SetPosition(Vector2.Zero); _camera.RecalculateTransformationMatrices(); base.Initialize(); }
/// <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() { //set virtual screen resolution _irr = new ResolutionRenderer(this, VIRTUAL_RESOLUTION_WIDTH, VIRTUAL_RESOLUTION_HEIGHT, _gfx.PreferredBackBufferWidth, _gfx.PreferredBackBufferHeight); _input = new InputHelper(this); base.Initialize(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { //update input helper data _input.Update(gameTime); #region Input processing if (_input.GamePadState.Buttons.Back == ButtonState.Pressed || _input.IsKeyPressed(Keys.Escape)) { Exit(); return; } if (_input.IsKeyPressed(Keys.D1)) { _gfx.PreferredBackBufferWidth = 1000; _gfx.PreferredBackBufferHeight = 400; _irr = new ResolutionRenderer(this, VIRTUAL_RESOLUTION_WIDTH, VIRTUAL_RESOLUTION_HEIGHT, _gfx.PreferredBackBufferWidth, _gfx.PreferredBackBufferHeight); _gfx.ApplyChanges(); return; } if (_input.IsKeyPressed(Keys.D2)) { _gfx.PreferredBackBufferWidth = 400; _gfx.PreferredBackBufferHeight = 500; _irr = new ResolutionRenderer(this, VIRTUAL_RESOLUTION_WIDTH, VIRTUAL_RESOLUTION_HEIGHT, _gfx.PreferredBackBufferWidth, _gfx.PreferredBackBufferHeight); _gfx.ApplyChanges(); return; } if (_input.IsKeyPressed(Keys.D3)) { _gfx.PreferredBackBufferWidth = 800; _gfx.PreferredBackBufferHeight = 480; _irr = new ResolutionRenderer(this, VIRTUAL_RESOLUTION_WIDTH, VIRTUAL_RESOLUTION_HEIGHT, _gfx.PreferredBackBufferWidth, _gfx.PreferredBackBufferHeight); _gfx.ApplyChanges(); return; } //get virtal equivalent of mouse coordinaes var pos = _irr.ToVirtual(_input.MousePos); //check for mouse click in the UFO rectangle area if (InputHelper.IsPosInBound(pos, _testRect) && _input.IsMousePressed(MouseButton.Left)) Exit(); #endregion base.Update(gameTime); }
public void Dispose() { Irr = null; }