i'm having problems adding sound to my game in graphics.h and main problem is; i don't know how to add sound does anybody know how to add sound?
i'm having problems adding sound to my game in graphics.h and main problem is; i don't know how to add sound does anybody know how to add sound?
On which OS?
On windows you just #include windows.h and mmsytem.h then you can use the PlaySound() api call...
I don't know about Mac, Linux or BSD... maybe the others can fill you in...
What compiler are you using? What operating system?
Jim
my os is windows. and i'm using devc++ 4.9
Last edited by hakanali; 04-25-2011 at 03:31 PM.
Ok do yourself a favour and update to Pelles C It has a full set of resource editors and all the windows headers and libraries... so you will be able to include your sound events into the program's resources instead of relying upon external files.... The Pelles C help file is amazing so I shouldn't expect you'll have much trouble changing over.
I don't think just switching IDEs is going to be very helpful. Dev-C++ is a decent program -- and since the OP is using graphics.h, I'm guessing that means a port of Borland's ancient libraries to Windows (with kbhit() etc). So switching to another IDE and at the same time using the Windows headers might not be productive.
On the other hand, it's not the best idea to use graphics.h as you might have guessed. It's very outdated and you'll find certain tasks (like playing sound...) to be difficult. I'd probably suggest, when you have time, that you try out a more modern library. Such as the Windows API that Pelles C apparently provides, if you wish (Dev-C++ also has these libraries, though perhaps not the resource editors).
Or if you want to be more portable you could try the SDL (libsdl.org). (The mingw devel package works with Dev-C++.) The SDL is a cross-platform library that makes it easy to draw primitives, bitmap files, play sounds, read mouse and keyboard and joystick events, etc. It's what I'd personally suggest you learn in the long run. But do your research.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Pelles C is more than just an IDE... it is a complete windows development system.
Pelle has written his own compiler (based loosly upon LCC), his own resource editors and compilers and his own assembler as part of the package. And, yes, you can probably use the libraries you're recommending with it (although it's Plain C-99 no C++).
FWIW... I don't make recommendations lightly and certainly not because it's what I use. Pelles C has earned it's stripes with me. Despite my ongoing search for a "better than C" language to work with I keep ending up back with it... because it really is the best setup I've seen (and yes I've even tried some commercial ones along the way). If you don't believe me, take a cruise through the help file... you'll understand.
My point was mainly that while Pelles C may be an excellent windows development system (I've never tried it), I'm not sure that's what the OP wants. Sounds like he or she is using a port of Borland's libraries, and so might be better off using Allegro or the SDL, which are more similar to graphics.h than Windows development is.
If I ever feel the urge to develop on Windows for some reason I'll have to check out Pelles C.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.