Пример #1
0
 private void DrawRotatedTank(AnimatedTank aTank, Color color)
 {
     if (!aTank.IsAlive)
     {
         return;
     }
     GL.LoadIdentity();
     Spritebatch.Begin(this.Width, this.Height);
     GL.Rotate(aTank.Angle, Vector3d.UnitZ);
     Spritebatch.Draw(tank, (aTank.PhisicalPosition - new Vector2(Width / 2, Height / 2) + new Vector2(25, 25)).Rotate(-aTank.Angle) + new Vector2(-25, -25), new Vector2(1f, 1f), color, new Vector2(0, 0));
 }
Пример #2
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            //view.Update();
            GL.Clear(ClearBufferMask.ColorBufferBit);

            GL.ClearColor(Color.White);

            Spritebatch.Begin(this.Width, this.Height);
            Vector2 upLeft = new Vector2(-this.Width / 2, -this.Height / 2);
            Vector2 zero   = new Vector2(0, 0);

            for (int i = 0; i < gm.map.Blocks.GetLength(0); i++)
            {
                for (int j = 0; j < gm.map.Blocks.GetLength(1); j++)
                {
                    if (gm.map.Blocks[i, j].Pattern == Core.Pattern.Brick)
                    {
                        Spritebatch.Draw(texture, new Vector2(i * 50, j * 50), new Vector2(1f, 1f), Color.DarkRed, upLeft);
                    }
                }
            }
            Spritebatch.Draw(redFlag, new Vector2(gm.map.RedFlagBlock.X * 50, gm.map.RedFlagBlock.Y * 50), new Vector2(1f, 1f), Color.Transparent, upLeft);
            Spritebatch.Draw(blueFlag, new Vector2(gm.map.BlueFlagBlock.X * 50, gm.map.BlueFlagBlock.Y * 50), new Vector2(1f, 1f), Color.Transparent, upLeft);
            //Red Tank 1

            DrawRotatedTank(redTank1, Color.Purple);
            //Blue Tank 1
            DrawRotatedTank(blueTank1, Color.GreenYellow);
            //Red Tank 2
            DrawRotatedTank(redTank2, Color.Red);

            //Blue Tank 2
            DrawRotatedTank(blueTank2, Color.GreenYellow);

            GL.LoadIdentity();

            //Spritebatch.Draw(tank, new Vector2(tankY / 2 + 100, tankX / 2 - 100), new Vector2(1f, 1f), Color.White, view.Position);
            //GL.Rotate(rotate, Vector3d.UnitZ);
            //Vector2 d = new Vector2(100, 100);

            ////Vector2 newD= new Vector2()
            //Spritebatch.Draw(tank, d.Rotate(-rotate) + new Vector2(-20, -20), new Vector2(1f, 1f), Color.Yellow, view.Position);
            //GL.LoadIdentity();
            //Spritebatch.Begin(this.Width, this.Height);
            //GL.Rotate(-rotate, Vector3d.UnitZ);
            //Vector2 d2 = new Vector2(0, 0);
            //Spritebatch.Draw(tank, (d2).Rotate(rotate) + new Vector2(-20, -20), new Vector2(1f, 1f), Color.Pink, view.Position);
            this.SwapBuffers();
        }