Ok, so for whatever reason I cannot make classes in new files anymore. Don’t really know what’s causing this, it just kind of started happening. When I try to compile I get an error, if I press “Show Errors” I get nothing of substance because there aren’t any and if I press “Debug Anyway” I get “…filepath…/main’ does not exists” or the same depending which class window I have open when I try to compile.
My best guess is that for whatever reason the compiler is seeing every file in the folder as the main file and gets confused but I don’t have the slightest clue on how to fix that. The worst part - I have two laptops and it’s happening on both
Also, somehow old projects that already have classes in separate files in them compile fine but only for what’s already there, if I try to add a new class in a new header&cpp files - same problem
I can have classes in the main file but not in separate ones…
Error Messages
main.cpp
#include <iostream>
#include "raylib.h"
#include "Block.h"
const int WIN_WIDTH = 1280;
const int WIN_HEIGHT = 720;
int main()
{
Block block;
InitWindow(WIN_WIDTH,WIN_HEIGHT,"Project Test");
SetTargetFPS(60);
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(WHITE);
block.Draw();
EndDrawing();
}
CloseWindow();
return 0;
}
Block.h
#include "raylib.h"
class Block
{
private:
Vector2 position;
Vector2 dimensions;
Rectangle collider;
public:
Vector2 GetPosition() {return position;}
Vector2 GetDimensions() {return dimensions;}
Rectangle GetCollider() {return collider;}
void Update();
void Draw();
Block();
~Block();
};
Block::Block()
{
position = {0.0f,0.0f};
dimensions = {10.0f,10.0f};
collider = {position.x,position.y,dimensions.x,dimensions.y};
}
Block::~Block()
{
}
Block.cpp
#include "Block.h"
void Block::Update()
{
}
void Block::Draw()
{
DrawRectangle(position.x,position.y,dimensions.x,dimensions.y,BLUE);
}
This is some code for the purpose of testing the crash, as you can see there is nothing that should be wrong with it, at least so far as I can tell.
Please help, this has been incredibly frustrating, especially because for a while I thought this was me doing something wrong in my bigger project with lots of spaghetti. I have two left hands when it comes to coding so I really don’t know how to fix this.