Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
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 707 times)
0 Members and 1 Guest are viewing this topic.
Offline Don Kiddick

Junior Member





« 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 Ninja


Medals: 20
Projects: 10


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. "SoundPlayer.play(<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. SoundPlayer.play(<SongName>) just adds a new song to play to the sound player thread. "play(<...>)" should return immediately.

Offline Don Kiddick

Junior Member





« 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.

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

Junior Member




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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (25 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (13 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (58 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!