|
Finished the music and sound today, it all seems to be working pretty well and I added to that you can enter the level design in a text file, it doesn’t work if you want several levels but I am working on it. Tomorrow I’m gonna see if I can make more levels somehow but first I’ve got to get TTF working so that we can have actual high-score. If I can’t work with TTF then I might just record the score to a text file anyway. Maybe I should start out with that seeing as it is one of the goals with the assignment and it can’t take too long to learn, right?
Oh right, I’ve been writing about putting up some examples of what I’ve done but I always post these so late at night that I don’t have any energy – so I’ll grab some examples now before it’s way too late and post them. (Y’know… maybe posting these a little bit earlier than tomorrow is something I should start considering)
The Pausestate:
(basically right now the pausestate is more or less an extended version of the menustate with two “substates” that can be switched between. I am rather happy with the outcome of this even if I know that it could probably use a lot of improvement, also: this might be rather hard to read – I don’t know if there is some sort of tool that allows for easier code viewing on sites like blogger but that would be rather nice to have in this case…)
bool Pausestate::Update(float p_fDtime){ // So, first of all the update checks wether or not the player has pressed Space and loops through all of the menu items if (m_cpKeyboard->IsDownOnce(SDLK_SPACE)){ for (int i = 0; i GetVector().size(); i++){ // …it then checks if the items are part of the Pausestate and the correct substate – in Pausestate there’s two substates: Mainstate and Exitstate. // Mainstate simply asks the player if s/he wants to leave and the Exitstate asks them if they’re sure. This also applies to Pausestate’s Draw method. if (m_cpGobjman->GetVector()[i]->Instate(“Pausestate”) && m_cpGobjman->GetVector()[i]->GetInt(1) == m_iCurrsub){ if (m_cpGobjman->GetVector()[i]->IsObj(“Menu”) && m_cpGobjman->GetVector()[i]->GetInt() >= 0){ // After checking States and Substates the game checks if it’s Choice (That is – what choice number it is) is higher or equal then zero // It also checks if it is a MenuObject and if it’s Choice number is equal to the one currently selected if (m_cpGobjman->GetVector()[i]->GetInt() == m_iChoice){ // The Bool that is checked sets wether or not the choice leads to a Substate or a normal State if (m_cpGobjman->GetVector()[i]->GetBool()){ for (int ii = 0; ii < 2; ii++){ // If the Choice leads to a Substate it starts out to check which Substate it is part of and then sets the active Substate to that. // …after that the active choice is set to zero so that the cursor is at the top choice if (m_cpGobjman->GetVector()[i]->GetString().compare(m_sSubstate[ii]) == 0){ m_iCurrsub = ii; m_iChoice = 0; return true; } } } else { // If the Choice leads to a State it sets the m_sNextstate (Member_StringNextstate) to the current Choice’s and returns false so that the Stateman can switch to it std::cout <GetVector()[i]->GetString();; m_sNextstate = m_cpGobjman->GetVector()[i]->GetString(); return false; } } } } } } //Basically everything below just makes it so that pressing w/s changes your position in the menu. // It also makes sure that you’re always in the menu and if you move below the menu you are brought to the top. // Because both states only have two options this means that no matter what you press (w or s) it has the same effect in this calse. else if (m_cpKeyboard->IsDownOnce(SDLK_w)){ m_iChoice -= 1; if (m_iChoice < 0 && m_iCurrsub == 0){ m_iChoice = e_Exit; } else if (m_iChoice < 0 && m_iCurrsub == 1){ m_iChoice = e_No; } } else if (m_cpKeyboard->IsDownOnce(SDLK_s)){ m_iChoice += 1; if (m_iChoice > e_Exit && m_iCurrsub == 0){ m_iChoice = 0; } else if (m_iChoice > e_No && m_iCurrsub == 1){ m_iChoice = 0; } } // This once simply changes the position of the arrow to match the current Choice selected – The choice is a MenuObject just like all of the Choices // …to keep track of it I have an Int with the arrows position in m_cpGobjman (Member_ClassPointerGobjman) // I know that this is far from the best solution but at the moment of writing this I do not have time to implement something better – practical or not it still works in practice. for (int i = 0; i GetVector().size(); i++){ if (m_cpGobjman->GetVector()[i]->IsObj(“Menu”) && m_cpGobjman->GetVector()[i]->GetInt() >= 0){ if (m_cpGobjman->GetVector()[i]->GetInt() == m_iChoice && m_cpGobjman->GetVector()[i]->Instate(“Pausestate”) && m_cpGobjman->GetVector()[i]->GetInt(1) == m_iCurrsub){ Vector2 l_cTemppos((m_cpGobjman->GetVector()[i]->GetPosition().m_x – 32.0f), (m_cpGobjman->GetVector()[i]->GetPosition().m_y + 0.0f)); m_cpGobjman->GetVector()[m_iArrow]->SetPosition(l_cTemppos); } } } return true; }
Well, by the time I’ve finished my posting it’s almost three in the morning – it got too late anyway… Good night!
|