public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; engine = new Engine(new Point(1600, 900), new Point(10, 10)); drawEngine = new DrawEngine(engine, new Vector2(1600.0f, 900.0f), new Vector2(1600.0f, 450.0f), false, graphics); drawEngine.AddExtension(new BasicDrawEngine(drawEngine)); viewport1 = new PlumGine2D.Graphics.Viewport( new Rectangle(0, 0, 800, 900), new Point(1600, 900)); viewport2 = new PlumGine2D.Graphics.Viewport( new Rectangle(800, 0, 800, 900), new Point(800, 900)); drawEngine.AddViewport(viewport1); drawEngine.AddViewport(viewport2); engine.AddEngineExt(drawEngine); frameCounter = new FrameCounter(); }
/// <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) { // For Mobile devices, this logic will close the Game when the Back button is pressed // Exit() is obsolete on iOS #if !__IOS__ if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } #endif // TODO: Add your update logic here if (v1) { v = viewport1; } else { v = viewport2; } KeyboardState state = Keyboard.GetState(); if (state.IsKeyDown(Keys.Left)) { v.centerMapPos = v.centerMapPos + new Vector2(-20.0f, 0.0f); } if (state.IsKeyDown(Keys.Right)) { v.centerMapPos = v.centerMapPos + new Vector2(20.0f, 0.0f); } if (state.IsKeyDown(Keys.Up)) { v.centerMapPos = v.centerMapPos + new Vector2(0.0f, -20.0f); } if (state.IsKeyDown(Keys.Down)) { v.centerMapPos = v.centerMapPos + new Vector2(0.0f, 20.0f); } if (state.IsKeyDown(Keys.OemPlus)) { if (v.zoom < 3.0f) { v.zoom = v.zoom * 1.01f; } } if (state.IsKeyDown(Keys.OemMinus)) { if (v.zoom > 0.3f) { v.zoom = v.zoom * 0.99f; } } if (state.IsKeyDown(Keys.Space)) { v1 = !v1; } frameCounter.Update((float)gameTime.ElapsedGameTime.TotalSeconds); base.Update(gameTime); }