summaryrefslogtreecommitdiff
path: root/source/game/components/physics/PhysicsEntity.cs
blob: 7214dfffc135311c9e04d34cfec548437628365c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using Microsoft.Xna.Framework;

namespace Celesteia.Game.Components.Physics {
    public class PhysicsEntity {
        public float Mass;

        public bool Gravity;

        public bool CollidingUp;
        public bool CollidingLeft;
        public bool CollidingRight;
        public bool CollidingDown;

        public PhysicsEntity(float mass, bool affectedByGravity) {
            Mass = mass;
            Gravity = affectedByGravity;
        }

        private Vector2 _velocity;
        public Vector2 Velocity => _velocity;

        public void SetVelocity(Vector2 vector) {
            _velocity = vector;
        }

        public void SetVelocity(float x, float y) {
            SetVelocity(new Vector2(x, y));
        }

        public void AddVelocity(Vector2 vector) {
            _velocity += vector;
        }

        public void AddVelocity(float x, float y) {
            AddVelocity(new Vector2(x, y));
        }
    }
}