Esempio 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();
        }
Esempio n. 2
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);

            shapeRenderer.Begin();

            //Create matrix transforms based on the body's rotation and position
            Vector2 ballPosition = ball.Position * unitToPixel;

            shapeRenderer.SetTransform(
                Matrix4.CreateRotationZ(ball.Rotation) *
                Matrix4.CreateTranslation(ballPosition.X, ballPosition.Y, 0f));
            shapeRenderer.DrawShape(rocketShape, Color4.Black);

            shapeRenderer.ClearTransform();
            shapeRenderer.DrawRect(new Vector2(0f, 425f), new Vector2(800f, 25f), Color4.Red);

            foreach (Body box in boxes)
            {
                Vector2 boxPos = (box.Position * unitToPixel) - new Vector2(25f);
                shapeRenderer.SetTransform(
                    Matrix4.CreateTranslation(-boxPos.X - 25f, -boxPos.Y - 25f, 0f) *
                    Matrix4.CreateRotationZ(box.Rotation) *
                    Matrix4.CreateTranslation(boxPos.X + 25f, boxPos.Y + 25f, 0f));
                shapeRenderer.DrawRect(boxPos, new Vector2(50f), Color4.Brown);
            }

            shapeRenderer.End();

            SwapBuffers();
        }
Esempio n. 3
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);

            shapeRenderer.Begin();

            //Create matrix transforms based on the body's rotation and position
            Vector2 body01Position = (body01.Position * unitToPixel) - new Vector2(25f, 25f);

            shapeRenderer.SetTransform(
                Matrix4.CreateRotationZ(body01.Rotation) *
                Matrix4.CreateTranslation(body01Position.X + 25f, body01Position.Y + 25f, 0f));
            shapeRenderer.FillShape(body01Shape, Color4.Red);
            shapeRenderer.DrawShape(body01Shape, Color4.Black);

            Vector2 body02Position = (body02.Position * unitToPixel) - new Vector2(400f, 25f);

            shapeRenderer.SetTransform(
                Matrix4.CreateRotationZ(body02.Rotation) *
                Matrix4.CreateTranslation(body02Position.X + 400f, body02Position.Y + 25f, 0f));
            shapeRenderer.FillShape(body02Shape, Color4.Blue);
            shapeRenderer.DrawShape(body02Shape, Color4.Black);
            shapeRenderer.End();

            SwapBuffers();
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        public InterfaceManager(ContentManager content)
        {
            fontLibrary = new Library();
            fontFace    = new Face(fontLibrary, "Content/Fonts/Jack.ttf");
            fontFace.SetCharSize(0, 18f, 0, 0);

            textureRenderer = new TextureRenderer(content, 800, 450);
            shapeRenderer   = new ShapeRenderer(content, 800, 450);
            stringRenderer  = new StringRenderer();

            shapeRenderer.Begin();
            shapeRenderer.SetProjection(Matrix4.CreateOrthographicOffCenter(0f, 800f, 450f, 0f, -1f, 1f));
            shapeRenderer.End();

            screens = new Dictionary <string, Screen>();
            screens.Add("MainMenu", new MainMenu(this));
            screens.Add("GameOverlay", new GameOverlay(this));

            ChangeScreen("GameOverlay");
        }