J
JohnSebek
Guest
So I made a day-night cycle by FriendlyCosmonaut and I wanted to change it so the cycle would be real-time. So if your pc has 15:40 the game time would be 15:40. I was using the date_get variables. But it was no use. I tried to set up it several times. But the day kept being too fast and not aligned to real-time. Here´s my code that I am using as a base(i tried to change the variables reals,realh,realm, etc. to mysecond,myhour, etc. But this does not seem to work either.
CREATE:
STEP:
DRAW:
CREATE:
GML:
//time cycle
myminute = date_get_minute(date_current_datetime());
myhour = date_get_hour(date_current_datetime());
mysecond = date_get_second(date_current_datetime());
realh = 0;
reals = 0;
realm = 0;
time_increment = mysecond
day = 1;
season = 1;
year = 1;
//DAYNIGHT
darkness = 0;
light_colour = c_black;
guiWidth = room_width;
guiHeight = room_height;
GML:
///DAY NIGHT
//Time setup
reals += time_increment
realm = reals/60
realh = realm/60
darkness = realh/24
//cycle check
if(realh >=24){
reals = 0;
day +=1;
if(day > 30){
day = 1
season +=1;
if(season >4){
season = 1;
year +=1;
}
}
}
GML:
//draw daycycle
var c = light_colour;
draw_set_alpha(darkness);
draw_rectangle_color(0,0,guiWidth,guiHeight,c,c,c,c,false);