T
TonyZh
Guest
I want to make a simple day and night cycle in my game but the code fails when I run it. I don't know what is wrong with my code and I am looking for help to fix it. Feel free to ask for more information if necessary. I appreciate the help from you guys and I thank you for helping me.
It gives me this error:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Draw Event
for object obj_Daycycle:
Variable obj_Daycycle.light_colour(100038, -2147483648) not set before reading it.
at gml_Object_obj_Daycycle_Draw_64 (line 1) - var c = light_colour;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_Daycycle_Draw_64 (line 1)
Create event
Step event
Draw GUI event
It gives me this error:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Draw Event
for object obj_Daycycle:
Variable obj_Daycycle.light_colour(100038, -2147483648) not set before reading it.
at gml_Object_obj_Daycycle_Draw_64 (line 1) - var c = light_colour;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_Daycycle_Draw_64 (line 1)
Create event
Code:
seconds = 0;
minutes = 0;
hours = 0;
day = 1;
season = 1;
year = 1;
time_increment = 1000;
darkness = 0;
lightcolour = c_black;
guiWidth = display_get_gui_width();
guiHeight = display_get_gui_height();
Code:
seconds += time_increment;
minutes = seconds/60;
hours = minutes/60;
darkness = hours/24;
//Cycle Check
if(hours >= 24) {
seconds = 0;
day += 1;
if(day > 30){
day = 1;
season += 1;
if(season > 4){
season = 1;
year += 1;
}
}
}
Code:
var c = light_colour;
draw_set_alpha(darkness);
draw_rectangle_color(0,0, guiWidth, guiHeight, c,c,c,c, false);
draw_set_alpha(1);
var c = c_yellow;
draw_text_color(10,10, string(seconds), c,c,c,c, 1);
draw_text_color(10,30, string(minutes), c,c,c,c, 1);
draw_text_color(10,50, string(hours), c,c,c,c, 1);
draw_text_color(10,70, string(day), c,c,c,c, 1);
draw_text_color(10,90, string(season), c,c,c,c, 1);
draw_text_color(10,110, string(year), c,c,c,c, 1);