Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About 123abcd1983

  • Rank
  1. 123abcd1983

    C language string problem

    Quote:Original post by Lajnold scanf breaks at the first blank character (space, tab, newline, etc.). You can use something like fgets to always read until the first newline (or the size of the buffer that you specify, whichever comes first). hi actually how to use fgets? I get some info from internet, but all are for File, but i just wish to use it as scanf. Can you show some example. Thanks a lot
  2. Hi, I got some problem on the scanf of the string, for example I want to type the student name is 'kenneth Smith', but only 'kenneth' stored into "stud_detail[x].student_name" but the 'Smith' store into next scanf variable 'stud_detail[x].index_num'. Hope some one could help me struct STUDENT_RECORD{ char index_num[9],student_name[50],gender; }; ------------A part of code------------------ struct STUDENT_RECORD stud_detail[CLASS_SIZE]; printf("Student %d \n", x+1); printf("Student Name :\t "); scanf("%s ",&stud_detail[x].student_name); printf("Index Number :\t "); scanf("%s ",&stud_detail[x].index_num); printf("Gender :\t "); scanf("%s ",&stud_detail[x].gender); printf("Grade of AACS1084 Programming Concepts & Design II :\t "); scanf("%s ", &exam[x][0].grade); printf("Grade of AACS1123 Principle of Information Systems :\t "); scanf("%s ", &exam[x][1].grade);
  3. hi i got some problem by using virtual keycode, I wish to enter the "I" key , but it only tell me the "I" key value is "49", but went i put 49 to case, it didn't work. http://delphi.about.com/od/objectpascalide/l/blvkc.htm void CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown ) { if( bKeyDown ) { switch( nChar ) { //Play button and Again button shortcut key -- Enter case VK_RETURN: if ( Scene == IntroScene ) { PlayStart(); } break; case 49: if ( Scene == IntroScene ) { g_pIntroSound->Stop(); playInstruction(0); } break; } }
  4. hi, How to set the random number between 150 to 250 I think i know how to set the maximum of the random number it should be, rand()%250 but can anyone tell me how to set the minimum random number Thanks
  5. hi, i wish to open the exe file in the dugug folder, but when i clicked the exe file, the application will be hang. Just wondering is it have anyway to open the application file without run the program in the visual studio .net platform.
  6. Hi, i got some problem with the keyboard VK_UP and VK_DOWN key. I want to change the value of the velocity variable. The velocity variable is a global variable, and declared like below int velocity = 50; When the user pressed the UP key, the velocity value will be increase, and when the user pressed the down key velocity value will be decrease. But it didn't work in that way, when i pressed the UP key the value didn't change, but when i pressed the down key the value -1. I think it's because of VK_UP and VK_DOWN are changing velocity variable also, because when i remove one of the VK_UP or VK_DOWN, the velocity variable will -1 also. Just wish anyonone could help me to solve tis problem. Thanks void CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown ) { if( bKeyDown ) { switch( nChar ) { //Increase the volume of duck moving sound case VK_UP: if ( Scene == PlayingScene || Scene == PractiseScene ) { velocity++; } //Decrease the volume of duck moving sound case VK_DOWN: if ( Scene == PlayingScene || Scene == PractiseScene ) { velocity--; } } } }
  7. hi, I wish to pause the sound, just wondering is it possible to do this. In my game project, the game instruction will be read automatically when the game start. When the mouse cursor over a button, the button sound will be read, for example "Start" will be read out if the mouse over the start button. But it's too noisy to play button sound and instruction sound at the same time. So i wish to pause the instruction sound when the mouse over the button, when the mouse cursor left the button, the instruction sound will be continue. Because i don't know how to pause the sound, now i only stop the sound when the mouse over the button, and instruction sound will be replay from start when the cursor left the mouse. Wish anyone could tell me how to pause the sound. void playInstruction(DWORD dwFlags) { static TCHAR strFileName[MAX_PATH] = TEXT("GameInstruction.wav"); g_pIntroSoundManager = new CSoundManager(); HANDLE hFile = CreateFile( strFileName, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ); DWORD dwHighWord = NULL; DWORD dwFileSize = GetFileSize( hFile, &dwHighWord ); g_pIntroSoundManager->Initialize( hwnd,DSSCL_PRIORITY); g_pIntroSoundManager->Create( &g_pIntroSound, strFileName, 0, GUID_NULL,1 ); g_pIntroSound->Play( 0, dwFlags); }
  8. how to draw a line by using directX, i wish to draw a few line to sprate the screen to 9 gride sides, and i got some example for google. but it didn't work correctly.
  9. hi i got some problem about the input library file. My friend gave me an example program for me to refer. But the program got error message, which is "Cannot open Input file ifc22.lib", but i couldn't find any ifc22.lib from internet, the only file i found is ifc22.dll. Just wondering i should copy ifc22.dll to which folder, is it to "lib" folder? Is it possible to vert the ifc22.dll to ifc22.lib, do you think both files are same?
  10. I think I can use the number get by Rand() multiply by the current time. So the random number will be different. I have some problem to get the system time. I used the getTime() function to get it, but it was wrong I wish I could get some suggestion.
  11. 123abcd1983

    Control MIDI left and right volume

    Quote:Original post by benryves By high and low order it's referring to packaging two words together to form a single 32-bit integer. That is, 0xFFFFFFFF is both channels full volume, 0xFFFF0000 is right channel full on and left channel off, 0x80008000 is both channels at half-way and 0x00008000 is left channel at half-way. You can pack them together by using bitwise shifts and OR; int Left = 0xFFFF; int Right = 0x8000; int Packed = (Right << 16) | Left; // Packed = 0x8000FFFF (I haven't used this function before, so am going by what you've said in your post alone). hi i already try your's way, but it still didn't work. The text below i copied from msdn library. I think i understand the first paragraph. But i'm not really understand the paragraph 2 and 3. Could you give me some suggestion? http://msdn2.microsoft.com/en-us/library/ms711639.aspx "You can also determine whether the device supports volume control on both the left and right channels by querying the device using the midiOutGetDevCaps function and the MIDICAPS_LRVOLUME flag. Devices that do not support a full 16 bits of volume-level control use the high-order bits of the requested volume setting. For example, a device that supports 4 bits of volume control produces the same volume setting for the following volume-level values: 0x4000, 0x43be, and 0x4fff. The midiOutGetVolume function returns the full 16-bit value, as set by midiOutSetVolume, irrespective of the device's capabilities. Volume settings are interpreted logarithmically. This means that the perceived increase in volume is the same when increasing the volume level from 0x5000 to 0x6000 as it is from 0x4000 to 0x5000."
  12. -------------------------------------------------------------------------------- Hi, I have some problem by using the midi file. I wish to control the left and the right channels volumes, and i got some information from msdn library, but it didn't tell me the exact way to do it. Could anyone tell me what is the meaning of "The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence." The sentence above i copy from the the msdn library of MidiOutGetVolume and midiOutSetVolume. Does it mean the low order is 0x000 to 0x7777(left channel) and 0x8000 to 0xFFFF is high order (right channel)? The code below is modified from an example from internet. Although I set the midiOutSetVolume(hdev, 0xF000); But it didn't work at all. Anyone have similar example could control the left and right volumes? I already stuck on this step quite a while. I wish someone could give some suggestion for me. Thanks a lot. #include <windows.h> #include <stdio.h> #pragma comment(lib, "Winmm.lib") #define NOTE_ON 0x90 #define NOTE_OFF 0x80 //command, note, velocity #define MAKE_MSG(X, Y, Z) (X + (Y<<8) + (Z<<16)) int playChord(HMIDIOUT hdev) { ---> midiOutSetVolume(hdev, 0x0000); midiOutShortMsg(hdev, MAKE_MSG(NOTE_ON, 62, 65)); Sleep(1000); ---> midiOutSetVolume(hdev, 0xF000); midiOutShortMsg(hdev, MAKE_MSG(NOTE_ON, 62, 65)); Sleep(1000); ---> midiOutSetVolume(hdev, 0x5555); midiOutShortMsg(hdev, MAKE_MSG(NOTE_ON, 62, 65)); Sleep(1000); ---> midiOutSetVolume(hdev, 0xFFF0); midiOutShortMsg(hdev, MAKE_MSG(NOTE_ON, 62, 65)); Sleep(1000); midiOutShortMsg(hdev, MAKE_MSG(NOTE_OFF, 62, 65)); midiOutShortMsg(hdev, MAKE_MSG(NOTE_OFF, 62, 65)); midiOutShortMsg(hdev, MAKE_MSG(NOTE_OFF, 62, 65)); midiOutShortMsg(hdev, MAKE_MSG(NOTE_OFF, 62, 65)); return 0; } int main() { HMIDIOUT hdev; static MIDIOUTCAPS devCaps; static LPMIDIOUTCAPS lpCaps = &devCaps; DWORD abc; ---> devCaps.dwSupport = MIDICAPS_VOLUME|MIDICAPS_LRVOLUME; abc = devCaps.dwSupport; if (devCaps.dwSupport == MIDICAPS_VOLUME|MIDICAPS_LRVOLUME) { wprintf(L"abc"); } midiOutGetDevCaps(0, lpCaps, sizeof(MIDIOUTCAPS)); // Get device capabilities for first device (curDevice == 0) midiOutOpen(&hdev, -1, NULL, NULL, CALLBACK_NULL); midiOutSetVolume(hdev, 0x0000); wchar_t menu_sel = 0; while(menu_sel != 'q') { wprintf(L"Midi test app\nc: play chord\nd: change device\nv: set volume\nq: quit\n"); wscanf(L" %c", &menu_sel); switch(menu_sel) { case 'q': break; case 'c': playChord(hdev); break; default: wprintf(L"try again\n"); break; } } midiOutClose(hdev); return 0; }
  13. 123abcd1983

    The problem of D3DXCreateTexture

    Quote:Original post by Evil Steve D3DXCreateTexture[Ex] is for creating an empty texture which you then fill. If you're filling it yourself, you'll need to specify an alpha channel (Which you can set to 0 or 255 for fully opaque or fully transparant). The function the last person told you to use was probably D3DXCreateTextureFrom*Ex (E.g. D3DXCreateTextureFromFileEx). That allows you to load a texture from a file, and specify a colour you want to use as transparant. Thanks, it really help a lot, at least i know which function i need to call, but i still not sure which parameter i have to change to make the background color transparent, i think should be the ColorKey parameter, and I tried to changed it to 0xFFFFFFFF (white color), because the picture background color is white, and i wish to make it transparent,but when i run the program agains, that white color background became black color. Below is the value i passed into D3DXCreateTextureFromFileEx just wondering what value i need to pass in if i want to make the white color transparent. HRESULT D3DXCreateTextureFromFileEx( // value pas in my coding LPDIRECT3DDEVICE9 pDevice, // ---> pd3dDevice LPCTSTR pSrcFile, // ---> L"Duck.bmp", UINT Width, // ---> 100 UINT Height, // ---> 50 UINT MipLevels, // ---> D3DX_DEFAULT DWORD Usage, // ---> 0 D3DFORMAT Format, // ---> D3DFMT_FROM_FILE D3DPOOL Pool, // ---> D3DPOOL_DEFAULT DWORD Filter, // ---> D3DX_DEFAULT DWORD MipFilter, // ---> DD3DX_DEFAULT D3DCOLOR ColorKey, // ---> 0xFFFFFFFF D3DXIMAGE_INFO * pSrcInfo, // ---> NULL PALETTEENTRY * pPalette, // ---> NULL LPDIRECT3DTEXTURE9 * ppTexture // ---> &g_pDuckTexture );
  14. hi, I'm using D3DXCreateTextureFromFile to display the picture,but i got some problem on it, the picture has a white color background, so i wish to make the white color background transparent. Last time a guy told me use the D3DXCreateTexture or D3DXLoadSurface, and it has a colorkey can make the color transparent, but i not sure which one is the color key? Is it have any example can refer? How to load the picture file i want from my computer by using D3DXCreateTexture . HRESULT D3DXCreateTexture( LPDIRECT3DDEVICE9 pDevice, UINT Width, UINT Height, UINT MipLevels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, LPDIRECT3DTEXTURE9 * ppTexture ); The code below is how i write the code in my program void InitPlayingScene(IDirect3DDevice9* pd3dDevice) { D3DXCreateTextureFromFile( pd3dDevice, L"duck3.bmp", &g_pDuckTexture ); D3DXCreateSprite( pd3dDevice, &g_pDuckSprite); } void CALLBACK onPlayingSceneRender(IDirect3DDevice9* pd3dDevice) { DuckVec = D3DXVECTOR3(x, y, 0); // render the background of the playing scene SetRect(&rc, 0, 0, 120,60); g_pDuckSprite ->Begin( D3DXSPRITE_DONOTSAVESTATE); g_pDuckSprite ->Draw ( g_pDuckTexture, &rc, NULL, &DuckVec, 0xFFFFFFFF); g_pDuckSprite ->End(); }
  15. I knew the DirectX 8 got support it, because of directMusic, but it has been removed in directx9, just wondering what can i do, if i want to generate a midi voice note, and i wish to ctrl the note sound of left and right channels too.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!