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

C# Vector2f类代码示例

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

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



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

示例1: SetNewState

 private void SetNewState(VelocityComponentState state)
 {
     if (_lastState != null)
         _previousState = _lastState;
     _lastState = state;
     Velocity = new Vector2f(state.VelocityX, state.VelocityY);
 }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:7,代码来源:VelocityComponent.cs


示例2: Draw

        public override void Draw(RenderTarget rt)
        {
            Vector2f actualPosition = Position + (Selected ? new Vector2f(0, -12.0f - 5.0f * GetSelectedIndex()) : new Vector2f());

            // Draw card
            Sprite sprite = new Sprite(Assets.LoadTexture(Info.Type == CardType.White ? "CardWhite.png" : "CardBlack.png"));
            Size = new Vector2f(sprite.GetGlobalBounds().Width, sprite.GetGlobalBounds().Height);
            sprite.Position = actualPosition;
            sprite.Scale = Scale;
            rt.Draw(sprite);

            // Draw text
            Text text = GameUtility.Wrap(Info.Value, Assets.LoadFont("arialbd.ttf"), (uint)Math.Floor(24.0f * Scale.X),
                                     Math.Floor(207.0f * Scale.X));

            text.Color = Info.Type == CardType.White ? Color.Black : Color.White;
            text.Position = actualPosition + new Vector2f(16.0f * Scale.X, 10.0f * Scale.Y);
            text.Round();
            rt.Draw(text);

            // Draw decorations
            if (Info.PickCount > 1)
            {
                Sprite pickMultiple = new Sprite(Assets.LoadTexture(Info.PickCount == 2 ? "PickTwo.png" : "PickThree.png"))
                {
                    Position =
                        actualPosition +
                        new Vector2f((241.0f - 56.0f - 10.0f - 4.0f) * Scale.X, (320.0f - 10.0f - 20.0f) * Scale.Y),
                    Scale = Scale
                };

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


示例3: LightWeightPolylineVertex

 /// <summary>
 /// Initializes a new instance of the <c>LightWeightPolylineVertex</c> class.
 /// </summary>
 public LightWeightPolylineVertex()
 {
     this.location = Vector2f.Zero;
     this.bulge = 0.0f;
     this.beginThickness = 0.0f;
     this.endThickness = 0.0f;
 }
开发者ID:lomatus,项目名称:SharpDxf,代码行数:10,代码来源:LightWeightPolylineVertex.cs


示例4: HighscoreList

 public HighscoreList(Vector2f position)
 {
     Text = new Text();
     Text.Font = Game.Assets.Fonts["PixelPlay"];
     Text.CharacterSize = 30;
     Text.Position = position;
 }
开发者ID:Wezthal,项目名称:GameProject,代码行数:7,代码来源:HighscoreList.cs


示例5: Draw

        public override void Draw()
        {
            if (!_visible) return;
            var d = new Vector2f(Math.Abs(Base.X - Pos.X), Math.Abs(Base.Y - Pos.Y));

            var sx = Pos.X < Base.X ? 1 : -1;
            var sy = Pos.Y < Base.Y ? 1 : -1;

            var worker = new Vector2f(Pos.X, Pos.Y);

            var err = d.X - d.Y;
            while (!(worker.X == Base.X && worker.Y == Base.Y))
            {
                Parent.Parent.Window.Draw(new Sprite(Rsc.Tex("rsc/ThrowLine.png"))
                                              {
                                                  Position = worker,
                                                  Rotation = Rotation + 90,
                                                  Origin = new Vector2f(2.5f, 2.5f),
                                                  Color = new Color(255,255,255,100)
                                              });
                var e2 = 2*err;
                if (e2 > -d.Y)
                {
                    err -= d.Y;
                    worker.X += sx;
                }
                if (!(e2 < d.X)) continue;
                err += d.X;
                worker.Y += sy;
            }
            base.Draw();
        }
开发者ID:gigimoi,项目名称:ld25-Inversetroids,代码行数:32,代码来源:Thrower.cs


示例6: AddTile

        public void AddTile(float x, float y)
        {
            Vector2f pos = new Vector2f (x, y);
              CollisionTiles.Add (pos, new Tile (pos, true));

              CollisionTiles [pos].ChangeSprite (DAO.GetSprite (Element.Tile5));
        }
开发者ID:colincapurso,项目名称:IndieSpeedRun2013,代码行数:7,代码来源:Map.cs


示例7: Draw

        public override void Draw(RenderManager renderMgr, Camera camera)
        {
            int xStart = (int)((camera.Center.X - camera.Size.X * 0.5f) / TileWidth);
            int xEnd = (int)(1 + (camera.Center.X + camera.Size.X * 0.5f) / TileWidth);

            var yStart = (int)((camera.Center.Y - camera.Size.Y * 0.5f) / TileHeight);
            var yEnd = (int)(1 + (camera.Center.Y + camera.Size.Y * 0.5f) / TileHeight); ;

            if (xStart < 0)
                xStart = 0;
            if (xEnd > MapWidth - 1)
                xEnd = MapWidth - 1;
            if (yStart < 0)
                yStart = 0;
            if (yEnd > MapHeight - 1)
                yEnd = MapHeight - 1;

            for (var i = xStart; i < xEnd; i++)
            {
                for (var j = yStart; j < yEnd; j++)
                {
                    if (Tiles[i, j].Texture == null)
                        continue;

                    var position = new Vector2f(
                                    TileWidth * i + TileWidth * 0.5f,
                                    TileHeight * j + TileHeight * 0.5f);

                    renderMgr.DrawSprite(Tiles[i, j].Texture, Tiles[i, j].SubImageRect, position + WorldPosition, TileWidth, TileHeight, false, false, Tint, ZIndex);

                }
            }
        }
开发者ID:robert-porter,项目名称:Jeden,代码行数:33,代码来源:TileMapRenderComponent.cs


示例8: SpawnProjectile

        public virtual Projectile SpawnProjectile(Vector2f pos, float direction, float offset, Vector2f? targetPos = null)
        {
            Projectile proj = new Projectile(Game, GetProjectileModel(), this);

            // Position and Velocity
            proj.SetPosition(pos);
            proj.Rotate(direction);

            float angle = offset == 0 ? (float)Utils.ToRadians(direction) : (float)Utils.ToRadians(direction + offset);
            proj.Velocity = new Vector2f((float)Math.Cos(angle) * ProjectileSpeed, (float)Math.Sin(angle) * ProjectileSpeed);

            // Stats
            proj.Damage = Damage;
            proj.SetLifeSpan(ProjectileLifeSpan);
            if (targetPos.HasValue)
                proj.SetTargetPosition(targetPos.Value);
            if (ProjectileRotateSpeed != 0)
            {
                proj.RotateSpeed = ProjectileRotateSpeed*(Utils.RandomInt() == 1 ? 1 : -1);
                proj.Rotate(Utils.RandomInt(0, 359));
            }

            Game.Layer_Other.AddChild(proj);

            return proj;
        }
开发者ID:Torrunt,项目名称:SingleSwitchGame,代码行数:26,代码来源:ProjectileWeapon.cs


示例9: SetFrame

        public void SetFrame(int newFrame, bool resetTime)
        {
            if (Animation != null)
            {
                // calculate new vertex positions and texture coordinates 
                var rect = Animation.Frames[newFrame];

                var texCoordA = new Vector2f(0, 0);
                var texCoordB = new Vector2f(0, rect.Height);
                var texCoordC = new Vector2f(rect.Width, rect.Height);
                var texCoordD = new Vector2f(rect.Width, 0);

                var left = rect.Left + 0.0001f;
                var right = left + rect.Width;
                float top = rect.Top;
                var bottom = top + rect.Height;

                _vertices[0] = new Vertex(texCoordA, new Vector2f(left, top));
                _vertices[1] = new Vertex(texCoordB, new Vector2f(left, bottom));
                _vertices[2] = new Vertex(texCoordC, new Vector2f(right, bottom));
                _vertices[3] = new Vertex(texCoordD, new Vector2f(right, top));
            }

            if (resetTime)
            {
                _currentTime = Time.Zero;
            }
        }
开发者ID:Tetramputechture,项目名称:Ending_0.1b,代码行数:28,代码来源:AnimatedSprite.cs


示例10: Fire

        public virtual void Fire(Vector2f pos, float direction, Vector2f? targetPos = null)
        {
            if (!CanShoot)
                return;

            SpawnProjectiles(pos, direction, targetPos);
        }
开发者ID:Torrunt,项目名称:SingleSwitchGame,代码行数:7,代码来源:ProjectileWeapon.cs


示例11: getRectOfFrame

        internal static IntRect getRectOfFrame(short mFrame, int framesPerRow, Vector2f frameSize)
        {
            int rowNum = mFrame / framesPerRow;
            int colNum = mFrame % framesPerRow;

            return new IntRect((int)(colNum * frameSize.X), (int)(rowNum * frameSize.Y), (int)frameSize.X, (int)frameSize.Y);
        }
开发者ID:nik0kin,项目名称:ProjectTurtle,代码行数:7,代码来源:GeoLib.cs


示例12: Circle

 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;
 }
开发者ID:dabbertorres,项目名称:PhysicsPlayground,代码行数:7,代码来源:Circle.cs


示例13: MeasureString

        public Vector2f MeasureString(TextString str)
        {
            Vector2f size = new Vector2f(0f,0f);
            Vector2f curLineSize = new Vector2f(0f, 0f);

            foreach (KeyValuePair<TextStyle, string> s in str.FormatedText)
            {
                if (s.Key == TextStyle.EndLine)
                {
                    size.Y += curLineSize.Y;
                    size.X = curLineSize.X > size.X ? curLineSize.X : size.X;
                    curLineSize = new Vector2f(0f, 0f);
                }
                else
                {
                    Text textSlope = new Text(s.Value, Font, str.CharacterSize);
                    Text.Styles textStyle = Text.Styles.Regular;
                    if ((s.Key & TextStyle.Bold) != 0)
                        textStyle |= Text.Styles.Bold;
                    if( (s.Key & TextStyle.Italic) != 0)
                        textStyle |= Text.Styles.Italic;
                    textSlope.Style = textStyle;
                    FloatRect localBounds = textSlope.GetLocalBounds();

                    Vector2f ssize = new Vector2f(localBounds.Width,localBounds.Height);
                    curLineSize.X += (int)ssize.X;
                    curLineSize.Y = (int)ssize.Y > curLineSize.Y ? (int)ssize.Y : curLineSize.Y;
                }
            }

            size.X = curLineSize.X > size.X ? curLineSize.X : size.X;
            size.Y += curLineSize.Y;
            return size;
        }
开发者ID:Ziple,项目名称:NOubliezPas,代码行数:34,代码来源:Font.cs


示例14: Initialize

        static void Initialize()
        {
            Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + Environment.CurrentDirectory + "\\libs");
            dtClock = new Stopwatch();
            textFps = new Text("0", new Font(new FileStream("assets\\fonts\\arial.ttf", FileMode.Open, FileAccess.Read)));
            window = new RenderWindow(new VideoMode(1280, 768), "Test", Styles.Default);
            window.SetFramerateLimit(60);
            window.SetTitle("NATE");
            tiles = new TileManager("assets\\tilemaps\\rpgtiles.png", 32);
            iMap = new MapInterface();
            //map = new Map(new Vector2i(32, 32), ((int)tiles.image.Size.X / tiles.tileSize) * ((int)tiles.image.Size.Y / tiles.tileSize), true); -- for random
            //map = new Map(new Vector2i(32, 32), ((int)tiles.image.Size.X / tiles.tileSize) * ((int)tiles.image.Size.Y / tiles.tileSize), false); -- blank
            map = iMap.ReadMap("map1.ntm");
            
            scaling = new Vector2f(2, 2);
            textureCollection = new Texture[(tiles.image.Size.X / tiles.tileSize) * (tiles.image.Size.Y / tiles.tileSize)];
            camera = new Camera();
            camera.speed = 1000;

            window.Closed += (s, a) => window.Close();
            window.KeyPressed += (s, a) => { if (a.Code == Keyboard.Key.Z) { iMap.WriteMap("map0.ntm", map); } };
            window.MouseWheelMoved += (s, a) => { scaling.X += a.Delta * 0.075f; scaling.Y += a.Delta * 0.075f; };

            dtClock.Start();

            for (int i = 0; i < (tiles.image.Size.X / tiles.tileSize) * (tiles.image.Size.Y / tiles.tileSize); i++)
            {
                textureCollection[i] = tiles.GetTile(i);
                textureCollection[i].Smooth = false;
            }
        }
开发者ID:leontodd,项目名称:NATE,代码行数:31,代码来源:Program.cs


示例15: InGame

        public InGame(IEnumerable<Player> players)
        {
            ChatBacklog = new List<string>();

            Input.Text = InputText;
            chatValue = "";

            // Add every player from lobby
            foreach (Player p in players)
                Entities.Add(p);

            // Set local player position first
            LocalPlayer.Position = new Vector2f(GameOptions.Width / 2.0f - 128.0f - 8.0f, GameOptions.Height - 194.0f - 8.0f - 64.0f);

            // Add everyone else
            Vector2f otherPosition = new Vector2f(GameOptions.Width / 2.0f - ((128.0f + 32.0f) * (Players.Count - 2)) / 2.0f - 128.0f - 8.0f, 100.0f + 32.0f + 8.0f);
            foreach (Player p in Players.Where(p => !p.IsLocalPlayer))
            {
                p.Position = otherPosition;

                otherPosition += new Vector2f(128.0f + 32.0f, 0.0f);
            }

            // Play match start sound
            string startSoundFilename = "Start" + new Random().Next(5).ToString("G") + ".wav";
            Timer.NextFrame(() => Assets.PlaySound(startSoundFilename));
        }
开发者ID:joepie91,项目名称:HumanityAgainstCards,代码行数:27,代码来源:InGame.cs


示例16: ParticleSystem

 public ParticleSystem(Sprite particleSprite, Vector2f position)
 {
     MaximumParticleCount = 200;
     //TODO start with sane defaults
     Acceleration = new Vector2f();
     AccelerationVariance = 0f;
     ColorRange = new SS14.Shared.Utility.Range<Vector4f>(Vector4f.UnitX * 255, Vector4f.Zero);
     ColorVariance = 0f;
     EmissionOffset = new Vector2f();
     EmissionRadiusRange = new SS14.Shared.Utility.Range<float>(0f, 0f);
     Emit = false;
     EmitRate = 1;
     EmitterPosition = position;
     Lifetime = 1.0f;
     LifetimeVariance = 0f;
     ParticleSprite = particleSprite;
     RadialAcceleration = 0f;
     RadialAccelerationVariance = 0f;
     RadialVelocity = 0f;
     RadialVelocityVariance = 0f;
     SizeRange = new SS14.Shared.Utility.Range<float>(1, 0);
     SizeVariance = 0.1f;
     SpinVelocity = new SS14.Shared.Utility.Range<float>(0f, 0f);
     SpinVelocityVariance = 0f;
     TangentialAcceleration = 0;
     TangentialAccelerationVariance = 0;
     TangentialVelocity = 0;
     TangentialVelocityVariance = 0;
     Velocity = new Vector2f();
     VelocityVariance = 0;
 }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:31,代码来源:ParticleSystem.cs


示例17: Thrower

 public Thrower(Vector2f pos, World parent, bool add = true)
     : base(Rsc.Tex("rsc/Throw.png"), pos, parent, add)
 {
     Origin = new Vector2f(32, 1);
     _visible = false;
     Col.A = 100;
 }
开发者ID:gigimoi,项目名称:ld25-Inversetroids,代码行数:7,代码来源:Thrower.cs


示例18: ClientPlayer

        public ClientPlayer(Deathmatch dm)
            : base(dm)
        {
            this.model = MainGame.Char2Model;
            Pos = new Vector2f(10, 10);
            Speed = 2f;
            MaxJumps = 2;
            JumpsLeft = MaxJumps;
            Alive = true;
            Health = 100;
            Texture = Content.GetTexture(model.idleFile);
            deathTimer = 0;
            Killer = this;

            idle = new Animation(Content.GetTexture(model.idleFile), 4, 120, 1);
            running = new Animation(Content.GetTexture(model.runFile), 6, 60, 2);
            backpedal = new Animation(Content.GetTexture(model.runFile), 6, 60, 2, false);
            jumpUp = new Animation(Content.GetTexture(model.jumpUpFile), 1, 60, 0);
            jumpDown = new Animation(Content.GetTexture(model.jumpDownFile), 3, 60, -5);
            animation = idle;

            weapons = new List<Weapon>()
            {
                new Revolver(this),
                null,
                null,
                null,
            };

            respawnTimer = respawnLength * 60;

            weapon = weapons[0];
        }
开发者ID:libjared,项目名称:iris,代码行数:33,代码来源:ClientPlayer.cs


示例19: Update

 public override void Update()
 {
     base.Update();
     Pos = MouseManager.Pos;
     if (Pos.X < 640 && (Base.X > 558 || Base.Y < 62 || Base.X < 82 || Base.Y > 540) && !_disabled && SpawnButton.Selected!=null)
     {
         Rotation = (float)Angle.AngleBetween(Base, Pos);
         if (_visible == false && MouseManager.LeftDown)
         {
             Base = Pos;
         }
         if (_visible && !MouseManager.LeftDown)
         {
             SpawnButton.Selected.Throw(this);
         }
         _visible = MouseManager.LeftDown;
     }
     else
     {
         if (Pos.X > 640 && MouseManager.LeftDown)
         {
             _disabled = true;
         }
         _visible = false;
     }
     if (MouseManager.LeftDown == false)
     {
         _disabled = false;
     }
     if (Pos.X < 640 && (Base.X > 558 || Base.Y < 62 || Base.X < 82 || Base.Y > 540) && !_disabled && SpawnButton.Selected != null) return;
     _visible = false;
     Base = new Vector2f(559, 10);
 }
开发者ID:gigimoi,项目名称:ld25-Inversetroids,代码行数:33,代码来源:Thrower.cs


示例20: DrawLine

    // Bresenham line algorithm
    private void DrawLine(Vector2f p0, Vector2f p1, Texture2D tx, Color c, int offset = 0)
    {
        int x0 = (int)p0.x;
        int y0 = (int)p0.y;
        int x1 = (int)p1.x;
        int y1 = (int)p1.y;

        int dx = Mathf.Abs(x1-x0);
        int dy = Mathf.Abs(y1-y0);
        int sx = x0 < x1 ? 1 : -1;
        int sy = y0 < y1 ? 1 : -1;
        int err = dx-dy;

        while (true) {
            tx.SetPixel(x0+offset,y0+offset,c);

            if (x0 == x1 && y0 == y1) break;
            int e2 = 2*err;
            if (e2 > -dy) {
                err -= dy;
                x0 += sx;
            }
            if (e2 < dx) {
                err += dx;
                y0 += sy;
            }
        }
    }
开发者ID:CawawaC,项目名称:Diplodocus-Project,代码行数:29,代码来源:VoronoiSurface.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Vector2i类代码示例发布时间:2022-05-24
下一篇:
C# Vector2d类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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