Jump to content
  • Advertisement
Sign in to follow this  
Dan Verssen

VB 2005 - Restart Program

This topic is 4110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Well, you could probably do something like:

System.Diagnostics.Process.Start(Application.ExeName)
Application.Exit()

The code should start a new instance of your program, and then exit the current one. Have not tried it, so I don´t know if it works. However, you should generaly not restart the whole program instance, but just reset the game logic inside your game so that the player can play again if he wants.

//chinc

Share this post


Link to post
Share on other sites
At the start of the game, I enter data into Arrays and set initial values for some variables.

So, I would have them as normal, and copy them into a "re-start game" sub that would get accessed when the player restarted the game?

Share this post


Link to post
Share on other sites
Quote:
Original post by Dan Verssen
At the start of the game, I enter data into Arrays and set initial values for some variables.

So, I would have them as normal, and copy them into a "re-start game" sub that would get accessed when the player restarted the game?


What you want is to manage game states.

At the beginning of the game, you are in a state "menu"; the user then press for a key (or select a menu option) and you go in state "game". When the player dies, you go in state "game over", which either wait for a keypress or lasts a few seconds and then goes to state "menu".

States are quite easy to implement in C# (that's a simple object). If you need any kind of help, do not hesitate to continue this thread with other questions.

Share this post


Link to post
Share on other sites
They're not something you necessarily have to "go in and out of" explicitly - more just a way of splitting up your program.

That said, I think they're not relevant to this particular problem - they're a good plan for other reasons, but all you really need to do here is change these arrays from being set up at "program start" into being set up at "game start." That way, the code is only in one place, but you can go through the "game start" code as many times as you want.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!