Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Architectural Advice  (Read 3028 times)

0 Members and 1 Guest are viewing this topic.

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Architectural Advice
« 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
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Architectural Advice
« Reply #1 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.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: Architectural Advice
« Reply #2 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 ?
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Architectural Advice
« Reply #3 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.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: Architectural Advice
« Reply #4 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
Logged
 

Page created in 0.217 seconds with 20 queries.