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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? main.cpp

?? 《游戲編程中的人工智能技術》書中源代碼和可執(zhí)行文件
?? CPP
字號:
//-----------------------------------------------------------------------
//  
//  Name: Bouncing Balls with Timer example project
//  
//  Author: Mat Buckland 2002
//
//  Desc: Code demonstrating a timer
//------------------------------------------------------------------------

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

#include "defines.h"
#include "utils.h"
#include "CTimer.h"



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

char* g_szApplicationName = "Bouncing Balls - With Timer";
char*	g_szWindowClassName = "MyWindowClass";

//--------------------------------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(){}
  
};

//---------------------------- 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 = new SBall[NUM_BALLS];

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

    switch (msg)
    {
	
		//A WM_CREATE msg is sent when your application window is first
		//created
    case WM_CREATE:
      {
         //to get get the size of the client window first we need  to create
         //a RECT and then ask Windows to fill in our RECT structure with
         //the client window size. Then we assign to cxClient and cyClient 
         //accordingly
			   RECT rect;

			   GetClientRect(hwnd, &rect);

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

         //seed random number generator
         srand((unsigned) time(NULL));
         
         //set up the balls with random positions and velocities
         for (int i=0; i<NUM_BALLS; ++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 WM_KEYUP:
      {
        switch(wParam)
        {
         case VK_ESCAPE:
          {
            PostQuitMessage(0);
          }
          
          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<NUM_BALLS; ++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 - RADIUS,
                   balls[i].posY - RADIUS,
                   balls[i].posX + RADIUS,
                   balls[i].posY + RADIUS);
 

         }
        
         //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);

      }

      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  = NULL;
     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);
     }
         
     //make the window visible
		 ShowWindow (hWnd, iCmdShow);
     UpdateWindow (hWnd);

	   // Enter the message loop
	   bool bDone = false;

     //create a timer
	  CTimer timer(FRAMES_PER_SECOND);

	  //start the timer
	  timer.Start();

     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 );
			  }
		  }

		if (timer.ReadyForNextFrame())
		{
		  //**any game update code goes in here**
      
      //this will call WM_PAINT which will render our scene
			InvalidateRect(hWnd, NULL, TRUE);
			UpdateWindow(hWnd);
    }
   					
    }//end while

     UnregisterClass( g_szWindowClassName, winclass.hInstance );

     return msg.wParam;
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美va亚洲va| 欧美亚洲自拍偷拍| 日韩高清在线电影| 亚洲国产视频一区二区| 亚洲乱码一区二区三区在线观看| 久久综合久久鬼色| 国产亚洲污的网站| 国产日韩欧美精品一区| 国产精品青草久久| 亚洲视频在线观看三级| 一区二区日韩av| 亚洲.国产.中文慕字在线| 日韩激情在线观看| 久久激情五月激情| 高清国产午夜精品久久久久久| 国产在线麻豆精品观看| 成熟亚洲日本毛茸茸凸凹| 成人av资源在线观看| 色哟哟一区二区在线观看| 欧美久久一区二区| 精品国产精品网麻豆系列| 国产欧美视频一区二区三区| 国产精品国产自产拍高清av| 性久久久久久久久久久久| 国产综合色在线视频区| 99精品久久99久久久久| 在线观看亚洲a| 精品日韩一区二区三区 | 欧美videos中文字幕| 精品88久久久久88久久久| 中文字幕欧美国产| 亚洲高清免费观看| 国产福利一区在线| 欧美三电影在线| 久久一日本道色综合| 亚洲男女一区二区三区| 久久99精品久久久久| av不卡在线观看| 日韩三级伦理片妻子的秘密按摩| 久久免费偷拍视频| 午夜电影网亚洲视频| 成人午夜激情片| 日韩一级免费一区| 亚洲精品国产视频| 国产suv精品一区二区883| 777久久久精品| 亚洲精选视频在线| 国产成人精品网址| 久久综合色之久久综合| 亚洲欧美偷拍三级| 国产麻豆成人传媒免费观看| 欧美色综合影院| 日韩理论片网站| 国产在线视视频有精品| 555夜色666亚洲国产免| 亚洲欧美另类在线| 从欧美一区二区三区| 日韩一级在线观看| 青青青伊人色综合久久| 色老汉一区二区三区| 国产精品三级电影| 国产一区二区三区在线观看免费| 欧美日韩一区二区三区四区| 亚洲色图在线播放| 不卡大黄网站免费看| 久久精品视频一区二区三区| 日韩成人dvd| 欧美一区三区四区| 日本美女一区二区| 91精品国产综合久久久久久漫画 | 色偷偷成人一区二区三区91| 久久久.com| 国产精品一区在线观看乱码| 日韩免费高清电影| 精品一区二区影视| 久久综合狠狠综合久久激情| 久久精品噜噜噜成人88aⅴ| 日韩亚洲电影在线| 美女一区二区视频| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 国产精品网曝门| 成人午夜av影视| 中文字幕一区二区三区乱码在线| 风间由美中文字幕在线看视频国产欧美| 精品精品国产高清一毛片一天堂| 捆绑调教一区二区三区| 欧美精品一区男女天堂| 久久国产三级精品| 国产亚洲一区字幕| 色成人在线视频| 亚洲bt欧美bt精品777| 制服丝袜中文字幕一区| 美女一区二区三区在线观看| www激情久久| 99免费精品在线观看| 亚洲女同一区二区| 91精品国产综合久久久蜜臀粉嫩| 免费av成人在线| 久久久美女毛片| 91一区二区在线观看| 舔着乳尖日韩一区| 精品国产乱码久久久久久1区2区| 国产不卡免费视频| 亚洲综合免费观看高清完整版 | 三级成人在线视频| 精品国产乱码久久久久久闺蜜| 国产精品一二三四| 一区二区三区欧美亚洲| 欧美一区二区国产| 成人av午夜电影| 无吗不卡中文字幕| 欧美激情综合在线| 91精品婷婷国产综合久久性色| 麻豆精品国产91久久久久久| 日本一区二区不卡视频| 欧美日韩你懂得| 国产资源在线一区| 亚洲成人午夜影院| 国产精品少妇自拍| 欧美喷潮久久久xxxxx| 成人丝袜18视频在线观看| 午夜亚洲国产au精品一区二区| 国产日韩欧美麻豆| 欧美一级片在线看| 欧美在线视频不卡| av不卡免费电影| 国产精品一区在线观看乱码 | 成人福利视频在线看| 日韩黄色一级片| 一区二区在线观看免费| 国产日韩欧美综合在线| 日韩一区二区影院| 欧洲精品一区二区| 97精品久久久久中文字幕| 国产综合久久久久久久久久久久| 亚洲小少妇裸体bbw| 亚洲欧美日韩国产综合在线| 欧美精品一区二区三| 日韩视频在线一区二区| 欧美在线视频不卡| 色呦呦一区二区三区| 99热国产精品| 91一区二区在线| 91性感美女视频| 91在线观看高清| 97超碰欧美中文字幕| 国产成人啪午夜精品网站男同| 国产一区二区在线电影| 精品一区二区三区免费视频| 免费在线观看不卡| 青草国产精品久久久久久| 亚洲成a人v欧美综合天堂下载 | 欧美高清在线一区| 国产亚洲va综合人人澡精品| 精品国产污污免费网站入口| 欧美一区二区二区| 欧美v国产在线一区二区三区| 日韩女同互慰一区二区| 欧美电视剧在线看免费| 日韩欧美一区二区不卡| 欧美伦理视频网站| 日韩午夜av电影| www国产精品av| 久久久久久久久蜜桃| 国产日韩欧美综合一区| 亚洲视频一区二区在线| 亚洲女人小视频在线观看| 亚洲一级不卡视频| 日本成人在线网站| 国产一区二区视频在线播放| 不卡视频在线看| 欧美亚洲尤物久久| 精品国产91久久久久久久妲己| 久久色在线视频| 亚洲男人的天堂av| 免播放器亚洲一区| 成人午夜免费av| 欧美日韩一区不卡| 精品久久久久一区| 亚洲免费看黄网站| 免费观看一级特黄欧美大片| 国产精品伊人色| 欧美在线短视频| 久久久久国产免费免费| 亚洲精品国产无天堂网2021 | 国产色91在线| 亚洲激情网站免费观看| 久久国产精品99精品国产| 成人免费看的视频| 欧美精品aⅴ在线视频| 国产亚洲成av人在线观看导航| 亚洲一区影音先锋| 国产99精品国产| 欧美日韩另类一区| 亚洲国产经典视频| 日本中文字幕不卡| 91网址在线看| 久久久久久久久久电影| 亚洲影院在线观看| 高清成人在线观看|