diff --git a/Game.cpp b/Game.cpp index 082100c..f76e0da 100644 --- a/Game.cpp +++ b/Game.cpp @@ -464,7 +464,12 @@ bool LGame::initObjs() { printf("Failed to load robber texture!\n"); return false; - } + } + if (!window.loadTexture(yuluTexture, "resources/yulu.png")) + { + printf("Failed to load yulu texture!\n"); + return false; + } LTexture *sleepingAnimationTexture = new LTexture(); LTexture *burgerAnimationTexture = new LTexture(); LTexture *hotdogAnimationTexture = new LTexture(); @@ -514,7 +519,7 @@ bool LGame::initObjs() basketballAnimation = new Animation(*basketBallAnimationTexture, 32, 32); tennisAnimation = new Animation(*tennisAnimationTexture, 32, 32); footballAnimation = new Animation(*footBallAnimationTexture, 32, 32); - Player ash(ashTexture, *this, 32, 32, 3, 1, 2, 0); + Player ash(ashTexture, yuluTexture, *this, 32, 32, 3, 1, 2, 0); players.push_back(ash); int numberOfNPCs = 5; for (int i = 0; i < numberOfNPCs; i++) @@ -527,7 +532,7 @@ bool LGame::initObjs() NPCs.push_back( robber) ; } - Player opponent(ash2Texture, *this, 32, 32, 3, 1, 2, 0); + Player opponent(ash2Texture, yuluTexture , *this, 32, 32, 3, 1, 2, 0); players.push_back(opponent); camera = {0, 0, window.getWidth() - tasksVPWidth, window.getHeight() - 3 * gyRenderOffset - 5 * gyPadding}; diff --git a/Game.h b/Game.h index 41363c2..91befd5 100644 --- a/Game.h +++ b/Game.h @@ -81,6 +81,7 @@ class LGame : public LScreen LTexture profTexture; LTexture ash2Texture; LTexture robberTexture ; + LTexture yuluTexture ; TileAtlas tileAtlas; diff --git a/Player.cpp b/Player.cpp index 7a49f02..4a378c8 100644 --- a/Player.cpp +++ b/Player.cpp @@ -18,7 +18,7 @@ std ::vector hostelNames{"nilgiri", "kara", "aravali", "jwala", "kumaon", "vindy", "satpura", "udai_girnar", "himadri", "kailash"}; -Player ::Player(LTexture &myTexture, LGame &game, int playerHeight, int playerWidth, int right, int left, int top, int bottom) : mTexture(myTexture), mGame(game) +Player ::Player(LTexture &myTexture, LTexture &yuluTexture, LGame &game, int playerHeight, int playerWidth, int right, int left, int top, int bottom) : mTexture(myTexture), yuluTexture(yuluTexture), mGame(game) { // Initialize the collision box mCollisionMusic = Mix_LoadWAV("resources/collision.wav"); @@ -291,7 +291,8 @@ int Player::render(SDL_Renderer *renderer, SDL_Rect &camera) } else { - mTexture.render(renderer, mBox.x - camera.x, mBox.y - camera.y, &playerImages[dimension + offset]); + if( hasYulu())yuluTexture.render(renderer, mBox.x - camera.x, mBox.y - camera.y, &playerImages[dimension + offset]); + else mTexture.render(renderer, mBox.x - camera.x, mBox.y - camera.y, &playerImages[dimension + offset]); } mframes = (mframes + 1) % (numOfAnimationImages * animationSpeed); if (isBusy()) diff --git a/Player.h b/Player.h index d44ed62..034427c 100644 --- a/Player.h +++ b/Player.h @@ -21,7 +21,7 @@ class Player : public Renderable public: // Initializes the variables - Player(LTexture &myTexture, LGame &game, int playerHeight, int playerWidth, int right, int left, int top, int bottom); + Player(LTexture &myTexture, LTexture &yuluTexture , LGame &game, int playerHeight, int playerWidth, int right, int left, int top, int bottom); // Takes key presses and adjusts the dot's velocity void handleEvent(SDL_Event &e); @@ -88,6 +88,7 @@ class Player : public Renderable LGame &mGame; SDL_Rect mBox; LTexture &mTexture; + LTexture &yuluTexture ; Animation *taskAnimation; bool hasTaskAnimation; // bool touchesWall(std::vector tiles); diff --git a/resources/robber.png b/resources/robber.png index feb5865..d78134b 100644 Binary files a/resources/robber.png and b/resources/robber.png differ diff --git a/resources/yulu.png b/resources/yulu.png index 47f89d9..d415638 100644 Binary files a/resources/yulu.png and b/resources/yulu.png differ