Page 1 of 1
How do I change an image according to real time?
Posted: Mon Dec 10, 2018 8:47 pm
by Nanahs
In a scene on my game, I wanted an image to change according to the real time the person is playing.
If it's something between like 6pm till 7pm I wanted "windowsun.png" to show up and if it's from 8pm till 5am I wanted "windowmoon.png" to show up.
It's a scene in the living room. And according to the real time, I wanted it to show the window with the sun outside or with the moon.
How can I do it? Is it using the "If" statements?
I still get confused about it.
Thanks.
Re: How do I change an image according to real time?
Posted: Tue Dec 11, 2018 2:18 am
by Per K Grok
Nanahs wrote: ↑Mon Dec 10, 2018 8:47 pm
In a scene on my game, I wanted an image to change according to the real time the person is playing.
If it's something between like 6pm till 7pm I wanted "windowsun.png" to show up and if it's from 8pm till 5am I wanted "windowmoon.png" to show up.
It's a scene in the living room. And according to the real time, I wanted it to show the window with the sun outside or with the moon.
How can I do it? Is it using the "If" statements?
I still get confused about it.
Thanks.
Yes, you can use an if statement.
You use a variable (you could name it 'vHour') to hold the hour information from the time module. I am assuming you know how to do that. Is that correct?
You can then decide which image to show like this.
Code: Select all
if vHour==18 or vHour==19:
show windowsun
elif vHour>19 or vHour<6:
show windowmoon
Re: How do I change an image according to real time?
Posted: Wed Dec 12, 2018 11:58 am
by Nanahs
Per K Grok wrote: ↑Tue Dec 11, 2018 2:18 am
Nanahs wrote: ↑Mon Dec 10, 2018 8:47 pm
In a scene on my game, I wanted an image to change according to the real time the person is playing.
If it's something between like 6pm till 7pm I wanted "windowsun.png" to show up and if it's from 8pm till 5am I wanted "windowmoon.png" to show up.
It's a scene in the living room. And according to the real time, I wanted it to show the window with the sun outside or with the moon.
How can I do it? Is it using the "If" statements?
I still get confused about it.
Thanks.
Yes, you can use an if statement.
You use a variable (you could name it 'vHour') to hold the hour information from the time module. I am assuming you know how to do that. Is that correct?
You can then decide which image to show like this.
Code: Select all
if vHour==18 or vHour==19:
show windowsun
elif vHour>19 or vHour<6:
show windowmoon
Thank you!
About time, I only know how to show the current hour, and day/month/year. My knowledge stops right there I guess hah