Skip to content

Commit

Permalink
robber and yulu animation added
Browse files Browse the repository at this point in the history
  • Loading branch information
ChinmayMittal committed Apr 18, 2022
1 parent 4bbe770 commit acabf0a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
11 changes: 8 additions & 3 deletions Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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++)
Expand All @@ -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};
Expand Down
1 change: 1 addition & 0 deletions Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class LGame : public LScreen
LTexture profTexture;
LTexture ash2Texture;
LTexture robberTexture ;
LTexture yuluTexture ;

TileAtlas tileAtlas;

Expand Down
5 changes: 3 additions & 2 deletions Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

std ::vector<std ::string> 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");
Expand Down Expand Up @@ -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())
Expand Down
3 changes: 2 additions & 1 deletion Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<Tile> tiles);
Expand Down
Binary file modified resources/robber.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/yulu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit acabf0a

Please sign in to comment.