diff --git a/img/player.png b/img/player.png new file mode 100644 index 0000000..615b19f Binary files /dev/null and b/img/player.png differ diff --git a/img/player/player-full.png b/img/player/player-full.png new file mode 100644 index 0000000..a0e499e Binary files /dev/null and b/img/player/player-full.png differ diff --git a/img/player/player.pdn b/img/player/player.pdn new file mode 100644 index 0000000..7159a30 Binary files /dev/null and b/img/player/player.pdn differ diff --git a/main.cpp b/main.cpp index bd461b4..1d60825 100644 --- a/main.cpp +++ b/main.cpp @@ -15,6 +15,7 @@ std::atomic running(true); SDL_Window* window = nullptr; SDL_Renderer* renderer = nullptr; SDL_Texture* schoolTexture = nullptr; +SDL_Texture* playerTexture = nullptr; std::vector school; Rock rock(100, 100, 50, 255, 0, 0); @@ -122,6 +123,10 @@ bool initSDL() { schoolTexture = SDL_CreateTextureFromSurface(renderer, schoolSurface); SDL_FreeSurface(schoolSurface); + SDL_Surface* playerSurface = IMG_Load("../img/player.png"); + playerTexture = SDL_CreateTextureFromSurface(renderer, playerSurface); + SDL_FreeSurface(playerSurface); + return true; } @@ -194,9 +199,8 @@ void renderScene(int playerX, int playerY) { fish.draw(renderer); } - SDL_Rect playerRect = { playerX - offsetX, playerY - offsetY, 20, 20 }; - SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); - SDL_RenderFillRect(renderer, &playerRect); + SDL_Rect playerRect = { playerX - offsetX, playerY - offsetY, 75, 75 }; + SDL_RenderCopy(renderer, playerTexture, nullptr, &playerRect); SDL_RenderPresent(renderer); }