Esempio n. 1
0
    void LevelUp()
    {
        Chelik    = new CircleShape(width, height);
        Chelik    = new CircleShape(width * 2, height * 2);
        BigChelik = new CircleShape(width * 4, height * 4);
        CurLevel += 1;
        Hp       *= HpMultiplier;
        MoveStep *= SpeedMultiplier;
        MaxXp    *= MaxXpMultiplier;

        if (CurLevel == 2)
        {
            CurShape = Chelik;
            CurColor = ColorII;
        }
        if (CurLevel == 3)
        {
            CurShape = BigChelik;
            CurColor = ColorIII;
        }
        else
        {
            return;
        }
        CurShape.FillColor = CurColor;
        CurShape.Position  = CurPos;
        CurShape.Draw(window, RenderStates.Default);
    }
Esempio n. 2
0
        public override void Draw()
        {
            GraphicsMgr.CurrentColor = Color.Red;
            var position = GetComponent <PositionComponent>();

            CircleShape.Draw(position.Position, Raduis, true);
        }
Esempio n. 3
0
        public override void Draw()
        {
            base.Draw();

            var startingPosition = new Vector2(64, 64);
            var position         = startingPosition;
            var spacing          = 100;

            GraphicsMgr.CurrentColor = Color.White;

            _fireSprite.Draw(position, _fireAnimation.Progress, Vector2.Zero, Vector2.One, Angle.Right, Color.White);

            position += Vector2.UnitX * spacing;
            CircleShape.Draw(position, 8, _autoAlarmSwitch);

            position += Vector2.UnitX * 32;
            CircleShape.Draw(position, 8, _slowAlarmSwitch);

            position += Vector2.UnitX * 32;
            CircleShape.Draw(position, 8, _counterSwitch);

            position += Vector2.UnitX * 32;
            GraphicsMgr.CurrentColor = _color;
            if (_isRectangle)
            {
                RectangleShape.DrawBySize(position, Vector2.One * 16, _isOutline);
            }
            else
            {
                CircleShape.Draw(position, 8, _isOutline);
            }
        }
Esempio n. 4
0
        void Draw()
        {
            window.Clear(Color.Green);

            Circle.Draw(window, RenderStates.Default);
            Rectangle1.Draw(window, RenderStates.Default);
            Rectangle2.Draw(window, RenderStates.Default);

            window.Display();
        }
Esempio n. 5
0
        /// <summary>
        /// Draws the robot's shapes.
        /// </summary>
        /// <param name="target">The render target.</param>
        /// <param name="states">The render state (default).</param>
        public void Draw(RenderTarget target, RenderStates states)
        {
            if (Simulation.HasStarted)
            {
                StartPoint.Draw(target, states);
            }

            EndPoint.Draw(target, states);
            _circle.Draw(target, states);
            _rectangle.Draw(target, states);
        }
Esempio n. 6
0
        private void Draw()
        {
            window.Clear();

            Ball.FillColor = Color.Red;
            Ball.Draw(window, RenderStates.Default);

            LeftBat.Draw(window, RenderStates.Default);
            RightBat.Draw(window, RenderStates.Default);

            window.Display();
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a new surface and draws test stuff on it.
        /// </summary>
        void InitSurface()
        {
            _surface = new Surface(128, 128);

            Surface.SetTarget(_surface);

            GraphicsMgr.Device.Clear(_secondaryColor);

            GraphicsMgr.CurrentColor = _mainColor;
            CircleShape.Draw(new Vector2(64, 64), 64, false);

            Surface.ResetTarget();
        }
Esempio n. 8
0
 public void Circle(CircleShapeHandle handle)
 {
     if (_circleShape == null)
     {
         _circleShape = new CircleShape();
     }
     _circleShape.Radius           = handle.Radius;
     _circleShape.FillColor        = handle.FillColor;
     _circleShape.OutlineThickness = handle.OutlineThickness;
     _circleShape.OutlineColor     = handle.OutlineColor;
     _circleShape.Position         = handle.Position;
     _circleShape.Draw(_win, RenderStates.Default);
 }
Esempio n. 9
0
        public override void Draw(Canvas canvas)
        {
            base.Draw(canvas);

            var circleX = canvas.Width / 2 - CircleShape.MinimumWidth / 4;
            var circleY = canvas.Height / 2 - CircleShape.MinimumHeight;

            CircleShape.SetBounds(circleX, circleY, circleX + CircleShape.MinimumWidth, circleY + CircleShape.MinimumHeight);
            CircleShape.Draw(canvas);

            LabelPaint.GetTextBounds(BubbleText, 0, BubbleText.Length, textBoundsRect);
            canvas.DrawText(BubbleText,
                            circleX + CircleShape.MinimumWidth / 2 - textBoundsRect.Width() / 2,
                            (canvas.Height - textBoundsRect.Height()) / 2, LabelPaint);
        }
Esempio n. 10
0
        public void Draw()
        {
            // Transform matrices took care of the rotations,
            // so all panels assume they are drawn with no rotation\offset.
            RectangleShape.DrawBySize(Offset - Vector2.UnitY * Size / 2f, Size, true);

            CircleShape.Draw(Offset, 4, true);

            LineShape.Draw(Offset, Offset - Vector2.UnitY * 8);

            if (Attachments == null)
            {
                return;
            }

            // Transform matrices stack.
            GraphicsMgr.AddTransformMatrix(
                Matrix.CreateTranslation(-(Vector2.UnitY * Size / 2f).ToVector3())
                );
            foreach (var panel in Attachments)
            {
                // We need to offset the child panel by half of parent's
                // width or height depending on the side.
                var length     = Size.X / 2f;
                var resultSide = panel.Side;
                if (panel.Side % 2 == 0)
                {
                    length = Size.Y / 2f;
                }

                GraphicsMgr.AddTransformMatrix(
                    //Matrix.CreateRotationZ(0.3f) // Future reference - use this to pivot the panels.
                    Matrix.CreateTranslation(-(Vector2.UnitY * length).ToVector3())
                    * Matrix.CreateRotationZ((float)(Math.PI - Math.PI / 2f * resultSide))
                    * Matrix.CreateTranslation(Offset.ToVector3())
                    );
                panel.Draw();
                GraphicsMgr.ResetTransformMatrix();
            }

            GraphicsMgr.ResetTransformMatrix();
        }
Esempio n. 11
0
        static void ShapesDraw()
        {
            rect.Draw(window, RenderStates.Default);
            rectbl2.Draw(window, RenderStates.Default);
            rect1.Draw(window, RenderStates.Default);
            rect2.Draw(window, RenderStates.Default);

            recty1.Draw(window, RenderStates.Default);
            recty2.Draw(window, RenderStates.Default);


            rectbl1.Draw(window, RenderStates.Default);
            rectb1.Draw(window, RenderStates.Default);

            circle.Draw(window, RenderStates.Default);



            TextInGame();
        }
Esempio n. 12
0
        /// <summary>
        /// Method that impoments draw command for various shapes.
        /// </summary>
        /// <param name="statement">Syntax for specific Shape</param>
        public void Draw(StatementSyntax statement)
        {
            switch (statement)
            {
            case RectangleStatementSyntax rectangleSyntax:
                RectangleShape rectangle = (RectangleShape)ShapeFactory.GetShape(rectangleSyntax, _graphics, _fillState);
                rectangle.Draw(_pen, _brush, X, Y);
                MoveTo(X + rectangleSyntax.Width, Y + rectangleSyntax.Height);
                break;

            case CircleStatementSyntax circleSyntax:
                CircleShape circle = (CircleShape)ShapeFactory.GetShape(circleSyntax, _graphics, _fillState);
                circle.Draw(_pen, _brush, X, Y);
                MoveTo(X, Y);
                break;

            case TriangleStatementSyntax triangleSyntax:
                TriangleShape triangle = (TriangleShape)ShapeFactory.GetShape(triangleSyntax, _graphics, _fillState);
                triangle.Draw(_pen, _brush, X, Y);
                MoveTo(X, Y);
                break;
            }
        }
Esempio n. 13
0
        public override void Draw()
        {
            base.Draw();

            _secondaryColor.H += TimeKeeper.Global.Time(360 / 4f);
            if (_secondaryColor.H >= 360f)
            {
                _secondaryColor.H -= 360;
            }
            Debug.WriteLine(_secondaryColor.H);

            // This code shows how to draw shapes using static methods and instanced objects.

            var startingPosition = new Vector2(100, 100);
            var position         = startingPosition;
            var spacing          = 100;

            // Circles.
            GraphicsMgr.CurrentColor = _mainColor;             // Setting current color. It's active for all shapes and sprites.
            CircleShape.Draw(position, 24, false);             // Filled circle.

            GraphicsMgr.CurrentColor = _secondaryColor.ToColor();
            CircleShape.Draw(position, 32, true);             // Outline.


            position += Vector2.UnitX * spacing;


            CircleShape.CircleVerticesCount = 8;             // Changing the amount of circle vertices.

            GraphicsMgr.CurrentColor = _mainColor;
            CircleShape.Draw(position, 24, false);

            GraphicsMgr.CurrentColor = _secondaryColor.ToColor();
            CircleShape.Draw(position, 32, true);

            CircleShape.CircleVerticesCount = 32;
            // Circles.


            position  += Vector2.UnitY * spacing;
            position.X = startingPosition.X;


            // Rectangles.

            // You can draw rectangle using its top left and bottom right point...
            RectangleShape.Draw(position - Vector2.One * 24, position + Vector2.One * 24, false);

            GraphicsMgr.CurrentColor = _mainColor;
            // ...or its center position and size!
            RectangleShape.DrawBySize(position, Vector2.One * 64, true);

            position += Vector2.UnitX * spacing;

            RectangleShape.Draw(             // We can also manually set colors for each vertex.
                position - Vector2.One * 24,
                position + Vector2.One * 24,
                false,
                _mainColor,
                _mainColor,
                _mainColor,
                _secondaryColor.ToColor()
                );

            RectangleShape.DrawBySize(
                position,
                Vector2.One * 64,
                true,
                _mainColor,
                _secondaryColor.ToColor(),
                _mainColor,
                _mainColor
                );
            // Rectangles.


            position  += Vector2.UnitY * spacing;
            position.X = startingPosition.X;


            // Triangles.

            _triangle.Position = position;
            _triangle.Draw();             // Drawing an instantiated triangle.

            GraphicsMgr.CurrentColor = _mainColor;

            TriangleShape.Draw(
                position + new Vector2(-24, -24),
                position + new Vector2(24, -24),
                position + new Vector2(24, 24),
                false
                );

            // Be aware of culling. This triangle, for example, will be culled.
            // You can disable culling, if you don't want to deal with it.
            TriangleShape.Draw(new Vector2(-24, -24), new Vector2(24, 24), new Vector2(24, -24), false);

            // Triangles.



            // Lines.

            position += Vector2.UnitX * spacing;
            LineShape.Draw(position - Vector2.One * 24, position + Vector2.One * 24);

            position += Vector2.UnitX * spacing / 2f;
            ThickLineShape.Draw(position - Vector2.One * 24, position + Vector2.One * 24, 5);

            // Lines.
        }
Esempio n. 14
0
        /// <summary>
        /// Draws each <see cref="Body"/> instance that is managed by this drawer to the <see cref="RenderTarget"/> specified
        /// in the constructor, using the current view settings (rotation, zoom, etc.) to project the positions from 3D to 2D.
        /// This method should be called every frame, as without it the view isn't updated and neither are rotation or zoom.
        /// </summary>
        public void DrawBodies()
        {
            foreach (Body body in managedBodies)
            {
                // get the cached shape and projects the current bodies 3D position down to a 2D position,
                // which is used as the new position of the shape
                CircleShape shape = managedBodyShapeMap[body];

                // get the vertex array used to store orbit tracer points for this body
                VertexArray orbitTracerVertexArray = managedBodyTracerVertexArrayMap[body];

                // we need to clear the vertex array, to ensure that no garbage values are present. otherwise
                // there are lines from the origin to the first actually desired position
                orbitTracerVertexArray.Clear();

                // we only attempt to draw tracers if the body instance in question should record its previous position
                // otherwise, we skip the relatively expensive rendering code
                if (body.RecordPreviousPositions)
                {
                    Vector4[] orbitTracerPositions = body.OrbitTracer.PreviousPositions.ToArray();

                    double clampedSpeed = body.Velocity.Abs() < MaximumRenderedSpeed?body.Velocity.Abs() :
                                              body.Velocity.Abs() < MinimumRenderedSpeed ? MinimumRenderedSpeed : MaximumRenderedSpeed;

                    double clampedRainbowColour = Map(clampedSpeed, MinimumRenderedSpeed, MaximumRenderedSpeed, 0, 360);

                    // we cache the colours used for the orbit tracers and the background, and pack them into a 4D vector
                    Color   tracerColour = ColorFromHsv(clampedRainbowColour, 1, 1), bgColour = Color.Transparent;
                    Vector4 tracerVector = new Vector4(tracerColour.R, tracerColour.G, tracerColour.B, tracerColour.A);
                    Vector4 bgVector     = new Vector4(bgColour.R, bgColour.G, bgColour.B, bgColour.A);

                    for (uint i = 0; i < orbitTracerPositions.Length; i++)
                    {
                        Vector4 previousPosition = orbitTracerPositions[i];

                        // project previous position onto the screen
                        Vector4 pointScreenPosition = ProjectPoint(previousPosition);

                        // convert the final position into a Vector2f, useable by the SFML.NET Vertex struct
                        Vector2f finalOrbitTracerPosition = new Vector2f(
                            (float)(pointScreenPosition.X * renderTarget.Size.X / 2 + originOffset.X),
                            (float)(pointScreenPosition.Y * renderTarget.Size.Y / 2 + originOffset.Y));

                        // use linear interpolation to make the tail colour transition look smooth
                        Vector4 interpolatedColourVector =
                            LinearInterpolate(tracerVector, bgVector, i / (double)orbitTracerPositions.Length);

                        // unpack the colour from a vector into a colour
                        Color interpolatedColour = new Color(
                            (byte)interpolatedColourVector.X,
                            (byte)interpolatedColourVector.Y,
                            (byte)interpolatedColourVector.Z,
                            (byte)interpolatedColourVector.W
                            );

                        // append the new vertex to the orbit tracer array
                        orbitTracerVertexArray.Append(new Vertex(finalOrbitTracerPosition, interpolatedColour));
                    }

                    // single call to VertexArray.Draw() makes use of hardware acceleration without causing delays,
                    // as modern graphics processing units are optimised to render many vertices simultaneously, instead
                    // of rendering many vertices sequentially
                    orbitTracerVertexArray.Draw(renderTarget, RenderStates.Default);
                }

                Vector4 screenPosition = ProjectPoint(body.Position);

                // final position
                shape.Position = new Vector2f(
                    (float)(screenPosition.X * renderTarget.Size.X / 2 + originOffset.X),
                    (float)(screenPosition.Y * renderTarget.Size.Y / 2 + originOffset.Y)
                    );

                // the shape is drawn onto the render target at its final screen position
                shape.Draw(renderTarget, RenderStates.Default);
            }
        }
Esempio n. 15
0
        public override void Draw()
        {
            base.Draw();

            var startingPosition = new Vector2(64, 64);
            var position         = startingPosition;
            var spacing          = 100;

            GraphicsMgr.CurrentColor = _mainColor;

            // This position accounts for current camera transform matrix.
            // Visually it will be at the pointer's position when camera will move.
            CircleShape.Draw(Input.MousePosition, 4, false);

            // This position only accounts for screen transformation.
            // When the camera will move, it will offset.
            CircleShape.Draw(Input.ScreenMousePosition, 8, true);

            // You can also get mouse position from any camera.
            // This method can be used in Update, when no camera is active.
            CircleShape.Draw(GraphicsMgr.CurrentCamera.GetRelativeMousePosition(), 12, true);


            Text.CurrentFont = ResourceHub.GetResource <IFont>("Fonts", "Arial");

            Text.Draw("Keyboard input: " + _keyboardInput.ToString(), position);


            // Gamepad, mouse and keyboard buttons are using the same method.
            position += Vector2.UnitY * 64;
            CircleShape.Draw(position, 16, Input.CheckButton(KeyboardTestButton));
            position += Vector2.UnitX * 64;
            CircleShape.Draw(position, 16, Input.CheckButton(GamepadTestButton));
            position += Vector2.UnitX * 64;
            CircleShape.Draw(position, 16, Input.CheckButton(MouseTestButton));


            position = new Vector2(200, 200);

            if (Input.GamepadConnected(0))
            {
                Text.Draw("Gamepad is connected!", position);
            }
            else
            {
                Text.Draw("Gamepad is not connected.", position);
            }


            // Sticks.
            position += Vector2.UnitY * 96;
            CircleShape.Draw(position, 64, true);
            CircleShape.Draw(position + Input.GamepadGetLeftStick(0) * 64 * new Vector2(1, -1), 16, false);
            position += Vector2.UnitX * (128 + 64);
            CircleShape.Draw(position, 64, true);
            CircleShape.Draw(position + Input.GamepadGetRightStick(0) * 64 * new Vector2(1, -1), 16, false);

            // Triggers.
            position -= Vector2.UnitX * (64 + 16);
            RectangleShape.DrawBySize(position + Vector2.UnitY * Input.GamepadGetRightTrigger(0) * 64, Vector2.One * 8, false);
            LineShape.Draw(position, position + Vector2.UnitY * 64);
            position -= Vector2.UnitX * 32;
            RectangleShape.DrawBySize(position + Vector2.UnitY * Input.GamepadGetLeftTrigger(0) * 64, Vector2.One * 8, false);
            LineShape.Draw(position, position + Vector2.UnitY * 64);
        }
Esempio n. 16
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     circle.Draw(target, states);
 }
Esempio n. 17
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     tmp.Position = new SFML.System.Vector2f(ConvertUnits.ToDisplayUnits((float)body.Position.X) - tmp.Radius, ConvertUnits.ToDisplayUnits((float)body.Position.Y) - tmp.Radius);
     tmp.Draw(target, states);
 }