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

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

?? demo12_1_16b.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
字號:
// DEMO12_1_16b.CPP - fly brain demo
// 16-bit version, desktop must be in 16-bit mode!
// 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

// setup a 640x480 16-bit windowed mode example
#define WINDOW_TITLE      "16-Bit Fly Brain Demo"
#define WINDOW_WIDTH      640   // size of window
#define WINDOW_HEIGHT     480

#define WINDOW_BPP        16    // bitdepth of window (8,16,24 etc.)
                                // note: if windowed and not
                                // fullscreen then bitdepth must
                                // be same as system bitdepth
                                // also if 8-bit the a pallete
                                // is created and attached

#define WINDOWED_APP      1     // 0 not windowed, 1 windowed

// 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

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
main_instance = hinstance;

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

// create the window
if (!(hwnd = CreateWindowEx(NULL,                  // extended style
                            WINDOW_CLASS_NAME,     // class
						    WINDOW_TITLE, // title
						    (WINDOWED_APP ? (WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION) : (WS_POPUP | WS_VISIBLE)), 
					 	    0,0,	  // initial x,y
						    WINDOW_WIDTH,WINDOW_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;

if (WINDOWED_APP)
{
// now resize the window, so the client area is the actual size requested
// since there may be borders and controls if this is going to be a windowed app
// if the app is not windowed then it won't matter
RECT window_rect = {0,0,WINDOW_WIDTH-1,WINDOW_HEIGHT-1};

// make the call to adjust window_rect
AdjustWindowRectEx(&window_rect,
     GetWindowStyle(main_window_handle),
     GetMenu(main_window_handle) != NULL,
     GetWindowExStyle(main_window_handle));

// save the global client offsets, they are needed in DDraw_Flip()
window_client_x0 = -window_rect.left;
window_client_y0 = -window_rect.top;

// now resize the window with a call to MoveWindow()
MoveWindow(main_window_handle,
           0, // x position
           0, // y position
           window_rect.right - window_rect.left, // width
           window_rect.bottom - window_rect.top, // height
           TRUE);

// show the window, so there's no garbage on first render
ShowWindow(main_window_handle, SW_SHOW);
} // end if windowed


// 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

// initialize directdraw, very important that in the call
// to setcooperativelevel that the flag DDSCL_MULTITHREADED is used
// which increases the response of directX graphics to
// take the global critical section more frequently
DDraw_Init(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP, WINDOWED_APP);

// load background image
Load_Bitmap_File(&bitmap16bit, "FLYBACK_24.BMP");
Create_Bitmap(&background_bmp,0,0,640,480,16);
Load_Image_Bitmap16(&background_bmp, &bitmap16bit,0,0,BITMAP_EXTRACT_MODE_ABS);
Unload_Bitmap_File(&bitmap16bit);

// load the fly bitmaps
Load_Bitmap_File(&bitmap16bit, "FLYS8_24.BMP");

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

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

// unload flys
Unload_Bitmap_File(&bitmap16bit);

// 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();
   } // 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_Bitmap16(&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_BOB16(&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一区二区三区免费野_久草精品视频
一区二区三区在线看| 成人sese在线| 成人美女视频在线看| 7777精品伊人久久久大香线蕉的 | 国产在线不卡一区| 欧洲生活片亚洲生活在线观看| 日韩欧美国产一区二区在线播放| 亚洲欧美在线视频观看| 国产一区二三区好的| 欧美亚男人的天堂| 麻豆精品视频在线观看| 欧美视频完全免费看| 国产精品乱人伦中文| 国精品**一区二区三区在线蜜桃| 欧美精品乱码久久久久久按摩| 中文在线一区二区| 国产在线看一区| 91精品免费在线观看| 亚洲第一激情av| 91麻豆成人久久精品二区三区| 国产日韩欧美a| 精品一二线国产| 欧美一区二区视频观看视频| 亚洲国产欧美另类丝袜| 91麻豆6部合集magnet| 亚洲国产精品精华液ab| 国产精品911| 久久久精品国产免费观看同学| 久久99久久精品| 日韩一区二区三区四区| 日本欧美肥老太交大片| 欧美一区二区三区公司| 亚洲一级二级三级| 色悠久久久久综合欧美99| 亚洲色图另类专区| 91精品欧美久久久久久动漫| 青青草原综合久久大伊人精品 | 亚洲一二三四区不卡| 91在线高清观看| 亚洲天堂网中文字| 94-欧美-setu| 亚洲成a人片在线观看中文| 欧美在线看片a免费观看| 亚洲h精品动漫在线观看| 欧美日韩国产a| 蜜乳av一区二区| 久久久久久久久久久久久久久99 | 久久成人免费网| 久久奇米777| www.日韩在线| 亚洲精选视频在线| 欧美人与性动xxxx| 麻豆成人久久精品二区三区小说| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 久久精品久久久精品美女| 欧美刺激午夜性久久久久久久| 精品亚洲成a人| 国产精品久久久久一区二区三区共| gogogo免费视频观看亚洲一| 亚洲女同ⅹxx女同tv| 欧美久久高跟鞋激| 国产精品亚洲一区二区三区妖精 | 久久久91精品国产一区二区三区| 成人中文字幕在线| 伊人性伊人情综合网| 欧美一级黄色大片| 日韩精品自拍偷拍| 成人h动漫精品一区二| 日韩精品欧美精品| 国产精品久久久久久久久动漫 | 免费成人美女在线观看.| 亚洲国产高清在线| 欧美一级欧美三级在线观看| 国产高清久久久久| 天天综合日日夜夜精品| 国产欧美日韩在线| 欧美日韩免费电影| av成人免费在线| 毛片不卡一区二区| 一区二区三区精品视频| 久久天堂av综合合色蜜桃网| 欧美亚洲综合一区| 波多野结衣中文字幕一区| 久久99在线观看| 亚洲午夜激情网站| 亚洲丝袜美腿综合| 国产亚洲欧美日韩在线一区| 3d成人动漫网站| 一本大道久久a久久精二百| 激情深爱一区二区| 秋霞电影一区二区| 亚洲午夜在线观看视频在线| 国产精品色婷婷久久58| 久久这里只有精品视频网| 欧美精品少妇一区二区三区| 99久久免费视频.com| 国产福利一区二区三区视频| 久久爱www久久做| 天天影视涩香欲综合网| 一区二区高清在线| 国产精品久久看| 国产精品污www在线观看| 久久午夜色播影院免费高清| 日韩一级二级三级| 制服视频三区第一页精品| 欧美日韩你懂得| 欧美在线免费观看视频| 91免费国产在线观看| 99精品偷自拍| 91在线看国产| 97超碰欧美中文字幕| 91蜜桃在线观看| 91蝌蚪porny九色| 97精品视频在线观看自产线路二| 国产成人午夜精品5599| 国产激情一区二区三区四区 | 欧美日韩卡一卡二| 欧美日韩视频在线观看一区二区三区| 99re热视频这里只精品| 成人福利视频网站| 不卡视频免费播放| 93久久精品日日躁夜夜躁欧美| av成人免费在线观看| 精品99999| 国产欧美日韩视频在线观看| 中文字幕乱码亚洲精品一区| 国产精品蜜臀在线观看| 亚洲欧美激情插| 午夜免费欧美电影| 久久精品国产久精国产爱| 国内成人免费视频| 成人自拍视频在线| 色狠狠色狠狠综合| 欧美乱妇23p| 久久色在线观看| 国产精品久久久久三级| 一区二区三区不卡在线观看| 一区av在线播放| 美女视频黄久久| 成人网在线播放| 91蜜桃传媒精品久久久一区二区| 欧美日韩在线一区二区| 精品欧美乱码久久久久久| 国产经典欧美精品| 国产成人亚洲综合色影视| 成人深夜在线观看| 在线视频欧美精品| 日韩欧美一级精品久久| 欧美国产丝袜视频| 亚洲成人一区在线| 国产自产高清不卡| 91麻豆swag| 日韩欧美中文一区二区| 日本一区二区视频在线观看| 亚洲综合一区二区精品导航| 视频一区二区国产| 丁香六月综合激情| 欧美精品色综合| 综合av第一页| 老司机精品视频一区二区三区| 成人av小说网| 欧美变态凌虐bdsm| 亚洲资源中文字幕| 经典三级在线一区| 色婷婷国产精品综合在线观看| 欧美成人女星排名| 一区二区三区高清| 国产精品亚洲第一| 91精品婷婷国产综合久久| 中文在线一区二区| 精品一区二区综合| 欧美性生活一区| 国产精品私房写真福利视频| 久久丁香综合五月国产三级网站| 在线一区二区视频| 亚洲欧洲一区二区三区| 国产真实乱对白精彩久久| 9191精品国产综合久久久久久 | 国产精选一区二区三区| 欧美日韩国产高清一区二区| 日韩久久一区二区| 国产成人欧美日韩在线电影| 51精品秘密在线观看| 亚洲综合自拍偷拍| 成人av免费观看| 国产日韩欧美综合在线| 美洲天堂一区二卡三卡四卡视频| 欧美日韩亚洲高清一区二区| 一区二区三区资源| 99久久精品国产一区二区三区| 久久精品一区四区| 欧美性videosxxxxx| 一区二区三区av电影 | 亚洲激情校园春色| 成人97人人超碰人人99| 国产精品免费视频一区| 成人sese在线| 亚洲天堂成人在线观看| 99re这里只有精品6| 最近日韩中文字幕|