Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: eborr on August 01, 2010, 05:07:53 PM

Title: Architectural Advice
Post by: eborr on August 01, 2010, 05:07:53 PM
The goal is this - in the game there will be music playing - say 20 tunes, the order in which those tunes are to be played is random.  The playing of music is initiated by finding a radio in one scene. When the player leaves the scene the tunes will continue to be played unless the player turns off music as a menu item.
My question is this does the code which checks to see if music is playing have to exist in the main game loop ? I really don't like clutter in the main loop itself.  Is is possible to create a method which will be persitent = eg it can check the state of a "do you want to hear music" global variable - or is there a nice neat and obvisous way to solve this.

My thinking for randomness is that music played will be stored in an array until such time as all the tunes have been played - then the whole thing will re-initialise.

Sorry for the ramble
Title: Re: Architectural Advice
Post by: metamorphium on August 01, 2010, 11:11:17 PM
you can create script and attach it to game object. This way you'll have the music logic in separate file / loop and it will be persistent for the whole game.
Title: Re: Architectural Advice
Post by: eborr on August 01, 2010, 11:40:12 PM
thanks for the speedy answer so I would attach the script within Game.script. or have I misunderstood ?
Title: Re: Architectural Advice
Post by: metamorphium on August 02, 2010, 06:57:24 AM
you can either use Game.AttachScript fr the part of the game which uses it and later on detach it or you can attach it in Project Manager permanently.
Title: Re: Architectural Advice
Post by: eborr on August 02, 2010, 11:29:32 AM
many thanks it works very nicely both in the test harness and also in the main game, although I still ahve some concerns that it may affect performance - but lets wait and see on that