• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Graphics.RectangleShape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SFML.Graphics.RectangleShape的典型用法代码示例。如果您正苦于以下问题:C# RectangleShape类的具体用法?C# RectangleShape怎么用?C# RectangleShape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RectangleShape类属于SFML.Graphics命名空间,在下文中一共展示了RectangleShape类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Draw

        public override void Draw(RenderTarget rt)
        {
            RectangleShape overylay = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height))
            {
                FillColor = new Color(0, 0, 0, 128)
            };

            rt.Draw(overylay);

            RectangleShape window = new RectangleShape(new Vector2f(GameOptions.Width * (1.0f - PaddingHorizontal * 2.0f), GameOptions.Height * (1.0f - PaddingVertical * 2.0f)))
            {
                Position = new Vector2f(GameOptions.Width * PaddingHorizontal, GameOptions.Height * PaddingVertical),
                FillColor = Color.White,
                OutlineColor = Color.Black,
                OutlineThickness = 2.0f
            };

            rt.Draw(window);

            Text labelSettings = new Text("Join by IP", Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height * PaddingVertical + 48.0f),
                Color = Color.Black,
                CharacterSize = 32
            };

            labelSettings.Center();
            labelSettings.Round();
            rt.Draw(labelSettings);

            base.Draw(rt);
        }
开发者ID:DatZach,项目名称:HumanityAgainstCards,代码行数:32,代码来源:JoinByIpOverlay.cs


示例2: Rowboat

        public Rowboat(Game game)
            : base(game, game.GraphicsMode == Game.GRAPHICSMODE_NORMAL ? Graphics.GetAnimatedSprite(game, "assets/sprites/rowboat.xml") : Graphics.GetAnimatedSprite(game, "assets/sprites/blueprint/rowboat.xml"))
        {
            Collision = new RectangleShape(new Vector2f(82f, 38f));
            Collision.Position = new Vector2f(-41f, -19f);

            Model.Stop();

            HealthMax = 8000;
            Health = HealthMax;

            SpeedMax = 50.0f + Math.Min(0.5f * Game.AIManager.Difficulty, 25.0f);
            Acc = 200.0f;

            // Add Infantry Passengers
            AddInfantryman(new Vector2f(0, -10));
            AddInfantryman(new Vector2f(0, 10));

            AddInfantryman(new Vector2f(25, -10));
            AddInfantryman(new Vector2f(25, 10));

            AddInfantryman(new Vector2f(-25, -10));
            AddInfantryman(new Vector2f(-25, 10));

            SetAI(new RowboatAI(Game));
        }
开发者ID:Torrunt,项目名称:SingleSwitchGame,代码行数:26,代码来源:Rowboat.cs


示例3: Draw

        public override void Draw(RenderTarget rt)
        {
            RectangleShape bgOverlay = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height)) { FillColor = Color.Black };
            rt.Draw(bgOverlay);

            Text title = new Text("Game Over", Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, 48.0f),
                CharacterSize = 48,
                Color = Color.White
            };

            title.Center();
            title.Round();
            rt.Draw(title);

            Text winnerTitle = new Text(GetWinnerText(), Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f),
                CharacterSize = 48,
                Color = Color.White
            };

            winnerTitle.Center();
            winnerTitle.Round();
            rt.Draw(winnerTitle);

            base.Draw(rt);
        }
开发者ID:DatZach,项目名称:HumanityAgainstCards,代码行数:29,代码来源:GameOverScreen.cs


示例4: loadContent

        public override void loadContent()
        {
            float logoScale;

            _logoTexture = ResourceManager.getResource<Texture>("logo_1");
            _logoShape = new RectangleShape();
            _logoShape.Texture = _logoTexture;
            _logoShape.Size = new Vector2f(_logoTexture.Size.X, _logoTexture.Size.Y);
            logoScale = Game.window.GetView().Size.X / (float)_logoTexture.Size.X;
            _logoShape.Scale = new Vector2f(logoScale, logoScale);

            _font = ResourceManager.getResource<Font>("immortal_font");
            _options = new List<Text>();
            _options.Add(new Text("New Game", _font, 48));
            _options.Add(new Text("Continue", _font, 48));
            _options.Add(new Text("Options", _font, 48));
            _options.Add(new Text("Exit", _font, 48));

            for (int i = 0; i < _options.Count; i++)
            {
                Text text = _options[i];

                text.Position = new Vector2f(128, i * 48 + _logoShape.Size.Y * _logoShape.Scale.Y + 64);
            }
        }
开发者ID:klutch,项目名称:Loderpit,代码行数:25,代码来源:MainMenuScreen.cs


示例5: PauseState

        public PauseState(StateStack stack, Context context)
            : base(stack, context)
        {
            RenderWindow window = mContext.window;

            mBackgroundSprite = new Sprite();
            mPausedText = new Text();
            mInstructionText = new Text();

            mPausedText.Font = mContext.fonts.get(FontID.Main);
            mPausedText.DisplayedString = "Game Paused";
            mPausedText.CharacterSize = 70;
            mPausedText.centerOrigin();
            mPausedText.Position = new Vector2f(0, 0);

            mInstructionText.Font = mContext.fonts.get(FontID.Main);
            mInstructionText.DisplayedString = "(Press Backspace to return to main menu)";
            mInstructionText.centerOrigin();
            mInstructionText.Position = new Vector2f(0, 0);

            backgroundShape = new RectangleShape();
            backgroundShape.FillColor = new Color(0, 0, 0, 150);
            backgroundShape.Position = window.GetView().Center;
            backgroundShape.centerOrigin();
            backgroundShape.Size = window.GetView().Size;
        }
开发者ID:pixeltasim,项目名称:SFML.NET_Gamedev,代码行数:26,代码来源:PauseState.cs


示例6: ButtonControl

        public ButtonControl(Font font, uint size, Texture button, Texture hover, Texture press)
        {
            left = new RectangleShape();
            middle = new RectangleShape();
            right = new RectangleShape();

            left.Texture = button;
            middle.Texture = button;
            right.Texture = button;

            left.TextureRect = new IntRect(0, 0, (int)button.Size.X / 2 - 1, (int)button.Size.Y);
            middle.TextureRect = new IntRect((int)button.Size.X / 2 - 1, 0, 2, (int)button.Size.Y);
            right.TextureRect = new IntRect((int)button.Size.X / 2 + 1, 0, (int)button.Size.X / 2, (int)button.Size.Y);

            text = new TextControl(font, size) { TextAlignment = Alignment.MiddleCenter, Bold = true };
            text.BackgroundColor = Color.Transparent;

            IsHovered = false;
            IsPressed = false;
            ClickYOffset = 4.0f;

            buttonTexture = button;
            hoverTexture = hover;
            pressedTexture = press;
        }
开发者ID:Scellow,项目名称:sfml-ui,代码行数:25,代码来源:ButtonControl.cs


示例7: CircleRectangleCollision

        /// <summary>Checks collision between Circle and Rotated Rectangle.</summary>
        /// <param name="rectAngle">In Degrees.</param>
        public static bool CircleRectangleCollision(Vector2f circleCenter, float circleRadius, RectangleShape rect, float rectAngle = 0, Vector2f rectOffset = default(Vector2f))
        {
            Vector2f rectPos = new Vector2f(rect.Position.X + rectOffset.X, rect.Position.Y + rectOffset.Y);
            Vector2f rectCenter = new Vector2f(rectPos.X + (rect.Size.X / 2), rectPos.Y + (rect.Size.Y / 2));

            // Rotate circle's center point back

            Vector2f unrotatedCircle = new Vector2f();
            unrotatedCircle.X = (float)Math.Cos(rectAngle) * (circleCenter.X - rectCenter.X) - (float)Math.Sin(rectAngle) * (circleCenter.Y - rectCenter.Y) + rectCenter.X;
            unrotatedCircle.Y = (float)Math.Sin(rectAngle) * (circleCenter.X - rectCenter.X) + (float)Math.Cos(rectAngle) * (circleCenter.Y - rectCenter.Y) + rectCenter.Y;

            // Closest point in the rectangle to the center of circle rotated backwards(unrotated)
            Vector2f closest = new Vector2f();

            // Find the unrotated closest x point from center of unrotated circle
            if (unrotatedCircle.X < rectPos.X)
                closest.X = rectPos.X;
            else if (unrotatedCircle.X > rectPos.X + rect.Size.X)
                closest.X = rectPos.X + rect.Size.X;
            else
                closest.X = unrotatedCircle.X;

            // Find the unrotated closest y point from center of unrotated circle
            if (unrotatedCircle.Y < rectPos.Y)
                closest.Y = rectPos.Y;
            else if (unrotatedCircle.Y > rectPos.Y + rect.Size.Y)
                closest.Y = rectPos.Y + rect.Size.Y;
            else
                closest.Y = unrotatedCircle.Y;

            // Determine collision
            return Distance(unrotatedCircle, closest) < circleRadius;
        }
开发者ID:Torrunt,项目名称:SingleSwitchGame,代码行数:35,代码来源:Utils.cs


示例8: Hud

        public Hud(GameBase state)
        {
            _state = state;

            _selected = new Sprite(Assets.LoadTexture("wep_selected.png")).Center();

            _statusBack = new RectangleShape(new Vector2f(BarWidth + Padding * 2, BarHeight * 2 + Padding * 3));
            _statusBack.Position = new Vector2f(Padding, Padding);
            _statusBack.FillColor = new Color(0, 0, 0);
            _statusBack.OutlineThickness = 2;
            _statusBack.OutlineColor = new Color(38, 38, 38);

            _health = new RectangleShape(new Vector2f(BarWidth, BarHeight));
            _health.Position = _statusBack.Position + new Vector2f(Padding, Padding);
            _health.FillColor = new Color(0, 120, 0);

            _healthText = new Text("", Program.Font, (int)(BarHeight - Padding));
            _healthText.Position = _health.Position + new Vector2f(BarWidth / 2, BarHeight / 2);
            _healthText.Color = new Color(225, 225, 225);

            _energy = new RectangleShape(new Vector2f(BarWidth, BarHeight));
            _energy.Position = _health.Position + new Vector2f(0, BarHeight + Padding);
            _energy.FillColor = new Color(30, 30, 180);

            _energyText = new Text("", Program.Font, (int)(BarHeight - Padding));
            _energyText.Position = _energy.Position + new Vector2f(BarWidth / 2, BarHeight / 2);
            _energyText.Color = new Color(225, 225, 225);
        }
开发者ID:Rohansi,项目名称:FPCompo11,代码行数:28,代码来源:Hud.cs


示例9: Draw

        public override void Draw(RenderTarget target, Vector2f position)
        {
            _icon.Position = position;
            target.Draw(_icon);

            if (_amount == 0)
            {
                var darken = new RectangleShape(new Vector2f(Hud.IconSize - Hud.IconBorderTwice, Hud.IconSize - Hud.IconBorderTwice));
                darken.Origin = new Vector2f(Hud.IconSizeHalf - Hud.IconBorder, Hud.IconSizeHalf - Hud.IconBorder);
                darken.FillColor = new Color(0, 0, 0, 200);
                darken.Position = position;
                target.Draw(darken);
            }

            if (_time > 0)
            {
                var per = _time / BuildTime;
                var box = new RectangleShape(new Vector2f(per * (Hud.IconSize - Hud.IconBorderTwice), 8));
                box.FillColor = new Color(0, 180, 0, 128);
                box.Position = position - new Vector2f(Hud.IconSizeHalf - Hud.IconBorder, Hud.IconSizeHalf - Hud.IconBorder);
                target.Draw(box);
            }

            _amountText.DisplayedString = _amount.ToString("G");
            _amountText.Position = position + new Vector2f(Hud.IconSizeHalf - Hud.Padding, Hud.IconSizeHalf - Hud.Padding);

            var bounds = _amountText.GetLocalBounds();
            _amountText.Origin = new Vector2f(bounds.Width + bounds.Left, bounds.Height + bounds.Top);

            target.Draw(_amountText);
        }
开发者ID:Rohansi,项目名称:FPCompo11,代码行数:31,代码来源:DroneLauncher.cs


示例10: ClassSelectorComponent

        public ClassSelectorComponent(Screen screen, Texture upArrowTexture, Texture downArrowTexture, Texture classSelectorTexture, List<Texture> classTextures, Vector2f position)
            : base(screen)
        {
            _position = position;
            _classTextures = classTextures;

            _upArrow = new RectangleShape();
            _upArrow.Position = position + new Vector2f(0f, -42f);
            _upArrow.Origin = new Vector2f(8f, 8f);
            _upArrow.Texture = upArrowTexture;
            _upArrow.Size = new Vector2f(16f, 16f);

            _classSelector = new RectangleShape();
            _classSelector.Position = position;
            _classSelector.Origin = new Vector2f(32f, 32f);
            _classSelector.Texture = classSelectorTexture;
            _classSelector.Size = new Vector2f(64f, 64f);

            _classIcon = new RectangleShape();
            _classIcon.Position = position;
            _classIcon.Origin = new Vector2f(32f, 32f);
            _classIcon.Texture = _classTextures[(int)_selectedClass];
            _classIcon.Size = new Vector2f(64f, 64f);

            _downArrow = new RectangleShape();
            _downArrow.Position = position + new Vector2f(0f, 42f);
            _downArrow.Origin = new Vector2f(8f, 8f);
            _downArrow.Texture = downArrowTexture;
            _downArrow.Size = new Vector2f(16f, 16f);
        }
开发者ID:klutch,项目名称:Loderpit,代码行数:30,代码来源:ClassSelectorComponent.cs


示例11: Menu

        public Menu()
            : base()
        {
            hoverCursor = Content.GetTexture("cursorHover.png");
            defaultCursor = Content.GetTexture("cursorPointer.png");
            currentCursor = defaultCursor;
            char1 = new Animation(Content.GetTexture("idle.png"), 4, 0, 0, true);
            char2 = new Animation(Content.GetTexture("char2_idle.png"), 4, 0, 0, true);
            shader = new RenderStates(new Shader(null, "Content/bgPrlx.frag"));

            rectConnect = new RectangleShape()
            {
                Size = new Vector2f(150, 30),
                Position = new Vector2f(-25, 70)
            };
            rectIP = new RectangleShape()
            {
                Size = new Vector2f(150, 20),
                Position = new Vector2f(-25, 40)
            };
            rectUsername = new RectangleShape()
            {
                Size = new Vector2f(150, 20),
                Position = new Vector2f(-25, 10)
            };

            MainGame.window.TextEntered += TextEnteredEvent;
        }
开发者ID:libjared,项目名称:iris,代码行数:28,代码来源:Menu.cs


示例12: Ship

        public Ship(Game game)
            : base(game)
        {
            if (Game.GraphicsMode == Game.GRAPHICSMODE_NORMAL)
            {
                Model = Graphics.GetAnimatedSprite(game, "assets/sprites/ship.xml");
            }
            else
            {
                Model = Graphics.GetSprite("assets/sprites/blueprint/ship.png");
                Model.Scale = new Vector2f(0.5f, 0.5f);
                Model.Origin = new Vector2f(265, 244);
            }
            AddChild(Model);

            Collision = new RectangleShape(new Vector2f(265, 105));
            Collision.Position = new Vector2f(-132.5f, -52.5f);

            SpeedMax = 50.0f + Math.Min(0.5f * Game.AIManager.Difficulty, 25.0f);
            Acc = 200.0f;

            AmountOfInfantry = Utils.RandomInt(12, 18);

            SetAI(new ShipAI(Game));
        }
开发者ID:Torrunt,项目名称:SingleSwitchGame,代码行数:25,代码来源:Ship.cs


示例13: Frame

        public Frame(RectangleShape borderRect, Color fillColor)
        {
            BorderRect = borderRect;
            BorderRect.FillColor = fillColor;

            BoundingRect = borderRect.GetGlobalBounds();
        }
开发者ID:Tetramputechture,项目名称:Ending_0.1b,代码行数:7,代码来源:Frame.cs


示例14: BigLabeledButtonComponent

        public BigLabeledButtonComponent(Screen screen, Texture buttonTexture, Vector2f position, string text, Color buttonColor, Action onClick)
            : base(screen)
        {
            _buttonTexture = buttonTexture;
            _position = position;
            _buttonColor = buttonColor;
            _selectedColor = new Color(
                (byte)Math.Min(255, (int)_buttonColor.R + 50),
                (byte)Math.Min(255, (int)_buttonColor.G + 50),
                (byte)Math.Min(255, (int)_buttonColor.B + 50),
                255);
            _onClick = onClick;
            _font = ResourceManager.getResource<Font>("immortal_font");

            // Initialize button shape
            _buttonShape = new RectangleShape();
            _buttonShape.Texture = _buttonTexture;
            _buttonShape.Position = position;
            _buttonShape.Size = new Vector2f(_buttonShape.Texture.Size.X, _buttonShape.Texture.Size.Y);
            _buttonShape.FillColor = _buttonColor;

            // Initialize text
            _firstLetter = new Text(text.Substring(0, 1), _font, 72);
            _firstLetter.Position = position + new Vector2f(30, 0);
            _firstLetter.Color = Color.White;
            _firstLetterShadow = new Text(_firstLetter.DisplayedString, _font, 72);
            _firstLetterShadow.Position = _firstLetter.Position + new Vector2f(3, 3);
            _firstLetterShadow.Color = Color.Black;
            _word = new Text(text.Substring(1, text.Length - 1), _font, 48);
            _word.Position = _firstLetter.Position + new Vector2f(_firstLetter.GetLocalBounds().Width + 4, 13);
            _word.Color = Color.White;
            _wordShadow = new Text(_word.DisplayedString, _font, 48);
            _wordShadow.Position = _word.Position + new Vector2f(3, 3);
            _wordShadow.Color = Color.Black;
        }
开发者ID:klutch,项目名称:Loderpit,代码行数:35,代码来源:BigLabeledButtonComponent.cs


示例15: Tile

 public Tile(Color color, Vector2f position, bool walkable, Vector2f size)
 {
     shape = new RectangleShape(size);
     shape.FillColor = color;
     shape.Position = position;
     Walkable = walkable;
 }
开发者ID:gamodo,项目名称:Intro2DGame,代码行数:7,代码来源:Tile.cs


示例16: TileRenderer

 public TileRenderer(Tile data)
 {
     this.data = data;
     rectangleShape = new RectangleShape();
     rectangleShape.Size = this.data.Size;
     rectangleShape.FillColor = data.FillColor;
 }
开发者ID:Cellmon95,项目名称:Wargames2,代码行数:7,代码来源:TileRenderer.cs


示例17: NewGame

        public void NewGame()
        {
            while (Window.IsOpen)
            {
                Window.DispatchEvents();
                Window.Clear();

                var x = Window.Size.X; var y = Window.Size.Y;
                var line = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(16, y));
                line.Position = new SFML.System.Vector2f(x / 3, 0);
                Window.Draw(line);

                line = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(x, 16));
                line.Position = new SFML.System.Vector2f(0, y / 3);
                Window.Draw(line);

                line = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(16, y));
                line.Position = new SFML.System.Vector2f(x * 2 / 3, 0);
                Window.Draw(line);

                line = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(x, 16));
                line.Position = new SFML.System.Vector2f(0, y * 2 / 3);
                Window.Draw(line);

                Window.Display();
            }
        }
开发者ID:TrueNoob,项目名称:LivingSpace,代码行数:27,代码来源:Game.cs


示例18: Draw

        public override void Draw(RenderTarget rt)
        {
            RectangleShape checkbox = new RectangleShape(Size)
            {
                Position = Position,
                FillColor = Color.Black,
            };

            rt.Draw(checkbox);

            if (mouseIn)
            {
                RectangleShape checkboxHover = new RectangleShape(new Vector2f(48.0f - 8.0f, 48.0f - 8.0f))
                {
                    Position = Position + new Vector2f(4.0f, 4.0f),
                    FillColor = Color.Black,
                    OutlineColor = Color.White,
                    OutlineThickness = 2f
                };

                rt.Draw(checkboxHover);
            }

            Text labelText = new Text(Label, Assets.LoadFont(Program.DefaultFont))
            {
                Position = Position + new Vector2f(48.0f + 16.0f, 24.0f + 2.0f),
                CharacterSize = 32,
                Color = Color.Black
            };

            labelText.Center(false);
            labelText.Round();
            rt.Draw(labelText);

            if (Value)
            {
                RectangleShape x1 = new RectangleShape(new Vector2f(48.0f, 3.0f))
                {
                    Position = Position + new Vector2f(24.0f, 24.0f),
                    Origin = new Vector2f(24.0f, 2.0f),
                    FillColor = Color.White,
                    Rotation = -45.0f
                };

                rt.Draw(x1);

                RectangleShape x2 = new RectangleShape(new Vector2f(48.0f, 3.0f))
                {
                    Position = Position + new Vector2f(24.0f, 24.0f),
                    Origin = new Vector2f(24.0f, 2.0f),
                    FillColor = Color.White,
                    Rotation = 45.0f
                };

                rt.Draw(x2);
            }

            base.Draw(rt);
        }
开发者ID:DatZach,项目名称:HumanityAgainstCards,代码行数:59,代码来源:Checkbox.cs


示例19: Rectangle

        public Rectangle(float width, float height)
            : base(width * height)
        {
            rect = new RectangleShape(new Vector2f(width, height));
            rect.FillColor = Color.Red;

            Origin = rect.Size / 2f;
        }
开发者ID:dabbertorres,项目名称:PhysicsPlayground,代码行数:8,代码来源:Rectangle.cs


示例20: UnitRenderer

 public UnitRenderer(Unit data)
 {
     this.data = data;
     rectangleShape = new RectangleShape(data.Size);
     rectangleShape.Scale = data.Scale;
     rectangleShape.FillColor = data.FillColor;
     rectangleShape.Position = data.Position;
 }
开发者ID:Cellmon95,项目名称:WarGames,代码行数:8,代码来源:UnitRenderer.cs



注:本文中的SFML.Graphics.RectangleShape类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Graphics.RenderStates类代码示例发布时间:2022-05-26
下一篇:
C# Graphics.Font类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap