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();
}