SFML community forums

Help => General => Topic started by: SirForce on June 04, 2009, 02:55:04 pm

Title: Restart Game
Post by: SirForce on June 04, 2009, 02:55:04 pm
Hello,

after a long time of doing a lot of stuff except programing, I´m back :)
Now I have a new computer and have everything set up new. I found in ne SFML dev-pack the source for an little pong game (quite funny) and wanted to add a few things, like a Gameloop. Because it´s really annoying to resart the whole game for a new round.

My problem is that I don´t know how to make it.
When now the game is finished, the source look like this

Code: [Select]
if (Ball.GetPosition().x < 0.f)
{
IsPlaying = false;
End.SetText("You lost !\n(press escape to exit)");
}


Ok, that IsPlaying = false; is the problem. I tried something like this:


Code: [Select]
Ball.SetPosition(400.f, 300.f);
sf::Sleep(0.5f);
Ball.Move(std::cos(BallAngle) * Factor, std::sin(BallAngle) * Factor);


But this doesn´t work.
I don´t no where the problem is - when the ball reachs one side of the screen, I set him into the middle and he moves again till he reaches one side of the screen.

So, does anybody know how solve this problem?

   
thanks in advance
Title: Restart Game
Post by: SirForce on June 09, 2009, 12:27:44 am
probably no one could or want to help me. this is a little bit pity, because this isn´t a very big problem and I need just a little help :)
Title: Restart Game
Post by: nitram_cero on June 09, 2009, 02:39:12 am
Post the full source if you don't mind (and it's not that lengthy). It's easier for us to find the problem.
Title: Restart Game
Post by: SirForce on June 11, 2009, 01:51:28 pm
Ok sorry, you are right!
I got the code from the SFML doc.

http://codeviewer.org/view/code:888
Title: Restart Game
Post by: K-Bal on June 11, 2009, 02:14:37 pm
Basically, you would just look what value all variables have at the beginning of the program and on restart restore these values.