Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ChinmayMittal/Maze-Game int…
Browse files Browse the repository at this point in the history
…o main
  • Loading branch information
TanishTuteja committed Apr 17, 2022
2 parents 8e3486c + dd52276 commit cc3b6d8
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 235 deletions.
37 changes: 33 additions & 4 deletions Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,11 @@ bool LGame::initObjs()
printf("Failed to load ash texture!\n");
return false;
}
if (!window.loadTexture(ash2Texture, "resources/ash2.bmp"))
{
printf("Failed to load ash2 texture!\n");
return false;
}
if (!window.loadTexture(dogTexture, "resources/dog.png"))
{
printf("Failed to load dog texture!\n");
Expand All @@ -437,6 +442,7 @@ bool LGame::initObjs()
LTexture *icecreamAnimationTexture = new LTexture();
LTexture *tennisAnimationTexture = new LTexture();
LTexture *basketBallAnimationTexture = new LTexture();
LTexture *footBallAnimationTexture = new LTexture() ;
if (!window.loadTexture(*sleepingAnimationTexture, "resources/sleeping.png"))
{
printf("Failed to load sleeping texture!\n");
Expand Down Expand Up @@ -467,13 +473,17 @@ bool LGame::initObjs()
printf("Failed to load basketball texture!\n");
return false;
}
if( !window.loadTexture(*footBallAnimationTexture , "resources/football.png")){
printf("Failed to load football texture!\n");
return false;
}
sleepingAnimation = new Animation(*sleepingAnimationTexture, 32, 32);
burgerAnimation = new Animation(*burgerAnimationTexture, 32, 32);
hotDogAnimation = new Animation(*hotdogAnimationTexture, 32, 32);
icecreamAnimation = new Animation(*icecreamAnimationTexture, 32, 32);
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);
players.push_back(ash);
int numberOfNPCs = 5;
Expand All @@ -485,7 +495,7 @@ bool LGame::initObjs()
NPCs.push_back(prof);
}

Player opponent(ashTexture, *this, 32, 32, 3, 1, 2, 0);
Player opponent(ash2Texture, *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 Expand Up @@ -859,8 +869,27 @@ void LGame::initEntities()
{ displayText = "shop"; });
Entity sac("sac", [&](Player &player, std::string &displayText)
{ displayText = "sac"; });
Entity foot("foot", [&](Player &player, std::string &displayText)
{ displayText = "foot"; });
Entity foot("foot", getTextPromptFunc("PRESS F to PLAY FOOTBALL") ,
[&](SDL_Event &e, Player &player)
{
if (e.type == SDL_KEYDOWN && e.key.repeat == 0)
{
switch (e.key.keysym.sym)
{
case SDLK_f:
player.setTaskText("playing basketball... ");
player.setTaskAnimation(player.getGame().footballAnimation);
player.setCurrentTaskTime(3000);
player.getCurrentTaskTimer().start();
player.setUpdateStateParameters({-5,
0,
0,
10});
break;
}
}
}
);
Entity basketball("basketball", getTextPromptFunc("PRESS B TO PLAY BASKTEBALL"),
[&](SDL_Event &e, Player &player)
{
Expand Down
2 changes: 2 additions & 0 deletions Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class LGame : public LScreen
LTexture ashTexture;
LTexture dogTexture;
LTexture profTexture;
LTexture ash2Texture;

TileAtlas tileAtlas;

Expand Down Expand Up @@ -111,6 +112,7 @@ class LGame : public LScreen
Animation *hotDogAnimation;
Animation *tennisAnimation;
Animation *basketballAnimation;
Animation* footballAnimation ;
LTimer getTimer();
Mix_Music *backGroundMusic;
Mix_Chunk *introMusic;
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ OBJS = Button.o collision.o Game.o main.o MainMenu.o MessageStructs.o MyTexture.
COMPILER_FLAGS = -g

#LINKER_FLAGS specifies the libraries we're linking against
LINKER_FLAGS = -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lSDL2_net
LINKER_FLAGS = -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer

#OBJ_NAME specifies the name of our exectuable
OBJ_NAME = experiment.out
Expand All @@ -28,7 +28,7 @@ Game.o: Tile.h Player.h MyTexture.h TileAtlas.h TileAtlas.h Renderable.h Entity.

main.o: MyWindow.h Game.h MainMenu.h

MainMenu.o: Screen.h Game.h TextInput.h SearchOpponent.h MyWindow.h Button.h
MainMenu.o: Screen.h Game.h TextInput.h MyWindow.h Button.h

MessageStructs.o: MessageStructs.h

Expand All @@ -40,8 +40,6 @@ Player.o: Tile.h MyTexture.h Renderable.h MyWindow.h SoundEffect.h Timer.h utili

Screen.o: MyWindow.h

#SearchOpponent.o: MyWindow.h MessageStructs.h Game.h Screen.h

Text.o: MyTexture.h MyWindow.h

TextInput.o: MyWindow.h
Expand Down
6 changes: 0 additions & 6 deletions MyWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_mixer.h>
#include <SDL2/SDL_net.h>
#include <vector>
#include <sstream>
#include <string>
Expand Down Expand Up @@ -233,11 +232,6 @@ bool LWindow::initLibs()
}
Mix_AllocateChannels(32);

if (SDLNet_Init() < 0)
{
fprintf(stderr, "SDLNet_Init: %s\n", SDLNet_GetError());
return false;
}

return true;
}
Expand Down
185 changes: 0 additions & 185 deletions SearchOpponent.cpp

This file was deleted.

36 changes: 0 additions & 36 deletions SearchOpponent.h

This file was deleted.

0 comments on commit cc3b6d8

Please sign in to comment.