[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/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] enter is called before transitions

Slick Forums

Discuss the Slick 2D Library
It is currently Thu Jul 29, 2021 7:31 pm

All times are UTC




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Feb 17, 2012 5:19 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
One thing that bugs me about state based games is the enter method in the BasicGameState. The enter method is used to setup the new state before the user sees it, so that everything is in the right place. However, when transitions are used, the enter method is not called until after all of the transitions are done. This means that the user sees your state before it has had a chance to set itself up. I can think of no benefit to having enter() called after all of the transitions. Should enter be called before the entrance transition is started? Is there some reason to wait that I have overlooked?

_________________
"Artificial intelligence will never be a match for human stupidity" - "Jamos Kennedynos"


Top
 Profile  
 
PostPosted: Mon Feb 20, 2012 3:01 am 
Offline
User avatar

Joined: Wed Feb 08, 2012 10:32 pm
Posts: 13
Location: Germany
I wondered about this too!


Top
 Profile  
 
PostPosted: Tue Feb 28, 2012 11:37 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
sorry to bump this, but I would like to hear form other developers. Is there a reason that enter() should not be called before the entering transition starts? this is something that keeps bugging me. As i said before, I can think of no reason to transition into the state before the state has its enter method called.

_________________
"Artificial intelligence will never be a match for human stupidity" - "Jamos Kennedynos"


Top
 Profile  
 
PostPosted: Wed Feb 29, 2012 10:41 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
me too, if he others are okay with it, you can change it :)

_________________
Current Projects:


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


Top
 Profile  
 
PostPosted: Thu Mar 01, 2012 4:51 am 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
Thanks R.D. I'm already using a copy of Slick that handles enter before the state entrance, so if nobody objects by Monday, March 5, I'll add it to the repository.

_________________
"Artificial intelligence will never be a match for human stupidity" - "Jamos Kennedynos"


Top
 Profile  
 
PostPosted: Thu Mar 01, 2012 1:37 pm 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
Yes, I think that's fine. We would also get rid of exceptions in the render() method of the GameState because enter() is not yet called.

A game programmer might then need to consider the amount of time the transition requires to finish before the entered GameState should do something useful.
Otherwise your space ship is already destroyed after the entering transition is done :wink:

_________________
|
| |


Top
 Profile  
 
PostPosted: Thu Mar 01, 2012 4:32 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
I believe this case would not be a problem because the update method is still not called until the transition is finished. Thus there are no extra updates or updates with unusually long intervals.

_________________
"Artificial intelligence will never be a match for human stupidity" - "Jamos Kennedynos"


Top
 Profile  
 
PostPosted: Thu Mar 01, 2012 4:42 pm 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
Aaah, okay, then the fix makes even more sense 8)

Looks like a tiny code change that you could commit and push on the development branch to get used to Mercurial, Mr. Kenkron :wink:

:!: Don't forget to pull my changes before you start...

_________________
|
| |


Top
 Profile  
 
PostPosted: Wed Apr 18, 2012 5:47 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
This might break old code that depends on the order of enter.

Ideally there should be two methods for clarity:
entering() - before transitions
entered() - after transitions

That way a state can reset itself (i.e. re-position everything to default locations) so that, say, a fade transition will show the new state as expected. But the new state won't "start" until it has fully been entered.

We can adapt this to the current naming, which might let us include the same functionality without breaking old code.


Top
 Profile  
 
PostPosted: Wed Apr 18, 2012 6:00 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Then we just mark the method as deprecated and add the two new functions :D How about it? I don't have that much time to change stuff but may on weekend...

_________________
Current Projects:


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


Top
 Profile  
 
PostPosted: Sat Apr 21, 2012 11:36 am 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
That is not a very good idea marking a interface method as deprecated as this forces everyone using the GameState to implement the deprecated method.

Nitram


Top
 Profile  
 
PostPosted: Thu Apr 26, 2012 1:55 am 
Offline
Regular

Joined: Tue Aug 23, 2011 8:19 am
Posts: 111
I think it would be smart to leave the enter() method called after the transition and simply add a willEnter() method that is called before the transition. That way old code doesn't stop working and anyone who wants to use willEnter() can.

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


Top
 Profile  
 
PostPosted: Thu May 03, 2012 6:19 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
I believe I already pushed changes to make the enter method call before the enter transition. If you think it will bread old code, then it can change it back, but I don't think this is actually a code breaking change. I have not been able to come up with a reasonable case in which someone might use the enter method after a transition where it would not work before the transition, and there seem to be many reasons to call the enter method before the entering transition (load resources, reset level, do something computationally intensive without the user noticing the frame drop).

Can anybody come up with a situation that this code would break?

_________________
"Artificial intelligence will never be a match for human stupidity" - "Jamos Kennedynos"


Top
 Profile  
 
PostPosted: Thu May 03, 2012 9:16 pm 
Offline
Slick Zombie

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


Top
 Profile  
 
PostPosted: Thu May 03, 2012 10:15 pm 
Offline
Regular

Joined: Tue Aug 23, 2011 8:19 am
Posts: 111
That's exactly what I was thinking: Physics. It's only a problem, though, if your physics implementation is updated during the transition. I thought the game totally froze until the transition finished, but that might be different when enter() is called before the transition.

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


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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