Results 1 to 8 of 8

Thread: To create a pause game function

  1. #1
    Join Date
    May 2011
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default To create a pause game function

    Hi there,

    Let say I'm developing a widget game for Symbian^3, and this game is actually a fast pace object falling down game.(Sometimes more than 1 objects can fall together) So what's is the simplest yet effective way to create a pause function for such a game?
    Thank you in advance.

  2. #2
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: To create a pause game function

    that depends on your game logic. maybe it's sufficient to set a bool "moving" which is set to false when paused. in your code, you check the state of "moving" and move the objects only if true.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,365
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: To create a pause game function

    The simplest and most effective way to create a pause is to stop the timer.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    May 2011
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: To create a pause game function

    Wysota I'm not clear what you mean by stop the timer. Is it to stop the timer which control the object to fall down or is there some internal timer which I do not know of. Please enlighten me.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,365
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: To create a pause game function

    Stop the timer that you have that controls the game loop.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    May 2011
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: To create a pause game function

    But isn't stopping the QTimer will literally stop the timer which makes resuming the game can be pretty ugly because the QTimer will restart the interval again upon resuming.

  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: To create a pause game function

    I wouldn't have thought it was be noticable.

    After all, you would execute the game loop once per timer event, so stopping and then restarting the timer would have no real drawback.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,365
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: To create a pause game function

    You can always stop the timer from within the method executed as a result of the timer's timeout. Or you can calculate how much time is left till the next timeout and correct the interval while resuming the game. But I think it doesn't matter if the game loop triggers 10ms or 9ms after unpausing the game.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 5
    Last Post: 24th October 2010, 06:54
  2. Replies: 1
    Last Post: 22nd May 2010, 07:38
  3. Does Qt have function to create Bézier curve?
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 20th April 2009, 06:22
  4. how to create a new function
    By tommy in forum Qt Programming
    Replies: 3
    Last Post: 10th November 2007, 17:08
  5. create play,pause and stop buttons
    By Sheetal in forum Qt Tools
    Replies: 6
    Last Post: 31st January 2007, 14:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.