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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? demo12_4.cpp

?? 一本外國人寫的關(guān)于3D游戲編程的書的源碼
?? CPP
字號:
// DEMO12_4.CPP - evasion 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

// 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          bat,              // the ai bat bob
             ghost;            // the player ghost bob

static int ghost_anim[] = {0,1,2,1}; // animation sequence for ghost

int bat_sound_id  = -1,        // sound of bat flapping wings
    wind_sound_id = -1;        // the ambient wind

// 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
						  "Evasion 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, "GHOSTBACK.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);

// load the ghost bitmaps
Load_Bitmap_File(&bitmap8bit, "GHOSTS8.BMP");

// create ghost bob
Create_BOB(&ghost,100,200, 64,100, 3, BOB_ATTR_MULTI_ANIM | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY);
Set_Anim_Speed_BOB(&ghost, 10);

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

// unload ghost
Unload_Bitmap_File(&bitmap8bit);

// set animation for ghost
Load_Animation_BOB(&ghost, 0, 4, ghost_anim);

// set the animation
Set_Animation_BOB(&ghost,0);

// 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");
wind_sound_id = DSound_Load_WAV("WIND.WAV");

// start the sounds
DSound_Play(bat_sound_id, DSBPLAY_LOOPING);
DSound_Play(wind_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);

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

// 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 Bat_AI(void)
{
// this function performs the bat ai

// do evasion algorithm

// only evade if bat is within specified distance
// otherwise bat will end up in corner

if ((abs(bat.x-ghost.x) + abs(bat.y-ghost.y))<250)
{
// first x-axis    
if (ghost.x < bat.x)
   bat.x+=2;
else
if (ghost.x > bat.x)
   bat.x-=2;

// now y-axis
if (ghost.y < bat.y)
   bat.y+=2;
else
if (ghost.y > bat.y)
   bat.y-=2;
} // end if
else
    {
    // just move back to center of screen
    // first x-axis    
    if (SCREEN_WIDTH/2 > bat.x)
       bat.x+=1;
    else
    if (SCREEN_WIDTH/2 < bat.x)
       bat.x-=1;
    
    // now y-axis
    if (SCREEN_HEIGHT/2 > bat.y)
       bat.y+=1;
    else
    if (SCREEN_HEIGHT/2 < bat.y)
       bat.y-=1;

    } // end else

// check boundaries
if (bat.x >= SCREEN_WIDTH)
   bat.x = -bat.width;
else
if (bat.x < -bat.width)
   bat.x = SCREEN_WIDTH;

if (bat.y >= SCREEN_HEIGHT)
   bat.y = -bat.height;
else
if (bat.y < -bat.height)
   bat.y = SCREEN_HEIGHT;

} // end Bat_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

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

// read keyboard
DInput_Read_Keyboard();

// call the bat AI
Bat_AI();

// the animate the bat
Animate_BOB(&bat);

// draw the bat
Draw_BOB(&bat, lpddsback);

// allow player to move
if (keyboard_state[DIK_RIGHT])
   ghost.x+=4;
else
if (keyboard_state[DIK_LEFT])
   ghost.x-=4;

if (keyboard_state[DIK_UP])
   ghost.y-=4;
else
if (keyboard_state[DIK_DOWN])
   ghost.y+=4;

// test if player is off screen, if so wrap around
if (ghost.x >= SCREEN_WIDTH)
   ghost.x = -ghost.width;
else
if (ghost.x < -ghost.width)
   ghost.x = SCREEN_WIDTH;

if (ghost.y >= SCREEN_HEIGHT)
   ghost.y = -ghost.height;
else
if (ghost.y < -ghost.height)
   ghost.y = SCREEN_HEIGHT;

// the animate the ghost
Animate_BOB(&ghost);

// draw the ghost
Draw_BOB(&ghost, lpddsback);

// draw title
Draw_Text_GDI("GOING BATS! - Evasion Demo",10, 10,RGB(0,255,0), lpddsback);

// flip the surfaces
DDraw_Flip();

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

// check of user is trying to exit
if (KEY_DOWN(VK_ESCAPE) || keyboard_state[DIK_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

// return success
return(1);

} // end Game_Main

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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99r国产精品| 国内不卡的二区三区中文字幕| 成人国产精品免费网站| 欧美国产综合色视频| 91在线精品秘密一区二区| 中文字幕在线免费不卡| 91麻豆产精品久久久久久| 亚洲午夜国产一区99re久久| 777精品伊人久久久久大香线蕉| 日本91福利区| 国产亚洲精品免费| 91美女片黄在线| 亚洲一二三四在线| 欧美精品一区二区三区蜜桃视频| 国产夫妻精品视频| 一区二区视频在线| 日韩一区二区三区在线视频| 国产成人啪午夜精品网站男同| 中文字幕亚洲在| 91精品国模一区二区三区| 国产一区二区电影| 亚洲在线视频免费观看| 日韩一区二区三区电影在线观看| 国产精品1区二区.| 亚洲永久精品大片| 久久噜噜亚洲综合| 精品视频在线免费观看| 国产一区在线视频| 亚洲电影在线播放| 26uuu色噜噜精品一区| 91视频国产资源| 免费在线一区观看| 综合激情网...| 精品美女被调教视频大全网站| 成人av在线一区二区三区| 亚洲电影激情视频网站| 国产精品嫩草影院av蜜臀| 欧美色爱综合网| 风间由美性色一区二区三区| 香蕉影视欧美成人| 中文字幕中文乱码欧美一区二区| 欧美一级片在线观看| a美女胸又www黄视频久久| 青青草国产成人av片免费| 国产精品免费人成网站| 日韩欧美精品在线视频| 欧美性高清videossexo| 成人高清伦理免费影院在线观看| 日本不卡一区二区三区高清视频| 中文字幕欧美区| 日韩精品最新网址| 欧美日韩国产一区| 色香色香欲天天天影视综合网| 久久精品国产**网站演员| 亚洲在线观看免费视频| 中文字幕一区在线| 久久精品人人爽人人爽| 日韩免费一区二区三区在线播放| 欧美性高清videossexo| 91免费国产在线观看| 国产成人午夜99999| 老司机一区二区| 日韩成人一级片| 午夜久久电影网| 一区二区不卡在线视频 午夜欧美不卡在| 国产欧美一区二区三区在线看蜜臀 | 国产精品乱码妇女bbbb| 精品国产成人在线影院| 欧美精品 国产精品| 欧美日精品一区视频| 91成人在线免费观看| 一本一道久久a久久精品| 99精品黄色片免费大全| 91无套直看片红桃| 色噜噜久久综合| 欧美午夜精品久久久久久孕妇| 一本大道久久a久久精品综合| 成人精品小蝌蚪| 99久久精品免费看国产免费软件| 成人午夜在线播放| eeuss鲁片一区二区三区| 成人app软件下载大全免费| 99精品国产视频| 一本色道a无线码一区v| 欧美伊人精品成人久久综合97| 91色.com| 在线观看91精品国产麻豆| 欧美一级夜夜爽| 久久久久久久性| 国产精品丝袜一区| 亚洲欧美一区二区久久 | 亚洲美女一区二区三区| 亚洲精品视频在线观看网站| 亚洲综合色丁香婷婷六月图片| 香蕉av福利精品导航| 久久精品国产精品亚洲精品| 国产成人啪免费观看软件| 99r国产精品| 欧美男女性生活在线直播观看| 欧美精品久久一区二区三区| 日韩欧美中文一区二区| 久久久精品免费免费| 中文字幕一区二区三区四区不卡| 亚洲毛片av在线| 日本午夜一本久久久综合| 精品一区二区免费| 成人aa视频在线观看| 欧美日韩大陆一区二区| 久久精品视频一区二区三区| 中文字幕亚洲一区二区av在线| 亚洲成人av一区二区| 国产呦萝稀缺另类资源| 日本高清成人免费播放| 欧美一二区视频| 亚洲欧洲成人自拍| 免费在线成人网| 91亚洲精品一区二区乱码| 538prom精品视频线放| 国产欧美日韩另类视频免费观看| 亚洲毛片av在线| 国产精品亚洲一区二区三区在线| 色哟哟精品一区| 国产日产亚洲精品系列| 偷拍亚洲欧洲综合| 成人激情小说网站| 欧美一二三区在线观看| 亚洲欧洲制服丝袜| 国产麻豆精品在线观看| 欧美精品乱码久久久久久| 国产精品久久久久久久午夜片| 日韩高清一级片| 91麻豆国产在线观看| 国产偷国产偷精品高清尤物| 亚洲国产日韩a在线播放性色| 国产美女视频91| 欧美日韩美女一区二区| 国产精品对白交换视频| 精品一区免费av| 91搞黄在线观看| 亚洲欧洲性图库| 国产v综合v亚洲欧| 日韩欧美久久久| 午夜免费欧美电影| 在线精品视频一区二区| 1024成人网| 国产成人精品亚洲午夜麻豆| 精品欧美乱码久久久久久1区2区| 一区二区在线观看免费视频播放| 风间由美性色一区二区三区| 精品国产伦一区二区三区观看体验| 亚洲一二三四在线| 一本到不卡精品视频在线观看| 欧美极品少妇xxxxⅹ高跟鞋| 久久99热99| 日韩欧美国产高清| 免费观看在线综合色| 91精品国产综合久久久久久久久久| 夜夜爽夜夜爽精品视频| 99久久精品免费看| 亚洲三级电影网站| 色诱视频网站一区| 亚洲一区在线播放| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 久久9热精品视频| 欧美一区二区日韩| 日韩精品成人一区二区三区| 欧美亚洲综合一区| 亚洲国产综合视频在线观看| 欧美在线看片a免费观看| 亚洲影院理伦片| 欧美精品九九99久久| 亚洲aaa精品| 日韩精品中午字幕| 国产在线视频精品一区| 久久精品一区四区| 成人国产在线观看| 亚洲视频免费看| 欧美三级韩国三级日本一级| 爽好久久久欧美精品| 91精品视频网| 国产.欧美.日韩| 自拍偷拍亚洲欧美日韩| 欧美日韩一卡二卡三卡| 青青草原综合久久大伊人精品优势| 日韩午夜激情视频| 国产精品18久久久久久vr| 国产精品九色蝌蚪自拍| 91九色最新地址| 人人狠狠综合久久亚洲| 久久久综合网站| 色呦呦一区二区三区| 天天综合日日夜夜精品| 欧美大度的电影原声| 成人一区二区视频| 亚洲一卡二卡三卡四卡五卡| 欧美变态tickle挠乳网站| 国产成人综合在线播放| 亚洲激情图片qvod| 2020日本不卡一区二区视频| 91麻豆国产在线观看|