# How do I control the Day to Night mini-Cycle?

Get help using Construct 2

### » Fri Feb 28, 2014 7:24 am

I've been trying to apply the method Rory gave on this threat 2 Years ago based on the day to night cycle. But applying such a cycle can be a bit devastating. You see, I want the Day to Night cycle of the sun and Moon orbit around the mini map that I've assigned. But Unfortunately, it requires a lot of mathematical approach towards problem solving this issue that I'm currently having. Here is the event that I've assigned on my mini map cycle (it is originally done by Rory. But I've changed the values): -

the mini map's size is at around: 245.603, 183.059, and it lies on the top left side of the screen.

Global Value: Name: Period, Type: Numeric and the rest are default
Event > System: Every tick: Set Period to time*20 (for testing procedures, I need to assign the time 20 times faster than its original real time).
: Sun: Set position to (1037 -sin(Period)*150 ,172-sin(Period)*-10 )

At first, I'm testing whether the Sun is able to orbit around the mini map from Dawn to Dusk. But I can't get the value right. Is there an another approach towards this? Or Do I need to explain even further in details just for the problem that I'm currently facing to be quite clear?

Cheers,
Abdul
B
6
S
1
Posts: 8
Reputation: 431

### » Fri Feb 28, 2014 7:43 am

Maybe I don't understand the problem, but why are you doing it the hard way?
I'd just create a sun sprite and set the origin wherever you need it (For example at the horizon when the sun is rising). Then give the sun the rotate behavior.
To check whether it's night or day just ask if sun is on screen
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

### » Fri Feb 28, 2014 7:49 am

Good point. I think I'll try what You've suggested. I'll let You know if Your method works :}.
B
6
S
1
Posts: 8
Reputation: 431

### » Fri Feb 28, 2014 8:01 am

It worked! Thanks for that Raben. I have one more question however. Is there a way to apply the sun's rotation based on the In-Game time standards? such as each In-game Hour is equivilant to 1-2 Minutes
B
6
S
1
Posts: 8
Reputation: 431

### » Fri Feb 28, 2014 8:08 am

Sure, you can change the rotate speed. It tells you how many degrees the sun will rotate in one second. Since a circle has 360 degrees you could just divide them by the seconds the sun should take to do one rotation.
Examples:
One minute: 360° / 60 seconds = 6 rotationspeed
Two minutes: 360° / 120 seconds = 3 rotationspeed
and so on.
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

### » Fri Feb 28, 2014 9:29 am

It worked out well than anticipated. Thanks for that Raben. But there is one more thing that still bothers me. How am I able to control both the Sun and Moon cycle on different in-game time period (e.g. the Sun operates from Dawn to Dusk, while the Moon operates from the position where Dawn usually goes and falls down to the position where Dusk usually lies)?
B
6
S
1
Posts: 8
Reputation: 431

### » Fri Feb 28, 2014 10:02 am

I'm not sure if I understood what you mean (Sorry I'm not a native speaker). But when you want the moon do rotate anti clockwise just set the rotation speed to minus.
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

### » Fri Feb 28, 2014 10:27 am

I'll give it a shot. Thanks for the info man.
B
6
S
1
Posts: 8
Reputation: 431