Time passing...

0 favourites
From the Asset Store
Time rewind like in "Braid". Choose objects that will be affected by time rewind
  • Hello,

    When I go from one scene to another, time stops, doesn't it?

    How can I make sure that time is the same everywhere?

    For example, to make a "free open world" game, because if I have to make just one scene, it's going to be huge, and that might not be the best solution!

    How can I ensure that time passes at the same time on all scenes?

  • You can use the System expression 'time' which returns the number of seconds since the beginning. The value always progresses forward no matter when you call it.

  • Thank you for your reply but could you please answer my questions ?

  • Try setting up a few layouts and some way to change between them. Then make sure to have a Text instance in each layout to display the result of of the expression.

    In your event sheet set the text of the Text instance to the time expression on every tick.

    You will see that no matter in which Layout you are the time is always the same in all layouts.

  • how can i make it so that for example there are 2 scenes.

    - on the first there are two hens, every 2 seconds they move in a random direction, they reproduce (+1) every (between 5 and 10 seconds), the new hen also moves in a random direction.

    On the second there are two sheep, every 3 seconds they move in a random direction, they reproduce (+1) every (between 10 and 20 seconds), the new sheep also moves in a random direction.

    this is just an example of how to make a scene where time passes everywhere in the same way.

  • I see what the real question is now :P

    What you need to do is run the simulation of time passing when you enter each layout/scene.

    To do that the first thing is keep track of the time when you leave a scene so you can calculate the time difference when you enter it again later.

    If you know the last time you where in a given scene and the current time, you can tell how much time has passed.

    Assuming everything is in the same place and has the same state as before you left the scene, you need to be able to tell each object in the scene to do all the things it would have done in the time that passed.

    Taking from your example, if you left a scene at 30 seconds after the game started, and came back to it 60 seconds after the game started, that means that you need to figure out all the things that would have happened in those 30 seconds, and make those changes.

    For instance, and to keep things simple. If a hen were to reproduce every 5 seconds, in 30 seconds there would be 6 (30 / 5) more hens that spawned from the original hen. If the original hen should move randomly every 2 seconds, it would have moved a total of 15 (30 / 2) times.

    That only takes care of the first hen. The simulation should also take into account what happens to the new objects that would have appeared during the elapsed time and what would have happened to them.

    All of this is easier said than done. I suggest you start real small and then build from that.

  • Thank you for your reply.

    Well yes, but it's far too complicated to do it this way, that's why I wanted to make a single scene, the whole world would be in this scene, map, house, dungeon, etc, all of it.

    But I'm sure the game won't stand for it, and will go ballistic! ^^'

  • I don't know if I understand, but I'll try to give my idea even if it's not exactly what you want.

    Instead of directly manipulating the objects in the scene, I would make different arrays for each object. For example:

    An Array for chickens, where the number of lines would be the number of chickens. With each new chicken, a new line is created.

    In the columns, you can put its X position, Y position, and if they have more than one color, another column for the Frame of each one.

    The same idea would follow for the other objects.

    This way, when you read the time, you just need to read the arrays to know the position of all the objects at the same moment. And create them according to the scene that is currently loaded.

    When time passes, you manipulate all arrays so that the change is synchronized between all of them.

    Sorry if that's not what you want, that's just what I understood from your problem.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks ForsakenBA for your idea, I can see the gist of it but I don't totally understand it.

    There's still a question hanging in the air but I think the answer is YES.

    When I go from one scene to another, time stops, doesn't it?

  • Yes, events no longer process on layouts that are not active, effectively "stopping time" for that layout.

    As others have mentioned, you'll need to add events for the time to "catch up" to current time, by using the expression to find out how much time has passed since you left the layout.

    Another option is to not use layouts in the first place, if possible for your game. You can use layers instead, and hide visibility (and remember to account for controls or input so they do not work on invisible layers). This way, all your "scenes" are actually on the same layout and running, just hidden.

  • Thanks ForsakenBA for your idea, I can see the gist of it but I don't totally understand it.

    There's still a question hanging in the air but I think the answer is YES.

    When I go from one scene to another, time stops, doesn't it?

    The confusion in understanding is because when you refer to time, it implies that you are asking about project time in general. But you basically want to know if objects stop moving when you switch scenes, and the answer is Yes.

    Another option is to not use layouts in the first place, if possible for your game. You can use layers instead, and hide visibility (and remember to account for controls or input so they do not work on invisible layers). This way, all your "scenes" are actually on the same layout and running, just hidden.

    oosyrag, your idea works, and it is an option. But I wouldn't do that because of the memory consumption. Although the objects are hidden, they would still be allocated in memory. Depending on the size of the project, this would be fatal.

    However, manipulating values ​​in an array is fast, lightweight and easy to manage. But I believe there may be several other solutions for this.

  • Oosyrag, very interesting "tip", thank you.

    Thank you both.

    ForsakenBA I don't really understand the idea of the painting...

    I'd like to make an "open world and free" game.

    but I want the time to be the same everywhere as if there was only one scene, so I'll probably have to create a single scene...

  • Other method I remembered for having everything in one layout, besides using layers, is to use different, separated positions on the same layout (teleport/scroll to another screen or area)

    As mentioned, beware of memory issues. Layouts are useful for memory management - to separate what textures are loaded in memory at a time. Again it depends on your game. Some games push the limits of memory usage, some don't.

  • Suppose your open world for now is a small farm with 3 crops: Tomatoes, Potatoes and Carrots, each of them will be shown on a different screen.

    In this example, each object has 3 values. Random X Position, Random Y Position, and Size.

    At the beginning of the game you create an empty Array for each of these objects. (X=0,Y=3)

    Let's assume that every 1 second a Tomato is "born", every 2 seconds a Potato and every 3 a Carrot. All with initial size 1.

    You create an event screen and write that:

    Every 1 second, Add 1 to the ArrayTomates (X+1), and insert the other values ​​in the Y positions of the Array (posX, posY, size)

    Every 2 seconds, Add 1 to the Potatoes Array (X+1), and insert the other values ​​in the Y positions of the Array (posX, posY, size)

    Every 3 seconds, Add 1 to the Carrots Array (X+1), and insert the other values ​​in the Y positions of the Array (posX, posY, size)

    Furthermore, every 1 second, all these objects gain 1 in size.

    When loading the scene, you will create the objects by reading the respective Array. If you are loading the Tomatoes screen, you are reading the Tomatoes Array. And it creates objects based on the number of lines that were added to the Array, the corresponding X and Y position and the size that is also there.

    In this example, you could also set a different harvesting time for each type of object, which would give money when it reached a certain size and would "disappear" from the Array, giving way to another (the same thing that is done in idle games)

    In other words, time in this case passes to all "screens", but you only create the objects in the scene that is active, but this does not prevent other elements from other scenes from evolving, understand?

  • thank you for all your answers.

    You mean event sheet, not screen?

    But for event sheets it's the same, isn't it? time only passes if they're loaded with a scene, isn't it?

    So how do I do that? because you can't load several sheets at the same time?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)