sonic101 Posted June 12, 2006 Report Share Posted June 12, 2006 Okay Ive seena couple games do this now som im curious how can you make your level's back grounds show day or night depending on the actual time of day it is? with game maker preferibly. Link to comment Share on other sites More sharing options...
Mr.S Posted June 12, 2006 Report Share Posted June 12, 2006 I can help you only if you need it for gamemaker. I could make an example in GM ? Link to comment Share on other sites More sharing options...
Kain Posted June 12, 2006 Report Share Posted June 12, 2006 current_hour is a variable that stores the current hour according to the computer's clock (in military time, i.e. hour 13 = 1 PM, 14 = 2 PM, etc...). current_minute is the minute of the hour accourding to the computer's clock. current_second is the second. Using these variables, you arange to show a different background depending on what time it is. For example if you want day to be from 6:00 AM to 6:00 PM and night to be the opposite: if( current_hour >= 6 && current_hour < 18) { background_index = bg_day; } else { background_index = bg_night; } You could make more complicated effects dealing with tints of the sky based on more precise times, but this is the jist of how it's done. Involving minutes and seconds could be a bit confusing, but if you want to get more elaborate, the functions under "GML->Computing Things->Dealing with dates and times" in the manual should simplify things. Link to comment Share on other sites More sharing options...
sonic101 Posted June 12, 2006 Author Report Share Posted June 12, 2006 I'd like to have it do a transition between day and night aswell... how would you work with tints? i wasnt aware gm could do that. If you cold can soem one make a tutrorial? i learn better from visual then i do reading Link to comment Share on other sites More sharing options...
FredrikTheEvil Posted June 12, 2006 Report Share Posted June 12, 2006 Does GM by any chance support pixel shaders? Link to comment Share on other sites More sharing options...
DimensionWarped Posted June 12, 2006 Report Share Posted June 12, 2006 Considering that its primarily a 2D game authoring tool along the lines of TGF and MMF, I'd say probably not. Link to comment Share on other sites More sharing options...
FredrikTheEvil Posted June 12, 2006 Report Share Posted June 12, 2006 Ahh ok. I thought there was a chance it did since it uses D3D. But if anyone else needs a day/night pixel shader its very easy. Just by doing a linear interpolation between two images using the current time in the 0.0-1.0 range as the interpolation factor. Here is a HLSL Pixel shader for day/night transitions using the current time: //The following 3 variables has to be set in the constant table(assuming you use D3D)! float fTIme; // The current time in the 0.0-1.0 range sampler2D dayMap; sampler2D nightMap; struct PS_INPUT { float2 Texcoord : TEXCOORD0; }; float4 ps_main(PS_INPUT Input) : COLOR0 { float4 dayColor = tex2D(dayMap,Input.Texcoord); float4 nightColor = tex2D(nightMap,Input.Texcoord); return lerp(dayColor,nightColor, fTime); }; Link to comment Share on other sites More sharing options...
Mark the Echidna Posted June 12, 2006 Report Share Posted June 12, 2006 GM has some really cool tinting effects. Link to comment Share on other sites More sharing options...
Blackarms Posted June 18, 2006 Report Share Posted June 18, 2006 In MMF, you just need to use the time object to modify the shade of your sprites, or animations, depending how your working with it. When time= noon, for instance, set Sonic to highest tone and backgrounds to animation "noon" after you make a darker and lighter tone based on the time , you'll need to recolor a lot os sprites, though, to fit times of day. Link to comment Share on other sites More sharing options...
Damizean Posted June 18, 2006 Report Share Posted June 18, 2006 You could use GM's blend effects, just doing a Lerp of the backgrounds (just change the background_alpha) depending on the hour of the day Link to comment Share on other sites More sharing options...
Recommended Posts