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

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

?? demo13_11.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
字號:

// DEMO13_11.CPP - Time based motion modeling
// to compile make sure to include DDRAW.LIB, DSOUND.LIB,
// DINPUT.LIB, WINMM.LIB, and of course the T3DLIB files

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

// variable indices
#define SHIP_X_POS  0
#define SHIP_Y_POS  1
#define SHIP_X_VEL  2

#define SHIP_INITIAL_VELOCITY   0.050    // 50 pixels/sec

// MACROS ///////////////////////////////////////////////

#define RAND_RANGE(x,y) ( (x) + (rand()%((y)-(x)+1)))
#define DOT_PRODUCT(ux,uy,vx,vy) ((ux)*(vx) + (uy)*(vy))

// 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[256];                 // used to print text

BITMAP_IMAGE background_bmp;      // holds the background
BOB          ship;                // the ship

int engine_id = -1;              // sound of engine

// 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
						  "Collision 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 varsIable

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

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

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

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

// create ship
Create_BOB(&ship,0,0,80,32,2,BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY);

// load the imagery in
for (index=0; index < 2; index++)
    Load_Frame_BOB(&ship, &bitmap8bit, index, index,0,BITMAP_EXTRACT_MODE_CELL);

// unload bitmap image
Unload_Bitmap_File(&bitmap8bit);

// position the ship to left of screen

// use element 0,1 to hold float accurate position
ship.varsF[SHIP_X_POS] = 0;
ship.varsF[SHIP_Y_POS] = screen_height/2;

// use index 2 to hold x velocity
ship.varsF[SHIP_X_VEL] = SHIP_INITIAL_VELOCITY; 

// hide the mouse
ShowCursor(FALSE);

// initialize directinput
DInput_Init();

// acquire the keyboard only
DInput_Init_Keyboard();

// initilize DirectSound
DSound_Init();

// load background sounds
engine_id = DSound_Load_WAV("PULSAR.WAV");

// start the sounds
DSound_Play(engine_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);

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

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

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

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

static int delay = 30; // initial delay per frame

// start the timing clock
DWORD start_time = Start_Clock();

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

// update delay
if (keyboard_state[DIK_RIGHT]) 
   delay+=5;
else
if (delay > 5 && keyboard_state[DIK_LEFT]) 
   delay-=5;


// draw the ship
ship.x = ship.varsF[SHIP_X_POS]+0.5;
ship.y = ship.varsF[SHIP_Y_POS]+0.5;
ship.curr_frame = 0;
Draw_BOB(&ship, lpddsback);

// draw shadow
ship.curr_frame = 1;
ship.x-=64;
ship.y+=128;
Draw_BOB(&ship, lpddsback);

// draw the title
Draw_Text_GDI("Time Based Kinematic Motion DEMO, Press <ESC> to Exit.",10, 10,RGB(255,255,255), lpddsback);

sprintf(buffer, "Frame rate = %f, use <RIGHT>, <LEFT> arrows to change load", 1000*1/(float)delay );
Draw_Text_GDI(buffer,10, 25,RGB(255,255,255), lpddsback);

sprintf(buffer,"Ship Velocity is %f pixels/sec",1000*ship.varsF[SHIP_X_VEL]);
Draw_Text_GDI(buffer,10, 40,RGB(255,255,255), lpddsback);

// this models the load in the game
Wait_Clock(delay);

// flip the surfaces
DDraw_Flip();

// move the ship based on time //////////////////////////////////
// x = x + v*dt

// compute dt
float dt = Get_Clock() - start_time; // in milliseconds

// move based on 30 pixels per seconds or .03 pixels per millisecond
ship.varsF[SHIP_X_POS]+=(ship.varsF[SHIP_X_VEL]*dt);

// test for off screen
if (ship.varsF[SHIP_X_POS] > screen_width+ship.width)
   ship.varsF[SHIP_X_POS] = -ship.width;

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

// 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_DARKNESS,NULL,0);
    } // end if

// return success
return(1);

} // end Game_Main

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美激情一区二区三区四区| 亚洲国产一区二区三区 | 日韩一区二区三区在线| 色吧成人激情小说| eeuss鲁片一区二区三区在线看| 久久国产婷婷国产香蕉| 美女国产一区二区| 国产一区二区主播在线| 国产精品亚洲视频| 成人精品视频一区二区三区 | 中文字幕欧美一| 一区二区成人在线观看| 亚洲三级理论片| 一区二区三区免费看视频| 亚洲最大成人网4388xx| 视频一区在线视频| 国产一区二区三区av电影| 国产伦精品一区二区三区视频青涩| 国产一区二区三区久久悠悠色av| 国产精品2024| 91在线国产观看| 在线视频观看一区| 91精品国产综合久久久久久久久久| 日韩一区二区三区在线| 国产精品免费视频一区| 洋洋av久久久久久久一区| 日产国产高清一区二区三区| 国产一区福利在线| 在线观看视频欧美| 欧美一区二区三区婷婷月色| 国产欧美一二三区| 亚洲国产一二三| 国产精品一区2区| 在线观看日韩高清av| 精品国产91乱码一区二区三区| 欧美国产综合一区二区| 三级久久三级久久久| 国产精品一二三四区| 一本色道久久综合亚洲aⅴ蜜桃| 欧美精品一区二| 中文字幕在线观看一区| 日韩有码一区二区三区| 成人涩涩免费视频| 91精品国产91综合久久蜜臀| 中文字幕乱码日本亚洲一区二区| 亚洲精品乱码久久久久久久久| 久久99久久99小草精品免视看| av亚洲精华国产精华| 精品成人免费观看| 视频在线观看国产精品| 色综合网色综合| 中文欧美字幕免费| 精品在线播放免费| 91精品国产综合久久久久久久 | 亚洲国产aⅴ成人精品无吗| 高清免费成人av| 精品国产精品网麻豆系列| 一级日本不卡的影视| 成人免费观看视频| 精品国产乱码久久久久久老虎| 亚洲成人午夜电影| 一本一本大道香蕉久在线精品| 国产三级三级三级精品8ⅰ区| 日韩电影一区二区三区| 欧美天堂一区二区三区| 亚洲乱码精品一二三四区日韩在线| 国产精品一品视频| www激情久久| 国模一区二区三区白浆| 精品国产乱码久久久久久浪潮 | 97精品电影院| 国产亚洲欧美日韩俺去了| 精品系列免费在线观看| 日韩精品一区二区在线| 麻豆91免费看| 日韩午夜电影av| 精品在线观看免费| 久久久久国产一区二区三区四区| 麻豆成人在线观看| 精品国产免费人成电影在线观看四季| 麻豆国产精品官网| 久久久亚洲高清| 国产a区久久久| 中文字幕欧美国产| 一本久久a久久精品亚洲| 一区二区三区四区视频精品免费 | 麻豆极品一区二区三区| 精品福利av导航| 国产综合久久久久久鬼色| 精品国产三级电影在线观看| 国产酒店精品激情| 国产精品国模大尺度视频| 色婷婷久久99综合精品jk白丝| 亚洲夂夂婷婷色拍ww47| 欧美高清视频不卡网| 国产在线不卡一卡二卡三卡四卡| 国产欧美日韩三区| 色综合天天综合网天天狠天天 | 日韩一区二区三区在线观看| 国产美女精品一区二区三区| 成人欧美一区二区三区| 欧美精品视频www在线观看| 国产在线视频一区二区| 中文字幕一区二区视频| 欧美浪妇xxxx高跟鞋交| 国产乱码一区二区三区| 亚洲在线视频一区| 久久综合九色综合欧美98| 91丨九色丨蝌蚪丨老版| 免费xxxx性欧美18vr| 久久久久高清精品| 在线精品观看国产| 国产麻豆精品在线| 亚洲永久精品大片| 中文字幕乱码一区二区免费| 欧美日韩不卡视频| 丁香婷婷深情五月亚洲| 性久久久久久久| 国产精品国产三级国产aⅴ入口 | 日日夜夜精品免费视频| 国产女人18水真多18精品一级做| 色猫猫国产区一区二在线视频| 男女男精品网站| 一区二区久久久久久| 精品少妇一区二区| 精品视频免费在线| 99视频精品在线| 国产精品99久久久久久似苏梦涵 | 不卡高清视频专区| 精品在线播放午夜| 亚洲r级在线视频| 亚洲青青青在线视频| 久久夜色精品国产噜噜av| 日本电影欧美片| 成人高清伦理免费影院在线观看| 日本成人在线视频网站| 亚洲自拍另类综合| 亚洲视频免费观看| 国产精品网站导航| 国产偷国产偷精品高清尤物 | 国产精品电影一区二区三区| 精品国产伦一区二区三区免费 | 久久精品人人爽人人爽| 日韩欧美国产电影| 欧美一区二区精品久久911| 欧美午夜一区二区| 欧美日韩在线精品一区二区三区激情| 国产激情精品久久久第一区二区| 狠狠色伊人亚洲综合成人| 九九视频精品免费| 国内久久精品视频| 国产乱色国产精品免费视频| 国产精品一区二区三区四区| 国产一区 二区 三区一级| 国产乱子伦一区二区三区国色天香 | 日韩精品在线一区| 日韩三级.com| 亚洲精品一区二区三区蜜桃下载 | 成人亚洲精品久久久久软件| 国产成人精品免费一区二区| 国产精品一区二区男女羞羞无遮挡| 国产乱码字幕精品高清av| 国产精品一区二区视频| 不卡一区中文字幕| 欧美专区在线观看一区| 欧美日韩一区成人| 日韩亚洲欧美综合| 国产日韩欧美麻豆| 日韩理论片一区二区| 亚洲福利视频导航| 看国产成人h片视频| 国产成人亚洲综合a∨婷婷图片| 国产成人免费在线视频| 波多野结衣一区二区三区 | 久久久久久久久久看片| 欧美激情一区二区三区| 日韩美女视频一区| 亚洲国产成人porn| 精品亚洲成a人| 99r国产精品| 欧美精品久久一区| 久久精品人人爽人人爽| 樱花草国产18久久久久| 日韩高清在线电影| 国产aⅴ精品一区二区三区色成熟| 91在线视频观看| 日韩免费看的电影| 日韩毛片精品高清免费| 日韩av一二三| av资源网一区| 日韩一级片在线观看| 亚洲人成人一区二区在线观看 | 欧美人成免费网站| 久久在线免费观看| 亚洲一区二区不卡免费| 国产精品一品二品| 欧美电影影音先锋| 亚洲四区在线观看| 黄页网站大全一区二区| 欧美日韩精品一二三区|