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

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

?? demo12_1.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
字號:
// DEMO12_1.CPP - fly brain demo
// to compile make sure to include DDRAW.LIB, DSOUND.LIB,
// DINPUT.LIB, WINMM.LIB, and of course 
// T3DLIB1.CPP,T3DLIB2.CPP,T3DLIB3.CPP,

// INCLUDES ///////////////////////////////////////////////

#define INITGUID

#define WIN32_LEAN_AND_MEAN  

#include <windows.h>   // include important windows stuff
#include <windowsx.h> 
#include <mmsystem.h>
#include <iostream.h> // include important C/C++ stuff
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h> 
#include <math.h>
#include <io.h>
#include <fcntl.h>

#include <ddraw.h>  // directX includes
#include <dsound.h>
#include <dmksctrl.h>
#include <dmusici.h>
#include <dmusicc.h>
#include <dmusicf.h>
#include <dinput.h>
#include "T3DLIB1.h" // game library includes
#include "T3DLIB2.h"
#include "T3DLIB3.h"


// DEFINES ////////////////////////////////////////////////

// defines for windows 
#define WINDOW_CLASS_NAME "WINXCLASS"  // class name

#define WINDOW_WIDTH    320   // size of window
#define WINDOW_HEIGHT   240

// defines for flys
#define MAX_FLYS        128

// bounding box for flys
#define MIN_X_FLY       190 
#define MAX_X_FLY       450
#define MIN_Y_FLY       350
#define MAX_Y_FLY       470

// PROTOTYPES /////////////////////////////////////////////

// game console
int Game_Init(void *parms=NULL);
int Game_Shutdown(void *parms=NULL);
int Game_Main(void *parms=NULL);

// GLOBALS ////////////////////////////////////////////////

HWND main_window_handle           = NULL; // save the window handle
HINSTANCE main_instance           = NULL; // save the instance
char buffer[80];                          // used to print text

BITMAP_IMAGE background_bmp;   // holds the background

BOB flys[MAX_FLYS];            // the flys

int fly_sound_id = -1;         // sound id for fly sound

// FUNCTIONS //////////////////////////////////////////////

LRESULT CALLBACK WindowProc(HWND hwnd, 
						    UINT msg, 
                            WPARAM wparam, 
                            LPARAM lparam)
{
// this is the main message handler of the system
PAINTSTRUCT	ps;		   // used in WM_PAINT
HDC			hdc;	   // handle to a device context

// what is the message 
switch(msg)
	{	
	case WM_CREATE: 
        {
		// do initialization stuff here
		return(0);
		} break;

    case WM_PAINT:
         {
         // start painting
         hdc = BeginPaint(hwnd,&ps);

         // end painting
         EndPaint(hwnd,&ps);
         return(0);
        } break;

	case WM_DESTROY: 
		{
		// kill the application			
		PostQuitMessage(0);
		return(0);
		} break;

	default:break;

    } // end switch

// process any messages that we didn't take care of 
return (DefWindowProc(hwnd, msg, wparam, lparam));

} // end WinProc

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

int WINAPI WinMain(	HINSTANCE hinstance,
					HINSTANCE hprevinstance,
					LPSTR lpcmdline,
					int ncmdshow)
{
// this is the winmain function

WNDCLASS winclass;	// this will hold the class we create
HWND	 hwnd;		// generic window handle
MSG		 msg;		// generic message
HDC      hdc;       // generic dc
PAINTSTRUCT ps;     // generic paintstruct

// first fill in the window class stucture
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;

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

// create the window, note the use of WS_POPUP
if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, // class
						  "Fly Brain Demo",	 // title
						  WS_POPUP | WS_VISIBLE,
					 	  0,0,	   // x,y
						  WINDOW_WIDTH,  // width
                          WINDOW_HEIGHT, // height
						  NULL,	   // handle to parent 
						  NULL,	   // handle to menu
						  hinstance,// instance
						  NULL)))	// creation parms
return(0);

// save the window handle and instance in a global
main_window_handle = hwnd;
main_instance      = hinstance;

// perform all game console specific initialization
Game_Init();

// enter main event loop
while(1)
	{
	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

// shutdown game and release all resources
Game_Shutdown();

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

} // end WinMain

// T3D GAME PROGRAMMING CONSOLE FUNCTIONS ////////////////

int Game_Init(void *parms)
{
// this function is where you do all the initialization 
// for your game

int index; // looping variable

// start up DirectDraw (replace the parms as you desire)
DDraw_Init(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP);

// load background image
Load_Bitmap_File(&bitmap8bit, "FLYBACK.BMP");
Create_Bitmap(&background_bmp,0,0,640,480);
Load_Image_Bitmap(&background_bmp, &bitmap8bit,0,0,BITMAP_EXTRACT_MODE_ABS);
Set_Palette(bitmap8bit.palette);
Unload_Bitmap_File(&bitmap8bit);

// load the fly bitmaps
Load_Bitmap_File(&bitmap8bit, "FLYS8.BMP");

// create master fly bob
Create_BOB(&flys[0],320,200, 8,8, 4, BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY);
Set_Anim_Speed_BOB(&flys[0], 1);

// load the fly in 
for (index=0; index<4; index++)
    Load_Frame_BOB(&flys[0], &bitmap8bit, index, index, 0, BITMAP_EXTRACT_MODE_CELL);

// unload flys
Unload_Bitmap_File(&bitmap8bit);


// now replicate flys
for (index = 1; index<MAX_FLYS; index++)
    Clone_BOB(&flys[0], &flys[index]);

// now set all of their values
for (index=0; index<MAX_FLYS; index++)
    {
    // set positions
    Set_Pos_BOB(&flys[index], 320-32+rand()%64, 450-rand()%32);

    // set start frame randomly
    flys[index].curr_frame = 0;

    } // end for index

// initilize DirectSound
DSound_Init();

// load fly sound
fly_sound_id = DSound_Load_WAV("FLYS.WAV");

// start the sound
DSound_Play(fly_sound_id, DSBPLAY_LOOPING);

// return success
return(1);

} // end Game_Init

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

int Game_Shutdown(void *parms)
{
// this function is where you shutdown your game and
// release all resources that you allocated

// shut everything down

// kill all the flys
for (int index=0; index<MAX_FLYS; index++)
    Destroy_BOB(&flys[index]);

// shutdown directdraw last
DDraw_Shutdown();

// now directsound
DSound_Stop_All_Sounds();
DSound_Shutdown();

// return success
return(1);
} // end Game_Shutdown

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

void Flys_AI(void)
{
// this function performs the AI for the flys

for (int curr_fly=0; curr_fly<MAX_FLYS; curr_fly++)
    {   
    // test if fly directional counter <= 0
    if (--flys[curr_fly].varsI[0] <= 0)
        {
        // select a new random directional velocity
        flys[curr_fly].xv = -4 + rand()%9;
        flys[curr_fly].yv = -4 + rand()%9;

        // set time for motion to occur
        flys[curr_fly].varsI[0] = 2+rand()%8;

        } // end if

    // move the fly
    Move_BOB(&flys[curr_fly]);

    // animate the fly
    Animate_BOB(&flys[curr_fly]);

    // test if fly has left the fresh meat
    if (flys[curr_fly].x > MAX_X_FLY) 
       {
       flys[curr_fly].xv=-flys[curr_fly].xv;
       flys[curr_fly].x = MAX_X_FLY;
       } // end if

    if (flys[curr_fly].x < MIN_X_FLY) 
       {
       flys[curr_fly].xv=-flys[curr_fly].xv;
       flys[curr_fly].x = MIN_X_FLY;
       } // end if

    if (flys[curr_fly].y > MAX_Y_FLY) 
       {
       flys[curr_fly].yv=-flys[curr_fly].yv;
       flys[curr_fly].y = MAX_Y_FLY;
       } // end if

    if (flys[curr_fly].y < MIN_Y_FLY) 
       {
       flys[curr_fly].yv=-flys[curr_fly].yv;
       flys[curr_fly].y = MIN_Y_FLY;
       } // end if

    } // end for curr_fly

} // end Flys_AI

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

int Game_Main(void *parms)
{
// this is the workhorse of your game it will be called
// continuously in real-time this is like main() in C
// all the calls for you game go here!

int index; // looping var

// check of user is trying to exit
if (KEY_DOWN(VK_ESCAPE))
    {
    PostMessage(main_window_handle, WM_DESTROY,0,0);

    // stop all sounds
    DSound_Stop_All_Sounds();

    // do a screen transition
    Screen_Transitions(SCREEN_REDNESS,NULL,0);

    } // end if

// start the timing clock
Start_Clock();

// clear the drawing surface
DDraw_Fill_Surface(lpddsback, 0);

// lock back buffer and copy background into it
DDraw_Lock_Back_Surface();

// draw background
Draw_Bitmap(&background_bmp, back_buffer, back_lpitch,0);

// unlock back surface
DDraw_Unlock_Back_Surface();

// process the fly ai, move them buzz around dead bodies
Flys_AI();

// draw the flys
for (index=0; index < MAX_FLYS; index++)
     Draw_BOB(&flys[index], lpddsback);

// flip the surfaces
DDraw_Flip();

// sync to 30ish fps
Wait_Clock(30);

// return success
return(1);

} // end Game_Main

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美影片第一页| 麻豆国产欧美一区二区三区| 亚洲午夜电影在线观看| 日韩在线一二三区| 国产麻豆精品theporn| 99久久99久久精品免费看蜜桃| 欧美网站一区二区| 久久只精品国产| 成人免费在线视频| 五月婷婷久久丁香| 国产一区二区剧情av在线| 91蝌蚪porny成人天涯| 欧美一区二区三区成人| 中文字幕免费观看一区| 亚洲v日本v欧美v久久精品| 久久电影国产免费久久电影| av不卡在线播放| 欧美一级在线视频| 专区另类欧美日韩| 国产在线播放一区三区四| 色婷婷国产精品综合在线观看| 日韩精品中文字幕在线不卡尤物| 国产精品热久久久久夜色精品三区| 亚洲午夜精品在线| 国产福利精品导航| 91麻豆精品国产无毒不卡在线观看| 国产欧美在线观看一区| 婷婷开心激情综合| www.性欧美| 精品少妇一区二区三区在线播放| 一区二区三区中文字幕精品精品| 精品一区二区精品| 欧美日韩aaa| 99精品国产91久久久久久| 亚洲va天堂va国产va久| 成人免费视频一区二区| 日韩一级片网站| 亚洲综合在线视频| 成人一二三区视频| www久久精品| 日本不卡高清视频| 欧美性色aⅴ视频一区日韩精品| 欧美激情在线观看视频免费| 免费三级欧美电影| 欧美在线观看一区二区| 国产精品久久免费看| 国产一区视频网站| 日韩女优毛片在线| 性做久久久久久免费观看欧美| 99精品久久只有精品| 国产午夜精品久久久久久免费视| 日韩精品乱码av一区二区| 色婷婷久久久亚洲一区二区三区| 久久影院午夜论| 青青草97国产精品免费观看| 日本国产一区二区| 国产精品国产三级国产aⅴ中文 | 国产成人无遮挡在线视频| 在线播放欧美女士性生活| 亚洲精品视频在线| 91污在线观看| 国产精品国模大尺度视频| 国产成人啪免费观看软件| 精品黑人一区二区三区久久| 日日夜夜免费精品视频| 欧美性色黄大片手机版| 亚洲一区二区高清| 欧美三级日韩在线| 亚洲综合成人在线视频| 色婷婷久久综合| 亚洲乱码中文字幕| 91玉足脚交白嫩脚丫在线播放| 国产精品美女久久久久久| 成人av在线影院| 欧美韩国日本综合| 成人综合在线观看| 亚洲欧美在线视频观看| 99久久精品国产观看| 亚洲欧美日韩中文播放| 色综合视频在线观看| 亚洲日本一区二区三区| 色香蕉久久蜜桃| 亚洲一区二区三区四区在线观看| 日本道色综合久久| 亚洲电影第三页| 91精品国产综合久久国产大片| 麻豆成人免费电影| 久久久久久久久蜜桃| 东方欧美亚洲色图在线| 国产精品国产三级国产aⅴ原创 | 亚洲精品国产精华液| 91精品福利视频| 亚瑟在线精品视频| 精品少妇一区二区三区日产乱码| 国产一区二区三区精品欧美日韩一区二区三区 | 制服视频三区第一页精品| 另类成人小视频在线| 欧美精品一区二区蜜臀亚洲| 国产高清视频一区| 国产在线精品一区二区三区不卡| 国产午夜精品福利| 91看片淫黄大片一级在线观看| 亚洲综合一区二区三区| 欧美一级免费观看| 国产一区二区中文字幕| 亚洲天堂2014| 777精品伊人久久久久大香线蕉| 久久99九九99精品| 亚洲国产精品高清| 欧美中文字幕亚洲一区二区va在线| 丝袜a∨在线一区二区三区不卡| 欧美成人精品高清在线播放| 国产成人精品亚洲午夜麻豆| 亚洲三级在线看| 91精品国产一区二区| 国产不卡视频在线观看| 亚洲美女电影在线| 91精品国产综合久久婷婷香蕉| 国产麻豆91精品| 一区二区三区在线影院| 日韩欧美国产一区二区三区| 粉嫩嫩av羞羞动漫久久久 | 99re这里都是精品| 五月婷婷激情综合网| 国产欧美精品日韩区二区麻豆天美| 在线免费观看日本欧美| 极品少妇xxxx精品少妇偷拍| 亚洲精品视频免费看| 精品国产乱码久久久久久久| 91在线porny国产在线看| 久久国产生活片100| 亚洲三级在线播放| 欧美成人r级一区二区三区| 91丨porny丨国产| 久久99精品网久久| 亚洲一区二区三区在线看| 久久综合久久久久88| 91福利视频在线| 国产成人精品一区二区三区四区| 亚洲va国产天堂va久久en| 中文av字幕一区| 日韩欧美在线不卡| 91麻豆国产福利在线观看| 国产一区二区在线观看视频| 亚洲国产va精品久久久不卡综合| 国产视频一区在线播放| 538在线一区二区精品国产| 99re8在线精品视频免费播放| 蜜桃av一区二区三区| 亚洲女厕所小便bbb| 久久久99免费| 欧美一区二区三区四区视频| 色域天天综合网| 国产东北露脸精品视频| 免费观看91视频大全| 亚洲综合无码一区二区| 国产精品国产馆在线真实露脸| 久久伊99综合婷婷久久伊| 欧美私人免费视频| 色呦呦国产精品| 成人激情文学综合网| 国产盗摄视频一区二区三区| 久久精品国产精品亚洲红杏| 婷婷成人综合网| 亚洲一区二区三区影院| 亚洲日本乱码在线观看| 中文字幕高清一区| 久久久久久久久久久久久久久99 | 久久成人久久爱| 天天射综合影视| 亚洲一区二区av电影| 亚洲免费色视频| 1000部国产精品成人观看| 中文字幕av资源一区| 国产日韩精品一区二区三区| 久久精品在线免费观看| 亚洲精品在线免费播放| 精品国产在天天线2019| 欧美大尺度电影在线| 在线不卡一区二区| 欧美少妇一区二区| 欧美午夜在线一二页| 在线中文字幕一区二区| 91激情在线视频| 在线免费不卡视频| 色悠悠久久综合| 欧美午夜在线一二页| 欧美日韩免费视频| 欧美人与性动xxxx| 欧美电影一区二区| 欧美一区二区三区成人| 日韩欧美激情一区| 久久亚洲私人国产精品va媚药| 欧美大片免费久久精品三p| 欧美精品一区二区三区在线| 久久久亚洲精华液精华液精华液 | 国产成人免费视频一区| 丰满放荡岳乱妇91ww| 91婷婷韩国欧美一区二区| 色综合视频一区二区三区高清|