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

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

?? demo12_6.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// DEMO12_6.CPP - pattern demo with tracking instruction
// 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

#define NUM_PATTERNS    4     // number of patterns in system

// pattern instruction opcodes for skelaton

// directional instructions
#define OPC_E    0  // move west
#define OPC_NE   1  // move northeast
#define OPC_N    2  // move north
#define OPC_NW   3  // move northwest
#define OPC_W    4  // move west
#define OPC_SW   5  // move southwest
#define OPC_S    6  // move south
#define OPC_SE   7  // move southeast

// special instructions
#define OPC_STOP        8  // stop for a moment
#define OPC_RAND        9  // select a random direction
#define OPC_TEST_DIST   10 // test distance 
#define OPC_END        -1  // end pattern


#define MIN_LONELYNESS  100 // minimum distance before skelaton
                            // gets lonely for its pet bat

// 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          skelaton;         // the AI skelaton

BOB          bat;                // this time your the bat
int          bat_sound_id  = -1, // sound of bat flapping wings
             laugh_sound_id = -1; // sound of skelaton laughing

// animation sequences for bob
int skelaton_anims[8][4] = { {0,1,0,2},
                             {0+4,1+4,0+4,2+4},
                             {0+8,1+8,0+8,2+8},
                             {0+12,1+12,0+12,2+12},
                             {0+16,1+16,0+16,2+16},
                             {0+20,1+20,0+20,2+20},
                             {0+24,1+24,0+24,2+24},
                             {0+28,1+28,0+28,2+28}, };


// patterns in opcode operand format
int pattern_1[] = {OPC_W, 10, OPC_NW, 10, OPC_N, 10, OPC_NE, 10, 
                   OPC_TEST_DIST, 50, // a distance test
                   OPC_E, 10, OPC_SE, 10, OPC_S, 10, OPC_SW, 10, 
                   OPC_W, 10, OPC_RAND, 10,
                   OPC_TEST_DIST, 50, // a distance test                   
                   OPC_W, 20, OPC_NW, 10, OPC_N, 20, OPC_NE, 10, 
                   OPC_E, 20, OPC_SE, 10, OPC_S, 20, OPC_SW, 10, 
                   OPC_TEST_DIST, 50, // a distance test
                   OPC_W, 10, OPC_END,0};
                   

int pattern_2[] = {OPC_E, 20, OPC_W, 20, OPC_STOP, 20, OPC_NE, 10, 
                   OPC_TEST_DIST, 50, // a distance test                   
                   OPC_W, 10, OPC_NW, 10, OPC_SW, 20, OPC_NW, 20, 
                   OPC_TEST_DIST, 50, // a distance test
                   OPC_SW, 20, OPC_NW, 30, OPC_SW, 10, OPC_S, 50,  
                   OPC_TEST_DIST, 50, // a distance test                   
                   OPC_W, 2, OPC_NW, 2, OPC_N, 2, OPC_NE, 50,  OPC_TEST_DIST, 50, // a distance test
                   OPC_E,2, OPC_SE,2, OPC_S,2, OPC_RAND, 10, OPC_END,0};



int pattern_3[] = { OPC_N, 10, OPC_S, 10, OPC_N, 10, OPC_S, 10, 
                    OPC_TEST_DIST, 50, // a distance test                    
                    OPC_E, 10, OPC_W, 10, OPC_E, 10, OPC_W, 10,
                    OPC_TEST_DIST, 50, // a distance test
                    OPC_NW, 10, OPC_N, 10, OPC_NE, 10, OPC_N, 10, 
                    OPC_TEST_DIST, 60, // a distance test
                    OPC_STOP, 20, OPC_RAND, 5, OPC_E, 50, OPC_S, 50, OPC_W, 50, 
                    OPC_TEST_DIST, 50, // a distance test                    
                    OPC_E, 10, OPC_E, 10, OPC_E, 10, OPC_NW, 100,   OPC_TEST_DIST, 60, // a distance test
                    OPC_STOP, 10, OPC_END,0};


int pattern_4[] = {OPC_W, 100, 
                   OPC_NW, 2,OPC_N, 2,OPC_NE, 2,
                   OPC_E, 100, 
                   OPC_NE, 2,OPC_N, 2,OPC_NW, 2,
                   OPC_TEST_DIST, 50, // a distance test                    
                   OPC_W, 100, 
                   OPC_NW, 2,OPC_N, 2,OPC_NE, 2,
                   OPC_E, 100, 
                   OPC_NE, 2,OPC_N, 2,OPC_NW, 2,
                   OPC_TEST_DIST, 50, // a distance test                    
                   OPC_W, 100, 
                   OPC_NW, 2,OPC_N, 2,OPC_NE, 2,
                   OPC_E, 100, 
                   OPC_NE, 2,OPC_N, 2,OPC_NW, 2,
                   OPC_TEST_DIST, 50, // a distance test
                   OPC_RAND, 10, OPC_RAND, 5,

                   OPC_SW, 2,OPC_S, 2,OPC_SE, 2,
                   OPC_E, 100, 
                   OPC_TEST_DIST, 50, // a distance test
                   OPC_SE, 2,OPC_S, 2,OPC_SW, 2,
                   OPC_W, 100,
                   OPC_TEST_DIST, 50, // a distance test
                   OPC_SW, 2,OPC_S, 2,OPC_SE, 2,
                   OPC_E, 100, 
                   OPC_SE, 2,OPC_S, 2,OPC_SW, 2,
                   OPC_W, 100,
                   OPC_TEST_DIST, 50, // a distance test
                   OPC_SW, 2,OPC_S, 2,OPC_SE, 2,
                   OPC_E, 100, 
                   OPC_TEST_DIST, 50, // a distance test
                   OPC_SE, 2,OPC_S, 2,OPC_SW, 2,
                   OPC_W, 100, OPC_END,0};

// master pattern array
int *patterns[NUM_PATTERNS] = {pattern_1, pattern_2, pattern_3, pattern_4};

int *curr_pattern=NULL;  // current pattern being processed

int opcode,                   // general opcode
    operand,                  // general operand
    skelaton_ip     =0,       // pattern instruction pointer for skelaton
    skelaton_counter=0,       // counter of pattern control
    skelaton_pattern_index;   // the current pattern being executed

// used as a index to string lookup to help print out
char *opcode_names[] = {"OPC_E",
                        "OPC_NE", 
                        "OPC_N",    
                        "OPC_NW",   
                        "OPC_W",    
                        "OPC_SW",   
                        "OPC_S",    
                        "OPC_SE",   
                        "OPC_STOP", 
                        "OPC_RAND", 
                        "OPC_TEST_DIST"};  
// sound stuff

// 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
						  "Pattern demo with embedded instructions",	 // 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
int skelaton_anim[2];

char filename[80]; // used to build up filenames

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

// load background image
Load_Bitmap_File(&bitmap8bit, "DUNGEON.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 bat bitmaps
Load_Bitmap_File(&bitmap8bit, "BATS8_2.BMP");

// create bat bob
Create_BOB(&bat,320,200, 16,16, 5, BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY);
Set_Anim_Speed_BOB(&bat, 2);

// load the bat in 
for (index=0; index < 5; index++)
    Load_Frame_BOB(&bat, &bitmap8bit, index, index, 0, BITMAP_EXTRACT_MODE_CELL);

// unload bat
Unload_Bitmap_File(&bitmap8bit);


// create skelaton bob
if (!Create_BOB(&skelaton,0,0,56,72,32,
           BOB_ATTR_VISIBLE | BOB_ATTR_MULTI_ANIM,DDSCAPS_SYSTEMMEMORY))
   return(0);

// load the frames in 8 directions, 4 frames each
// each set of frames has a walk and a fire, frame sets
// are loaded in counter clockwise order looking down
// from a birds eys view or the x-z plane
for (int direction = 0; direction < 8; direction++)
    { 
    // build up file name
    sprintf(filename,"SKELSP%d.BMP",direction);

    // load in new bitmap file
    Load_Bitmap_File(&bitmap8bit,filename);
 
    Load_Frame_BOB(&skelaton,&bitmap8bit,0+direction*4,0,0,BITMAP_EXTRACT_MODE_CELL);  
    Load_Frame_BOB(&skelaton,&bitmap8bit,1+direction*4,1,0,BITMAP_EXTRACT_MODE_CELL);  
    Load_Frame_BOB(&skelaton,&bitmap8bit,2+direction*4,2,0,BITMAP_EXTRACT_MODE_CELL);  
    Load_Frame_BOB(&skelaton,&bitmap8bit,3+direction*4,0,1,BITMAP_EXTRACT_MODE_CELL);  

    // unload the bitmap file
    Unload_Bitmap_File(&bitmap8bit);

    // set the animation sequences for skelaton
    Load_Animation_BOB(&skelaton,direction,4,skelaton_anims[direction]);

    } // end for direction

// set up stating state of skelaton
Set_Animation_BOB(&skelaton, 0);
Set_Anim_Speed_BOB(&skelaton, 4);
Set_Vel_BOB(&skelaton, 0,0);
Set_Pos_BOB(&skelaton, 0, 128);

// initialize directinput
DInput_Init();

// acquire the keyboard only
DInput_Init_Keyboard();

// initilize DirectSound
DSound_Init();

// load background sounds
bat_sound_id = DSound_Load_WAV("BAT.WAV");
laugh_sound_id = DSound_Load_WAV("LAUGH.WAV");

// start the sounds
DSound_Play(bat_sound_id, DSBPLAY_LOOPING);

// set clipping rectangle to screen extents so objects dont
// mess up at edges
RECT screen_rect = {0,0,screen_width,screen_height};
lpddclipper = DDraw_Attach_Clipper(lpddsback,1,&screen_rect);

// hide the mouse
ShowCursor(FALSE);

// seed random number generate
srand(Start_Clock());

// 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 bobs
Destroy_BOB(&skelaton);
Destroy_BOB(&bat);

// shutdown directdraw last
DDraw_Shutdown();

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

// shut down directinput
DInput_Shutdown();

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

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

void Skelaton_AI(void)
{
// this function controls the ai of the skelaton and the pattern
// processing

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩亚洲欧美成人一区| 久久成人免费电影| 看电视剧不卡顿的网站| 9人人澡人人爽人人精品| 欧美日韩国产一二三| 国产精品妹子av| 久久国产乱子精品免费女| 在线视频一区二区三| 久久久99免费| 麻豆精品在线观看| 欧美精品免费视频| 亚洲男人电影天堂| 99久久免费国产| 国产日韩欧美综合一区| 久久精品国产久精国产爱| 精品视频免费在线| 亚洲欧美色图小说| 本田岬高潮一区二区三区| 精品久久久久久久久久久久久久久久久 | 日韩—二三区免费观看av| 97久久超碰精品国产| 国产片一区二区三区| 国产一区二区三区免费播放| 欧美一区二区福利视频| 日韩高清一区二区| 欧美高清激情brazzers| 亚洲国产综合91精品麻豆| 欧美午夜一区二区三区| 一区二区三区蜜桃| 色呦呦国产精品| 亚洲午夜久久久久久久久久久| 91视频免费看| 怡红院av一区二区三区| 欧日韩精品视频| 亚洲免费在线电影| 欧美亚洲国产bt| 亚洲成人在线观看视频| 欧美日韩日日摸| 日本不卡视频一二三区| 在线综合视频播放| 捆绑紧缚一区二区三区视频| 精品福利av导航| 国内精品在线播放| 久久久精品免费网站| 国产1区2区3区精品美女| 国产欧美日韩一区二区三区在线观看| 国产传媒欧美日韩成人| 国产精品美女久久久久久| 91啪亚洲精品| 亚洲bt欧美bt精品| 欧美sm极限捆绑bd| 99久久婷婷国产精品综合| 亚洲综合视频在线观看| 91精品国产色综合久久不卡电影 | 色综合天天综合在线视频| 亚洲综合另类小说| 欧美一级二级三级蜜桃| 狠狠狠色丁香婷婷综合久久五月| 国产日韩精品视频一区| 色一情一乱一乱一91av| 免费在线欧美视频| 自拍偷拍国产亚洲| 3d动漫精品啪啪一区二区竹菊| 国产激情一区二区三区桃花岛亚洲| 国产精品久久久一区麻豆最新章节| 一本色道**综合亚洲精品蜜桃冫| 青娱乐精品在线视频| 国产三区在线成人av| 欧美主播一区二区三区| 国产激情精品久久久第一区二区| 伊人一区二区三区| 国产亚洲一区二区三区四区| 欧美伊人久久大香线蕉综合69 | www国产亚洲精品久久麻豆| 成人国产精品免费网站| 日韩vs国产vs欧美| 亚洲日本青草视频在线怡红院| 6080午夜不卡| 99精品视频一区二区三区| 久久99热狠狠色一区二区| 亚洲狠狠爱一区二区三区| 欧美—级在线免费片| 欧美精品三级在线观看| 色综合天天性综合| 国产精品影音先锋| 蜜桃久久av一区| 亚洲国产欧美在线| 亚洲视频香蕉人妖| 欧美国产国产综合| 精品国产区一区| 欧美精品成人一区二区三区四区| 99久久精品国产毛片| 国产河南妇女毛片精品久久久| 美脚の诱脚舐め脚责91 | 欧美亚洲综合网| 91色porny蝌蚪| 夫妻av一区二区| 精品在线亚洲视频| 日韩av电影一区| 一区二区三区波多野结衣在线观看| 亚洲国产成人私人影院tom | 美女免费视频一区| 日本伊人色综合网| 亚洲成人精品在线观看| 亚洲精品国产视频| 亚洲视频免费在线| 亚洲视频一区二区在线| 亚洲欧美中日韩| 国产精品短视频| 亚洲视频网在线直播| 综合电影一区二区三区| 亚洲色图欧美偷拍| 亚洲欧美成人一区二区三区| 欧美国产日韩一二三区| 国产欧美日韩在线观看| 日本一区二区动态图| 国产欧美久久久精品影院| 国产精品久久久久久久久晋中 | 成人黄色网址在线观看| 成人国产精品免费| a4yy欧美一区二区三区| 在线视频中文字幕一区二区| 欧美午夜精品久久久久久超碰| 欧美日韩一区二区电影| 在线电影一区二区三区| 欧美一级高清大全免费观看| 精品国产乱码久久久久久浪潮| 久久久久久久免费视频了| 亚洲国产岛国毛片在线| 亚洲欧洲av另类| 亚洲国产日韩一区二区| 蜜臀av一区二区| 国产福利一区二区三区在线视频| 成人午夜电影网站| 色妹子一区二区| 欧美日韩精品欧美日韩精品一 | 美腿丝袜亚洲三区| 国产乱子轮精品视频| 不卡一区二区三区四区| 欧美三片在线视频观看| 日韩精品一区二区三区蜜臀| 国产色一区二区| 亚瑟在线精品视频| 久久精品国产久精国产| 99久久99久久精品免费看蜜桃| 欧美午夜在线一二页| 精品伦理精品一区| 亚洲人123区| 久久国产尿小便嘘嘘尿| a级精品国产片在线观看| 欧美久久久久久久久久| 久久久久久97三级| 亚洲一二三专区| 国产麻豆精品视频| 欧美日韩国产另类一区| 国产欧美精品日韩区二区麻豆天美 | 丝袜亚洲另类欧美| 成人免费视频播放| 欧美日韩午夜在线| 国产欧美一区二区精品忘忧草 | 中文字幕第一区综合| 亚洲成av人片观看| www.欧美.com| 精品国产百合女同互慰| 五月婷婷欧美视频| 成人av影院在线| 亚洲精品在线一区二区| 亚洲激情图片小说视频| 国产成人精品1024| 欧美一区二区人人喊爽| 亚洲婷婷综合久久一本伊一区| 美女在线一区二区| 欧美日韩激情在线| 亚洲丝袜制服诱惑| 成人午夜激情片| 久久久国产精华| 蜜桃传媒麻豆第一区在线观看| 欧洲人成人精品| 亚洲欧美日韩国产综合| 风间由美一区二区三区在线观看| 91精品国产品国语在线不卡| 一区二区三区在线观看欧美| 波多野结衣中文字幕一区| 2017欧美狠狠色| 久久精品国产精品亚洲综合| 欧美高清dvd| 亚洲成a人片在线观看中文| 日本高清成人免费播放| 国产精品成人午夜| 成人免费毛片a| 国产日韩欧美综合在线| 国产精品18久久久久久vr| 日韩欧美中文字幕公布| 日韩成人免费电影| 91精品国产综合久久久久| 丝袜脚交一区二区| 69久久99精品久久久久婷婷 | 国产精品污网站| 成人高清视频在线| 最新国产成人在线观看|