Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (843)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  MVC & sounds  (Read 1650 times)
0 Members and 1 Guest are viewing this topic.
Offline Don Kiddick

Junior Devvie

« Posted 2006-05-04 01:19:29 »

Writing my 1st game at the moment. I know Java well but not writing games. I've implemented a MVC pattern and all is working well.

My model get's ticked every game frame and my renderers get told to draw every frame. The renderers get asked to draw every frame. They query the model for it's current state and draw it.

Is this a common/good implementation model?

I'm planning on implementing sounds next. I'm thinking of making my model fire synchronous events for things that happen.  A 'SoundRenderer' will listen to these events, and decide on what sounds to play.

Is this a common/good implementation model?

thanks, D.
Offline noblemaster

« JGO Spiffy Duke »

Medals: 35
Projects: 11

Age of Conquest makes your day!

« Reply #1 - Posted 2006-05-04 03:16:07 »

I am using MVC too, and I definitly think it is the way to go.

What sound concerns, I was wondering about that too? In my opinion sound is pretty much related to the view. So, you add remove/change items in the view - you output a sound for it.

Advantage: It's easy to maintain - add one line of code (e.g. "<SongName>);") to wherever you need it based on display changes. Usually I have 100+ lines of GUI code and 1 line of sound player code - which does not bloat the GUI/view. Also it makes synchronization between sound & view easier.

Disadvantage: Huh - I am not sure if there is one? You should program SoundPlayer so it runs in a separate thread to not block your GUI. I.e.<SongName>) just adds a new song to play to the sound player thread. "play(<...>)" should return immediately.

Offline Don Kiddick

Junior Devvie

« Reply #2 - Posted 2006-05-04 04:35:35 »

Yeah my sound support would essentially be a view. It would work in a different way though as my renderer "view" polls the model everytime it is ticked for  the current state, whereas the sound "view" will be event driven - ie it listens to events from the model.

I think I'm happy with this implementation, I just thought I'd throw it out there for comments.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline beowulf03809

Senior Devvie

Medals: 2

We live for the code, we die for the code

« Reply #3 - Posted 2006-05-04 12:34:41 »

When considering overall design direction sound has been a consideration for me.  One worry I have had about using a separate sound thread would be sync.  If you're just talking about changing background sound tracks and such it's probably safe, but sound effects that are off by even a little bit are often far more noticable than a skipped frame in my opinion. 

It sounds ( no pun ) like you have a safe design. If the sound thread is doing nothing more than watching for request events and processing requested sounds then it shouldn't be too burdened.  But how well does it manage multiple sounds?  if you have a soundtrack playing, a couple seconds of dialog going and suddenly something requests rocket_launched.wav followed almost immediately by explosion.wav do you have the sound effects preempt the dialog or layer over it?
Pages: [1]
  ignore  |  Print  

EgonOlsen (37 views)
2018-06-10 19:43:48

EgonOlsen (20 views)
2018-06-10 19:43:44

EgonOlsen (39 views)
2018-06-10 19:43:20

DesertCoockie (186 views)
2018-05-13 18:23:11

nelsongames (122 views)
2018-04-24 18:15:36

nelsongames (121 views)
2018-04-24 18:14:32

ivj94 (861 views)
2018-03-24 14:47:39

ivj94 (122 views)
2018-03-24 14:46:31

ivj94 (758 views)
2018-03-24 14:43:53

Solater (139 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!