Beispiel #1
0
        public ConvexShape GetRectangleBoundary()
        {
            Vector2f leftSide      = this.Position + _direction * Radius;
            Vector2f pointUpLeft   = leftSide + new Vector2f(-_direction.Y, _direction.X) * Radius;
            Vector2f pointDownLeft = leftSide + new Vector2f(_direction.Y, -_direction.X) * Radius;

            Vector2f rightSide      = _oldPosition - _direction * Radius;
            Vector2f pointUpRight   = rightSide - new Vector2f(-_direction.Y, _direction.X) * Radius;
            Vector2f pointDownRight = rightSide - new Vector2f(_direction.Y, -_direction.X) * Radius;

            ConvexShape shape = new ConvexShape();

            shape.SetPointCount((uint)4);
            shape.SetPoint(0, pointUpLeft);
            shape.SetPoint(2, pointUpRight);
            shape.SetPoint(1, pointDownRight);
            shape.SetPoint(3, pointDownLeft);

            return(shape);
        }
        static List <ConvexShape> CreateConvexShapes(Vector2f windowSize, List <Object3D> objects3D)
        {
            List <ConvexShape> convexShapes   = new List <ConvexShape>();
            List <float>       planeDistances = new List <float>();

            for (int k = 0; k < objects3D.Count; k++)
            {
                List <Vector3> object3DPoints          = objects3D[k].Vertices;
                Vector2f[]     processedObject3DPoints = new Vector2f[objects3D[k].Vertices.Count];

                for (int i = 0; i < object3DPoints.Count; i++)
                {
                    (float tempX, float tempY) = PerspectiveProjection(object3DPoints[i], 600);
                    processedObject3DPoints[i] = new Vector2f(tempX + windowSize.X / 2, tempY + windowSize.Y / 2);
                }

                for (int i = 0; i < objects3D[k].Planes.Count; i++)
                {
                    ConvexShape convex = new ConvexShape();
                    Vector3[]   plane  = new Vector3[objects3D[k].Planes[i].FieldVertices.Length];
                    convex.SetPointCount((uint)objects3D[k].Planes[i].FieldVertices.Length);

                    for (uint j = 0; j < objects3D[k].Planes[i].FieldVertices.Length; j++)
                    {
                        convex.SetPoint(j, processedObject3DPoints[objects3D[k].Planes[i].FieldVertices[j]]);
                        plane[j] = objects3D[k].Vertices[objects3D[k].Planes[i].FieldVertices[j]];
                    }
                    planeDistances.Add(GetDistanceToPlane(plane));

                    Vector3 center = objects3D[k].getCenterVector();
                    convex.FillColor = FlatShading(objects3D[k].Vertices[objects3D[k].Planes[i].FieldVertices[0]],
                                                   objects3D[k].Vertices[objects3D[k].Planes[i].FieldVertices[1]],
                                                   objects3D[k].Vertices[objects3D[k].Planes[i].FieldVertices[2]],
                                                   center, objects3D[k].Color);
                    convexShapes.Add(convex);
                }
            }
            return(PainterAlgorithm(convexShapes, planeDistances));
        }
        private void ImgChararctersConstruction()
        {
            if (_characterPlayer1 != string.Empty)
            {
                _imgPlayer1.SetPointCount(9);
                _imgPlayer1.SetPoint(0, new Vector2f(125f, 15f));
                _imgPlayer1.SetPoint(1, new Vector2f(575f, 15f));
                _imgPlayer1.SetPoint(2, new Vector2f(370f, 760f));
                _imgPlayer1.SetPoint(3, new Vector2f(345f, 760f));
                _imgPlayer1.SetPoint(4, new Vector2f(325f, 800f));
                _imgPlayer1.SetPoint(5, new Vector2f(329f, 760f));
                _imgPlayer1.SetPoint(6, new Vector2f(267f, 760f));
                _imgPlayer1.SetPoint(7, new Vector2f(298f, 898f));
                _imgPlayer1.SetPoint(8, new Vector2f(-155f, 898f));

                _imgPlayer1.Position    = new Vector2f(900f, 0f);
                _imgPlayer1.Texture     = _img.Character[_characterPlayer1];
                _imgPlayer1.TextureRect = new IntRect(0, 0, Convert.ToInt32(_img.Character[_characterPlayer1].Size.X), Convert.ToInt32(_img.Character[_characterPlayer1].Size.Y));
            }

            if (_characterPlayer2 != string.Empty)
            {
                _imgPlayer2.SetPointCount(7);
                _imgPlayer2.SetPoint(0, new Vector2f(130f, 15f));
                _imgPlayer2.SetPoint(1, new Vector2f(490f, 15f));
                _imgPlayer2.SetPoint(2, new Vector2f(490f, 330f));
                _imgPlayer2.SetPoint(3, new Vector2f(345f, 898f));
                _imgPlayer2.SetPoint(4, new Vector2f(-50f, 898f));
                _imgPlayer2.SetPoint(5, new Vector2f(-50f, 758f));
                _imgPlayer2.SetPoint(6, new Vector2f(-95f, 758f));

                _imgPlayer2.Position    = new Vector2f(1428f, 0f);
                _imgPlayer2.Texture     = _img.Character[_characterPlayer2];
                _imgPlayer2.TextureRect = new IntRect(0, 0, Convert.ToInt32(_img.Character[_characterPlayer2].Size.X), Convert.ToInt32(_img.Character[_characterPlayer2].Size.Y));
            }
        }
Beispiel #4
0
        public Map(RenderWindow window, CharacterMenu character)
        {
            _nextState     = this;
            _characterMenu = character;
            _mapImage      = CreateListMap();
            _selectMap     = CreateSelectMao();

            _background = new RectangleShape()
            {
                Position = new Vector2f(0f, 0f),
                Size     = new Vector2f(window.Size.X, window.Size.Y),
                Texture  = new Texture("../../../../img/Menu/SelectMap.jpg"),
            };

            _mapDisplay = new RectangleShape()
            {
                Size     = new Vector2f(1880f, 517f),
                Position = new Vector2f(20f, 175f),
                Texture  = new Texture("../../../../img/stages/stage1.jpg"),
            };

            _Map1.SetPointCount(4);
            _Map1.SetPoint(0, new Vector2f(0f, 0f));
            _Map1.SetPoint(1, new Vector2f(72f, 0f));
            _Map1.SetPoint(2, new Vector2f(189f, 187f));
            _Map1.SetPoint(3, new Vector2f(115f, 187f));
            _Map1.Texture          = new Texture("../../../../img/stages/stage1.jpg");
            _Map1.Texture.Smooth   = true;
            _Map1.OutlineColor     = Color.White;
            _Map1.OutlineThickness = 2;
            _Map1.Position         = new Vector2f(594f, 744f);

            _Map2.SetPointCount(4);
            _Map2.SetPoint(0, new Vector2f(0f, 0f));
            _Map2.SetPoint(1, new Vector2f(72f, 0f));
            _Map2.SetPoint(2, new Vector2f(189f, 187f));
            _Map2.SetPoint(3, new Vector2f(115f, 187f));
            _Map2.Texture          = new Texture("../../../../img/stages/stage2.jpg");
            _Map2.Texture.Smooth   = true;
            _Map2.OutlineColor     = Color.White;
            _Map2.OutlineThickness = 2;
            _Map2.Position         = new Vector2f(676f, 744f);

            _Map3.SetPointCount(4);
            _Map3.SetPoint(0, new Vector2f(0f, 0f));
            _Map3.SetPoint(1, new Vector2f(72f, 0f));
            _Map3.SetPoint(2, new Vector2f(189f, 187f));
            _Map3.SetPoint(3, new Vector2f(115f, 187f));
            _Map3.Texture          = new Texture("../../../../img/stages/stage3.png");
            _Map3.Texture.Smooth   = true;
            _Map3.OutlineColor     = Color.White;
            _Map3.OutlineThickness = 2;
            _Map3.Position         = new Vector2f(758f, 744f);

            _Map4.SetPointCount(4);
            _Map4.SetPoint(0, new Vector2f(0f, 0f));
            _Map4.SetPoint(1, new Vector2f(72f, 0f));
            _Map4.SetPoint(2, new Vector2f(189f, 187f));
            _Map4.SetPoint(3, new Vector2f(115f, 187f));
            _Map4.Texture          = new Texture("../../../../img/stages/stage4.png");
            _Map4.Texture.Smooth   = true;
            _Map4.OutlineColor     = Color.White;
            _Map4.OutlineThickness = 2;
            _Map4.Position         = new Vector2f(1162f, 744f);
            _Map4.Scale            = new Vector2f(-1f, 1f);

            _Map5.SetPointCount(4);
            _Map5.SetPoint(0, new Vector2f(0f, 0f));
            _Map5.SetPoint(1, new Vector2f(72f, 0f));
            _Map5.SetPoint(2, new Vector2f(189f, 187f));
            _Map5.SetPoint(3, new Vector2f(115f, 187f));
            _Map5.Texture          = new Texture("../../../../img/stages/stage5.png");
            _Map5.Texture.Smooth   = true;
            _Map5.OutlineColor     = Color.White;
            _Map5.OutlineThickness = 2;
            _Map5.Position         = new Vector2f(1244f, 744f);
            _Map5.Scale            = new Vector2f(-1f, 1f);

            _Map6.SetPointCount(4);
            _Map6.SetPoint(0, new Vector2f(0f, 0f));
            _Map6.SetPoint(1, new Vector2f(72f, 0f));
            _Map6.SetPoint(2, new Vector2f(189f, 187f));
            _Map6.SetPoint(3, new Vector2f(115f, 187f));
            _Map6.Texture          = new Texture("../../../../img/stages/stage6.jpg");
            _Map6.Texture.Smooth   = true;
            _Map6.OutlineColor     = Color.White;
            _Map6.OutlineThickness = 2;
            _Map6.Position         = new Vector2f(1326f, 744f);
            _Map6.Scale            = new Vector2f(-1f, 1f);

            window.MouseButtonReleased += (sender, e) => ClickSelectMap(e, window);
        }