Copy and Paste resulted in errors?

Hi, I copied and pasted per them instructions but errors have arisen that I cant fix.
#include “raylib.h”

struct AnimData

{

Rectangle rec;

Vector2 pos;

int frame;

float updateTime;

float runningTime;

};

int main()

{

// Window Dimensions

int windowDimensions[2];

windowDimensions[0] = 512;

windowDimensions[1] = 380;



// Intialise WIndow

InitWindow(windowDimensions[0], windowDimensions[1], "Dapper Dasher!");

// Acceleration Due to Gravity (pixels/second)/second

const int gravity{1'000};



// Nebula Variables

Texture2D nebula = LoadTexture("textures/12_nebula_spritesheet.png");

// AnimData for Nebula

AnimData nebData{

    {0.0, 0.0, nebula.width/8, nebula.height/8}, // Retangle rec

    {windowDimensions[0], windowDimensions[1] - nebula.height/8}, // Vector 2 pos

    0, // int frame

    1.0/12.0, // float updateTime

    0.0 // float runningTime

};

//AnimData for Nebula 2

AnimData neb2Data{

    {0.0, 0.0, nebula.width/8, nebula.height/8}, //Retangle rec

    {windowDimensions[0] + 300, windowDimensions[1] - nebula.height/8}, // Vector 2 pos

    0, // int frame

    1.0/16.0, // float updateTime

    0.0 // float runningTime

};

AnimData nebulae[2]{ nebulae[0], nebulae[1] };

// Nebula X Velocity (pixels/second)

int nebVel{-200};

// Scarfy Variables

Texture2D scarfy = LoadTexture("textures/scarfy.png");

AnimData scarfyData;

scarfyData.rec.width = scarfy.width/6;

scarfyData.rec.height = scarfy.height;

scarfyData.rec.x = 0;

scarfyData.rec.y = 0;

scarfyData.pos.x = windowDimensions[0]/2 - scarfyData.rec.width/2;

scarfyData.pos.y = windowDimensions[1] - scarfyData.rec.height;

scarfyData.frame = 0;

scarfyData.updateTime = 1.0/12.0;

scarfyData.runningTime = 0.0;

// Is the Rectangle in the Air?

bool isInAir{};

// Jump Velocity (pixels/second)

const int jumpVel{-600};

int velocity{0};



SetTargetFPS(60);

while (!WindowShouldClose())

{

    // Delta Time (time since last frame)

    const float dT{GetFrameTime()};

    // Start Drawing

    BeginDrawing();

    ClearBackground(WHITE);

   

    // Ground Check

    if (scarfyData.pos.y >= windowDimensions[1] - scarfyData.rec.height)

    {

        // Rectangle is on the Ground

        velocity = 0;

        isInAir = false;

    }

    else

    {

        // Rectangle is in the Air?

        velocity += gravity * dT;

        isInAir = true;

    }

    // Check for Jumping

    if (IsKeyPressed(KEY_SPACE) && !isInAir)

    {

        velocity += jumpVel;

    }

    // Update Nebula Position

    nebulae[0].pos.x += nebVel * dT;

    // Update Nebula2 Position

    nebulae[1].pos.x += nebVel * dT;

    // Upadate Scarfy Position

    scarfyData.pos.y += velocity * dT;

    ///Update Scarfy Animation Frame

    if(!isInAir)

    {

        //Update Running Time

        scarfyData.runningTime += dT;

        if (scarfyData.runningTime >= scarfyData.updateTime)

        {

            scarfyData.runningTime = 0.0;

            // Update Animation Frame

            scarfyData.rec.x = scarfyData.frame * scarfyData.rec.width;

            scarfyData.frame++;

            if (scarfyData.frame > 5)

            {

            scarfyData.frame = 0;

            }

        }

    }

   

    //Update Nebula Animation Frame

    nebulae[0].runningTime += dT;

    if (nebulae[0].runningTime >= nebulae[0].updateTime)

    {

        nebulae[0].runningTime = 0.0;

        nebulae[0].rec.x = nebulae[0].frame * nebulae[0].rec.width;

        nebulae[0].frame++;

        if (nebulae[0].frame > 7)

        {

            nebulae[0].frame = 0;

        }

    }

    //Update Nebula Animation Frame

    nebulae[1].runningTime += dT;

    if (nebulae[1].runningTime >= nebulae[1].updateTime)

    {

        nebulae[1].runningTime = 0.0;

        nebulae[1].rec.x = nebulae[1].frame * nebulae[1].rec.width;

        nebulae[1].frame++;

        if (nebulae[0].frame > 7)

        {

            nebulae[0].frame = 0;

        }

    }

    // Draw Nebula

    DrawTextureRec(nebula, nebulae[0].rec, nebulae[0].pos, WHITE);

    // Draw Nebula2

    DrawTextureRec(nebula, nebulae[1].rec, nebulae[1].pos, RED);

   

    // Draw Scarfy

    DrawTextureRec(scarfy, scarfyData.rec, scarfyData.pos, WHITE);

    // Stop Drawing

    EndDrawing();

}

UnloadTexture(scarfy);

UnloadTexture(nebula);

CloseWindow();

}

I don’t know all of the errors you are facing since you didn’t mention them. However, I do know that sometimes the quotation marks can be a symbol that gets VS Code and the MingW compiler confused.

Which is what I’m seeing for #include “raylib.h”, try #include "raylib.h" instead.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms