Are these operators pre-defined or am I doing something wrong? I did try to compile but also gave same error. By the way, same is happenning with all Vector2 ops.:( Here is the code:
#include "raylib.h"
#include "raymath.h"
#include <algorithm>
using namespace std;
int main(void)
{
InitWindow(800, 450, "raylib [core] example - basic window");
SetWindowState(FLAG_VSYNC_HINT);
while (!WindowShouldClose()){
BeginDrawing();
ClearBackground(RAYWHITE);
DrawFPS(10,10);
EndDrawing();
}
CloseWindow();
return 0;
}
class Particle {
public:
Vector2 pos;
Vector2 vel;
Vector2 acc;
void Update() {
vel += acc;
pos += vel;
acc -= acc;
}
void Show(Color c) {
DrawCircle(pos.x,pos.y,5,c);
}
};
Operator overloading is a C++ feature, which is added by raylib-cpp, while raylib itself is a C library, and C doesn't support operator overloading.
Raylib-cpp is a header-only library, you only need to download it and put its #include
directory somewhere inside your project and tell the compiler to add this #include
directory to your project's include directories.