If I were including weather in a game I made, I would include a weather check in whatever code I was using to progress the time. For example, in the code for my current game...
I use the calendar code created by xela, which is located in the Quickstart that RicharDann linked above.
Then I have a "timecount" label, which I call whenever I want to check to see what time of day it is, and if the game has moved to the next day:
Code: Select all
label timecount_nomsg:
if time_cnt > 5:
$ time_cnt = 1
$ timeofday = "sunrise"
$ day_cnt += 1
$ calendar.next()
### Here I keep a list of all variables that get "reset" at the end of each day
if time_cnt == 1:
$ timeofday = "sunrise"
elif time_cnt == 2:
$ timeofday = "morning"
elif time_cnt == 3:
$ timeofday = "noon"
elif time_cnt == 4:
$ timeofday = "sunset"
else:
$ timeofday = "night"
jump check_events
return
And then throughout my code, if going to certain places or performing certain actions makes time move forward, I include some code saying "$ time_cnt += 1".
To add weather, especially randomized weather, I would add a weather check inside the timecount code. I'd have to make a label that checks the weather, and gives me a list of random weather effects. Could even make it different for each month. Ex:
Code: Select all
label weather_checker:
$ weather_spawn = renpy.random.randint(1, 100)
if calendar.month == "January":
if weather_spawn < 10:
weather = "Sunny"
elif weather_spawn <50:
weather = "Cloudy"
elif weather_spawn <97:
weather = "Rainy"
else:
weather = "Snowy"
## Continue making lists like this for each month, with different ratios of weather as you feel appropriate.
return
If you wanted weather to get progressively worse or better, you could always make another variable that is triggered by certain events, for example, a variable called "weather_worse" or "weather_better".
Code: Select all
label weather_checker:
$ weather_spawn = renpy.random.randint(1, 100)
if weather_better == True:
weather_spawn += 30
if weather_worse == True:
weather_spawn -= 30
if calendar.month == "January":
if weather_spawn < 10:
weather = "Sunny"
elif weather_spawn <50:
weather = "Cloudy"
elif weather_spawn <97:
weather = "Rainy"
else:
weather = "Snowy"
$ weather_better = False
$ weather_worse = False
return