123456789101112131415161718192021222324252627282930313233343536373839404142 |
- /*
- * 2D Physic Engine
- * particle.h:
- * Based on pikuma.com Learn Game Physics Engine Programming course.
- * Copyright (c) 2022 986-Studio. All rights reserved.
- *
- * Created by Manoël Trapier on 07/06/2022.
- */
- #ifndef PHYSICENGINE_PHYSICS_PARTICLE_H
- #define PHYSICENGINE_PHYSICS_PARTICLE_H
- #include <physics/vec2.h>
- class particle
- {
- public:
- uint16_t radius;
- vec2 position;
- vec2 acceleration;
- vec2 velocity;
- vec2 sum_of_forces;
- double mass;
- public:
- particle(double x, double y, double mass): radius(4), position(x, y), mass(mass) {};
- particle(double x, double y, double mass, double radius): radius(radius), position(x, y), mass(mass) {};
- ~particle() = default;
- void clearForces()
- {
- this->sum_of_forces = vec2(0, 0);
- }
- void addForce(const vec2 &force);
- void integrate(double dt);
- };
- #endif /* PHYSICENGINE_PHYSICS_PARTICLE_H */
|