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

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

?? demo7_14.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 3 頁
字號:


// draw all the bots
for (index=0; index < 3; index++)
    {
    // draw objects but with scaled destination size
    DDraw_Draw_Surface_Scaled(aliens[index].frames[animation_seq[aliens[index].current_frame]], 
                       aliens[index].x, aliens[index].y,
                       aliens[index].width,aliens[index].height,
                       (float)aliens[index].width*aliens[index].scale,
                       (float)aliens[index].height*aliens[index].scale,
                       lpddsback);

    } // end for index


// flip pages
while (FAILED(lpddsprimary->Flip(NULL, DDFLIP_WAIT)));

// wait a sec
Sleep(30);

// return success or failure or your own return code here
return(1);

} // end Game_Main

////////////////////////////////////////////////////////////

int Game_Init(void *parms = NULL, int num_parms = 0)
{
// this is called once after the initial window is created and
// before the main event loop is entered, do all your initialization
// here

// create IDirectDraw interface 7.0 object and test for error
if (FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL)))
   return(0);

// set cooperation to full screen
if (FAILED(lpdd->SetCooperativeLevel(main_window_handle, 
                                      DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | 
                                      DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)))
   return(0);

// set display mode to 640x480x8
if (FAILED(lpdd->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,0,0)))
   return(0);

// we need a complex surface system with a primary and backbuffer

// clear ddsd and set size
DDRAW_INIT_STRUCT(ddsd); 

// enable valid fields
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;

// set the backbuffer count field to 1, use 2 for triple buffering
ddsd.dwBackBufferCount = 1;

// request a complex, flippable
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;

// create the primary surface
if (FAILED(lpdd->CreateSurface(&ddsd, &lpddsprimary, NULL)))
   return(0);

// now query for attached surface from the primary surface

// this line is needed by the call
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;

// get the attached back buffer surface
if (FAILED(lpddsprimary->GetAttachedSurface(&ddsd.ddsCaps, &lpddsback)))
  return(0);

// build up the palette data array
for (int color=1; color < 255; color++)
    {
    // fill with random RGB values
    palette[color].peRed   = rand()%256;
    palette[color].peGreen = rand()%256;
    palette[color].peBlue  = rand()%256;

    // set flags field to PC_NOCOLLAPSE
    palette[color].peFlags = PC_NOCOLLAPSE;
    } // end for color

// now fill in entry 0 and 255 with black and white
palette[0].peRed     = 0;
palette[0].peGreen   = 0;
palette[0].peBlue    = 0;
palette[0].peFlags   = PC_NOCOLLAPSE;

palette[255].peRed   = 255;
palette[255].peGreen = 255;
palette[255].peBlue  = 255;
palette[255].peFlags = PC_NOCOLLAPSE;

// create the palette object
if (FAILED(lpdd->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256 | 
                                DDPCAPS_INITIALIZE, 
                                palette,&lpddpal, NULL)))
return(0);

// finally attach the palette to the primary surface
if (FAILED(lpddsprimary->SetPalette(lpddpal)))
   return(0);

// set clipper up on back buffer since that's where well clip
RECT screen_rect= {0,0,SCREEN_WIDTH-1,SCREEN_HEIGHT-1};
lpddclipper = DDraw_Attach_Clipper(lpddsback,1,&screen_rect);

// load the 8-bit image
if (!Load_Bitmap_File(&bitmap,"alley8.bmp"))
   return(0);

// load it's palette into directdraw
if (FAILED(lpddpal->SetEntries(0,0,MAX_COLORS_PALETTE,bitmap.palette)))
   return(0);

// clean the surfaces
DDraw_Fill_Surface(lpddsprimary,0);
DDraw_Fill_Surface(lpddsback,0);

// create the buffer to hold the background
lpddsbackground = DDraw_Create_Surface(640,480,0,-1);

// copy the background bitmap image to the background surface 

// lock the surface
lpddsbackground->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL);

// get video pointer to primary surfce
UCHAR *image_buffer = (UCHAR *)ddsd.lpSurface;       

// test if memory is linear
if (ddsd.lPitch == SCREEN_WIDTH)
   {
   // copy memory from double buffer to primary buffer
   memcpy((void *)image_buffer, (void *)bitmap.buffer, SCREEN_WIDTH*SCREEN_HEIGHT);
   } // end if
else
   { // non-linear

   // make copy of source and destination addresses
   UCHAR *dest_ptr = image_buffer;
   UCHAR *src_ptr  = bitmap.buffer;

   // memory is non-linear, copy line by line
   for (int y=0; y < SCREEN_HEIGHT; y++)
       {
       // copy line
       memcpy((void *)dest_ptr, (void *)src_ptr, SCREEN_WIDTH);

       // advance pointers to next line
       dest_ptr+=ddsd.lPitch;
       src_ptr +=SCREEN_WIDTH;
       } // end for

   } // end else

// now unlock the primary surface
if (FAILED(lpddsbackground->Unlock(NULL)))
   return(0);

// unload the bitmap file, we no longer need it
Unload_Bitmap_File(&bitmap);

// seed random number generator
srand(GetTickCount());

// initialize all the aliens (in real life do this in a loop or function)

// alien on level 1 of complex

aliens[0].x              = rand()%SCREEN_WIDTH;
aliens[0].y              = 116 - 72;                  
aliens[0].velocity       = 2+rand()%4;
aliens[0].current_frame  = 0;             
aliens[0].counter        = 0;       
aliens[0].width          = 72; // set real size
aliens[0].height         = 80;
aliens[0].scale          = ((float)(1+rand()%20))/10; // scale from 0.1 to 2.0
// fix up feet so they still contact floor
aliens[0].y+=(72 - aliens[0].scale*72);

// alien on level 2 of complex

aliens[1].x              = rand()%SCREEN_WIDTH;
aliens[1].y              = 246 - 72;                  
aliens[1].velocity       = 2+rand()%4;
aliens[1].current_frame  = 0;             
aliens[1].counter        = 0;  
aliens[1].width          = 72; // set real size
aliens[1].height         = 80;
aliens[1].scale          = ((float)(1+rand()%20))/10; // scale from 0.1 to 2.0
// fix up feet so they still contact floor
aliens[1].y+=(72 - aliens[1].scale*72);



// alien on level 3 of complex

aliens[2].x              = rand()%SCREEN_WIDTH;
aliens[2].y              = 382 - 72;                  
aliens[2].velocity       = 2+rand()%4;
aliens[2].current_frame  = 0;             
aliens[2].counter        = 0;  
aliens[2].width          = 72; // set real size
aliens[2].height         = 80;
aliens[2].scale          = ((float)(1+rand()%20))/10; // scale from 0.1 to 2.0

// fix up feet so they still contact floor
aliens[2].y+=(72 - aliens[2].scale*72);


// now load the bitmap containing the alien imagery
// then scan the images out into the surfaces of alien[0]
// and copy then into the other two, be careful of reference counts!

// load the 8-bit image
if (!Load_Bitmap_File(&bitmap,"dedsp0.bmp"))
   return(0);

// create each surface and load bits
for (int index = 0; index < 3; index++)
    {
    // create surface to hold image
    aliens[0].frames[index] = DDraw_Create_Surface(72,80,0);

    // now load bits...
    Scan_Image_Bitmap(&bitmap,                 // bitmap file to scan image data from
                      aliens[0].frames[index], // surface to hold data
                      index, 0);               // cell to scan image from    

    } // end for index

// unload the bitmap file, we no longer need it
Unload_Bitmap_File(&bitmap);

// now for the tricky part. There is no need to create more surfaces with the same
// data, so I'm going to copy the surface pointers member for member to each alien
// however, be careful, since the reference counts do NOT go up, you still only need
// to release() each surface once!

for (index = 0; index < 3; index++)
    aliens[1].frames[index] = aliens[2].frames[index] = aliens[0].frames[index];

// return success or failure or your own return code here
return(1);

} // end Game_Init

/////////////////////////////////////////////////////////////

int Game_Shutdown(void *parms = NULL, int num_parms = 0)
{
// this is called after the game is exited and the main event
// loop while is exited, do all you cleanup and shutdown here

// kill all the surfaces


// first the palette
if (lpddpal)
   {
   lpddpal->Release();
   lpddpal = NULL;
   } // end if

// now the primary surface
if (lpddsprimary)
   {
   lpddsprimary->Release();
   lpddsprimary = NULL;
   } // end if

// now blow away the IDirectDraw4 interface
if (lpdd)
   {
   lpdd->Release();
   lpdd = NULL;
   } // end if

// return success or failure or your own return code here
return(1);

} // end Game_Shutdown

// WINMAIN ////////////////////////////////////////////////

int WINAPI WinMain(	HINSTANCE hinstance,
					HINSTANCE hprevinstance,
					LPSTR lpcmdline,
					int ncmdshow)
{

WNDCLASSEX winclass; // this will hold the class we create
HWND	   hwnd;	 // generic window handle
MSG		   msg;		 // generic message
HDC        hdc;      // graphics device context

// first fill in the window class stucture
winclass.cbSize         = sizeof(WNDCLASSEX);
winclass.style			= CS_DBLCLKS | CS_OWNDC | 
                          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	= (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName	= NULL;
winclass.lpszClassName	= WINDOW_CLASS_NAME;
winclass.hIconSm        = LoadIcon(NULL, IDI_APPLICATION);

// save hinstance in global
hinstance_app = hinstance;

// register the window class
if (!RegisterClassEx(&winclass))
	return(0);

// create the window
if (!(hwnd = CreateWindowEx(NULL,                  // extended style
                            WINDOW_CLASS_NAME,     // class
						    "DirectDraw 8-Bit Blitting Demo", // title
						    WS_POPUP | WS_VISIBLE,
					 	    0,0,	  // initial x,y
						    SCREEN_WIDTH,SCREEN_HEIGHT,  // initial width, height
						    NULL,	  // handle to parent 
						    NULL,	  // handle to menu
						    hinstance,// instance of this application
						    NULL)))	// extra creation parms
return(0);

// save main window handle
main_window_handle = hwnd;

// initialize game here
Game_Init();

// enter main event loop
while(TRUE)
	{
    // test if there is a message in queue, if so get it
	if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
	   { 
	   // test if this is a quit
       if (msg.message == WM_QUIT)
           break;
	
	   // translate any accelerator keys
	   TranslateMessage(&msg);

	   // send the message to the window proc
	   DispatchMessage(&msg);
	   } // end if
    
       // main game processing goes here
       Game_Main();
       
	} // end while

// closedown game here
Game_Shutdown();

// return to Windows like this
return(msg.wParam);

} // end WinMain

///////////////////////////////////////////////////////////

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产揄拍国内精品对白| 亚洲成av人片一区二区三区| 欧美高清视频一二三区| 色婷婷综合久久久中文字幕| 国产高清一区日本| 国产精品一区免费视频| 粉嫩欧美一区二区三区高清影视| 国产一区二区视频在线| 国产成人久久精品77777最新版本| 国产精品18久久久| 成人av电影在线播放| 色天使色偷偷av一区二区| 91福利国产精品| 欧美乱妇15p| 日韩丝袜美女视频| 久久久久久久久97黄色工厂| 久久亚洲捆绑美女| 国产精品久久久久久一区二区三区 | 成人动漫在线一区| 99在线热播精品免费| 欧美专区日韩专区| 精品国产自在久精品国产| 国产清纯在线一区二区www| 亚洲色欲色欲www在线观看| 亚洲不卡在线观看| 韩日欧美一区二区三区| 色综合网站在线| 日韩限制级电影在线观看| 欧美经典三级视频一区二区三区| 亚洲欧美电影一区二区| 日韩中文字幕一区二区三区| 国产美女娇喘av呻吟久久| 日本精品免费观看高清观看| 日韩欧美成人一区| 亚洲免费av观看| 九九九精品视频| 色8久久人人97超碰香蕉987| 精品国产一区二区精华| 亚洲一区二区美女| 国产91精品露脸国语对白| 欧美日韩黄视频| 《视频一区视频二区| 蜜臀av性久久久久蜜臀aⅴ| 91在线播放网址| 久久精品一区二区三区不卡| 性做久久久久久| 99久久婷婷国产精品综合| 精品国产凹凸成av人网站| 亚洲一区中文日韩| 成人avav在线| 国产日韩三级在线| 精品一区二区三区欧美| 欧美精选一区二区| 亚洲久草在线视频| 成人美女在线观看| 欧美大片顶级少妇| 日本视频一区二区三区| 色94色欧美sute亚洲线路二| 欧美激情综合在线| 精品在线一区二区| 欧美一二三四在线| 日韩二区三区在线观看| 91欧美一区二区| 日韩理论电影院| 不卡免费追剧大全电视剧网站| 久久婷婷久久一区二区三区| 蜜乳av一区二区| 欧美一区二区三区在| 亚洲成人精品在线观看| 欧美三级资源在线| 亚洲在线成人精品| 欧美日精品一区视频| 一区二区三区四区不卡视频| 色综合天天综合网国产成人综合天| 欧美激情一区二区三区全黄| 成人久久18免费网站麻豆 | 中文字幕欧美日本乱码一线二线| 国产最新精品精品你懂的| 日韩精品一区二区三区蜜臀| 精品一区二区三区免费播放| 26uuu久久天堂性欧美| 国产精品白丝jk白祙喷水网站| 国产欧美一区二区精品久导航| 国产aⅴ精品一区二区三区色成熟| 国产日韩欧美精品在线| 成人网在线免费视频| 亚洲天堂网中文字| 91国产视频在线观看| 日韩经典一区二区| 欧美zozozo| 成人97人人超碰人人99| 一二三四社区欧美黄| 欧美一区二区三区在| 丰满少妇在线播放bd日韩电影| 亚洲欧美另类图片小说| 制服丝袜激情欧洲亚洲| 激情av综合网| 亚洲视频免费看| 欧美精品一级二级三级| 国产精品综合在线视频| 亚洲欧美日韩系列| 91精品国产入口| 成人深夜福利app| 亚洲成av人片一区二区| 久久综合国产精品| 色哟哟精品一区| 另类欧美日韩国产在线| 国产精品不卡一区| 7777女厕盗摄久久久| 成人视屏免费看| 日本成人在线一区| 亚洲欧洲av色图| 欧美α欧美αv大片| 欧洲一区二区av| 国产精品综合久久| 五月天欧美精品| 亚洲视频资源在线| 日韩精品一区二区三区视频在线观看| 99视频一区二区三区| 久久se精品一区精品二区| 亚洲免费在线观看| 国产亚洲精品bt天堂精选| 欧美日韩一区在线| www.亚洲国产| 国产一区二区免费在线| 日韩高清一区在线| 亚洲国产精品综合小说图片区| 欧美激情一区二区三区不卡 | 欧美日韩一卡二卡三卡 | 5566中文字幕一区二区电影| 波多野结衣一区二区三区 | 国产精品电影院| 久久免费看少妇高潮| 在线电影院国产精品| 91在线观看免费视频| 丰满少妇久久久久久久| 国产揄拍国内精品对白| 蜜桃一区二区三区在线观看| 亚洲一区二区欧美日韩| 自拍偷拍国产精品| 国产精品毛片大码女人| 亚洲国产高清在线观看视频| 久久精品一区八戒影视| www国产亚洲精品久久麻豆| 91精品国产免费| 91麻豆精品国产91久久久久久久久| 91麻豆免费视频| 一本大道久久a久久精品综合| 成人av网站免费观看| 成人精品鲁一区一区二区| 国产一区二区美女| 亚洲精品菠萝久久久久久久| 国产成人免费视频| 奇米一区二区三区| 亚洲尤物在线视频观看| 亚洲成人资源在线| 日韩综合在线视频| 麻豆精品蜜桃视频网站| 麻豆精品在线观看| 蜜臀av性久久久久蜜臀aⅴ流畅| 七七婷婷婷婷精品国产| 久久精品国产色蜜蜜麻豆| 国产在线播放一区三区四| 国产福利91精品| 成人在线视频一区| 97精品视频在线观看自产线路二 | 精品粉嫩超白一线天av| 精品国产一区二区三区不卡| 久久久精品2019中文字幕之3| 中文字幕欧美三区| 一区二区高清视频在线观看| 亚洲高清免费在线| 日本 国产 欧美色综合| 91网站黄www| 欧美影院精品一区| 欧美一卡二卡三卡| 久久久久久久久久久久久久久99 | 欧美中文字幕一区二区三区| 91精品在线观看入口| 久久精品欧美一区二区三区麻豆| 综合在线观看色| 麻豆成人久久精品二区三区小说| 国产福利一区二区三区视频在线 | 六月丁香综合在线视频| 国产aⅴ综合色| 欧美人与禽zozo性伦| 欧美精品一区二区蜜臀亚洲| 国产精品毛片大码女人| 日韩在线播放一区二区| 丁香啪啪综合成人亚洲小说| 欧美三级电影网站| 国产精品女主播av| 蜜桃久久精品一区二区| 色综合婷婷久久| 久久久一区二区三区| 婷婷综合在线观看| 91在线播放网址| 国产清纯在线一区二区www| 日韩1区2区日韩1区2区| 91丝袜美女网|