Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include "Main_Types.h"
- #include "Graphic_Library.h"
- #include "Graphic_Library.cpp"
- struct Vector2 {
- public:
- float x;
- public:
- float y;
- #pragma region Operators
- public:
- void operator+=(const Vector2 value) {
- x += value.x;
- y += value.y;
- }
- public:
- void operator-=(const Vector2 value) {
- x -= value.x;
- y -= value.y;
- }
- public:
- void operator*=(const Vector2 value) {
- x *= value.x;
- y *= value.y;
- }
- public:
- void operator/=(const Vector2 value) {
- x /= value.x;
- y /= value.y;
- }
- public:
- Vector2 operator+(const Vector2 value) const {
- return Vector2(x + value.x, y + value.y);
- }
- public:
- Vector2 operator-(const Vector2 value) const {
- return Vector2(x - value.x, y - value.y);
- }
- public:
- Vector2 operator*(const Vector2 value) const {
- return Vector2(x * value.x, y * value.y);
- }
- public:
- Vector2 operator/(const Vector2 value) const {
- return Vector2(x / value.x, y / value.y);
- }
- #pragma endregion
- public:
- __declspec(dllexport) void Invert() {
- x = -y;
- y = -y;
- }
- public:
- __declspec(dllexport) float Magnitude() {
- return sqrtf(x * x + y * y);
- }
- public:
- __declspec(dllexport) float SquareMagnitude() {
- return abs(x * x + y * y);
- }
- public:
- __declspec(dllexport) void Normalize() {
- float magnitude = Magnitude();
- if (magnitude > 0)
- {
- x = x / magnitude;
- y = y / magnitude;
- }
- }
- /*
- public:
- __declspec(dllexport) Vector2 ComponentProduct(const Vector2 vector) {
- return Vector2(x * vector.x,y * vector.y);
- }
- public:
- __declspec(dllexport) void ComponentProductUpdate(const Vector2 vector) {
- x *= vector.x;
- y *= vector.y;
- }
- public:
- __declspec(dllexport) float ScalarProduct(const Vector2 vector) {
- return x * vector.x + y * vector.y;
- }
- public:
- __declspec(dllexport) Vector2 VectorProduct(const Vector2 vector) {
- return 0;
- }
- public:
- __declspec(dllexport) float DotProduct(const Vector2 vector) {
- return (x * vector.x) + (y * vector.y);
- }
- public:
- __declspec(dllexport) float CrossProduct() {
- return 0;
- }
- */
- Vector2(float x = 0, float y = 0) {
- this->x = x;
- this->y = y;
- }
- };
- class GameObject {
- //------------------------------Graphical Library Variables-----------------------------//
- public: COORD PositionObject;
- public: Mesh MeshObject;
- public: DWORD Color;
- public: string Tag;
- //------------------------------Graphical Library Variables-----------------------------//
- //------------------------------Physical Library Variables-----------------------------//
- public: vector<Vector2> trianglesCollision;
- public: Vector2 gravityVector;
- public: float Mass;
- public: float Friction;
- public: float Buoyancy;
- public: float SpringAbility;
- //------------------------------Physical Library Variables-----------------------------//
- //------------------------------Other Variables-----------------------------//
- public: SpriteObject* SpritePart;
- public: PhysicalObject* PhysicalPart;
- //------------------------------Other Variable-----------------------------//
- void AddGraphics(
- Vector2 positionObject,
- Mesh meshObject,
- DWORD color = 15,
- string tag = "null"
- ) {
- //Initialization graphical part
- SpritePart->Pos = positionObject;
- SpritePart->mesh = meshObject;
- SpritePart->Tag = tag;
- SpritePart->Color = color;
- }
- void AddPhisics(
- vector<Vector2> trianglesCollision,
- Vector2 gravityVector = Vector2(0, -1),
- float mass = 0,
- float friction = 1,
- float buoyancy = 1,
- float springAbility = 0) {
- //Initialization physical part
- PhysicalPart->TrianglesCollision = trianglesCollision;
- PhysicalPart->Buoyancy = buoyancy;
- PhysicalPart->Friction = friction;
- PhysicalPart->Mass = mass;
- PhysicalPart->SpringAbility = springAbility;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement