Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //SET THE GLOBAL VAR IN SCRIPT
- ///DAY CYCLE CONSTS :
- globalvar MORNING ; MORNING = 0 ;
- globalvar EVENING ; EVENING = 1 ;
- globalvar MIDDAY ; MIDDAY = 2 ;
- globalvar NIGHT ; NIGHT = 3 ;
- globalvar SUNRISE; SUNRISE = 4 ;
- global.player_priorRoom = noone ;
- global.player_priorX = 0 ;
- global.player_priorY = 0 ;
- global.prior_viewX = 0 ;
- global.prior_viewY = 0 ;
- global.fps = true ;
- //SOUND CONTROLLER
- //Sound Volume = value 0 to 10
- global.soundOn= true ;
- global.currentVolume = 0 ;
- global.volume = 3 ;
- global.currentSound = 0 ;
- global.steps_per_hour = room_speed * 4 ; //4 secs
- global.shadow_angle = 0.5 ;
- global.shadow_height = 0.5;
- global.shadow_alpha = 0.1 ;
- global.shadow = true ;
- //DAY CYCLE
- global.day_type = MORNING ;
- global.time_of_day = 0 ;
- global.raining = false ;
- //global surf for the blackout of night or any other shader color transformation
- global.current_room = room ;
- global.value = 995 ;
- // THE VALUE IS USED FOR TESTING PURPOSES
- //
- //GLOBAL SURFACE CHECK SCRIPT
- //CHECK TO SEE IF SURFACE EXISTS OR IF ROOM HAS CHANGED
- if (! surface_exists(global.surf ) or global.current_room != room
- or (surface_get_width(global.surf ) != room_width
- and surface_get_height(global.surf) != room_height ))
- {
- if (surface_exists(global.surf))
- {
- surface_free(global.surf ) ;
- global.surf = surface_create(room_width, room_height ) ;
- global.current_room = room ;
- }
- else
- { global.surf = surface_create(room_width, room_height ) ;
- globa.current_room =room ;
- }
- surface_reset_target () ; // script clear / free targetted surface
- //END SCRIPT
- //CREATE OBJ
- //OBJ TIME OF THE DAY PARENT IS OBJENV
- // create surface and setup day clock
- if (instance_number(objTimeOfDay)>1)
- {
- instance_destroy() ;
- }
- time_of_day = 15 ;
- alpha = 0.0 ;
- scriptGlobalSurfaceCheck() ;
- //GET REF FROM PREVIOUS SCRIPT
- global.current_room = room ;
- day_type = MORNING ;
- //FIRST VALUE FOR DAY
- alarm[0] = global.Step_per_hour ;
- change_steps = 3 ;
- change = change_steps ;
- draw_surface = true ;
- global.time_of_day = time_of_day ;
- global.day_type = day_type ;
- //END OF SCRIPT
- //DESTROY EVENT
- instance_destroy();
- instance_destroy();
- //ALARM STEP EVENT
- //update informations for the new hour of the day
- //HOUR UPDATE
- alarm[0] = global.steps_per_hour ;
- time_of_day += 1 ;
- //CHANGE THE 24 clock to back to 0
- if (time_of_day > 23) then { time_of_day== 0 ;}
- //SUNRISE EVENT
- if (time_of_day < 7 ) and day_type <>4)
- {
- day_type = 4 ;
- global.shadow_alpha = 0.0 ;
- }
- //NIGHT
- else if (time_of_day>=18 and time_of_day < 24 )
- {
- day_type = 3 ;
- alpha += 1/6 ;
- global.shadow_alpha = 0.5 ; //1/6 ;
- }
- //MORNING
- else if (time_of_day == 7 and time_of_day < 12 and day_type <> 1 )
- {
- day_type = 1 ;
- alarm[1] = 1 ;
- global.shadow_alpha = 0.1 ;
- }
- //MIDDAY
- else if (time_of_day > 12 and time_of_day < 18 and day_type <> 2 )
- {
- day_type = 2 ;
- alarm[1] = 1 ;
- global.shadow_alpha = 0.2;
- }
- //SHADOW PARAMS
- var temp = (time_of_day - 6 ) * 15 ; //12 hours is 180 degrees
- global.shadow_angle = cos(degtorad(temp));
- global.shadow_height = clamp(abs(sin(degtorad(temp))) * 0.5, 0.5, 0.5);
- global.time_of_day = time_of_day ;
- global.day_type = day_type ;
- //ALARM 1
- //better transtion for morning hourse
- if (alpha > 0.0)
- {
- alpha -= 0.01;
- alarm[1] = 1 ;
- }
- //step objTimeof Day
- //update surface drawing lighted objects
- scriptGlobalSuraceCheck();
- surface_set_target(global.surf);
- if ((day_type ==1 and alpha <= 0) or room== rmRoom)
- {
- draw_surface = false ;
- }
- else if ((day_type == 2 or day_type == 3 or (daytype == 1 and alpha > 0 ))
- {
- draw_surface = true ;
- draw_set_colour(c_black ) ;
- draw_set_alpha(alpha ) ;
- draw_rectangle(0,0,room_width,room_height,false ) ;
- draw_set_blend_mode(bm_subtract);
- draw_set_color(c_black);
- draw_set_alpha(0.2 ) ;
- with(objLightSourceShadow)
- {
- draw_set_color(c_white) ;
- draw_set_alpha(lightcolorIntensity);
- if (sprite_index == objTorchLight)
- {
- //draw innerline
- draw_circle(x+offset_x[0], y+offset_y[0],lightinerradius+offset_y[1],false);
- draw_set_alpha(lightcolorintensity+0.5);
- //draw outerline
- draw_circle(x+offset_x[3], y+offset_y[2],lightinerradius+offset_y[0],false)
- draw_set_blend_mode(bm_normal);
- draw_set_color(lightcolor);
- draw_set_alpha(lightcolorintensity + 0.2) ;
- draw_circle(x+offset_x[3],y + offset_y[2], lightouterradius + offset_y[0], false ) ;
- draw_set_blend_mode(bm_subtract);
- }
- else if (sprite_index == sprTorch)
- {
- draw_set_color(c_white) ;
- }
- else
- {
- draw_circle(x+source_x + offset_x[3], y + source_y + offset_y[2], lightinnerradius + offset_y[0], false) ; // Color
- draw_set_blend_mode(bm_subtract);
- }
- }
- with(objPlayerCharacter)
- {
- draw_set_color(lightcolor) ;
- draw_set_alpha(lightcolorintensity) ;
- draw_circle(x+offset_x[0], y-10 + offset_y[1], lightouterradius + offset_y[2], false ) ;
- draw_circle(x+offset_x[2], y-10 + offset_y[3], lightinnerradius + offset_y[1], false ) ;
- }
- with(objLightSourceDraw)
- {
- draw_set_color(c_white) ;
- draw_set_alpha(image_alpha ) ;
- draw_circle_colour(x,y,lightradius, lightinnercolor, lightoutercolor, false ) ;
- draw_set_alpha(lightcolorintensity ) ;
- draw_set_color(lightcolor ) ;
- draw_circle_colour(x,y, lightradius, lightinnercolor, lightoutercolor, false) ;
- }
- }
- draw_set_colour(c_white) ;
- draw_set_blend_mode(bm_normal);
- draw_set_alpha(1.0) ;
- surface_reset_target();
- {
- //DRAW SURFACE OBJTIMEOFDAY
- if (!surface_exists(global.surf)
- {
- global.surf = surface_create(room_width, room_height ) ;
- draw_surface(global.Surf, 0 ,0 ) ;
- else
- {
- if (view_crrent == 0 )
- {
- if (draw_surface)
- {
- draw_surface(global.surf, 0 , 0 ) ;
- }
- }
- //END
- //NEW OBJ : OBJLIGHTSOURCESHADOW
- // create properties
- /*
- children : objFirePit
- children : objAction
- */
- //inherit events
- lightcolor = make_colour_rgb(255,255,255) ;
- lgihtcolorIntensity = 0.1 ;
- lightinnerraidus = 30 ;
- lightouterradius = 50 ;
- lightoffset = 2 ;
- scrSetOffsets(lightoffset);
- alarm[0] = random_range(0.1, 0.2) * room_speed ;
- source_x = 0;
- source_y = 0 ;
- /*
- OBJ = objLightSourceDraw
- parent = objShadowFixed
- //ALARM 0
- //ADD THE OBJCHARACTERPLAYER :
- */
- lightcolor = c_white
- lgithcolorIntensity = .5 ;
- lgihtoffset = 1;
- lightouterradius = 40 ;
- lightinnerradius = 25;
- scrSetOffsets(lightoffset) ;
- alarm[0] = random_range(.1, .2 ) * room_speed ;
- //ADD THE MAIN CHARACTER ALARM NUMBER WHATEVER
- scrSetOffsets(lightoffset) ;
- alarm[0] = random_range(0.05, 0.1) * room_speed ;
- //END OF TUT 1
- //START FIREFLIES LOGIC
- //new obj : objirefly
- /* parent : objLightSourceDraw
- create event : */
- event_inherited();
- surface_y =0 ;
- vspeed = random_range ( -0.1, 0.1 );
- hspeed = random_range ( -0.1, 0.1 );
- lifespan = random_range ( 0.35, 0.5 )* room_speed ; // 3.5 - 5 secs
- fadestep = 0 ;
- lifespan_max = lifespan ;
- lightcolorIntensity = .2 ;
- image_blend = make_colour_rgb(255,255,0 );
- lightcolor = make_colour_rgb(255,255,0 ) ;
- //step event
- event_inherited()
- ;
- depth = -1 * surface_y ;
- fadestep ++ ;
- lifespan = -1 ;
- if (lifespan < 0)
- {
- instance_destroy() ; }
- var calc = sqr(fadestep / lifespan_max ) / fadestep ;
- image_alpha -= calc ;
- image_blend = make_colour_rgb(255*image_alpha, 255 * image_alpha, 0 ) ;
- // THIS BLEND THE COLOR DEPENDING ON ITS ALPHA VALUE
- //BACK TO OBJTIMEOFDAY ADDITION
- //add to STEP EVENT
- //after "with (objChaaracterPlayer)
- /with (objLightSourceDraw )
- { draw_set_color(c_white ) ;
- draw_set_alpha ( image_alpha) ;
- draw_circle_colour(x, y , lightradius , lightinnercolor, lightoutercolor, false ) ;
- draw_set_alpha(lightcolor ) ;
- draw_set_color(lightcolor);
- draw_circle_colour(x,y,lightradisu, lightinnercolor, lightoutercolor ,false ) ;
- }
- }
- //ADD TO OBJGRASS CREATE EVENT
- var rustling = false; //affected by day night cycle
- //CHECK THE OBJBOB = OBJPLAYERCHARACTER COLISION
- if (animation == false )
- {
- animation = true ;
- if (other.move_x > 0 )
- { sprite _index = sprLeafaRight ;
- else if (other.move_x < 0 )
- {
- sprite_index = sprLeafLeft;
- else
- {
- if (other.move_y ! = 0 )
- { sprite_index = sprLeafDown;}
- else
- { sprite_index = sprLeafUp ;
- }
- }
- image_index = 0 ;
- //STARTS THE ANIMATION
- if (other.move_y != 0 or other.move_x != 0 ) //BASICALLY MOVING IN ANY IDRECTION
- {
- image_speed = 4 / room_speed ; //SET 4 SECS
- }
- else
- {
- animation = false ;
- //IF WE ARENT MOVING DOESNT TRIGGER THE ANIMATION OF THE GRASS
- }
- //LEAF PARTICULE RANDOMIZED
- if (other.running )
- {
- if (choose(0,0 ,1 ) == 1 )
- {
- var o = instance_create(other.x , other.y , objLeaf ) ;
- o.hspeed = other.move_x * random_range(0.05, 0.2 ) ;
- }
- }
- rustling = true ;
- }
- //ObjGrass
- //time of day Event STEP
- if (global.day_type == 2 )
- {
- if (random(1000) > global.value or //rare firefly
- (rustling and random(100) > 90 )) //rustling
- {
- var object = instance_create(x + irandom_range(-5, 5), y + irandom_range--10, -5), y + irandom
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement