[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Slick Forums • View topic - [IDEA] pause states

Slick Forums

Discuss the Slick 2D Library
It is currently Tue Aug 11, 2020 3:40 am

All times are UTC




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [IDEA] pause states
PostPosted: Fri Jun 22, 2012 10:00 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
This might useful. How about adding setters/getters for pausing the update/render call on the StateBasedGame. The Pre- and Post-Calls will not be changed. So the developer can "pause" the game for debugging or menus better.

If no one is against it, I will implement it and push the change.

_________________
Current Projects:


Projects:
- Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Sat Jun 23, 2012 5:32 am 
Offline
Regular

Joined: Tue Aug 23, 2011 8:19 am
Posts: 111
Would this only apply to the current state? It wouldn't allow us to start/stop a different state to have 2 states running at the same time, right?

I fail to see how this would be helpful, but if it isn't difficult to implement and you see a possible use for it, I say go for it. Just make sure the update() and render() methods can be paused separately.

_________________
My indie games: http://cmagames.webs.com


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Sat Jun 23, 2012 10:34 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534

_________________
Current Projects:


Projects:
- Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Wed Jun 27, 2012 2:32 pm 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
But this feature is rather useless for games that just don't need something like this or that would die due a freezed updated loop.

It would be a better option in my opinion to implement this as additional GameState implementation.

PausableGameState or something like this. Just to avoid cluttering the implementations of Slick with features that are just used in some cases.

Nitram


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Wed Jun 27, 2012 4:17 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
That may be true but I also never use Tiled and think of it as a rather useless thing ;) Of course not all people need this, but those you want to completly ignore updating and rendering a state. Making into GameState or abstracting it means three things which imho are not so good:

1. You need a cast to check if the state is a PausableGameState and the set it to true.
2. This will only pause the state, not all states. It about having a global property.
3. A PausableGame itself needs checks if should be updated.

Again it's about pausing a state. If you just want that make a boolean in your state for instance. It's about being able to ingore the actual game for a minute. This is extremly helpful for debugging just making a genrel stop. It's not so easy to implement it on your own. Since Kev thought it would be a good idea to make update and render BOTH final in StateBasedGame.

I hope you understand what I mean :/

_________________
Current Projects:


Projects:
- Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Wed Jun 27, 2012 7:54 pm 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
You never use Tiled, neither do I and I still hope its thrown out of the slick-core at some point :wink:

I don't want to talk down your proposal, I am just thinking about the best way to implement it.

In my opinion that would be a "Pausable" interface that defines the functions required to control the pause states (pause/unpause/setPause/isPaused/what_ever_else). This one then can be implemented in the BasicGameState and maybe in a upcomming Pauseable game? To get a nice abstraction level and a clean way to implement any sort of pauseable "systems". I expect this to become handy if you need to pause additional systems once the game/gamestate is paused. Like a pathfinding/particlesystem (that could run threaded).

Nitram


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Wed Jun 27, 2012 8:16 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534

_________________
Current Projects:


Projects:
- Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Wed Jun 27, 2012 8:41 pm 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
I would not add the interface in any case to "GameState" or "StateBasedGame". But to the Basic- implementations of these two classes. So the main implementations remain "clean".

If you want you could add additional interfaces, liks PausableGameState and PausableStateBasedGame that merge the Pauseable interface and the GameState or the StateBasedGame interface.

To the Pauseable interface I would just set the methods:
void pause();
void unpause();
void setPaused(boolean);
bool isPaused();

This way the interface can be used extremly flexible. And after all you can't pause the render loop of a application. OpenGL images are volatile, if you stop to render them you get artifacts most likely. But with the freeze of the update loop the image that is rendered should remain the same again and again.

Nitram


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Wed Jun 27, 2012 10:00 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Yay of course, stopping the render would lead to... nothing... a black screen xD (if you clear every frame that is). The thing is, you can't just make "PauseableStateBasedGame". As said. Kev makde the methods final.

I think we should removes this. Slick should be useable and making a method final in that case was not a good choice since making your own StateBasedGame class is basically copying code. Also the Transitions rely on the StateBasedGame class :D Mabye here a Interface to pass would be better too...

Well anyway, so we make a Interface Pausable with the methods you mentioned, and I would suggest, adding them directly to the current StateBasedGame, in the end it's really just a boolean and I don't want to copy the code just for one boolean... And of course removing the final from the init/update and render method. So the Developer can override them?

_________________
Current Projects:


Projects:
- Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Wed Jun 27, 2012 10:31 pm 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
I was for some reason under the impression that the StateBasedGame is... a interface. Guess I was wrong there. This renders my idea for the state based game void of cause.

So as you said I suggest you change the StatedBasedGame so it implements the Pauseable interface.

As implementation detail I suggest a final implementation for the functions pause() and unpause() that does nothing but calling setPause(boolean) with true or false. This way its clear what function needs to be overwritten in order to add additional things to the default behavior of the pause stuff.

EDIT:
The init and update being final is in general a good idea. Because a StateBasedGame is really nothing but a relay to the current state forwarding all calls to this state. Looking from this perspective you could even implement the whole pauseable stuff as final, as the only thing done by setting the paused flag will be that its state is forwarded to the current GameState. And at this point the developer can overwrite what ever is wanted. There is no real need to overwrite the functions of the StateBasedGame itself.

Nitram


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Wed Jun 27, 2012 11:56 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Thu Jun 28, 2012 12:30 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534

_________________
Current Projects:


Projects:
- Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Thu Jun 28, 2012 8:06 am 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
My problems with the pauseUpdate() and pauseRender() is that is reduces the flexibility of the Pausable interface a lot. There are parts that could use this interface, where there isn't such a thing as a render loop and a update loop.

My problem with freezing the render loop is that the image that is rendered is volatile. Means if its not constantly updated the graphic card/OS is allowed at any time to throw parts of it or the entire image away leaving either artifacts or a black screen behind. That happens especially in cases if the drawing area is resized or in case its part of a window that gets minimized. Also a hibernation cycle usually damages this image.

For the state based game. I really don't see this class as more then a relay to the states. This class itself shouldn't stall the update and render loop at all. It just calls the functions of the current state as usual. But it has to ensure that every state is informed of the current paused-state.
Means the StateBasedGame maintains the current state of the paused flag and forwards it upon change of the pause state and upon change of the current game state to the active game state. The gamestate itself is at liberty then to do what ever is needed with the paused information. This way you get the maximal flexibility as you can do what ever you like with the paused information inside your states.

Nitram


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Thu Jun 28, 2012 11:13 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534

_________________
Current Projects:


Projects:
- Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: [IDEA] pause states
PostPosted: Thu Jun 28, 2012 12:01 pm 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
If you clear the screen at every frame then sure. You just get a black screen.

But still I fail to see the reason why you need to freeze both separably. If you want the current state to do... nothing. Why don't you just switch to another state. I can't see the difference.

Nitram


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group