Example #1
0
        private static void Main(string[] args)
        {
            var contextSettings = new ContextSettings {
                DepthBits = 32
            };
            var window = new RenderWindow(new VideoMode(640, 480), "JukeSaver spike: SFML Basic", Styles.Default, contextSettings);
            window.SetActive();

            window.Closed += OnClosed;
            window.KeyPressed += OnKeyPressed;

            int r = 0, g = 0, b = 0;
            var shape = new CircleShape() {
                Position = new Vector2f(320, 240),
            };

            while (window.IsOpen()) {
                window.DispatchEvents();
                window.Clear(new Color((byte)r, (byte)g, (byte)b));

                shape.Radius = (float)(80.0 + GetPulse() * 40.0);
                shape.Origin = new Vector2f(shape.Radius * 0.5f, shape.Radius * 0.5f);
                shape.Position = new Vector2f(320 - shape.Radius * 0.5f, 240 - shape.Radius * 0.5f);

                shape.FillColor = new Color(50, (byte)(160 + 80 * GetPulse()), (byte)(40 - (40 * GetPulse())));

                window.Draw(shape);
                window.Display();
            }
        }
Example #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="pos">Posición inicial</param>
        /// <param name="radius">Radio</param>
        /// <param name="color">Color de la estrella</param>
        /// <param name="velocity">Velocidad de la estrella</param>
        public Star(Vector2f pos, float radius, Color color, Vector2f velocity) 
            : base(velocity) {

            _shape = new CircleShape(radius);
            Position = pos;
            _shape.FillColor = color;
        }
Example #3
0
 public Circle(float radius)
     : base((float)Math.PI * radius * radius)
 {
     circle = new CircleShape(radius);
     circle.FillColor = Color.Green;
     Origin = new Vector2f(1, 1).Unit() * radius;
 }
Example #4
0
        static void Main(string[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(800, 600), "Test01");
            window.Closed += (object sender, EventArgs e) => { (sender as Window).Close(); };

            Font font = new Font("SnowflakeLetters.ttf");
            Text text = new Text("BALD IST WEIHNACHTEN!", font);
            Color col1 = new Color(123, 12, 12);
            text.Position = new Vector2f(200, 200);
            CircleShape shape = new CircleShape(20, 8);
            shape.FillColor = Color.White;
            shape.Position = new Vector2f(50, 50);
            float a, c;
            a = c = 50f;

            while (window.IsOpen())
            {
                window.Clear(col1);
                window.Draw(text);
                if (Keyboard.IsKeyPressed(Keyboard.Key.Left) && a > 0)
                    a -= 0.1f;
                if (Keyboard.IsKeyPressed(Keyboard.Key.Right) && a < window.Size.X - shape.Radius * 2)
                    a += 0.1f;
                if (Keyboard.IsKeyPressed(Keyboard.Key.Down) && c < window.Size.Y - shape.Radius * 2)
                    c += 0.1f;
                if (Keyboard.IsKeyPressed(Keyboard.Key.Up) && c >  0)
                    c -= 0.1f;
                window.Draw(shape);
                shape.Position = new Vector2f(a, c);

                window.Display();
                window.DispatchEvents();
            }
        }
Example #5
0
 public Pickup(Game game, dynamic model = null)
     : base(game, (object) model)
 {
     Collision = new CircleShape(15);
     Collision.Origin = new Vector2f(15, 15);
     Collision.FillColor = new Color(0, 255, 0);
 }
Example #6
0
 public GameCharacter(Sorting sort, string str, int layer)
     : base(sort, str, layer)
 {
     BodyShape = new CircleShape(BodyRadius, 8);
     BodyShape.Origin = new Vector2f(BodyRadius, BodyRadius);
     Game.Sounds.Prepare(ref SFX_Death, "GenericHit1", 100, 0.5f);
 }
        public static CircleShape GetModel(int type, uint graphicsMode, byte alpha = 180, byte alpha_outline = 200)
        {
            CircleShape model = new CircleShape(15);
            model.Origin = new Vector2f(model.Radius, model.Radius);
            if (graphicsMode == Game.GRAPHICSMODE_NORMAL)
            {

                model.OutlineColor = new Color(0, 0, 0, alpha_outline);
                model.OutlineThickness = 6;
            }
            else
            {
                model.OutlineColor = new Color(255, 255, alpha_outline);
                model.OutlineThickness = 3;
            }

            switch (type)
            {
                case Powerup.DOUBLE_EXPLOSION_RADIUS: model.FillColor = new Color(255, 48, 48, alpha); break;
                case Powerup.AIM_SPEED_INCREASE: model.FillColor = new Color(96, 255, 99, alpha); break;
                case Powerup.FREEZE_TIME: model.FillColor = new Color(86, 198, 255, alpha); break;
                case Powerup.TRIPLE_CANNON: model.FillColor = new Color(255, 135, 205, alpha); break;
                case Powerup.OCTUPLE_CANNON: model.FillColor = new Color(172, 56, 255, alpha); break;
                case Powerup.RED_HOT_BEACH: model.FillColor = new Color(255, 87, 10, alpha); break;
            }

            return model;
        }
 public Ball(float x, float y, float radius, float speed, Color color)
     : base(x, y, radius*2, radius*2, speed)
 {
     graphic = new CircleShape(radius);
     graphic.FillColor = color;
     graphic.Position = new Vector2f(x, y);
 }
Example #9
0
 private void SetDisplayTraits()
 {
     m_shape = new CircleShape((float)Math.Log(Mass) * 2f);
     m_shape.Origin = new Vector2f(m_shape.Radius / 2f, m_shape.Radius / 2f);
     m_shape.FillColor = Color.White;
     m_shape.Position = Position;
 }
Example #10
0
        public void Draw(Points points, Color color)
        {
            var shape = new SFML.Graphics.CircleShape((points.TopRight - points.Center).Length());

            shape.Position  = GetDrawPositions(points.Center);
            shape.FillColor = new SFML.Graphics.Color(color.r, color.g, color.b);
            window.Draw(shape);
        }
Example #11
0
        public Player(FloatRect screenRect)
        {
            // setup player
            _shape = new CircleShape(30, 3);
            _shape.Position = new Vector2f(screenRect.Width/2 - (_shape.Radius), screenRect.Height - (_shape.Radius*2));
            _shape.FillColor = Color.Green;

            _bullets = new List<RectangleShape> ();
        }
Example #12
0
        public override void DrawSolidCircle(Vector2 center, float radius, Vector2 axis, float red, float blue, float green)
        {
            var col   = new Color((byte)red, (byte)green, (byte)blue);
            var shape = new SFML.Graphics.CircleShape(radius * 64, 8);

            shape.Position  = new Vector2f(center.X * 64, center.Y * 64);
            shape.Origin    = new Vector2f(radius * 64, radius * 64);
            shape.FillColor = col;
            rt.Draw(shape);
        }
Example #13
0
        public Planet(double mass, Vector2f vel)
        {
            Mass = 0;
            Mass = mass;
            Velocity = vel;
            m_shape = null;
            m_velDisplay = null;

            SetDisplayTraits();
        }
Example #14
0
        public WindowManager()
        {
            //Init main window shit
            window = new RenderWindow(new VideoMode(640, 480), "Super cool window title!");
            window.SetVerticalSyncEnabled(true);
            window.SetActive(true);
            window.Closed += window_Closed;

            // Open gl
            Gl.glEnable(Gl.GL_TEXTURE_2D);
            Gl.glLoadIdentity();
            Gl.glOrtho(0, 640, 480, 0, 0, 1);
            Gl.glMatrixMode(Gl.GL_MODELVIEW);

            Gl.glDisable(Gl.GL_DEPTH_TEST);

            Gl.glLoadIdentity();
            Gl.glTranslatef(0.375f, 0.375f, 0);

            particles = new CircleShape[pcount];
            for (int i = 0; i < pcount; i++)
            {
                particles[i] = new CircleShape(4f);
                particles[i].FillColor = Color.White;
                particles[i].Position = new Vector2f(0, 0);
                particles[i].Radius = 4;
            }

            circletest = new CircleShape();
            circletest.Position = new Vector2f(100, 100);
            circletest.OutlineColor = Color.Red;
            circletest.OutlineThickness = 1;
            circletest.FillColor = Color.Black;
            circletest.Radius = 100;

            circletest2 = new CircleShape();
            circletest2.Position = new Vector2f(200, 300);
            circletest2.OutlineColor = Color.Red;
            circletest2.OutlineThickness = 1;
            circletest2.FillColor = Color.Black;
            circletest2.Radius = 100;

            mytext = new Text("test", new Font("arial.ttf"), 16);
            mytext.Position = new Vector2f(4, 4);
            mytext.Color = Color.White;
            mytext.Style = Text.Styles.Bold;

            mytextShadow = new Text("test", new Font("arial.ttf"), 16);
            mytextShadow.Position = new Vector2f(6, 6);
            mytextShadow.Color = Color.Black;

            sim = new Simulation();
            sim.InitSimulation(pcount);
        }
        /// <summary>
        /// Drawing of the Project Model. Can simply override and return a Sprite if need be.
        /// </summary>
        /// <returns></returns>
        public virtual dynamic GetProjectileModel()
        {
            float radius = 10;
            CircleShape proj = new CircleShape(radius);
            proj.Origin = new Vector2f(radius, radius);
            proj.FillColor = new Color(0, 0, 0, 0);
            proj.OutlineThickness = 2;
            proj.OutlineColor = new Color(250, 250, 250);
            proj.SetPointCount(20);

            return proj;
        }
Example #16
0
        public Ball(int x, int y, int radius, Color colour)
        {
            Position = new Vector2f(x, y);
              Velocity = new Vector2f(
            (float)Game.Rand.NextDouble(),
            (float)Game.Rand.NextDouble());
              Radius = radius;
              Colour = colour;
              Speed = 600;

              Circle = new CircleShape();
              Circle.Radius = Radius;
        }
Example #17
0
        public PhysicsWorld(World world, bool noDim = false)
        {
            this.world = world;
            renderer = new SceneRenderer(world);
            Bodies = new List<BodyEx>();
            ignoreDim = noDim;

            unitCircle = new CircleShape(5.0f, 32);
            unitRect = new RectangleShape(new Vector2f(10, 10));
            unitRect.Origin = new Vector2f(5, 5);
            unitCircle.Origin = new Vector2f(5, 5);
            unitCircle.FillColor = Color.White;
            unitRect.FillColor = Color.White;
        }
        public AbstractTower()
            : base()
        {
            LoadStats();
            TowerHandler.Add(this);
            timeSpan = new TimeSpan();

            IsAlive = true;
            Activated = false;

            c = new CircleShape(Range);
            Color col = Color.Red;
            col.A = 100;
            c.FillColor = col;
        }
Example #19
0
        public void Draw(RenderWindow window)
        {
            // Draw outer dark circle
            CircleShape shape = new CircleShape(mass, 40);
            shape.FillColor = new Color((byte)Math.Max(color.R - 50, 0), (byte)Math.Max(color.G - 50, 0), (byte)Math.Max(color.B - 50, 0));
            shape.Position = new Vector2f(position.X - (ushort)mass, position.Y - (ushort)mass);
            window.Draw(shape);


            float diff = 4 + mass / 50;
            // Draw inner circle
            shape.Radius -= diff;
            shape.FillColor = color;
            shape.Position = new Vector2f(position.X - (ushort)mass + diff, position.Y - (ushort)mass + diff);
            window.Draw(shape);
        }
Example #20
0
 static void Main(string[] args)
 {
     //window = new RenderWindow(new VideoMode(500, 500), "test");
     //window = new Window(new VideoMode(500, 500), "My window");
     window.Closed += Window_Closed;
     window.Clear();
     CircleShape shape = new CircleShape(50);
     shape.FillColor = Color.Red;
     shape.OutlineThickness = 10;
     shape.OutlineColor = Color.Blue;
     //while (window.IsOpen) {
         window.Draw(shape);
         window.Display();
     //}
     Console.ReadKey();
 }
Example #21
0
        /// <param name="spawnDelay">In ms. Used to easily allow infantry to gradually move out of a ship.</param>
        /// <param name="ship">The ship this infantry is/will be spawned from (used only if spawnDelay is not 0).</param>
        public Infantryman(Game game, int spawnDelay = 0, Ship ship = null)
            : base(game, null)
        {
            Model = new CircleShape(4, 12);
            if (Game.GraphicsMode == Game.GRAPHICSMODE_NORMAL)
            {
                Model.FillColor = new Color((byte)Utils.RandomInt(0, 255), (byte)Utils.RandomInt(0, 255), (byte)Utils.RandomInt(0, 255));
                Model.OutlineColor = new Color(0, 0, 0);
                Model.OutlineThickness = 3;
            }
            else if (Game.GraphicsMode == Game.GRAPHICSMODE_BLUEPRINT)
            {
                Model.FillColor = new Color(0, 0, 0, 0);
                Model.OutlineColor = new Color(255, 255, 255);
                Model.OutlineThickness = 2;
            }
            AddChild(Model);
            Origin = new Vector2f(Model.Radius, Model.Radius);

            Collision = Model;

            HealthMax = 4000;
            Health = HealthMax;

            //SpeedMax = 100.0f;
            //Acc = 400.0f;
            SpeedMax = 10.0f + Math.Min(0.1f * Game.AIManager.Difficulty, 10.0f);
            Acc = 80.0f;
            Friction = 1000.0f;

            if (spawnDelay == 0)
            {
                SetAI(new InfantrymanAI(Game));
            }
            else
            {
                CanTakeDamage = false;
                Visible = false;
                if (ship == null)
                    return;
                Ship = ship;
                SpawnDelayTimer = new Timer(spawnDelay);
                SpawnDelayTimer.AutoReset = false;
                SpawnDelayTimer.Elapsed += OnSpawn;
                SpawnDelayTimer.Start();
            }
        }
Example #22
0
        public Circle(Vector2f position, float radius, uint fontSize)
        {
            _shape = new CircleShape(radius, 200);
            _shape.Origin = new Vector2f(_shape.Radius, _shape.Radius);
            _shape.Position = position;

            RadiusPow = _shape.Radius * _shape.Radius;

            _text = new Text(string.Empty, ResourceManager.Instance["fonts/verdana"] as Font, fontSize)
                        {
                            Color =
                                Color
                                .Black
                        };

            UpdateCircleText(string.Empty);
        }
Example #23
0
        public Player()
            : base(Sorting.Tag, "Player", 1)
        {
            Color = Color.Blue;
            BodyShape.FillColor = Color;
            MeleeShape = new CircleShape(MeleeRadius, 3);
            MeleeShape.FillColor = Color;
            MeleeShape.Origin = new Vector2f(MeleeRadius, MeleeRadius);

            Position = Game.Bounds.Center;
            Speed = 100;

            Health = new Stat(MaxHealth);
            Weapons[0] = new Minigun(this);
            Weapons[1] = new Flamer(this);
            SelectedWeapon = Weapons[0];
            IsWeaponUnlocked[0] = true;
        }
Example #24
0
        public Enemy(Vector position)
            : base(Sorting.Group, "Enemies", 2)
        {
            var roll = MathExtender.Roll(Chance_Fast, Chance_Big);

            if (roll == 0)
            {
                Color = new Color(255, 0, 255);
                Speed = 150;
                Health = new Stat(50);
                Radius = BodyRadius * 0.75f;
                MeleeTime = TimeSpan.FromSeconds(0.4);
                MeleeDamage = -5;
            }
            else if (roll == 1)
            {
                Color = new Color(0, 255, 0);
                Speed = 25;
                Health = new Stat(5000);
                Radius = BodyRadius * 2.0f;
                MeleeTime = TimeSpan.FromSeconds(0.8);
                MeleeDamage = -75;
            }
            else
            {
                Color = new Color(255, 0, 0);
                Speed = 50;
                Health = new Stat(100);
                Radius = BodyRadius;
                MeleeTime = TimeSpan.FromSeconds(1.5);
                MeleeDamage = -10;
            }

            Position = position;
            BodyShape.FillColor = Color;
            BodyShape.Radius = Radius;
            BodyShape.Origin = new Vector2f(Radius, Radius);
            MeleeRadius = Radius / 2.0f;
            MeleeShape = new CircleShape(MeleeRadius, 3);
            MeleeShape.Origin = new Vector2f(MeleeRadius, MeleeRadius);
            MeleeShape.FillColor = Color;

            ApplyDifficulty();
        }
Example #25
0
        public DebugView()
        {
            _staticColor = new Color(100, 150, 100, 128);
            _dynamicColor = new Color(100, 100, 150, 128);
            _staticOutlineColor = new Color(_staticColor.R, _staticColor.G, _staticColor.B, 255);
            _dynamicOutlineColor = new Color(_dynamicColor.R, _dynamicColor.G, _dynamicColor.B, 255);
            _circles = new CircleShape[MAX_SHAPES];
            _polygons = new ConvexShape[MAX_SHAPES];
            _lines = new RectangleShape[MAX_SHAPES];

            for (int i = 0; i < MAX_SHAPES; i++)
            {
                _circles[i] = new CircleShape();
                _circles[i].OutlineThickness = -0.05f;
                _polygons[i] = new ConvexShape();
                _polygons[i].OutlineThickness = -0.05f;
                _lines[i] = new RectangleShape();
            }
        }
Example #26
0
        public Planet(Vector2u displaySize)
            : base(displaySize)
        {
            _planet = new CircleShape(0.9f*displaySize.X / 2f, 4 + 2 * (uint)Math.Sqrt(displaySize.X))
            {
                Position = new Vector2f(1.1f*displaySize.X/2f, 1.1f*displaySize.Y/2f),
                OutlineThickness = 3,
                OutlineColor = new Color(20, 20, 20),
                Origin = new Vector2f(displaySize.X / 2f, displaySize.Y / 2f)
            };

            //_planet.FillColor = SFML.Graphics.Color.Magenta;
            _planet.Texture = GeneratePlanetTexture(new Vector2u((uint)_planet.Radius, (uint)_planet.Radius));

            AddItemToDraw(_planet, 5);

            //_hoverText = new Label("Planet", FontManager.ActiveFontManager, new Vector2u(100, 40));

            OnMouseMove += Planet_OnMouseMove;
        }
Example #27
0
        //Open Window
        public void StartGame()
        {
            this.XWindowSize = 400;
            this.YWindowSize = 300;
            this.WindowOffset = 15;

            _window = new RenderWindow(new VideoMode(XWindowSize, YWindowSize), "Pixel Blaster");
            _window.SetVisible(true);
            _window.Closed += new EventHandler(OnClosed);
            _window.KeyPressed += new EventHandler<SFML.Window.KeyEventArgs>(OnKeyPress);

            circle = new CircleShape();
            circle.Radius = 25f;
            circle.FillColor = Color.Green;

            Vector2f vect = new Vector2f();
            vect.X = (float)XWindowSize / 2 - circle.Radius;
            vect.Y = 4 * (float)YWindowSize / 5;

            circle.Position = vect;

            float circleSpeed = 4.0f;

            sprite = new Sprite();
            sprite.Color = Color.Red;
            sprite.Scale = vect;

            while (_window.IsOpen )
            {
                _window.DispatchEvents();

                _window.Clear();

                handleMovement(circleSpeed);

                _window.Draw(circle);
                _window.Draw(sprite);
                _window.Display();

            }
        }
Example #28
0
        /// <summary>
        /// Прави рисуваеми обекти
        /// </summary>
        /// <param name="rf">Рамката, която определя трансформациите</param>
        /// <returns>Обекти за рисуване</returns>
        public List<Drawable> getDrawables(RenderFrame rf)
        {
            Vector2f actualPos = new Vector2f(center.X - rf.xCenter, center.Y - rf.yCenter); // преместване на камерата
            actualPos.X *= rf.zoom;
            actualPos.Y *= rf.zoom;
            float actualR = radius * rf.zoom;

            // превръщане в екранни координати

            actualPos.X += rf.width / 2;
            actualPos.Y = -actualPos.Y + rf.height / 2;

            actualPos.X -= radius*rf.zoom;
            actualPos.Y -= radius*rf.zoom;

            CircleShape cs = new CircleShape(actualR, 60);
            cs.Position = actualPos;
            cs.FillColor = color;

            return new List<Drawable> { cs };
        }
Example #29
0
        static void Main(string[] args)
        {
            var mode   = new SFML.Window.VideoMode(800, 600);
            var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");
            //window.KeyPressed += Window_KeyPressed;

            var circle = new SFML.Graphics.CircleShape(100f)
            {
                FillColor = SFML.Graphics.Color.Blue
            };

            // Start the game loop
            while (window.IsOpen)
            {
                // Process events
                window.DispatchEvents();
                window.Draw(circle);

                // Finally, display the rendered frame on screen
                window.Display();
            }
        }
 public override void Draw(RenderWindow window)
 {
     CircleShape shape = new CircleShape(30);
     shape.Position = new Vector2f(position[0], position[1]);
     window.Draw(shape);
 }
Example #31
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Construct the shape from another shape
 /// </summary>
 /// <param name="copy">Shape to copy</param>
 ////////////////////////////////////////////////////////////
 public CircleShape(CircleShape copy) :
     base(copy)
 {
     Radius = copy.Radius;
     SetPointCount(copy.GetPointCount());
 }
Example #32
0
        protected override void UpdateDrawable()
        {
            base.UpdateDrawable();

            if (isCircle)
            {
                var circle = new SFML.Graphics.CircleShape(radius);
                circle.OutlineThickness = OutlineThickness;
                circle.OutlineColor     = OutlineColor.SFMLColor;
                circle.FillColor        = Color.SFMLColor;
                circle.SetPointCount((uint)CirclePointCount);
                SFMLDrawable = circle;
                Width        = (int)circle.GetLocalBounds().Width;
                Height       = (int)circle.GetLocalBounds().Height;
            }
            else
            {
                if (isShape)
                {
                    var rect = new SFML.Graphics.RectangleShape(new Vector2f(rectWidth, rectHeight));
                    rect.OutlineColor     = OutlineColor.SFMLColor;
                    rect.OutlineThickness = OutlineThickness;
                    rect.FillColor        = Color.SFMLColor;
                    SFMLDrawable          = rect;
                    Width  = (int)rect.GetLocalBounds().Width;
                    Height = (int)rect.GetLocalBounds().Height;
                }
                else
                {
                    SFMLVertices.Clear();

                    float x1, y1, x2, y2, u1, v1, u2, v2, cx1, cy1, cx2, cy2;

                    cx1 = ClippingRegion.Left;
                    cy1 = ClippingRegion.Top;
                    cx2 = ClippingRegion.Right;
                    cy2 = ClippingRegion.Bottom;

                    x1 = Util.Max(0, cx1);
                    u1 = TextureLeft + x1;

                    if (FlippedX)
                    {
                        u1 = TextureRegion.Width - u1 + TextureLeft + TextureRegion.Left;
                    }

                    y1 = Util.Max(0, cy1);
                    v1 = TextureTop + y1;

                    if (FlippedY)
                    {
                        v1 = TextureRegion.Height - v1 + TextureTop + TextureRegion.Top;
                    }

                    x2 = Util.Min(TextureRegion.Right, cx2);
                    u2 = TextureLeft + x2;

                    if (FlippedX)
                    {
                        u2 = TextureRegion.Width - u2 + TextureLeft + TextureRegion.Left;
                    }

                    y2 = Util.Min(TextureRegion.Bottom, cy2);
                    v2 = TextureTop + y2;

                    if (FlippedY)
                    {
                        v2 = TextureRegion.Height - v2 + TextureTop + TextureRegion.Top;
                    }

                    SFMLVertices.Append(x1, y1, Color, u1, v1);
                    SFMLVertices.Append(x1, y2, Color, u1, v2);
                    SFMLVertices.Append(x2, y2, Color, u2, v2);
                    SFMLVertices.Append(x2, y1, Color, u2, v1);
                }
            }
        }
Example #33
0
        /// <summary> Draws a user-defined circle object. </summary>
        public void Draw(CircleShape shape, RenderStates?state = null)
        {
            var shapeObj = new CircleShape(shape);

            DrawShape(shapeObj, state ?? RenderStates.Default);
        }
Example #34
0
        protected override void UpdateDrawable() {
            base.UpdateDrawable();

            if (isCircle) {
                var circle = new SFML.Graphics.CircleShape(radius);
                circle.OutlineThickness = OutlineThickness;
                circle.OutlineColor = OutlineColor.SFMLColor;
                circle.FillColor = Color.SFMLColor;
                circle.SetPointCount((uint)CirclePointCount);
                SFMLDrawable = circle;
                Width = (int)circle.GetLocalBounds().Width;
                Height = (int)circle.GetLocalBounds().Height;
            }
            else {

                if (isShape) {
                    var rect = new SFML.Graphics.RectangleShape(new Vector2f(rectWidth, rectHeight));
                    rect.OutlineColor = OutlineColor.SFMLColor;
                    rect.OutlineThickness = OutlineThickness;
                    rect.FillColor = Color.SFMLColor;
                    SFMLDrawable = rect;
                    Width = (int)rect.GetLocalBounds().Width;
                    Height = (int)rect.GetLocalBounds().Height;
                }
                else {
                    SFMLVertices.Clear();

                    float x1, y1, x2, y2, u1, v1, u2, v2, cx1, cy1, cx2, cy2;

                    cx1 = ClippingRegion.Left;
                    cy1 = ClippingRegion.Top;
                    cx2 = ClippingRegion.Right;
                    cy2 = ClippingRegion.Bottom;

                    x1 = Util.Max(0, cx1);
                    u1 = TextureLeft + x1;

                    if (FlippedX) {
                        u1 = TextureRegion.Width - u1 + TextureLeft + TextureRegion.Left;
                    }

                    y1 = Util.Max(0, cy1);
                    v1 = TextureTop + y1;

                    if (FlippedY) {
                        v1 = TextureRegion.Height - v1 + TextureTop + TextureRegion.Top;
                    }

                    x2 = Util.Min(TextureRegion.Right, cx2);
                    u2 = TextureLeft + x2;

                    if (FlippedX) {
                        u2 = TextureRegion.Width - u2 + TextureLeft + TextureRegion.Left;
                    }

                    y2 = Util.Min(TextureRegion.Bottom, cy2);
                    v2 = TextureTop + y2;

                    if (FlippedY) {
                        v2 = TextureRegion.Height - v2 + TextureTop + TextureRegion.Top;
                    }

                    SFMLVertices.Append(x1, y1, Color, u1, v1);
                    SFMLVertices.Append(x1, y2, Color, u1, v2);
                    SFMLVertices.Append(x2, y2, Color, u2, v2);
                    SFMLVertices.Append(x2, y1, Color, u2, v1);
                }
            }
        }
Example #35
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Construct the shape from another shape
 /// </summary>
 /// <param name="copy">Shape to copy</param>
 ////////////////////////////////////////////////////////////
 public CircleShape(CircleShape copy) : base(copy)
 {
     Radius = copy.Radius;
     SetPointCount(copy.GetPointCount());
 }
Example #36
0
        private void loadContent()
        {
            _font = new Font(@"resources\courbd.ttf");
            _messages = new List<Text>();
            _title = new Text("SFML_Farseer_Network", _font, 18);
            _title.Color = Color.White;
            _title.Position = new Vector2f(16, 16);

            Text clientOption = new Text("1. Start Client", _font, 14);
            clientOption.Position = new Vector2f(340, 300);
            clientOption.Color = Color.Red;

            Text serverOption = new Text("2. Start Server", _font, 14);
            serverOption.Position = new Vector2f(340, 332);
            serverOption.Color = Color.Red;

            _setupOptions = new List<Text>();
            _setupOptions.Add(clientOption);
            _setupOptions.Add(serverOption);

            _ipPrompt = new Text("Please enter an IP address:", _font, 14);
            _ipPrompt.Position = new Vector2f(340, 300);
            _ipPrompt.Color = Color.Red;

            _ipAddressText = new Text("", _font, 18);
            _ipAddressText.Position = new Vector2f(340, 332);
            _ipAddressText.Color = Color.Green;

            _fpsText = new Text("FPS: 0", _font, 18);
            _fpsText.Color = Color.Red;
            _fpsText.Position = new Vector2f(700, 16);

            _mousePointer = new CircleShape(0.1f);
            _mousePointer.Origin = new Vector2f(0.05f, 0.05f);
            _mousePointer.FillColor = Color.Yellow;
            _mousePointer.Position = new Vector2f(-100, -100);
        }
Example #37
0
            public void Run()
            {
                var mode   = new SFML.Window.VideoMode(800, 600);
                var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");



                window.KeyPressed += Window_KeyPressed;

                var circle = new SFML.Graphics.CircleShape(100f)
                {
                    FillColor = SFML.Graphics.Color.Blue
                };
                Clock clock = new Clock();


                window.SetActive(true);
                //window.PushGLStates();
                GuiImpl.Init(window);
                //window.PopGLStates();
                window.SetActive(false);


                Image   image   = new Image(100, 100, Color.Red);
                Texture texture = new Texture(image);

                // Start the game loop
                while (window.IsOpen)
                {
                    // Process events
                    window.DispatchEvents();
                    window.SetActive(true);
                    //window.PushGLStates();

                    GuiImpl.Update(window, clock.Restart());
                    ImGui.BeginMainMenuBar();
                    if (ImGui.BeginMenu("File"))
                    {
                        ImGui.MenuItem("Open");
                        ImGui.EndMenu();
                    }
                    ImGui.EndMainMenuBar();

                    ImGui.Begin("Hello, world!");
                    if (ImGui.Button("Look at this pretty button"))
                    {
                        System.Console.WriteLine("Hi!");
                    }

                    //System.Console.WriteLine(texture.NativeHandle);
                    ImGui.Image(new IntPtr(texture.NativeHandle), new System.Numerics.Vector2(200, 200));
                    ImGui.End();

                    ImGui.Begin("Hello, world!2");
                    if (ImGui.Button("Look at this pretty button22"))
                    {
                        System.Console.WriteLine("Hi2!");
                    }
                    ImGui.Text("Hallo");
                    ImGui.End();
                    ImGui.Button("lll");

                    //window.PopGLStates();
                    window.SetActive(false);


                    window.Clear();
                    window.Draw(circle);
                    GuiImpl.Render();
                    // Finally, display the rendered frame on screen
                    window.Display();
                }
                GuiImpl.Shutdown();
            }