Skeptron Posted April 22, 2015 Share Posted April 22, 2015 Hi everyone, I have to code a special feature which is, I guess, quite tricky. Thus I'd like to ask for advice before diving into some "bad-patterned" solution. I have a game where a character can consume an item which will slow down time for everyone / everything except the character himself. So everything is going to move slowly around him (and animate slowly), for a given period of time. He won't get any other special bonus (he keeps moving at the same speed, jump as high as usual, only the rest of the world is affected). What would be the best way to implement this? drhayes 1 Link to comment Share on other sites More sharing options...
grumpygamer Posted April 22, 2015 Share Posted April 22, 2015 Awesome feature I second this request too.Have no idea on how to achieve it. Stupidly I'd think you would set a FPS for the world (group?) and one for the player.Not sure though, just a hint. Sorry, I bet you've come back to your post hoping in a solution, but all you're getting is this silly comment!Anyways hope we find a way! Link to comment Share on other sites More sharing options...
rsadwick Posted April 23, 2015 Share Posted April 23, 2015 If you have a base class which your level objects inherit from - you could call a method on the base class to slow the objects down. If you didn't build your game objects like that - you could add a method that slows down the object but you'd need to implement it everywhere. I've done something similar in a way. I have a base powerup class. Every powerup inherits from that. So when I need to add, remove, check how many are available, pick one at random, or even use generic Phaser.Signals (events) I just call that method on the base class. The class that extends powerup - for example: Bomb does the specific heavy lifting - like when it will detonate, adds particles, and other Bomb specific stuff. Link to comment Share on other sites More sharing options...
Skeptron Posted April 23, 2015 Author Share Posted April 23, 2015 Yeah, I also thought that having global methods for this in a super class would be the best option (for the moment), but this is still quite a lot of work, because you need to change a lot of properties. You need to change the speed of the non-player "things", their animation speed, the gravity for them, and we could even go further and slow down all the timers related to them (cooldowns, for example). There is a lot to think of. I wondered if I could use something like a game 'slowmotion' feature (I think Phaser's latests versions come with one), which could take effect on all the scene except the concerned character. I haven't used the feature yet. Link to comment Share on other sites More sharing options...
MichaelD Posted April 23, 2015 Share Posted April 23, 2015 You can also set a global "motion" variable where all objects lookup to it on their update to determine their speed (velocity, etc). All ecxept from the character that can lookup into another variable, this way even new objects will start their lifecycle with the "slowmo" variable. Link to comment Share on other sites More sharing options...
grumpygamer Posted April 23, 2015 Share Posted April 23, 2015 Nice Idea! Link to comment Share on other sites More sharing options...
Skeptron Posted April 23, 2015 Author Share Posted April 23, 2015 The global variable idea is quite good but it costs a check every update (in every object), whereas the global-superclass function does not. And most importantly, it does no magic regarding slowing down the game (I still have to do all the work). But it could definitely be a nice play to start! Link to comment Share on other sites More sharing options...
MichaelD Posted April 23, 2015 Share Posted April 23, 2015 Here's another one, what if all objects move/animate with the same speed factor let's say x0.5 so everything moves at half the speed by default. And when you want to slowmotion, the character actually moves faster like x2 speed, this way it looks as if everything else is slowing down, this way you only have to configure the properties of the character and not everything else. It is a solution of perception rather than an algorithmical one. I tend to think that in games we sometimes have to think as directors and not as programmers there are alot of things that can be solved by mere optical tricks. Link to comment Share on other sites More sharing options...
Skeptron Posted April 23, 2015 Author Share Posted April 23, 2015 This is a really sweet idea also, but like you said, even though the "result" is the same, the gameplay is radically different. In a slow-moving world, I can have more time to prepare attacks, target / aim, think, etc. It sure can be a last resort solution, but if possible I would really like to give that feel of a slow motion environment (like the XMen scene with Quicksilver for example, which was mindblowing. The scene where time is slowed except for him is much more enjoyable than the scenes where he goes super fast in the normal time-scale). Link to comment Share on other sites More sharing options...
MichaelD Posted April 23, 2015 Share Posted April 23, 2015 I see. Have you tried the default Phaser approach to see how ti looks? https://phaser.io/docs/2.3.0/Phaser.Time.html#slowMotion I know it slows down the whole game even the character but it could be a good starting point. Link to comment Share on other sites More sharing options...
Skeptron Posted April 23, 2015 Author Share Posted April 23, 2015 I think that it's definitely a good direction. I haven't played with it yet - like I said, I was looking for advice before diving into the code. The feature seems awesome, but there's still some investigation to do regarding the main character's ability to still move at normal speed. Link to comment Share on other sites More sharing options...
Recommended Posts