Skip to content

Commit

Permalink
Code Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
abhayMore committed May 18, 2023
1 parent 6b23824 commit b3e6c66
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 166 deletions.
9 changes: 0 additions & 9 deletions AMMPED-UP/Header Files/GamePlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,8 @@ class GamePlay : public am::State
//COINS
std::list<Coin> m_coins;

//SFX and MUSIC

//sf::Sound m_damageSFX;
//sf::Sound m_blastSFX;
//sf::Sound m_coinEatSfx;
//sf::Sound m_enemyDeathSFX;
//sf::Music& m_inGame;

AudioManager* m_sound;


//EXPLOSIONS
std::vector<sf::Sprite> m_explosions;

Expand Down
1 change: 0 additions & 1 deletion AMMPED-UP/Header Files/LoginState.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ class LoginState : public am::State
void draw() override;
void start();
void pause();

};

98 changes: 4 additions & 94 deletions AMMPED-UP/Source/GamePlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ GamePlay::GamePlay(std::shared_ptr<Context>& context) :
m_scoreManager = ScoreManager::getInstance();
m_theme.load("Resources/Black.txt");


AudioManager& audioManager = AudioManager::getInstance(m_context->m_assets->getSoundTrack(MAIN_SOUND_TRACK),
m_context->m_assets->getSoundTrack(IN_GAME_SOUND_TRACK),
m_context->m_assets->getSoundEffect(DAMAGE_SFX),
m_context->m_assets->getSoundEffect(BLAST_SFX),
m_context->m_assets->getSoundEffect(COIN_SFX),
m_context->m_assets->getSoundEffect(ENEMY_DEATH_SFX)
);

m_sound = &audioManager;
//m_sound->setSFXVolume();

srand(time(nullptr));
}

Expand Down Expand Up @@ -287,19 +283,6 @@ void GamePlay::init()
i.init(m_context->m_assets->getTexture(COIN));
i.setPosition(sf::Vector2f(pos));
}

// SOUND EFFECT SETTINGS
//m_coinEatSfx.setBuffer(m_context->m_assets->getSoundEffect(COIN_SFX));
//m_coinEatSfx.setVolume(20);

//m_blastSFX.setBuffer(m_context->m_assets->getSoundEffect(BLAST_SFX));
//m_blastSFX.setVolume(80);

//m_damageSFX.setBuffer(m_context->m_assets->getSoundEffect(DAMAGE_SFX));
//m_damageSFX.setVolume(100);

//m_enemyDeathSFX.setBuffer(m_context->m_assets->getSoundEffect(ENEMY_DEATH_SFX));
//m_enemyDeathSFX.setVolume(100);
//takeScreenshot("../Resources/assets/");
}

Expand Down Expand Up @@ -354,14 +337,14 @@ void GamePlay::processInput()
}
break;
}
//TEMPORARY DEBUGGIN TOOL
/*case sf::Keyboard::Q:
{
m_shiftToGameOver = true;
m_currentGameState = std::string("You Won!!");
break;
}*/
//TEMPORARY DEBUGGIN TOOL
/*case sf::Keyboard::P:
}
case sf::Keyboard::P:
{
if (!showPowerUP)
showPowerUP = true;
Expand Down Expand Up @@ -1085,77 +1068,4 @@ int GamePlay::removeWalls(sf::Vector2f pos, int radius)
}
}
return explodeTileCount;
}
//REMOVE LATER
/*
void GamePlay::explosions(sf::Vector2f bombPos, int radius)
{
sf::Sprite center;
center.setTexture(m_context->m_assets->getTexture(EXPLOSION_CENTER));
center.setPosition(bombPos);
m_explosions.push_back(center);
//i = 1 i < radius for middle piece
for (int i = 1; i < radius; i++)
{
sf::Sprite sprite1;
sprite1.setTexture(m_context->m_assets->getTexture(EXPLOSION_SIDE));
sprite1.setPosition(sf::Vector2f(bombPos.x, bombPos.y - 16 * i));
sf::Sprite sprite2;
sprite2.setTexture(m_context->m_assets->getTexture(EXPLOSION_SIDE));
sprite2.setPosition(sf::Vector2f(bombPos.x, bombPos.y + 16 * i));
sf::Sprite sprite3;
sprite3.setTexture(m_context->m_assets->getTexture(EXPLOSION_SIDE));
sprite3.setPosition(sf::Vector2f(bombPos.x - 16 * i, bombPos.y));
sprite3.setOrigin(8, 8);
sprite3.setRotation(-90);
sprite3.setOrigin(0, 0);
sprite3.setPosition(sprite3.getPosition() + sf::Vector2f(0, 16));
sf::Sprite sprite4;
sprite4.setTexture(m_context->m_assets->getTexture(EXPLOSION_SIDE));
sprite4.setPosition(sf::Vector2f(bombPos.x + 16 * i, bombPos.y));
sprite4.setOrigin(8, 8);
sprite4.setRotation(90);
sprite4.setOrigin(0, 0);
sprite4.setPosition(sprite4.getPosition() + sf::Vector2f(16, 0));
m_explosions.push_back(sprite1);
m_explosions.push_back(sprite2);
m_explosions.push_back(sprite3);
m_explosions.push_back(sprite4);
}
sf::Sprite end[4];
for (int i = 0; i < 4; i++)
{
end[i].setTexture(m_context->m_assets->getTexture(EXPLOSION_END));
}
end[0].setPosition(sf::Vector2f(bombPos.x, bombPos.y - 16 * radius));
end[1].setPosition(sf::Vector2f(bombPos.x, bombPos.y + 16 * radius));
end[1].setOrigin(8, 8);
end[1].setRotation(180.0f);
end[1].setOrigin(0, 0);
end[1].setPosition(end[1].getPosition() + sf::Vector2f(16, 16));
end[2].setPosition(sf::Vector2f(bombPos.x - 16 * radius, bombPos.y));
end[2].setOrigin(8, 8);
end[2].setRotation(-90.0f);
end[2].setOrigin(0, 0);
end[2].setPosition(end[2].getPosition() + sf::Vector2f(0, 16));
end[3].setPosition(sf::Vector2f(bombPos.x + 16 * radius, bombPos.y));
end[3].setOrigin(8, 8);
end[3].setRotation(90.0f);
end[3].setOrigin(0, 0);
end[3].setPosition(end[3].getPosition() + sf::Vector2f(16, 0));
m_explosions.push_back(end[0]);
m_explosions.push_back(end[1]);
m_explosions.push_back(end[2]);
m_explosions.push_back(end[3]);
}*/
}
4 changes: 0 additions & 4 deletions AMMPED-UP/Source/LoginPageState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ void LoginPageState::init()
m_errorPrompt.setCharacterSize(20);
m_errorPrompt.setOrigin(m_errorPrompt.getLocalBounds().width / 2, m_errorPrompt.getLocalBounds().height / 2);
m_errorPrompt.setPosition(m_errorPrompt.getLocalBounds().width / 2 + 2, m_errorPrompt.getLocalBounds().height / 2 + 2);

}

void LoginPageState::processInput()
Expand Down Expand Up @@ -177,17 +176,14 @@ void LoginPageState::update(sf::Time deltaTime)
break;
}
}

}
else
{
m_errorPrompt.setString("User not found, did you register?");
//std::cout << "User not found, did you register?" << std::endl;
}
if(fileEmpty == false && verified == false)
{
m_errorPrompt.setString("Error login, invalid username or password");
//std::cout << "Error login, invalid username or password" << std::endl;
}
m_isSignInButtonPressed = false;
}
Expand Down
4 changes: 0 additions & 4 deletions AMMPED-UP/Source/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ void MainMenu::update(sf::Time deltaTime)
m_leadershipButton.setFillColor(::sf::Color::White);
m_optionsButton.setFillColor(::sf::Color::White);
}

if (m_isPlayButtonPressed)
{
//TODO
Expand All @@ -246,12 +245,10 @@ void MainMenu::update(sf::Time deltaTime)
{
m_context->m_states->add(std::make_unique<ExitState>(m_context), true);
}

if (m_bgm->isMenuMusicPlaying() == sf::SoundStream::Status::Stopped && !m_isPlayButtonPressed)
{
m_bgm->startMainMenuMusic();
}

}

void MainMenu::draw()
Expand All @@ -269,7 +266,6 @@ void MainMenu::draw()

void MainMenu::start()
{

}

void MainMenu::pause()
Expand Down
53 changes: 0 additions & 53 deletions AMMPED-UP/Source/RegisterPageState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,59 +217,6 @@ void RegisterPageState::processInput()
registerUser();
}
}
/*
std::cout << "entered for loop" << std::endl;
if (m_allTextBoxes[0].getText() == person["username"].get<std::string>())
{
if (m_allTextBoxes[2].getText() == person["email"].get<std::string>())
{
//std::cout << "same username, different mail ID" << std::endl;
//m_errorPrompt.setString("Username is already taken. Please choose another username!!");
m_errorPrompt.setString("User already exists. Please login!!");
resetTextboxes();
break;
}
else if (m_allTextBoxes[2].getText() != person["email"].get<std::string>())
{
m_errorPrompt.setString("Username is already taken. Please choose another username!!");
resetTextboxes();
break;
}
}
else if (m_allTextBoxes[2].getText() == person["email"].get<std::string>())
{
m_errorPrompt.setString("Email is already registered. Please use a different email!!");
resetTextboxes();
break;
}
else if()
else if (m_allTextBoxes[2].getText() == person["email"].get<std::string>() &&
m_allTextBoxes[0].getText() != person["username"].get<std::string>()
)
{
m_errorPrompt.setString("Email is already registered. Please use a different email!!");
resetTextboxes();
break;
}
else if (m_allTextBoxes[0].getText() == person["username"].get<std::string>() &&
m_allTextBoxes[2].getText() == person["email"].get<std::string>())
{
m_errorPrompt.setString("User already exists. Please login!!");
resetTextboxes();
break;
}
else if ((person["username"].get<std::string>() != m_allTextBoxes[0].getText()) && (person["email"].get<std::string>() != m_allTextBoxes[2].getText()))
{
if (!anyTextboxEmpty())
{
std::cout << "file not empty, and registered" << std::endl;
registerUser();
}
break;
}*/
isUsernameTaken = false;
isEmailRegistered = false;
isUserExists = false;
Expand Down
2 changes: 1 addition & 1 deletion AMMPED-UP/score.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"score": 150,
"score": 0,
"username": "gg"
}
]

0 comments on commit b3e6c66

Please sign in to comment.