示例#1
0
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     p1Bounds = new Rectangle(new Vector2(0, 0), spriteBatch.MeasureString(scoreBoardPlayer1, Font));
     p2Bounds = new Rectangle(new Vector2(GraphicsDevice.BackBuffer.Width - spriteBatch.MeasureString(scoreBoardPlayer2, Font).X, 0), spriteBatch.MeasureString(scoreBoardPlayer2, Font));
     spriteBatch.DrawString(scoreBoardPlayer1, Font, p1Bounds, Color);
     spriteBatch.DrawString(scoreBoardPlayer2, Font, p2Bounds, Color);
 }
示例#2
0
 /// <summary>
 /// Initializes a new Touch class.
 /// </summary>
 /// <param name="id">The Id.</param>
 /// <param name="contact">The ContactSize.</param>
 /// <param name="location">The Location.</param>
 /// <param name="dateTime">The DateTime.</param>
 /// <param name="touchMode">The TouchMode.</param>
 public Touch(int id, Vector2 contact, Vector2 location, DateTime dateTime, TouchMode touchMode)
 {
     Id = id;
     Contact = contact;
     Location = location;
     Time = dateTime;
     TouchMode = touchMode;
     ContactRectangle = new Rectangle(location, contact);
 }
示例#3
0
        /// <summary>
        /// Draws a Rectangle.
        /// </summary>
        /// <param name="pen">The Pen.</param>
        /// <param name="rectangle">The Rectangle.</param>
        public void DrawRectangle(Pen pen, Rectangle rectangle)
        {
            var dxPen = pen.Instance as DirectXPen;

            if (dxPen == null)
            {
                throw new ArgumentException("DirectX10 expects a DirectXPen as resource.");
            }

            _renderTarget.DrawRectangle(dxPen.GetPen(), DirectXHelper.ConvertRectangle(rectangle));
        }
示例#4
0
        /// <summary>
        /// Draws a string.
        /// </summary>
        /// <param name="text">The Text.</param>
        /// <param name="font">The Font.</param>
        /// <param name="rectangle">The Rectangle.</param>
        /// <param name="color">The Color.</param>
        public void DrawString(string text, IFont font, Rectangle rectangle, Color color)
        {
            var oglFont = font as OpenGLFont;

            if (oglFont == null)
            {
                throw new ArgumentException("Expected a OpenGLFont as resource.");
            }

            OpenGLTexture texture = _textEntityManager.GetFontTexture(text, oglFont, color, (int)rectangle.Width);

            DrawTexture(texture, new Vector2(rectangle.X, rectangle.Y), Color.White);
        }
示例#5
0
        /// <summary>
        /// Draws a string.
        /// </summary>
        /// <param name="text">The Text.</param>
        /// <param name="font">The Font.</param>
        /// <param name="rectangle">The Rectangle.</param>
        /// <param name="color">The Color.</param>
        public void DrawString(string text, Font font, Rectangle rectangle, Color color)
        {
            var dxFont = font.Instance as DirectXFont;

            if (dxFont == null)
            {
                throw new ArgumentException("DirectX10 expects a DirectXFont as resource.");
            }

            _renderTarget.DrawText(text, dxFont.GetFont(),
                                   new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height),
                                   DirectXHelper.ConvertSolidColorBrush(color));
        }
示例#6
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="texture">The Texture.</param>
        /// <param name="rectangle">The Rectangle.</param>
        /// <param name="opacity">The Opacity.</param>
        /// <param name="color">The Color.</param>
        public void DrawTexture(Texture2D texture, Rectangle rectangle, Color color, float opacity = 1)
        {
            var dxTexture = texture as DirectXTexture;

            if (dxTexture == null)
            {
                throw new ArgumentException("DirectX10 expects a DirectXTexture as resource.");
            }
            Bitmap dxBmp = dxTexture.GetBitmap();

            _renderTarget.DrawBitmap(dxBmp, DirectXHelper.ConvertRectangle(rectangle), opacity,
                                     InterpolationMode == InterpolationMode.Linear
                    ? SlimDX.Direct2D.InterpolationMode.Linear
                    : SlimDX.Direct2D.InterpolationMode.NearestNeighbor);
        }
示例#7
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="texture">The Texture.</param>
        /// <param name="source">The SourceRectangle.</param>
        /// <param name="destination">The DestinationRectangle.</param>
        /// <param name="color">The Color.</param>
        /// <param name="opacity">The Opacity.</param>
        public void DrawTexture(Texture2D texture, Rectangle source, Rectangle destination, Color color,
                                float opacity = 1)
        {
            var dxTexture = texture as DirectXTexture;

            if (dxTexture == null)
            {
                throw new ArgumentException("DirectX11 expects a DirectXTexture as resource.");
            }
            Bitmap dxBmp = dxTexture.GetBitmap();

            DirectXHelper.RenderTarget.DrawBitmap(dxBmp, DirectXHelper.ConvertRectangle(destination), opacity,
                                                  InterpolationMode == InterpolationMode.Linear
                    ? BitmapInterpolationMode.Linear
                    : BitmapInterpolationMode.NearestNeighbor, DirectXHelper.ConvertRectangle(source));
        }
示例#8
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="spriteSheet">The SpriteSheet.</param>
        /// <param name="rectangle">The Rectangle.</param>
        /// <param name="color">The Color.</param>
        /// <param name="opacity">The Opacity.</param>
        public void DrawTexture(SpriteSheet spriteSheet, Rectangle rectangle, Color color, float opacity = 1)
        {
            var dxTexture = spriteSheet.Texture2D as DirectXTexture;

            if (dxTexture == null)
            {
                throw new ArgumentException("DirectX11 expects a DirectXTexture as resource.");
            }
            Bitmap dxBmp = dxTexture.GetBitmap();

            DirectXHelper.RenderTarget.DrawBitmap(dxBmp,
                                                  new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height), opacity,
                                                  InterpolationMode == InterpolationMode.Linear
                    ? BitmapInterpolationMode.Linear
                    : BitmapInterpolationMode.NearestNeighbor, DirectXHelper.ConvertRectangle(spriteSheet.Rectangle));
        }
示例#9
0
 /// <summary>
 /// Initializes a new UIControl class.
 /// </summary>
 /// <param name="assignedUIManager">The assigned UIManager.</param>
 protected UIControl(UIManager assignedUIManager)
 {
     _position = new Vector2(0, 0);
     _size = new UISize(0, 0);
     UpdateBounds();
     _mouseRectangle = new Rectangle {Width = 1, Height = 1};
     Guid = Guid.NewGuid();
     _inputManager = SGL.Components.Get<InputManager>();
     CanGetFocus = true;
     Enable = true;
     Visible = true;
     _parent = null;
     _lastRelativeMousePostion = new Vector2(0, 0);
     Children = new List<UIControl>();
     UIManager = assignedUIManager;
     UIManager.Add(this);
 }
示例#10
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="texture">The Texture.</param>
        /// <param name="rectangle">The Rectangle.</param>
        /// <param name="opacity">The Opacity.</param>
        /// <param name="color">The Color.</param>
        public void DrawTexture(ITexture texture, Rectangle rectangle, Color color, float opacity = 1)
        {
            var tex = texture as OpenGLTexture;

            if (tex == null)
            {
                throw new ArgumentException("Expected OpenGLTexture as resource.");
            }
            OpenGLColor col = OpenGLHelper.ConvertColor(color);

            var vertices = new[]
            {
                //  Position                                         Color             Texcoords
                rectangle.X, rectangle.Y, col.R, col.G, col.B, 0.0f, 0.0f,                   // Top-left
                rectangle.X + rectangle.Width, rectangle.Y, col.R, col.G, col.B, 1.0f, 0.0f, // Top-right
                rectangle.X + rectangle.Width, rectangle.Y + tex.Height, col.R, col.G, col.B, 1.0f, 1.0f,
                // Bottom-right
                rectangle.X, rectangle.Y + rectangle.Height, col.R, col.G, col.B, 0.0f, 1.0f // Bottom-left
            };

            _sourceVbo.SetData(vertices);

            tex.Bind();

            _colorShader.SetUniform("dim", _graphicsDevice.BackBuffer.Width, _graphicsDevice.BackBuffer.Height, opacity);
            _colorShader.SetUniformMatrix("transform", _matrix4);

            uint posAttrib = _colorShader.GetAttribLocation("position");

            VertexBuffer.EnableVertexAttribArray(posAttrib);
            VertexBuffer.VertexAttribPointer(posAttrib, 2, false, 7 * sizeof(float), 0);

            uint colAttrib = _colorShader.GetAttribLocation("color");

            VertexBuffer.EnableVertexAttribArray(colAttrib);
            VertexBuffer.VertexAttribPointer(colAttrib, 3, false, 7 * sizeof(float), 2 * sizeof(float));

            uint texAttrib = _colorShader.GetAttribLocation("texcoord");

            VertexBuffer.EnableVertexAttribArray(texAttrib);
            VertexBuffer.VertexAttribPointer(texAttrib, 2, false, 7 * sizeof(float), 5 * sizeof(float));

            OpenGLInterops.DrawElements(OpenGLInterops.GL_TRIANGLES, 6, OpenGLInterops.GL_UNSIGNED_SHORT, IntPtr.Zero);

            tex.Unbind();
        }
示例#11
0
        /// <summary>
        /// Initializes a new DebugDisplay class.
        /// </summary>
        /// <param name="entityComposer">The EntityComposer.</param>
        public DebugDisplay(EntityComposer entityComposer)
        {
            _currentEntityComposer = entityComposer;
            _gameLoop = SGL.QueryComponents<GameLoop>();

            _font = new Font("Segoe UI", 12, TypefaceStyle.Regular);
            _cpuWatcher = new CpuWatcher();
            _memoryWatcher = new MemoryWatcher();
            _threadWatcher = new ThreadWatcher();
            _display = new Rectangle(0, 0, 800, 480);
            _debugMessage = "Query information ...";
            _pen = new Pen(Color.Green, 1);
            _pen2 = new Pen(Color.Red, 1);
            _pen3 = new Pen(Color.Blue, 1);

            _cpuWatcher.Start();
            _memoryWatcher.Start();
            _threadWatcher.Start();
        }
示例#12
0
        /// <summary>
        /// Intersects the specified rectangle.
        /// </summary>
        /// <param name="rectangle">The rectangle.</param>
        public Rectangle Intersect(Rectangle rectangle)
        {
            if (!Intersects(rectangle))
            {
                return Empty;
            }

            float[] horizontal = {Left, Right, rectangle.Left, rectangle.Right};
            float[] vertical = {Bottom, Top, rectangle.Bottom, rectangle.Top};

            Array.Sort(horizontal);
            Array.Sort(vertical);

            float left = horizontal[1];
            float bottom = vertical[1];
            float right = horizontal[2];
            float top = vertical[2];

            return new Rectangle(left, top, right - left, bottom - top);
        }
示例#13
0
 /// <summary>
 /// Determines whether this instance contains the specified rectangle.
 /// </summary>
 /// <param name="value">The value.</param>
 public bool Contains(Rectangle value)
 {
     return
         value.X >= X &&
         value.Y >= Y &&
         value.X + value.Width <= Right &&
         value.Y + value.Height <= Bottom;
 }
示例#14
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="spriteSheet">The SpriteSheet.</param>
 /// <param name="rectangle">The Rectangle.</param>
 /// <param name="color">The Color.</param>
 /// <param name="opacity">The Opacity.</param>
 public void DrawTexture(SpriteSheet spriteSheet, Rectangle rectangle, Color color, float opacity = 1f)
 {
     Renderer.DrawTexture(spriteSheet, rectangle, color, opacity);
 }
示例#15
0
 /// <summary>
 /// Draws an Arc.
 /// </summary>
 /// <param name="pen">The Pen.</param>
 /// <param name="rectangle">The Rectangle.</param>
 /// <param name="startAngle">The StartAngle.</param>
 /// <param name="sweepAngle">The SweepAngle.</param>
 public void DrawArc(Pen pen, Rectangle rectangle, float startAngle, float sweepAngle)
 {
     throw new NotSupportedException("DrawArc is not supported by DirectX10.");
 }
示例#16
0
 /// <summary>
 /// Fills a Rectangle.
 /// </summary>
 /// <param name="color">The Color.</param>
 /// <param name="rectangle">The Rectangle.</param>
 public void FillRectangle(Color color, Rectangle rectangle)
 {
     var line = new Line(_direct3D9Device) {Antialias = true, Width = rectangle.Height};
     line.Begin();
     line.Draw(
         DirectXHelper.ConvertToVertex(new Vector2(rectangle.X, rectangle.Center.Y),
             new Vector2(rectangle.X + rectangle.Width, rectangle.Center.Y)),
         DirectXHelper.ConvertColor(color));
     line.End();
 }
示例#17
0
        /// <summary>
        /// Draws a string.
        /// </summary>
        /// <param name="text">The Text.</param>
        /// <param name="font">The Font.</param>
        /// <param name="rectangle">The Rectangle.</param>
        /// <param name="color">The Color.</param>
        public void DrawString(string text, Font font, Rectangle rectangle, Color color)
        {
            var dxFont = font.Instance as DirectXFont;
            if (dxFont == null) throw new ArgumentException("DirectX9 expects a DirectXFont as resource.");

            dxFont.GetFont()
                .DrawString(_sprite, text, DirectXHelper.ConvertToWinRectangle(rectangle), DrawTextFormat.WordBreak,
                    DirectXHelper.ConvertColor(color));
        }
示例#18
0
 /// <summary>
 /// Draws an Arc.
 /// </summary>
 /// <param name="pen">The Pen.</param>
 /// <param name="rectangle">The Rectangle.</param>
 /// <param name="startAngle">The StartAngle.</param>
 /// <param name="sweepAngle">The SweepAngle.</param>
 public void DrawArc(Pen pen, Rectangle rectangle, float startAngle, float sweepAngle)
 {
     throw new NotSupportedException("DrawArc is not supported by DirectX9");
 }
示例#19
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="spriteSheet">The SpriteSheet.</param>
 /// <param name="rectangle">The Rectangle.</param>
 /// <param name="color">The Color.</param>
 /// <param name="opacity">The Opacity.</param>
 public void DrawTexture(ITexture texture, SpriteSheet spriteSheet, Rectangle rectangle, Color color,
                         float opacity = 1)
 {
     DrawTexture(texture, spriteSheet.Rectangle, rectangle, color, opacity);
 }
示例#20
0
        /// <summary>
        /// Draws a string.
        /// </summary>
        /// <param name="text">The Text.</param>
        /// <param name="font">The Font.</param>
        /// <param name="rectangle">The Rectangle.</param>
        /// <param name="color">The Color.</param>
        public void DrawString(string text, Font font, Rectangle rectangle, Color color)
        {
            var dxFont = font.Instance as DirectXFont;
            if (dxFont == null) throw new ArgumentException("DirectX10 expects a DirectXFont as resource.");

            _renderTarget.DrawText(text, dxFont.GetFont(),
                new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height),
                DirectXHelper.ConvertSolidColorBrush(color));
        }
示例#21
0
        /// <summary>
        /// Draws a Rectangle.
        /// </summary>
        /// <param name="pen">The Pen.</param>
        /// <param name="rectangle">The Rectangle.</param>
        public void DrawRectangle(Pen pen, Rectangle rectangle)
        {
            var dxPen = pen.Instance as DirectXPen;
            if (dxPen == null) throw new ArgumentException("DirectX10 expects a DirectXPen as resource.");

            _renderTarget.DrawRectangle(dxPen.GetPen(), DirectXHelper.ConvertRectangle(rectangle));
        }
示例#22
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="rectangle">The Rectangle.</param>
 /// <param name="opacity">The Opacity.</param>
 /// <param name="color">The Color.</param>
 public void DrawTexture(Texture2D texture, Rectangle rectangle, Color color, float opacity = 1f)
 {
     Renderer.DrawTexture(texture.Texture, rectangle, color, opacity);
 }
示例#23
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="source">The SourceRectangle.</param>
 /// <param name="destination">The DestinationRectangle.</param>
 /// <param name="opacity">The Opacity.</param>
 public void DrawTexture(Texture2D texture, Rectangle source, Rectangle destination, float opacity = 1f)
 {
     DrawTexture(texture, source, destination, Color.White, opacity);
 }
示例#24
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="source">The SourceRectangle.</param>
 /// <param name="destination">The DestinationRectangle.</param>
 /// <param name="color">The Color.</param>
 /// <param name="opacity">The Opacity.</param>
 public void DrawTexture(Texture2D texture, Rectangle source, Rectangle destination, Color color,
     float opacity = 1f)
 {
     Renderer.DrawTexture(texture.Texture, source, destination, color, opacity);
 }
示例#25
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="spriteSheet">The SpriteSheet.</param>
 /// <param name="rectangle">The Rectangle.</param>
 /// <param name="opacity">The Opacity.</param>
 public void DrawTexture(SpriteSheet spriteSheet, Rectangle rectangle, float opacity = 1f)
 {
     DrawTexture(spriteSheet, rectangle, Color.White, opacity);
 }
示例#26
0
 /// <summary>
 /// Intersectses the specified rectangle.
 /// </summary>
 /// <param name="rectangle">The rectangle.</param>
 public bool Intersects(Rectangle rectangle)
 {
     return
         !(Left > rectangle.Right ||
           Right < rectangle.Left ||
           Top > rectangle.Bottom ||
           Bottom < rectangle.Top);
 }
示例#27
0
 /// <summary>
 /// Initializes a new Keyframe class.
 /// </summary>
 /// <param name="displayRectangle">The DisplayRectangle.</param>
 /// <param name="duration">The Duration.</param>
 public Keyframe(Rectangle displayRectangle, float duration)
 {
     DisplayRectangle = displayRectangle;
     Duration = duration;
 }
示例#28
0
 /// <summary>
 /// Initializes a new BlackBlend class.
 /// </summary>
 public BlackBlend()
 {
     _display = new Rectangle(0, 0, 800, 480);
 }
示例#29
0
        /// <summary>
        /// Draws a Rectangle.
        /// </summary>
        /// <param name="pen">The Pen.</param>
        /// <param name="rectangle">The Rectangle.</param>
        public void DrawRectangle(Pen pen, Rectangle rectangle)
        {
            var dxPen = pen.Instance as DirectXPen;
            if (dxPen == null) throw new ArgumentException("DirectX9 expects a DirectXPen as resource.");

            var line = new Line(_direct3D9Device) {Antialias = true, Width = dxPen.Width};
            line.Begin();

            line.Draw(
                DirectXHelper.ConvertToVertex(
                    new Vector2(rectangle.X, rectangle.Y),
                    new Vector2(rectangle.X + rectangle.Width, rectangle.Y),
                    new Vector2(rectangle.X, rectangle.Y + rectangle.Height),
                    new Vector2(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height),
                    new Vector2(rectangle.X, rectangle.Y),
                    new Vector2(rectangle.X, rectangle.Y + rectangle.Height),
                    new Vector2(rectangle.X + rectangle.Width, rectangle.Y),
                    new Vector2(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height)),
                DirectXHelper.ConvertColor(dxPen.Color));

            line.End();
        }
示例#30
0
 /// <summary>
 /// Fills a Rectangle.
 /// </summary>
 /// <param name="color">The Color.</param>
 /// <param name="rectangle">The Rectangle.</param>
 public void FillRectangle(Color color, Rectangle rectangle)
 {
     _renderTarget.FillRectangle(new SolidColorBrush(_renderTarget, DirectXHelper.ConvertColor(color)),
                                 DirectXHelper.ConvertRectangle(rectangle));
 }
示例#31
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="texture">The Texture.</param>
        /// <param name="source">The SourceRectangle.</param>
        /// <param name="destination">The DestinationRectangle.</param>
        /// <param name="color">The Color.</param>
        /// <param name="opacity">The Opacity.</param>
        public void DrawTexture(Texture2D texture, Rectangle source, Rectangle destination, Color color,
            float opacity = 1)
        {
            var dxTexture = texture as DirectXTexture;
            if (dxTexture == null) throw new ArgumentException("DirectX9 expects a DirectXTexture as resource.");

            //calc percentages for scaling

            float scaleX = destination.Width/source.Width;
            float scaleY = destination.Height/source.Height;

            _sprite.Transform = Matrix.Scaling(scaleX, scaleY, 1f);

            _sprite.Draw(dxTexture.GetTexture(), DirectXHelper.ConvertToWinRectangle(source), null,
                DirectXHelper.ConvertVector3(new Vector2(destination.X/scaleX, destination.Y/scaleY)),
                DirectXHelper.ConvertColor(color));

            _sprite.Transform = Matrix.Identity;
        }
示例#32
0
 /// <summary>
 /// Initializes a new Projectile class.
 /// </summary>
 /// <param name="projectileTexture">The ProjectileTexture.</param>
 public Projectile(Texture2D projectileTexture)
 {
     Texture = projectileTexture;
     Position = new Vector2(0);
     Bounds = new Rectangle(Position, new Vector2(46, 16));
 }
示例#33
0
        /// <summary>
        ///     A value indicating whether the player intersects.
        /// </summary>
        /// <param name="player">The Player.</param>
        /// <returns>True if intersecting.</returns>
        public bool Intersects(Player player)
        {
            lock (_lockObj)
            {
                foreach (Pipe pipe in _pipes)
                {
                    /*/var polygon1 = new Polygon();
                    polygon1.Add(new Vector2(pipe.Position.X, pipe.Position.Y),
                        new Vector2(pipe.Position.X + 44, pipe.Position.Y),
                        new Vector2(pipe.Position.X + 44, pipe.Position.Y + pipe.TopPipeHeight + 22),
                        new Vector2(pipe.Position.X, pipe.Position.Y + pipe.TopPipeHeight + 22));

                    var polygon2 = new Polygon();
                    polygon2.Add(new Vector2(pipe.Position.X, 480), new Vector2(pipe.Position.X + 44, 480),
                      new Vector2(pipe.Position.X + 44, pipe.BottomPipeY - 22),
                                   new Vector2(pipe.Position.X, pipe.BottomPipeY - 22));

                    if (player.Bounds.Intersects(polygon1))
                    {
                        return true;
                    }

                    if (player.Bounds.Intersects(polygon2))
                    {
                        return true;
                    }/*/

                    var rect1 = new Rectangle(pipe.Position.X, pipe.Position.Y, 46, pipe.TopPipeHeight + 22);
                    var rect2 = new Rectangle(pipe.Position.X, pipe.BottomPipeY, 46, pipe.BottomPipeHeight);
                    var playerrect = new Rectangle(player.Position, new Vector2(32, 24));

                    if (playerrect.Intersects(rect1) || playerrect.Intersects(rect2))
                    {
                        return true;
                    }
                }
            }
            return false;
        }
示例#34
0
 /// <summary>
 /// Updates the projectile.
 /// </summary>
 /// <param name="gameTime">The GameTime.</param>
 public override void Update(GameTime gameTime)
 {
     Position = new Vector2(Position.X + (Velocity*gameTime.ElapsedGameTime), Position.Y);
     Bounds = new Rectangle(Position, new Vector2(46, 16));
 }
示例#35
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="spriteSheet">The SpriteSheet.</param>
        /// <param name="rectangle">The Rectangle.</param>
        /// <param name="color">The Color.</param>
        /// <param name="opacity">The Opacity.</param>
        public void DrawTexture(SpriteSheet spriteSheet, Rectangle rectangle, Color color, float opacity = 1)
        {
            var dxTexture = spriteSheet.Texture2D as DirectXTexture;
            if (dxTexture == null) throw new ArgumentException("DirectX10 expects a DirectXTexture as resource.");
            Bitmap dxBmp = dxTexture.GetBitmap();

            DirectXHelper.RenderTarget.DrawBitmap(dxBmp,
                new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height), opacity,
                InterpolationMode == InterpolationMode.Linear
                    ? SlimDX.Direct2D.InterpolationMode.Linear
                    : SlimDX.Direct2D.InterpolationMode.NearestNeighbor,
                DirectXHelper.ConvertRectangleF(spriteSheet.Rectangle));
        }
示例#36
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="rectangle">The Rectangle.</param>
 /// <param name="opacity">The Opacity.</param>
 public virtual void DrawTexture(Texture2D texture, Rectangle rectangle, float opacity = 1f)
 {
     DrawTexture(texture, rectangle, Color.White, opacity);
 }
示例#37
0
 /// <summary>
 /// Initialisieren der privaten Member
 /// </summary>
 public override void Initialize()
 {
     GraphicsDevice = SGL.Components.Get<GraphicsDevice>();
     inputManager = SGL.Components.Get<InputManager>();
     sceneManager = SGL.Components.Get<SceneManager>();
     ball = new Content.Ball();
     sL = new Content.Schlaeger(new Vector2(10, 250));
     sL.KeyMoveDown = Keys.S;
     sL.KeyMoveUp = Keys.W;
     sR = new Content.Schlaeger(new Vector2(780,250));
     sR.KeyMoveDown = Keys.Down;
     sR.KeyMoveUp = Keys.Up;
     int w = GraphicsDevice.BackBuffer.Width;    //800
     int h = GraphicsDevice.BackBuffer.Height;   //600
     this.torLinks        = new Rectangle(    9, 0, 1, h);
     this.begrenzungOben  = new Rectangle(    0, 0, w, 1);
     this.torRechts       = new Rectangle(w - 9, 0, 1, h);
     this.begrenzungUnten = new Rectangle(    0, h, w, 1);
     scoreBoard = new Content.ScoreBoard()
     {
         Color = Color.White,
         Font = new Font("Arial", 15f, TypefaceStyle.Regular),
         Pen = new Pen(Color.White, 15f),
         Spieler1 = new Content.Player()
         {
             Name = "Spieler1"
         },
         Spieler2 = new Content.Player()
         {
             Name = "Spieler2"
         }
     };
 }
示例#38
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="texture">The Texture.</param>
        /// <param name="source">The SourceRectangle.</param>
        /// <param name="destination">The DestinationRectangle.</param>
        /// <param name="color">The Color.</param>
        /// <param name="opacity">The Opacity.</param>
        public void DrawTexture(Texture2D texture, Rectangle source, Rectangle destination, Color color,
            float opacity = 1)
        {
            var dxTexture = texture as DirectXTexture;
            if (dxTexture == null) throw new ArgumentException("DirectX10 expects a DirectXTexture as resource.");
            Bitmap dxBmp = dxTexture.GetBitmap();

            DirectXHelper.RenderTarget.DrawBitmap(dxBmp, DirectXHelper.ConvertRectangleF(destination), opacity,
                InterpolationMode == InterpolationMode.Linear
                    ? SlimDX.Direct2D.InterpolationMode.Linear
                    : SlimDX.Direct2D.InterpolationMode.NearestNeighbor, DirectXHelper.ConvertRectangleF(source));
        }
示例#39
0
        /// <summary>
        /// Updates the Player.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public override void Update(GameTime gameTime)
        {
            if (!_isVisible) return;

            Sprite.Update(gameTime);
            Bounds = new Rectangle(Position, new Vector2(47, 61));
            _healthBarRed = new Rectangle(Position.X, Position.Y - 10, 38, 2);
            _healthBarGreen = new Rectangle(Position.X, Position.Y - 10, 38f*Health/MaximumHealth, 2);
        }
示例#40
0
 /// <summary>
 /// Fills a Rectangle.
 /// </summary>
 /// <param name="color">The Color.</param>
 /// <param name="rectangle">The Rectangle.</param>
 public void FillRectangle(Color color, Rectangle rectangle)
 {
     _renderTarget.FillRectangle(new SolidColorBrush(_renderTarget, DirectXHelper.ConvertColor(color)),
         DirectXHelper.ConvertRectangle(rectangle));
 }