0

In Raylib I am trying to make a player character move however it is not moving

I have tried using different functions like KeyPressed(). Here is the code(This is compiled in c++20):

#include <raylib.h>;

int main(){
    int camX = 0;
    int camY = 0;
    InitWindow(1080, 720, "Arachnacide");
    while(!WindowShouldClose()){
        if(IsKeyDown(KEY_W)){
            camY -= 1;
        }
        if(IsKeyDown(KEY_S)){
            camY += 1;
        }
        if(IsKeyDown(KEY_A)){
            camX += 1;
        }
        if(IsKeyDown(KEY_D)){
            camX -= 1;
        }
        BeginDrawing();
        DrawCircle(540, 360, 25, RED);
        DrawCircle(camX, camY, 25, BLUE);
        EndDrawing();
    }
}

1 Answers1

0

Remember to clear the background each time you draw.

BeginDrawing();
ClearBackground(RAYWHITE); // Substitute with any color you prefer

...

EndDrawing();
JarWarren
  • 1,343
  • 2
  • 13
  • 18