Night and Day... (SOLVED)

Started by Fugu, Fri 07/10/2005 01:18:33

Previous topic - Next topic

Fugu

I want to create a Night and Day rythm for my next game. By now i just have a short cutscene introducing the next daytime and then a new room with the same locationgraphic and elements but in different colors and nightsky.

Is it somehow possible to a)fade smoothly  from one background to the next....and b) caused by a timer?

Can I transport the actual player position coordinates from the "day" to "night" room?

I have an outdoor scene with an object to pick up. But caused by the night and day thing, I have it in 2 rooms. When i pick it up in the "nightroom", is there any way to let it disapear from the "dayroom" as well? 

Has somebody any other ideas how to solve the day-night rythm with ags?


thanx alot

MrColossal

do you specifically want it to be that when a certain event happens it changes to night time or that time is constantly going and if you left the game running it would go from night time to day time to night time to day time every 20 minutes or so?

Eric
"This must be a good time to live in, since Eric bothers to stay here at all"-CJ also: ACHTUNG FRANZ!

Fugu

It would be perfect if its possible to let it change in a time caused rythm....i know that there are some ags-games with time counters...but have no own experiences with using timers yet....
are there any plugins for or tutorials about this?
even more perfect would it be to let only several scenes (the outdoorscenes) change.

Gilbert

#3
Quote from: Fugu on Fri 07/10/2005 01:18:33
Is it somehow possible to a)fade smoothlyÃ,  from one background to the next....and b) caused by a timer?

a) Yes b) Yes

There're many ways to archive this, but don't make 2 rooms, make it in one room. If your game is in 256 colours it can be done with palettes for sure. If it's 16 bit or above there're many methods, one of them is to use 2 background frames, and use RawDrawFrameTransparent() to archive the result.

Here is an example, suppose you have day background in frame 0, and night background in frame 1, so something like:

In "first time player enters room" event:
Code: ags

SetBackgroundFrame(0);
RawSaveScreen();


In "Player enters room (before fade-in)":
Code: ags

SetTimer(0,800); //800=20 seconds


Then in "repeatedly_execute"
Code: ags

if (IsTimerExpired(0)) {
 Ã, int ii=100;
 Ã, While (ii>=0) {
 Ã,  Ã, RawRestoreScreen();
 Ã,  Ã, RawDrawFrameTransparent(1, ii);
 Ã,  Ã, Wait(1);
 Ã,  Ã, ii--;
 Ã, }
}


[Edit] The above example is for a specific event only, if you want to make it a continuous time effect, you can make a global variable to designate the time, and increment it by 1 every game loop (in repeatedly_execute), and modify the background to whatever the time is when needed. This is what I did in my (ancient and outdated) Day-Night Transition demo, but I'm too lazy busy to muck up some codes at the moment.

Fugu

Hey Gilbot...thanx a lot!!
(damn i hate it when it rhymes accidentally)

I hoped that its possible to avoid 2 rooms for one scene...so glad that it is.
Like i mentioned, I need this effect for all outdoorscenes and indoorscenes with windows. Im not completely sure yet, in how many rooms i will need this effect...possibly i need it in the majority of scenes. Can i avoid the effect for only some rooms if i set the transition variables globally?
and how can i set the timeframe for the fadinglength?
can i download your demo somewhere?

Gilbert

Well, since it's made with a very old version, it won't compile with more modern versions of AGS now.
So I took the time to fix it to compile with V2.7 (more a hack than an update), you can get it here if interested.
Only the necessary files are included.
You need to compile it with V2.7, then move the 2 *.PAL files into the compiled folder for it to work.
When you start it up, walk down and go to room 2 to see the effect.
Note that I wasn't using the method mentioned here, since I bound to use 256 colours and I'm all crazy about palettes, but the (messy) codes about how to set up the clock in the script may help you.

If you want to see the old documentations and/or the resource, you can download the original version here, which was made with AGS V2.12 five whole years ago (so it won't compile now, but useful if you want the docs and the graphics).

Fugu

#6
Thanx for the work again!!Ã,  :D
Really brings me a few steps closer to eternal wisdom!
I have a few questions on this one..
Can I let the two backgrounds fade more smoothly...or depends it just on the amount of colors/resolution? Why are the ways of fading different in the two rooms?
Im very interested in setting global variables for the whole game to let the backgrounds change depending on timcount..how can i do that?
Can I change the colors of objects and characters the same way?

Gilbert

Quote from: Fugu on Sat 08/10/2005 15:03:01
Can I let the two backgrounds fade more smoothly...or depends it just on the amount of colors/resolution?
Yes I think, just try using the raw draw transparent frame method and see how it works, as I said before, me demo was in 256 colours, so that raw draw transparent method won't work (and such a function didn't exist even for hicolour modes when I made that demo either).
Personally I will never use hicolour+, so I just pointed that raw draw transparent out as a suggestion, I had never tried it and I don't know how its performance would be like. So the demo is just for reference, mainly for you to look at the time codes.
Quote
Why are the ways of fading different in the two rooms?
If you had downloaded the old version and read the text filse you'll know that.
That demo was originally made with AGS V2.13, which was 5 years ago, when no one had ever archived this task, and the functions of the engine was a bit primitive, the demo was made to show two possible different methods on how to do the Day-night transition effect.

Quote
Im very interested in setting global variables for the whole game to let the backgrounds change depending on timcount..how can i do that?
Well you can read the scripts of the demo and see if it can inspire you.

Quote
Can I change the colors of objects and characters the same way?
I think there're functions like TintObject(), etc. (too lazy to check the manual for the names) that may help you. Personally I'll just modify the palette, but that works only with 256 colour games, and will not work (properly) for hicolour+ games, so I won't recommend that.

Fugu

Thanks alot again....your answers really helped!  :=
youll be in the credits (if you dont mind).

SMF spam blocked by CleanTalk