MasterMain.cpp
Upload User: hnktjx
Upload Date: 2009-12-18
Package Size: 39k
Code Size: 2k
Category:

Game Program

Development Platform:

C/C++

  1. // MasterX Skeleton
  2. // MasterX SDK written by Jared Bruni
  3. #include "masterx.h"
  4. #include "resource.h"
  5. // MasterX Window Message Process Prototype
  6. long __stdcall MasterProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
  7. void update(MASTERSCREEN screen);
  8. void LoadSound();
  9. void LoadGraphics();
  10. MasterXHWND mxhwnd;
  11. MasterSound mxsound;
  12. MasterGraphic mgraphic;
  13. int mgraphic_x = 0;
  14. int mgraphic_y = 0;
  15. // MasterX Program Entry Point
  16. int __stdcall MasterMain(HINSTANCE hInst,LPSTR line)
  17. {
  18. if(mxhwnd.CreateMasterX("MasterX_Skeleton",640,480,COLOR_DEFAULT,MasterProc,hInst,LoadIcon(NULL,IDI_APPLICATION),LoadCursor(NULL,IDC_ARROW)))
  19. {
  20. LoadSound();
  21. LoadGraphics();
  22. return mxhwnd.InitLoop(update);
  23. }
  24. return 0;
  25. }
  26. // MasterX Window Message Process Defenition Body
  27. long __stdcall MasterProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
  28. {
  29. switch(msg)
  30. {
  31. case WM_ACTIVATEAPP:
  32. mxhwnd.activeapp = wParam;
  33. break;
  34. case WM_DESTROY:
  35. PostQuitMessage(0);
  36. break;
  37. case WM_KEYDOWN:
  38. {
  39. switch(wParam)
  40. {
  41. case VK_ESCAPE:
  42. mxhwnd.Kill();
  43. break;
  44. case 13:
  45. mxsound.Play();
  46. break;
  47. }
  48. }
  49. break;
  50. default: return DefWindowProc(hwnd,msg,wParam,lParam);
  51. }
  52. return 0;
  53. }
  54. void update(MASTERSCREEN screen)
  55. {
  56. if(mxhwnd.KeyCheck(DIK_LEFT))
  57. {
  58. mgraphic_x--;
  59. if(mgraphic_x < 0)
  60. {
  61. mgraphic_x = 0;
  62. }
  63. }
  64. if(mxhwnd.KeyCheck(DIK_RIGHT))
  65. {
  66. mgraphic_x++;
  67. if(mgraphic_x > 640-mgraphic.w)
  68. {
  69. mgraphic_x = 640-mgraphic.w;
  70. }
  71. }
  72. if(mxhwnd.KeyCheck(DIK_DOWN))
  73. {
  74. mgraphic_y++;
  75. if(mgraphic_y >  480-mgraphic.h)
  76. {
  77. mgraphic_y = 480-mgraphic.h;
  78. }
  79. }
  80. if(mxhwnd.KeyCheck(DIK_UP))
  81. {
  82. mgraphic_y--;
  83. if(mgraphic_y < 0)
  84. {
  85. mgraphic_y = 0;
  86. }
  87. }
  88. mgraphic.DisplayGraphic(mgraphic_x,mgraphic_y);
  89. mxhwnd.text.printtext("Press escape to exit, and arrow keys to move the image, enter to play a sound",10,10);
  90. }
  91. void LoadSound()
  92. {
  93. mxhwnd.LoadSound(&mxsound,MAKEINTRESOURCE(IDR_WAVE1));
  94. }
  95. void LoadGraphics()
  96. {
  97. mxhwnd.LoadGraphic(&mgraphic,"quit.bmp");
  98. mgraphic.SetColorKey(RGB(255,0,255));
  99. }