Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Help to make Pause / Start code

pause start

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 googooli86

googooli86

    CC Lurker

  • New Member
  • Pip
  • 9 posts

Posted 23 August 2015 - 02:03 PM

Hello.

 

I am trying to add a Pause and Start function.

 

Like this: "Press Enter to start" and "Game Paused, press enter to resume".

where is the problem:

 

 
string start = "Press Enter to start";
            lblGameOver.Text = start;
            lblGameOver.Visible = true;

            //Set settings to default
            new Settings();

            //Set game speed and start timer
            gameTimer.Interval = 1000 / Settings.Speed;
            gameTimer.Tick += UpdateScreen;
            gameTimer.Start();

            //Start New game
            StartGame();

I want the above code to show up when starting the game. Right now it starts immediately.

And when P is pushed, it will pause the game with Game Paused text..

 

I am a bit stuck..



#2 MuStA

MuStA

    CC Regular

  • Member
  • PipPipPip
  • 43 posts

Posted 24 August 2015 - 10:45 PM

Hi,

 

In order to achieve this, you'd have to create a 'KeyDown' event, that you'll later link to a method such as:

private void Game_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Modifiers == Keys.Return)
    {
        //Add the game start code.
    }
    if (e.Modifiers == Keys.P)
    {
        //Add the pause code.
    }
}

Hope this answers your question, let me know if it works.


Edited by MuStA, 24 August 2015 - 10:48 PM.

.Musta { background-color: Black; }




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download