Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actuallride

Posted 02 December 2012 - 09:47 PM

Instead of using if-else chain to manage states, you could have used a nice polymorphism.
[source lang="cpp"]while(running){ currentState->update(); currentState->draw(); //change what currentState points to when necessary}[/source]

#3lride

Posted 02 December 2012 - 09:39 PM

You shouldn't use a using directive in a header file

[source lang="cpp"]// Copyright 2012 Liyaan Hasan//// Original File Author: Liyaan Hasan// Modified to use SFML 1.6#ifndef GUIMENU_H#define GUIMENU_Husing namespace std;//Get rid of thisclass GUIMenu{public: GUIMenu(sf::Vector2i position, int numOptionsIn, int firstSelectable); // X, Y, string array of Options, number of Options. ~GUIMenu(); int Update(sf::RenderWindow &targetWindow); void DisplayMenu(sf::RenderWindow &targetWindow); //draws the menu to the screen. void LoadMenuOption(std::string optionName); // Loads an option into the vector, using a stringprivate: //coordinates sf::Vector2i position_; vector<string> optionsList_; int selectedOption_, numOptions_; int curButtonState_, prevButtonState_; int firstSelectableOption_; // attribute that tells the Menu which item it may start at, useful for when the first option(s) are for Help text.};#endif //GUIMENU_H[/source]

#2lride

Posted 02 December 2012 - 09:38 PM

You shouldn't use a using directive in a header file

[source lang="cpp"]// Copyright 2012 Liyaan Hasan//// Original File Author: Liyaan Hasan// Modified to use SFML 1.6#ifndef GUIMENU_H#define GUIMENU_Husing namespace std;class GUIMenu{public: GUIMenu(sf::Vector2i position, int numOptionsIn, int firstSelectable); // X, Y, string array of Options, number of Options. ~GUIMenu(); int Update(sf::RenderWindow &targetWindow); void DisplayMenu(sf::RenderWindow &targetWindow); //draws the menu to the screen. void LoadMenuOption(std::string optionName); // Loads an option into the vector, using a stringprivate: //coordinates sf::Vector2i position_; vector<string> optionsList_; int selectedOption_, numOptions_; int curButtonState_, prevButtonState_; int firstSelectableOption_; // attribute that tells the Menu which item it may start at, useful for when the first option(s) are for Help text.};#endif //GUIMENU_H[/source]

#1lride

Posted 02 December 2012 - 09:37 PM

You shouldn't use a using directive in a header file
// Copyright 2012 Liyaan Hasan
//
// Original File Author: Liyaan Hasan
// Modified to use SFML 1.6

#ifndef GUIMENU_H
#define GUIMENU_H

using namespace std;

class GUIMenu
{
public:
GUIMenu(sf::Vector2i position, int numOptionsIn, int firstSelectable); // X, Y, string array of Options, number of Options.
~GUIMenu();

int Update(sf::RenderWindow &targetWindow);
void DisplayMenu(sf::RenderWindow &targetWindow); //draws the menu to the screen.
void LoadMenuOption(std::string optionName); // Loads an option into the vector, using a string

private:
//coordinates
sf::Vector2i position_;
vector<string> optionsList_;
int selectedOption_, numOptions_;
int curButtonState_, prevButtonState_;
int firstSelectableOption_; // attribute that tells the Menu which item it may start at, useful for when the first option(s) are for Help text.
};

#endif //GUIMENU_H

PARTNERS