![]() |
| ||
| Can you add pictures/sounds in a win32 console app? Hi guys, im new to this forum but congratulations, i looks great Im making a game for a TAFE class (which i will gladly send to any1). The game is a text based Role Playing Game. I am finished early so i am going to improve my current game. I was wondering whether i could add some sounds and pictures to my monsters. struct monster { int strength; int dexterity; int hp; char name[32]; }; That is my struct and i have an array of 4 monsters and a boss! Could i add something to the array, maybe monsterArray[].picture or monsterArray[].sound . Are there commands that allow pictures and sounds in a console application, if so can someone please tell me of them. Also feel free to get me to send you that game and/or source code! Cheers, Peter :p |
| ||
| Re: Can you add pictures/sounds in a win32 console app? I think that is helpful to you . # Microsoft Developer Studio Project File - Name="Sarien" - Package Owner=<4> |
| ||
| Re: Can you add pictures/sounds in a win32 console app? 1 Attachment(s) Introduction This article focuses on giving an example of using the DirectX API in PC game software development by using a DirectSound wrapper class. The DirectSound wrapper class The wrapper class has the functionality to handle various aspects of sound playback. The structure of the wrapper class The DirectSound object uses double buffers to manipulate the sound data processing and playback. The DirectSound object creates a single primary buffer to deal with output devices to play the sound data. The DirectSound object creates multiple second buffers to load, store various sound data, and configure sound data performance. The object loads and mixes sound data from the secondary buffers and sends the processed sound data to the primary buffer to play it through the output device. The wrapper class contains a pointer to the DirectSound object, a primary buffer object (a pointer of type DirectSoundBuffer), and the secondary buffer array (DirectSoundBuffer object array) DirectSound object in the wrapper class DirectSound is a COM interface, so the DirectSound object is the COM component object (a pointer to DirectSound). The DirectSound object is the core of sound playback and all of buffers, both primary buffer and secondary buffers are created by it, so it must be instantiated before doing any sound play back. Because the DirectSound object is a COM object, it can be instantiated by either the generic way of creation COM components, or by calling DirectSoundCreate. In my wrapper class, I find the generic method of creating a COM object is more reliable. Remember: The DirectX interfaces are a subset of the COM interfaces, so before you use them, call CoInitialize/ CoInitializeEx, and call CoUninitialize at the end of your application. // To start... Primary Buffer The primary buffer is a DirectSoundBuffer object, and its main task is to receive the processed sound data from the DirectSound object and send it to the output device to play. The primary’s format settings determine the sound play effect of the output device. The primary’s format is a WAVEFORMATEX structure and must be set before play. Second Buffer The second buffer loads sound data and sets the sound performance, then sends the sound to the DirectSound object. The second buffer is a DirectSoundBuffer object and is created by the DirectSound object. In my library, I use a wrapper class of DirectSoundBuffer for the second buffer. This wrapper class has the DirectSoundBuffer object, and the methods to set sound performances, such as adjustment of volume, frequency and channel. A special feature of the DirectSoundBuffer wrapper class is the special sound effect of Fade-In (volume up step by step) and Fade-Out (volume down step by step). To avoid the concurrency of incoming function calls, a mutex object is used in the DirectSoundBuffer wrapper class to synchronize the function calls. Timer Event The DirectSound wrapper class needs a timer to monitor and manipulate the sound status and performance in a special time interval. The DirectSound wrapper class is a generic class, so it is hard to use a windows timer in the class. As an alternative, a waitable timer is used in the class. A thread is created to check the timer event when the class object is instantiated. The test program The test program is a Dialog box application written in MFC. It tests the various wrapper class features, such as volume, frequency, channel, looping, mixing and fade-in and fade-out, etc. |
| ||
| Re: Can you add pictures/sounds in a win32 console app? Introduction Loading images under windows can always be a painful process, especially if the image formats are like JPEG, GIF or PNG. There's always the Imgdecmp library, that does a good job, but its also a bit of a bother with the documentation being so thin and all that. The other day I was trying to load a bitmap from my device using LoadImage, but somehow I kept getting the dreaded "The handle is invalid" error. So I did a search on the MFC code that ships with the PPC SDK in hope of finding a piece of code that will help me solve the puzzle. One thing led to another. I suddenly came across HBITMAP SHLoadImageFile(LPCTSTR pszFileName) in aygshell.h. Bingo! I had suddenly uncovered an undocumented API! No trace of it in MSDN, a search in Google produced nothing!! Since then, I've tried this API with gif's and bmp's also and I guess it will work fine for jpeg's and png's too. Here's a code sample... // assuming code is in the OnDraw method of a view.... That's all for now. |
| ||
| Re: Can you add pictures/sounds in a win32 console app? 1 Attachment(s) umm... THX a lot for trying mate but im not really that advanced at programming yet (im makinging a DOS 32 app thing). Ive included my source code (so far), if anyone could have a look and tell me if i could do this i would really appreciate it! Also any other suggestions to improve it would be greatly appreciated! |
| All times are GMT -4. The time now is 10:34 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC