Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Restart Game  (Read 7419 times)

0 Members and 1 Guest are viewing this topic.

SirForce

  • Newbie
  • *
  • Posts: 7
    • View Profile
Restart Game
« 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

SirForce

  • Newbie
  • *
  • Posts: 7
    • View Profile
Restart Game
« Reply #1 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 :)

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Restart Game
« Reply #2 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.

SirForce

  • Newbie
  • *
  • Posts: 7
    • View Profile
Restart Game
« Reply #3 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

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
Restart Game
« Reply #4 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.
Listen to my band: pencilcase.bandcamp.com

 

anything