亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? main.cpp

?? 《游戲編程中的人工智能技術(shù)》書中源代碼和可執(zhí)行文件
?? CPP
字號(hào):
//-----------------------------------------------------------------------
//  
//  Name: Resources_Dialog_Box2 example project
//  
//  Author: Mat Buckland 2002
//
//  Desc: Code demonstrating the use of a dialog box to change parameters
//------------------------------------------------------------------------

#include <windows.h>
#include <time.h>

#include "defines.h"
#include "utils.h"
#include "resource.h"



//--------------------------------- Globals ------------------------------
//
//------------------------------------------------------------------------

char* g_szApplicationName = "Bouncing Balls - with Dialog";
char*	g_szWindowClassName = "MyWindowClass";

//create some global variables for the ball size and number so that
//we can easily alter them via the options dialog box.
int g_iBallRadius = RADIUS;
int g_iNumBalls   = NUM_BALLS;

//global handle to our programs window
HWND g_hwnd = NULL;

//--------------------------------SBall------------------------------------
//
//  define a simple structure for the balls
//-------------------------------------------------------------------------
struct SBall
{
  //to hold the balls coordinates
  int posX;
  int posY;

  //and velocity
  int velX;
  int velY;

  SBall(){}
  
};
//--------------------------------- AboutDialogProc ----------------------
//
//  message handler for the 'About' dialog box
//------------------------------------------------------------------------
BOOL CALLBACK AboutDialogProc(HWND   hwnd,
                              UINT   msg,
                              WPARAM wParam,
                              LPARAM lParam)
{
  switch(msg)
  {
  case WM_INITDIALOG:
    {
      return true;
    }

    break;

  case WM_COMMAND:
    {
      switch(LOWORD(wParam))
      {
      case IDOK:
        {
          EndDialog(hwnd, 0);

          return true;
        }

        break;
      }
    }

    break;

  }//end switch

  return false;
}
//--------------------------------- OptionsDialogProc ----------------------
//
//  message handler for the 'Ball Options' dialog box
//------------------------------------------------------------------------
BOOL CALLBACK OptionsDialogProc(HWND   hwnd,
                                UINT   msg,
                                WPARAM wParam,
                                LPARAM lParam)
{
  //get handles to edit controls
  HWND hwndNumBalls = GetDlgItem(hwnd, IDC_EDIT1);
	HWND hwndRadius		= GetDlgItem(hwnd, IDC_EDIT2);
	
   switch(msg)
  {
  case WM_INITDIALOG:
    {
      //we have to update the edit boxes with the current radius
      //and number of balls
		  string s = itos(g_iNumBalls);
		  SetWindowText(hwndNumBalls, s.c_str());

      s = itos(g_iBallRadius);
		  SetWindowText(hwndRadius, s.c_str());
      
      return true;
    }

    break;

  case WM_COMMAND:
    {
      switch(LOWORD(wParam))
      {
      case IDOK:
        {
          //for each edit box we collect the information and then change
          //the parameters accordingly
				  char  buffer[5];

          //-----------first the number of balls
				  GetWindowText(hwndNumBalls, buffer, 5);

				  //convert to an int
          g_iNumBalls = atoi(buffer);

          //-----------Now the radius
				  GetWindowText(hwndRadius, buffer, 5);

				  //convert to an int
          g_iBallRadius = atoi(buffer);

          //send a custom message to the WindowProc so that
          //new balls are spawned
          PostMessage(g_hwnd, UM_SPAWN_NEW, NULL, NULL);

          EndDialog(hwnd, 0);
				
          return true;
        }

        break;
      }
    }

    break;

  }//end switch

  return false;
}
//---------------------------- WindowProc ---------------------------------
//	
//	This is the callback function which handles all the windows messages
//-------------------------------------------------------------------------

LRESULT CALLBACK WindowProc (HWND   hwnd,
                             UINT   msg,
                             WPARAM wParam,
                             LPARAM lParam)
{
    //create some pens to use for drawing
    static HPEN BluePen  = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
    static HPEN OldPen   = NULL;

    //create a solid brush
    static HBRUSH RedBrush = CreateSolidBrush(RGB(255, 0, 0));
    static HBRUSH OldBrush = NULL;
  
    //these hold the dimensions of the client window area
	  static int cxClient, cyClient;
  
    //create some balls
    static SBall* balls;

	 //used to create the back buffer
   static HDC		hdcBackBuffer;
   static HBITMAP	hBitmap;
   static HBITMAP	hOldBitmap;

   //this holds the hinstance
   static HINSTANCE hInstance;

    switch (msg)
    {
	
		//A WM_CREATE msg is sent when your application window is first
		//created
    case WM_CREATE:
      {
         //get the instance handle so we can invoke the dialogue box
         //when required
         hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
          
			   RECT rect;

			   GetClientRect(hwnd, &rect);

			   cxClient = rect.right;
			   cyClient = rect.bottom;

         //seed random number generator
         srand((unsigned) time(NULL));

         //create the array of balls
         balls = new SBall[g_iNumBalls];
         
         //set up the balls with random positions and velocities
         for (int i=0; i<g_iNumBalls; ++i)
         {
           balls[i].posX = RandInt(0, cxClient);
           balls[i].posY = RandInt(0, cyClient);
           balls[i].velX = RandInt(0, MAX_VELOCITY);
           balls[i].velY = RandInt(0, MAX_VELOCITY);
         }
         
         //---------------create a surface for us to render to(backbuffer)

         //create a memory device context
         hdcBackBuffer = CreateCompatibleDC(NULL);

         //get the DC for the front buffer
         HDC hdc = GetDC(hwnd);

         hBitmap = CreateCompatibleBitmap(hdc,
                                          cxClient,
                                          cyClient);

			  
         //select the bitmap into the memory device context
			   hOldBitmap = (HBITMAP)SelectObject(hdcBackBuffer, hBitmap);

         //don't forget to release the DC
         ReleaseDC(hwnd, hdc);
      }

      break;

    case UM_SPAWN_NEW:
      {
        //create a new array of balls of the required size
        if (balls)
        {
          delete balls;
        }

        //create the array of balls
         balls = new SBall[g_iNumBalls];
         
         //set up the balls with random positions and velocities
         for (int i=0; i<g_iNumBalls; ++i)
         {
           balls[i].posX = RandInt(0, cxClient);
           balls[i].posY = RandInt(0, cyClient);
           balls[i].velX = RandInt(0, MAX_VELOCITY);
           balls[i].velY = RandInt(0, MAX_VELOCITY);
         }
      }

      break;

    case WM_KEYUP:
      {
        switch(wParam)
        {
         case VK_ESCAPE:
          {
            PostQuitMessage(0);
          }
          
          break;
        }
      }
    
    case WM_COMMAND:
       {
         switch(wParam)
         {
         case ID_ABOUT:
           {
             DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), hwnd, AboutDialogProc);
           }
           break;

         case ID_BALL_OPTIONS:
           {
             DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG2), hwnd, OptionsDialogProc);
           }
           break;


         }// end switch WM_COMMAND
       }

       break;


    case WM_PAINT:
      {
 		       
         PAINTSTRUCT ps;
          
         BeginPaint (hwnd, &ps);

        //fill our backbuffer with white
         BitBlt(hdcBackBuffer,
                0,
                0,
                cxClient,
                cyClient,
                NULL,
                NULL,
                NULL,
                WHITENESS);
          
         //first select a pen to draw with and store a copy
         //of the pen we are swapping it with
         OldPen = (HPEN)SelectObject(hdcBackBuffer, BluePen);

         //do the same for our brush
         OldBrush = (HBRUSH)SelectObject(hdcBackBuffer, RedBrush);

         //update and draw the balls
         for (int i=0; i<g_iNumBalls; ++i)
         {

          //check to see if they have hit any walls and reverse velocity 
           //accordingly
           if ( (balls[i].posX >= cxClient) || (balls[i].posX <0))
           {
             balls[i].velX = -balls[i].velX;
           }

           if ( (balls[i].posY >= cyClient) || (balls[i].posY <0))
           {
             balls[i].velY = -balls[i].velY;
           }

           // update their position
           balls[i].posX += balls[i].velX;
           balls[i].posY += balls[i].velY;   
           
           //render to display
           Ellipse(hdcBackBuffer,
                   balls[i].posX - g_iBallRadius,
                   balls[i].posY - g_iBallRadius,
                   balls[i].posX + g_iBallRadius,
                   balls[i].posY + g_iBallRadius);
 

         }
        
         //replace the original pen
         SelectObject(hdcBackBuffer, OldPen);
         //and brush
         SelectObject(hdcBackBuffer, OldBrush);

         //now blit backbuffer to front
			   BitBlt(ps.hdc, 0, 0, cxClient, cyClient, hdcBackBuffer, 0, 0, SRCCOPY); 
          
         EndPaint (hwnd, &ps);

         //delay a little
         Sleep(10);

      }

      break;

    //has the user resized the client area?
		case WM_SIZE:
		  {
        //if so we need to update our variables so that any drawing
        //we do using cxClient and cyClient is scaled accordingly
			  cxClient = LOWORD(lParam);
			  cyClient = HIWORD(lParam);

      //now to resize the backbuffer accordingly. First select
      //the old bitmap back into the DC
			SelectObject(hdcBackBuffer, hOldBitmap);

      //don't forget to do this or you will get resource leaks
      DeleteObject(hBitmap); 

			//get the DC for the application
      HDC hdc = GetDC(hwnd);

			//create another bitmap of the same size and mode
      //as the application
      hBitmap = CreateCompatibleBitmap(hdc,
											cxClient,
											cyClient);

			ReleaseDC(hwnd, hdc);
			
			//select the new bitmap into the DC
      SelectObject(hdcBackBuffer, hBitmap);

      }

      break;
          
		 case WM_DESTROY:
			 {
				 //delete the pens        
         DeleteObject(BluePen);
         DeleteObject(OldPen);

         //and the brushes
         DeleteObject(RedBrush);
         DeleteObject(OldBrush);

         //and the balls
         delete[] balls;

         //clean up our backbuffer objects
         SelectObject(hdcBackBuffer, hOldBitmap);

         DeleteDC(hdcBackBuffer);
         DeleteObject(hBitmap); 
         
         // kill the application, this sends a WM_QUIT message  
				 PostQuitMessage (0);
			 }

       break;

     }//end switch

     //this is where all the messages not specifically handled by our 
		 //winproc are sent to be processed
		 return DefWindowProc (hwnd, msg, wParam, lParam);
}

//-------------------------------- WinMain -------------------------------
//
//	The entry point of the windows program
//------------------------------------------------------------------------
int WINAPI WinMain (HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR     szCmdLine, 
                    int       iCmdShow)
{
     //handle to our window
		 HWND						hWnd;
    
		 //our window class structure
		 WNDCLASSEX     winclass;
		 
     // first fill in the window class stucture
	   winclass.cbSize        = sizeof(WNDCLASSEX);
	   winclass.style         = CS_HREDRAW | CS_VREDRAW;
     winclass.lpfnWndProc   = WindowProc;
     winclass.cbClsExtra    = 0;
     winclass.cbWndExtra    = 0;
     winclass.hInstance     = hInstance;
     winclass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
     winclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
     winclass.hbrBackground = NULL;
     winclass.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU1);
     winclass.lpszClassName = g_szWindowClassName;
	   winclass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

		 //register the window class
		if (!RegisterClassEx(&winclass))
		{
			MessageBox(NULL, "Registration Failed!", "Error", 0);

			//exit the application
			return 0;
		}

		 //create the window and assign its ID to hwnd    
     hWnd = CreateWindowEx (NULL,                 // extended style
                            g_szWindowClassName,  // window class name
                            g_szApplicationName,  // window caption
                            WS_OVERLAPPEDWINDOW,  // window style
                            0,                    // initial x position
                            0,                    // initial y position
                            WINDOW_WIDTH,         // initial x size
                            WINDOW_HEIGHT,        // initial y size
                            NULL,                 // parent window handle
                            NULL,                 // window menu handle
                            hInstance,            // program instance handle
                            NULL);                // creation parameters

     //make sure the window creation has gone OK
     if(!hWnd)
     {
       MessageBox(NULL, "CreateWindowEx Failed!", "Error!", 0);
     }
        
     
     g_hwnd = hWnd;

     //make the window visible
		 ShowWindow (hWnd, iCmdShow);
     UpdateWindow (hWnd);

	   // Enter the message loop
	   bool bDone = false;

     MSG msg;

	   while(!bDone)
     {
					
		  while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) 
		  {
			  if( msg.message == WM_QUIT ) 
			  {
				  // Stop loop if it's a quit message
				  bDone = true;
			  } 

			  else 
			  {
				  TranslateMessage( &msg );
				  DispatchMessage( &msg );
			  }
		  }

			//this will call WM_PAINT which will render our scene
			InvalidateRect(hWnd, NULL, TRUE);
			UpdateWindow(hWnd);

      //*** your game loop goes here ***//
   					
    }//end while

     UnregisterClass( g_szWindowClassName, winclass.hInstance );

     return msg.wParam;
}


?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99久久久欧美国产| 国产三级一区二区| 99久久久精品| 91在线porny国产在线看| 岛国一区二区三区| 成人激情小说网站| 99热99精品| 在线观看亚洲一区| 在线日韩国产精品| 制服丝袜av成人在线看| 欧美一区二区免费观在线| 精品欧美乱码久久久久久1区2区 | 亚洲国产精品二十页| 久久女同精品一区二区| 久久久精品黄色| 亚洲欧美另类综合偷拍| 亚洲图片欧美综合| 看片网站欧美日韩| 成人国产电影网| 欧美在线观看一区二区| 欧美zozo另类异族| 国产欧美日韩另类视频免费观看 | 678五月天丁香亚洲综合网| 日韩视频一区二区三区| 国产日韩欧美精品在线| 亚洲欧美中日韩| 男男视频亚洲欧美| 懂色中文一区二区在线播放| 欧美网站一区二区| 久久综合久久鬼色中文字| 中文字幕日本不卡| 久久国产综合精品| 色94色欧美sute亚洲线路一久| 欧美草草影院在线视频| 亚洲欧美日韩国产另类专区| 裸体在线国模精品偷拍| 99国产精品国产精品毛片| 日韩欧美激情一区| 一区二区在线免费观看| 国产精品香蕉一区二区三区| 欧美亚洲一区二区三区四区| 欧美韩国日本不卡| 美女任你摸久久| 在线视频欧美精品| 国产精品国产馆在线真实露脸 | 综合久久久久久久| 久久er99热精品一区二区| 99re66热这里只有精品3直播| 亚洲精品一区二区三区福利| 亚洲国产精华液网站w| 香蕉成人伊视频在线观看| 中文字幕乱码久久午夜不卡| 香蕉成人啪国产精品视频综合网| 蜜臀精品久久久久久蜜臀 | 亚洲精品一区二区三区精华液| 亚洲区小说区图片区qvod| 国产毛片精品视频| 91精品欧美综合在线观看最新 | 欧美影院午夜播放| 日韩午夜电影在线观看| 国产欧美精品在线观看| 九色综合狠狠综合久久| 日韩午夜av一区| 日韩精品五月天| 欧美日韩在线播| 国产精品视频观看| 国产精品77777竹菊影视小说| 91精品国产全国免费观看| 五月婷婷激情综合网| 精品视频一区二区不卡| 亚洲自拍偷拍欧美| 在线看不卡av| 一区二区三区**美女毛片| 99re这里只有精品6| 亚洲欧洲日韩av| 91美女片黄在线观看| 综合av第一页| 91色九色蝌蚪| 国产精品女人毛片| 粉嫩在线一区二区三区视频| 国产精品卡一卡二卡三| 一本大道av伊人久久综合| 亚洲欧美日韩国产手机在线| 欧美性xxxxxxxx| 日韩精品乱码av一区二区| 欧美一区二区网站| 久久国产精品第一页| 久久久综合九色合综国产精品| 国产麻豆成人精品| 国产精品电影院| 欧美性色黄大片| 日本sm残虐另类| 欧美激情一区不卡| 欧美亚日韩国产aⅴ精品中极品| 偷窥国产亚洲免费视频| 日韩亚洲欧美成人一区| 成人黄页在线观看| 一区二区三区资源| 精品免费视频一区二区| 成人短视频下载| 亚洲h在线观看| 国产亚洲综合av| 色猫猫国产区一区二在线视频| 日韩精品一级中文字幕精品视频免费观看| 精品日韩一区二区三区免费视频| 国产91在线|亚洲| 婷婷激情综合网| 中文无字幕一区二区三区| 在线亚洲免费视频| 国产一区二区调教| 亚洲一区在线视频| 国产区在线观看成人精品| 欧美色图免费看| 成人晚上爱看视频| 国产在线视频精品一区| 亚洲色欲色欲www| 日韩欧美色电影| 在线这里只有精品| 色偷偷一区二区三区| 蜜臀久久久99精品久久久久久| 亚洲丝袜自拍清纯另类| 欧美成人a∨高清免费观看| 91成人在线免费观看| 国产黑丝在线一区二区三区| 日韩国产成人精品| 亚洲综合一二三区| 国产精品美女一区二区三区| 精品福利一区二区三区免费视频| 欧美婷婷六月丁香综合色| 成人综合激情网| 国产成人午夜电影网| 免费国产亚洲视频| 亚洲成人精品影院| 一区二区三区免费在线观看| 国产欧美精品一区aⅴ影院 | 国产精品一区二区三区四区| 日日摸夜夜添夜夜添亚洲女人| 自拍偷在线精品自拍偷无码专区 | 一区二区三区资源| 1024亚洲合集| ㊣最新国产の精品bt伙计久久| 国产日韩精品久久久| 久久精品夜夜夜夜久久| 精品久久国产老人久久综合| 91精品综合久久久久久| 欧美一区二区三区在线| 在线观看91av| 538prom精品视频线放| 日韩一区二区在线看片| 欧美精品aⅴ在线视频| 在线欧美日韩国产| 欧美日韩视频专区在线播放| 欧美日韩高清一区| 在线不卡一区二区| 精品欧美一区二区在线观看| 欧美不卡视频一区| 久久久久久久国产精品影院| 欧美国产一区二区在线观看 | 亚洲成人在线网站| 视频在线观看91| 美女免费视频一区| 国产激情视频一区二区在线观看| 国产ts人妖一区二区| 91在线porny国产在线看| 精品视频在线看| 日韩免费观看高清完整版在线观看| 26uuu久久综合| 国产精品乱人伦| 亚洲狠狠爱一区二区三区| 蜜桃视频在线观看一区| 黄一区二区三区| www.欧美日韩| 欧美日韩国产大片| 久久综合色之久久综合| 亚洲欧洲www| 日日噜噜夜夜狠狠视频欧美人| 久国产精品韩国三级视频| 成年人午夜久久久| 欧美日韩国产综合视频在线观看| 日韩欧美在线网站| 国产精品麻豆欧美日韩ww| 亚洲成人免费观看| 国产一区二区在线观看免费| 色婷婷综合久久| 精品国产乱码久久久久久闺蜜| 国产精品欧美一区喷水| 午夜成人免费视频| 成人在线综合网站| 欧美久久久久久久久久| 欧美激情资源网| 午夜精品福利视频网站| 成人黄色小视频在线观看| 这里只有精品视频在线观看| 国产精品乱码久久久久久| 免费高清视频精品| 91丝袜美腿高跟国产极品老师 | 久久99精品国产.久久久久久| 9l国产精品久久久久麻豆| 777xxx欧美| 亚洲另类色综合网站|