# Help with a variable, please.

Get help using Construct 2

### » Tue Oct 18, 2016 3:49 am

I am making a game with its own time frame, in other words time in the game runs faster than in real life. What I am trying to achieve is this. Player starts at the age of 10 but when she turns 20 for example I want time to run slower. Right now I have time running like this:

I have 2 global variables (daysVariable and yearsVariable) and EVERY X SECONDS days go by and so do the years but when player turns 20, system is checking yearsVariable EVERY second, I would like to slow down time. How could I achieve that?

Thank you.
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

### » Tue Oct 18, 2016 4:12 am

You could fool around with timescale and delta time... but why not simply make the every x seconds for day change be just more seconds so the day is longer... hard to say more not knowing exactly what your game entails.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
81
S
22
G
8
Posts: 664
Reputation: 10,333

### » Tue Oct 18, 2016 4:14 am

You would just use some if-then logic. You could have an event that runs every second with two subevents that change the day and year variables differently based on the value of the years variable.

Every 1 second
yearsVariable <= 20 add 1 to yearsVariable

(Does my shorthand make sense?)
Eh, Steve!
B
118
S
54
G
13
Posts: 115
Reputation: 16,244

### » Tue Oct 18, 2016 5:35 pm

chrisinfinger wrote:You could fool around with timescale and delta time... but why not simply make the every x seconds for day change be just more seconds so the day is longer... hard to say more not knowing exactly what your game entails.

I am still learning a lot of thinks thanks to people like you. What I am trying to achieve is to slow time down when player is 10 years old, for example. I tried all your suggestions but I think my limited knowledge was a deterrent. So I created a quick, clean project just to show you what I am trying to do.

I really appreciate all your help.

http://www.geocities.ws/kikoriogames/SlowTime.capx
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

### » Tue Oct 18, 2016 5:37 pm

calebbennetts wrote:You would just use some if-then logic. You could have an event that runs every second with two subevents that change the day and year variables differently based on the value of the years variable.

Every 1 second
yearsVariable <= 20 add 1 to yearsVariable

(Does my shorthand make sense?)

Yes. It makes sense but I am a newbie so I think I could't get it right. Thank you, though.

I am still learning a lot of thinks thanks to people like you. What I am trying to achieve is to slow time down when player is 10 years old, for example. I tried all your suggestions but I think my limited knowledge was a deterrent. So I created a quick, clean project just to show you what I am trying to do.

I really appreciate all your help.

http://www.geocities.ws/kikoriogames/SlowTime.capx
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

### » Tue Oct 18, 2016 5:46 pm

I couldn't open your capx cause I use the stable version of construct but I have a simple solution.

You use every X seconds, all you have to do is using a variable as X.

For example, if X=(yearsVariable/10) then every (10/10) 1 seconds

when he is 20 years old ---------- every (20/10) 2 seconds

If it's too quick, create timespeedVariable and use it as X.
Every timespeedVariable seconds
You change timespeedVariable when he is 20 years old.
B
12
S
7
G
4
Posts: 114
Reputation: 3,067

### » Tue Oct 18, 2016 6:11 pm

Pandadoor wrote:I couldn't open your capx cause I use the stable version of construct but I have a simple solution.

You use every X seconds, all you have to do is using a variable as X.

For example, if X=(yearsVariable/10) then every (10/10) 1 seconds

when he is 20 years old ---------- every (20/10) 2 seconds

If it's too quick, create timespeedVariable and use it as X.
Every timespeedVariable seconds
You change timespeedVariable when he is 20 years old.

So when I create this variable which value should I assign to it?

Thank you a lot!
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

### » Tue Oct 18, 2016 6:25 pm

Pandadoor wrote:I couldn't open your capx cause I use the stable version of construct but I have a simple solution.

You use every X seconds, all you have to do is using a variable as X.

For example, if X=(yearsVariable/10) then every (10/10) 1 seconds

when he is 20 years old ---------- every (20/10) 2 seconds

If it's too quick, create timespeedVariable and use it as X.
Every timespeedVariable seconds
You change timespeedVariable when he is 20 years old.

Alright, man!!! I did it!!! Thanks for the great explanation!!! Thanks everybody here!!!!!!!!!!!!!!
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

### » Wed Oct 19, 2016 12:06 am

Yay!
Eh, Steve!
B
118
S
54
G
13
Posts: 115
Reputation: 16,244