Exemplo n.º 1
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);
            shapeRenderer.Begin();

            float   cameraScale    = 2f;
            Vector2 rocketPosition = ConvertUnits.ToDisplayUnits(rocket.Position);
            Vector2 cameraCenter   = -rocketPosition + new Vector2(400f, 225f) / cameraScale;

            //Set camera
            shapeRenderer.SetCamera(
                Matrix4.CreateTranslation(cameraCenter.X, cameraCenter.Y, 0f) *
                Matrix4.CreateScale(cameraScale));

            //Draw world geometry
            shapeRenderer.SetTransform(Matrix4.Identity);
            foreach (Shape shape in geometry)
            {
                shapeRenderer.DrawShape(shape.Data, Color4.Black);
            }

            //Draw player rocket
            shapeRenderer.SetTransform(
                Matrix4.CreateRotationZ(rocket.Rotation) *
                Matrix4.CreateTranslation(rocketPosition.X, rocketPosition.Y, 0f));
            shapeRenderer.DrawShape(rocketShape.Data, Color4.Red);

            shapeRenderer.End();
            SwapBuffers();
        }
Exemplo n.º 2
0
        public override void LoadContent()
        {
            content  = new ContentManager("Content/");
            renderer = new ShapeRenderer(content, Window.Width, Window.Height);

            InputManager.Initialize();
            GameManager.Initialize(this);
            GameManager.LoadMap("level_01");
            interfaceManager = new InterfaceManager(content);

            renderer.SetCamera(Matrix4.CreateTranslation(Window.Width / 2f, Window.Height / 2f, 0f));
        }
Exemplo n.º 3
0
        public override void Draw(GameTime gameTime)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);

            renderer.Begin();
            renderer.SetCamera(camera.Transform);

            GameManager.Draw(gameTime, renderer);

            renderer.End();

            interfaceManager.Draw(gameTime);

            Window.SwapBuffers();
        }