No scarfy in window

Hello
For some reason when I run>start debugging the window pops up but scarfy seems to be missing. I have tried some of the solutions from other questions in this lecture but none seemed to have work.

#include "raylib.h"
int main()
{
    //window dimmention
    const int WindowWidth{512};
    const int WindowHeight{380};
    InitWindow(WindowWidth, WindowHeight, "Dapper Dasher!");

    

    //acceleration due to gravity (pixels per frame per frame)
    const int gravity{1};

    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;

    const int jumpVel{-22};
    bool isInAir{false};


   
    int velocity{0};


    SetTargetFPS(60);
    while (!WindowShouldClose())
    {
        //start drawing
        BeginDrawing();
        ClearBackground(WHITE);

        if (IsKeyPressed(KEY_SPACE))
        {
            velocity -= 10;
        }


        //ground check
        if (scarfyPos.y >= WindowHeight - scarfyRec.height )
        {
            //rectangle is on the ground
            velocity = 0;
            isInAir = false;

        }
        else
        {
            //rectangle is in air
            velocity += gravity;
            isInAir = true;
        }
        
        //check for jumping
         if (IsKeyPressed(KEY_SPACE) && !isInAir)
        {
            velocity += jumpVel;
        }

        //update position
        scarfyPos.y += velocity;

        DrawTextureRec(scarfy, scarfyRec, scarfyPos, WHITE);
        
        //stop drawing
        EndDrawing();
    }
    UnloadTexture(scarfy);
    CloseWindow();
 
}

Hi Alden,

When I run your code on my machine I can see scarfy and he jumps like I would expect. Let’s start with double-checking the filepath for Scarfy’s texture compared to how you setup your project.

Here is my file path. Also I changed the file path to("resouces/scarfy.png"); but it still doesn’t work.
Screenshot 2022-11-18 212053

Paths are relative. If your project starts at “First game” the the path for LoadTexture is “raylib/raylib/examples/textures/resources/scary.png”

Thank you, that worked

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

Privacy & Terms