Пример #1
0
        public Paddle(Sprite sprite, Vector2D position)
            : base(sprite, position,
			BodyFactory.CreateCapsule(Entities.world2D, sprite.Size.Height,
				sprite.Size.Width / 2, 1.0f, position))
        {
            body.Position = position;
            Entities.Register(this);
        }
Пример #2
0
        public Box(Vector2D position, Size size)
            : base(position, size,
				BodyFactory.CreateRectangle(Entities.world2D, size.Width, size.Height, 1.0f, position,
					BodyType.Dynamic))
        {
            Entities.Register(this);
            body.IsStatic = false;
            body.Restitution = 1;
            body.Friction = 0.01f;
        }
Пример #3
0
 public Circle(Vector2D position, float radius)
     : base(position, new Size(radius * 2, radius * 2),
 BodyFactory.CreateCircle(Entities.world2D, radius, 1.0f, position, BodyType.Dynamic))
 {
     this.radius = radius;
     Entities.Register(this);
     body.IsStatic = false;
     body.Restitution = 1;
     body.Friction = 0.01f;
 }
Пример #4
0
 public void Draw(Vector2D position)
 {
     GL.Enable(EnableCap.Texture2D);
     GL.BindTexture(TextureTarget.Texture2D, texture.Handle);
     var halfWidth = Size.Width / 2;
     var halfHeight = Size.Height / 2;
     vertices = new[]
     {
         position.x - halfWidth, position.y + halfHeight, 0,
         position.x - halfWidth, position.y - halfHeight, 0,
         position.x + halfWidth, position.y - halfHeight, 0,
         position.x + halfWidth, position.y + halfHeight, 0
     };
     GL.EnableClientState(ArrayCap.TextureCoordArray);
     GL.TexCoordPointer(2, TexCoordPointerType.Float, 0, uvs);
     GL.EnableClientState(ArrayCap.VertexArray);
     GL.VertexPointer(3, VertexPointerType.Float, 0, vertices);
     GL.DrawElements(PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedShort,
         indices);
 }
 protected PhysicsObject(Vector2D position, Size size, Body body)
 {
     this.size = size;
     this.body = body;
 }
Пример #6
0
 public bool Equals(Vector2D other)
 {
     return x > other.x - Epsilon && x < other.x + Epsilon && y > other.y - Epsilon &&
                 y < other.y + Epsilon;
 }
Пример #7
0
 private float DotProduct(Vector2D other)
 {
     return x * other.x + y * other.y;
 }
Пример #8
0
 public Vector2D MirrorAtNormal(Vector2D normal)
 {
     normal = normal.Normalize();
     return this - (normal * 2 * DotProduct(normal));
 }
 protected override void OnMouseClick(MouseEventArgs e)
 {
     MouseClickedHappenend = true;
     MouseClickPosition = new Vector2D(e.X, e.Y);
     base.OnMouseClick(e);
 }
 protected PhysicsSprite(Sprite sprite, Vector2D position, Body body)
     : base(position, sprite.Size, body)
 {
     this.sprite = sprite;
 }