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

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

?? demo12_4_16b.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
字號:
// DEMO12_4_16b.CPP - evasion demo
// 16-bit version, make sure your desktop is 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 Evasion 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

// 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
             arch;             // to do the 3d arch effect

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

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, "GHOSTBACK_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 bat bitmaps
Load_Bitmap_File(&bitmap16bit, "BATS8_2_24.BMP");

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

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

// create the arch bob
Create_BOB(&arch,320,200, 128,152, 1, BOB_ATTR_SINGLE_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY,0,16);

// load the arch
Load_Frame_BOB16(&arch, &bitmap16bit, 0,1,18, BITMAP_EXTRACT_MODE_ABS);

// unload arch and bat bitmap
Unload_Bitmap_File(&bitmap16bit);


// load the ghost bitmaps
Load_Bitmap_File(&bitmap16bit, "GHOSTS8_24.BMP");

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

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

// unload ghost
Unload_Bitmap_File(&bitmap16bit);

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

// hide the mouse
if (!WINDOWED_APP)
   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_Bitmap16(&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_BOB16(&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_BOB16(&ghost, lpddsback);

// draw the arches to create a 3D effect
Set_Pos_BOB(&arch, 18, 270);
Draw_BOB16(&arch, lpddsback);

Set_Pos_BOB(&arch, 496, 270);
Draw_BOB16(&arch, lpddsback);

// draw title
Draw_Text_GDI("(16-Bit Version) 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();

    } // end if

// return success
return(1);

} // end Game_Main

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美在线一区二区| 国产精品乱码一区二三区小蝌蚪| 欧美tk—视频vk| 亚洲丝袜另类动漫二区| 国产一区二区0| 欧美一区二区三区视频在线| 国产精品乱码久久久久久| 日本成人超碰在线观看| 欧美影视一区在线| 中文字幕一区二区三区精华液 | 免费精品视频在线| 一本大道久久a久久精二百| 国产拍欧美日韩视频二区| 美女网站色91| 91精品国产手机| 亚洲国产综合色| 在线观看亚洲a| 亚洲激情五月婷婷| 色婷婷久久久久swag精品| 国产精品的网站| 99久久国产免费看| 1000精品久久久久久久久| 成人av资源下载| 中国色在线观看另类| 国产成人自拍网| 国产嫩草影院久久久久| 国产一本一道久久香蕉| 久久午夜色播影院免费高清| 精品一区二区三区免费| 精品久久久久久最新网址| 蜜臀av性久久久久蜜臀aⅴ四虎| 91精品国产综合久久精品app| 亚洲一区二区三区视频在线| 在线免费观看日韩欧美| 亚洲美女视频在线| 欧美亚洲尤物久久| 日韩中文字幕区一区有砖一区| 欧美日韩国产中文| 日本三级亚洲精品| 欧美变态tickling挠脚心| 国产一区二区三区免费观看| 国产日韩欧美不卡在线| 91片在线免费观看| 亚洲精品高清在线观看| 欧美日韩小视频| 久久99精品久久久久婷婷| 久久久久久9999| 成人黄色网址在线观看| 一区二区免费在线| 欧美一级久久久| 国产成人啪免费观看软件| 日本一区二区电影| 色呦呦国产精品| 青青草91视频| 国产精品麻豆久久久| 欧美性高清videossexo| 狠狠狠色丁香婷婷综合激情| 日日夜夜精品视频免费| 精品久久久三级丝袜| av午夜精品一区二区三区| 一区二区三区精品在线| 精品久久久久久最新网址| 成人h动漫精品一区二| 婷婷亚洲久悠悠色悠在线播放| 久久综合色播五月| 在线视频你懂得一区| 精品中文字幕一区二区| 亚洲乱码一区二区三区在线观看| 欧美一区二区三区成人| eeuss国产一区二区三区| 亚洲123区在线观看| 国产欧美日产一区| 在线不卡免费欧美| 99久久精品免费| 久久疯狂做爰流白浆xx| 1024亚洲合集| 久久久久久夜精品精品免费| 欧美午夜精品久久久久久孕妇 | 免费看欧美美女黄的网站| 国产精品国产三级国产有无不卡| 欧美一区二区三区四区高清| 99视频一区二区三区| 久久精品国产99| 亚洲成人在线网站| 国产精品久久久久久久久快鸭| 日韩精品一区二区三区视频在线观看 | 一级日本不卡的影视| 国产欧美精品一区| 欧美一级二级三级蜜桃| 91国偷自产一区二区三区观看| 国产福利一区二区三区视频在线 | 欧美成人精品高清在线播放| 欧洲av在线精品| 91美女在线看| 国产成人综合在线播放| 韩国av一区二区| 另类小说视频一区二区| 视频一区二区三区入口| 亚洲夂夂婷婷色拍ww47| 中文字幕日韩av资源站| 欧美国产丝袜视频| 国产日韩视频一区二区三区| 精品国产免费人成在线观看| 日韩欧美国产一二三区| 在线电影院国产精品| 欧美高清视频www夜色资源网| 欧美亚州韩日在线看免费版国语版| 不卡视频一二三| 不卡av在线网| 91捆绑美女网站| 一本一本久久a久久精品综合麻豆| jlzzjlzz欧美大全| 国产成人在线视频网站| 成人av第一页| 色噜噜久久综合| 91高清视频在线| 在线电影国产精品| 欧美xxxxx裸体时装秀| 日韩一区二区精品葵司在线| 日韩欧美一区二区在线视频| 欧美成人官网二区| 国产丝袜欧美中文另类| 久久久久久毛片| 中文字幕高清不卡| 亚洲欧洲性图库| 一区二区三区欧美激情| 午夜久久福利影院| 日韩经典中文字幕一区| 国产一区二区三区不卡在线观看| 国产成人精品影视| 91麻豆产精品久久久久久 | 视频一区二区不卡| 精品一区二区在线播放| 岛国av在线一区| 色偷偷88欧美精品久久久| 欧美男人的天堂一二区| 欧美一区二区视频在线观看2022| 精品精品国产高清一毛片一天堂| 国产亚洲综合在线| 亚洲永久免费视频| 韩国av一区二区三区四区| 99久久免费精品高清特色大片| 欧美日韩亚州综合| 久久精品一区四区| 亚洲欧美激情在线| 看片的网站亚洲| 91色乱码一区二区三区| 日韩亚洲欧美一区二区三区| 中文字幕视频一区二区三区久| 三级在线观看一区二区| 国产成人在线免费| 欧美日韩情趣电影| 日本一区二区三区国色天香| 亚洲成人免费观看| 国产成人免费9x9x人网站视频| 欧美性一区二区| 欧美国产亚洲另类动漫| 日韩精品成人一区二区在线| aaa欧美日韩| 久久夜色精品国产噜噜av| 亚洲一区二区在线免费观看视频| 国产一区二区视频在线播放| 欧美又粗又大又爽| 欧美国产日韩一二三区| 日本在线不卡视频| 色狠狠一区二区| 国产亚洲欧美日韩日本| 日本v片在线高清不卡在线观看| 成人av在线影院| 久久青草欧美一区二区三区| 五月天欧美精品| 在线观看日韩电影| 日本一区二区三区久久久久久久久不 | 国产成人午夜电影网| 9191国产精品| 一区二区三区免费| 91在线国产观看| 中文字幕高清一区| 国产精品996| 欧美大白屁股肥臀xxxxxx| 日日欢夜夜爽一区| 欧美日韩亚洲综合一区二区三区| 国产精品成人免费| 成人黄色av电影| 国产日韩欧美综合一区| 国产成人自拍在线| 久久精品免视看| 国产精品亚洲一区二区三区妖精| 欧美第一区第二区| 麻豆视频观看网址久久| 91麻豆精品国产91久久久久久 | 国产精品99久久久久久有的能看| 欧美一区二区在线免费播放| 三级欧美在线一区| 777午夜精品视频在线播放| 亚洲狠狠丁香婷婷综合久久久| 91免费视频观看| 一区二区三区精品| 欧美亚洲动漫另类| 婷婷中文字幕一区三区|