Segmentation fault (core dumped) raylib and c++

I am trying to make a game with raylib and c++
I am using this template: https://replit.com/@smallcut/Raylib-C-Template?v=1

There is nothing when I hit the run button, it just exits for no reason. When I manually hit make and ./game, it says its segmentation fault. I have no idea whats wrong. (This code is not yet finished, I just was testing and noticed this)

#include <raylib.h>
#include <cmath>
#include <iostream>

class Player {
	int x = 0;
	int y = 0;
	int lastx = 0;
	int lasty = 0;
	Rectangle Rect = { x - 10, y - 10, 20, 20 };

	void MoveX(int sx) {
		x += sx;
	}
	void MoveY(int sy) {
		y += sy;
	}
	int cast(int a, Rectangle box) {
		int cx = cos(a)*50;
		int cy = sin(a)*50;
		Vector2 xy = { x, y };
		Vector2 cxcy = { x+cx, y+cy };
		DrawLineEx(xy, cxcy, 2.0f, RED);
		Vector2 bxby = { 0, 0 };
		Vector2 cxcy2 = { x, y };
		for (int i = 0; i < cx; i++) {
			cxcy2.x ++;
			cxcy2.y += (cy/cx);
			if (CheckCollisionPointRec(cxcy2, box)) {
				bxby = cxcy2;
				break;
			}
		}
		if (CheckCollisionPointRec(cxcy, box)) {
			DrawLineEx(cxcy, bxby, 2.0f, BLUE);
		}
	}
	public:
		Texture2D t2dplayer;
	 	void Draw(Rectangle box) {
			for (int a = 0; a < 360; a++) {
				cast(a, box);
			}
			DrawTexture(t2dplayer, x - t2dplayer.width/2, y - t2dplayer.height/2, WHITE);
		}
		void Update(Rectangle box) {
			if (IsKeyDown(KEY_W)) {
				MoveY(-1);
			}
			if (IsKeyDown(KEY_A)) {
				MoveX(-1);
			}
			if (IsKeyDown(KEY_S)) {
				MoveY(1);
			}
			if (IsKeyDown(KEY_D)) {
				MoveX(1);
			}
			Rect = { x - 10, y - 10, 20, 20 };
			if (CheckCollisionRecs(Rect, box)) {
				x = lastx;
				y = lasty;
			}
			else {
				lastx = x;
				lasty = y;
			}
			Rect = { x - 10, y - 10, 20, 20 };
		}
};

int main() {  
    const int screenWidth = 400;
    const int screenHeight = 400;

    InitWindow(screenWidth, screenHeight, "GAME THING");

	Player player;

	Image imgPlayer = LoadImage("resources/Player.png");
	ImageResize(&imgPlayer, 20, 20);
	player.t2dplayer = LoadTextureFromImage(imgPlayer); 
	UnloadImage(imgPlayer);

	Rectangle box = { 150, 150, 100, 100 };

    SetTargetFPS(120);

    while (!WindowShouldClose()) {
        // Update

		player.Update(box);
		
        // Draw
        BeginDrawing();

        ClearBackground(RAYWHITE);

		DrawRectangleRec(box, BLACK);

        player.Draw(box);

        EndDrawing();
    }

    // De-Initialization

	UnloadTexture(player.t2dplayer);
    
    CloseWindow();

    return 0;
}

You probably want all of these to be floats instead of ints, and you get a warning because of this.

But the issue is probably because of this:

This function, as the warnings say, does not return a value. Making those above variables floats and changing casts return type to void seems to fix the issues and I can see a red circle (which moves with W, A, S and D) and a black square display.