The Green Warden – Report 6

GreenWarden MainMenu4

Image looks weird because it is too big

 

This week I have been trying to do the final work on the main menu to prepare for bug fixes and such next week.
Since the post last week I have been able to load into the main menu state, I can now play music in the main menu and the background is being successfully loaded.
Changing states works in theory, but only in theory and I have yet to find where the problem originates that stops me from changing to the next state.

StateManager.cpp:

	bool StateManager::Initialize()
	{ 
		AttachState("Menu", new MainMenuState);
		//AttachState("TestState", new TestState);
		//SetActiveState("TestState");
		//AttachState("Test", new TestState);
		//AttachState("StartScreen", new StartScreen);
		//AttachState("GameOver", new GameOver);
		SetActiveState("Menu");

		return true;
	}

MainMenuState.cpp:

	std::string MainMenuState::GetNextState()
	{
		return std::string("TestState");
	}

TestState is the actual game state.

At this rate there’s no fear that I will not be able to complete the main menu by the time the game should be released, however, the issue I am facing with changing states could at worst cause me to miss the deadline. It might be easier to solve however with fresh eyes in the morning as I have been staring at the code for quite some time and gone blind to a lot of problems. I for example did not notice for a while that I called m_music.play() and went around to web to find an answer. The answer was that m_music was a local variable that wasn’t connected to anything, in contrast to “music” which was connected through a pointer.

AudioManager* audio_manager = ServiceLocator::GetService();
 
 sf::Music* music = audio_manager->CreateMusicFromFile("../assets/Audio/GameSoundtrack.wav");

 music->setLoop(true);
 music->setVolume(60.0f);
 music->play();

The funny part being that just an hour before, then I had worked on that pointer and it is right above what I was working on. It shows that it is easy to start working on something that is not in any way connected to the code as a whole which is something one needs to keep a watchful eye on as that type of unintentional procrastination which is all it really can be described as can cause a lot of problems as it can cause crashes and be hard to pin down in thousands of lines of code if you don’t know when the faulty code was added as it can be as tiny as in my case where it was music->play(); instead of m_music.play();.

The biggest problem one will face however is the changing of states which until one is used to it can be extremely hard in my experience. Plus, since the teacher was not able to pin it down either when I asked for help, it would seem that even the people who are good at what they do can get stuck when it comes to states.

Filed under: Game Development – introduction – 5SD033 Tagged: 5SD033

About Marcus van Aller

2015 Graphics