I’m starting to wonder if VS code is intentionally trolling me. Here’s what I have about halfway through Dapper Dasher:
#include “raylib.h”
int main()
{
//window dimensions
const int windowWidth{512};
const int windowHeight{380};
InitWindow(windowWidth, windowHeight, "Dapper Dasher");
//acceleration due to gravity (pixels/frame)/frame
const int gravity{1000};
const int jumpVel{-600};
//is the rectangle in the air
bool isInAir{};
//nebula variables
Texture2D nebula = LoadTexture("textures/12_nebula_spritesheet.png");
Rectangle nebRec {0, 0, nebula.width/8, nebula.height/8};
Vector2 nebPos{windowWidth, windowHeight - nebRec.height};
//mebula x velocity (pixels per second)
int nebVel{-600};
//scarfy variables
Texture2D scarfy = LoadTexture("textures/scarfy.png");
Rectangle scarfyRec;
scarfyRec.width = scarfy.width/6;
scarfyRec.height = scarfy.height;
scarfyRec.x = 0;
scarfyRec.y = 0;
Vector2 scarfyPos;
scarfyPos.x = windowWidth/2 - scarfyRec.width/2;
scarfyPos.y = windowHeight - scarfyRec.height;
//animeation frame
int frame{0};
int velocity{0};
//amount of time before updating the animation frame
const float updateTime{1.0/12.0};
float runningTime{0};
//initialize the window
SetTargetFPS(60);
while (!WindowShouldClose())
{
//delta time (time since last frame)
const float dT{GetFrameTime()};
//start drawing
BeginDrawing();
ClearBackground(WHITE);
if (scarfyPos.y >= windowHeight - scarfyRec.height)
{
//rectangle is on the ground
velocity = 0;
isInAir = false;
}
else
{
//rectangle is in the air, apply gravity
velocity += gravity * dT;
isInAir = true;
}
//check for jumping
if (IsKeyPressed(KEY_SPACE) && !isInAir)
{
velocity += jumpVel;
}
//update position
scarfyPos.y += velocity * dT;
//update running time
runningTime += dT;
if (runningTime >= updateTime)
{
runningTime = 0.0;
//update animation frame
scarfyRec.x = frame * scarfyRec.width;
frame++;
if (frame > 5)
{
frame = 0;
}
}
//Draw nebula
DrawTextureRec{nebula, nebRec, nebPos, WHITE};
//Draw Scarfy
DrawTextureRec(scarfy, scarfyRec, scarfyPos, WHITE);
//stop drawing
EndDrawing();
}
UnloadTexture(scarfy);
UnloadTexture(nebula);
CloseWindow();
}
Adding the line “DrawTextureRec{nebula, nebRec, nebPos, WHITE};” is breaking the program. By adding this line I am apparently missing a semicolon that prevents the program from compiling. It runs just fine when I remove that line, although it will sometimes put a red squiggle on the empty space with the same error message. It’s just adding code that looks right that prevents it from compiling. I’ve looked at it for 15 minutes and I have absolutely no idea what the problem could be. Clicking quick fix offers to turn off the error message but does not actually make the code compile so I’m not sure what value that is supposed to have either. A screenshot is attached on the chance that I am explaining this incorrectly.