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

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

?? demo13_2.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
字號:
// DEMO13_2.CPP - acceleration demo
// 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

// defines for rocket
#define ROCKET_STATE_ON_PAD    0
#define ROCKET_STATE_IN_FLIGHT 1

// 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          rocket;           // the rocket

int sound_id = -1;             // general 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

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
						  "Accleration 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

// WINX 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, "GANTRY.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, "ROCKET8.BMP");

// create bob
Create_BOB(&rocket,312,420,24,80,3,BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY);

// set animation speed
Set_Anim_Speed_BOB(&rocket, 2);

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

// set animation state to on pad
rocket.anim_state = ROCKET_STATE_ON_PAD;

// use varsI[0] to hold acceleration mode, set to on
rocket.varsI[0] = 1; // -1 is off

// use varsF[0,1] to hold the velocity and acceleration
rocket.varsF[0] = 0; // initial velocity
rocket.varsF[1] = 0.2; // initial acceleration 0.2 pixel/frame^2

// unload bitmap image
Unload_Bitmap_File(&bitmap8bit);

// initialize directinput
DInput_Init();

// acquire the keyboard only
DInput_Init_Keyboard();

// initilize DirectSound
DSound_Init();

// load background sounds
sound_id = DSound_Load_WAV("ROCKET.WAV");

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

// 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 debounce_a = 0; // used to debounce acceleration toggle key

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


// test if user is toggling acceleration control
if (keyboard_state[DIK_A] && !debounce_a)
   {
   // toggle acceleration
   rocket.varsI[0] = -rocket.varsI[0];
   
   // debounce key, so it doesn't toggle 60 times!
   debounce_a = 1;

   } // end if

if (!keyboard_state[DIK_A])
   debounce_a = 0;

// test if user is changing acceleration
if (keyboard_state[DIK_DOWN])
   {
   // decrease acceleration factor   
   if ((rocket.varsF[1]-=0.1) < 0)
        rocket.varsF[1] = 0.1;
   } // end if
else
if (keyboard_state[DIK_UP])
   {
   // increase acceleration factor   
   rocket.varsF[1]+=0.1;
   } // end if

// test if player is firing rocket
if (keyboard_state[DIK_SPACE] && rocket.anim_state == ROCKET_STATE_ON_PAD)
    {
    // fire the rocket
    rocket.anim_state = ROCKET_STATE_IN_FLIGHT;

    // start sound
    DSound_Play(sound_id, 0);

    } // end if

// test state of rocket
if (rocket.anim_state == ROCKET_STATE_ON_PAD)
   {
   // make sure there is no animation and frame is 0
   rocket.curr_frame = 0;

   } // end if
else // rocket is in flight
    {
    // animate the rocket
    Animate_BOB(&rocket);

    // move the rocket
   
    // update the position with the current velocity
    rocket.y-=(int)(rocket.varsF[0]+0.5);

    // update velocity with acceleration (if acceleration is on)
    if (rocket.varsI[0]==1)
       rocket.varsF[0]+=rocket.varsF[1];

    // test if the rocket has moved off the screen
    if (rocket.y < -4*rocket.height)
       {
       // reset everything
       rocket.anim_state = ROCKET_STATE_ON_PAD;
       rocket.curr_frame = 0;
       rocket.varsF[0]   = 0;

       // reset position
       Set_Pos_BOB(&rocket, 312, 420);

       // turn sound off
       DSound_Stop_All_Sounds();

       } // end if

    } // end else

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

// draw the title
Draw_Text_GDI("ACCELERATION DEMO - Space to Launch, Arrows to Change Acceleration.",10, 10,RGB(0,255,255), lpddsback);

// draw information

// first acceleration mode
if (rocket.varsI[0]==1)
    sprintf(buffer, "Acceleration is ON");
else
    sprintf(buffer, "Acceleration is OFF");

Draw_Text_GDI(buffer,10,25,RGB(0,255,0), lpddsback);

// now current velocity
sprintf(buffer, "Velocity = %f pixels/frame",rocket.varsF[0]);
Draw_Text_GDI(buffer,10,40,RGB(0,255,0), lpddsback);

// and acceleration
sprintf(buffer, "Acceleration = %f pixels/frame^2",rocket.varsF[1]);
Draw_Text_GDI(buffer,10,55,RGB(0,255,0), lpddsback);

// flip the surfaces
DDraw_Flip();

// sync to 30 fps = 1/30sec = 33 ms
Wait_Clock(33);

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

// return success
return(1);

} // end Game_Main

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品麻豆日日躁夜夜躁| 欧美午夜影院一区| 国产成人av一区二区三区在线| 免费久久精品视频| 国产精品一区二区你懂的| 丰满亚洲少妇av| 在线日韩一区二区| 91精品国产综合久久婷婷香蕉| 欧美一区二区高清| 欧美极品aⅴ影院| 日韩精品电影在线| 91九色02白丝porn| 国产精品久久久久久久久搜平片| 日本韩国欧美在线| 精品国产免费人成电影在线观看四季 | 亚洲欧美日韩久久精品| 亚洲高清不卡在线| www.在线欧美| 久久亚洲一区二区三区四区| 亚洲视频在线观看三级| 精品一区二区免费视频| 在线一区二区视频| 亚洲精品一区二区精华| 天天综合色天天| 色婷婷综合久久久中文一区二区| 久久精品一区蜜桃臀影院| 亚洲bt欧美bt精品777| 91视视频在线观看入口直接观看www| 91麻豆精品久久久久蜜臀| 一区免费观看视频| 久久99久久久久久久久久久| 欧美猛男超大videosgay| 亚洲欧美电影院| 欧美在线观看视频在线| 亚洲欧美一区二区三区极速播放 | 91精品国产综合久久福利软件| 自拍偷拍国产精品| 色综合天天狠狠| 中文字幕亚洲区| 色综合中文字幕| 亚洲伦理在线精品| 色香色香欲天天天影视综合网| 中文字幕一区二区三区在线不卡 | 中文字幕亚洲视频| 欧美性色欧美a在线播放| 丝袜亚洲另类欧美| xf在线a精品一区二区视频网站| 美女一区二区视频| 久久综合成人精品亚洲另类欧美| 成人不卡免费av| 国产精品理论片| 欧美网站一区二区| 国产精品亚洲专一区二区三区 | 国产精品99精品久久免费| 国产精品国产自产拍高清av| 欧美久久婷婷综合色| 激情久久五月天| 一区二区三区四区国产精品| 884aa四虎影成人精品一区| 国产真实乱偷精品视频免| 亚洲精品久久7777| 久久久精品蜜桃| 欧美精三区欧美精三区| 国产真实乱偷精品视频免| 亚洲午夜一区二区三区| 国产亚洲一区二区三区| 欧美日韩一级二级三级| 99久久久精品| 国产在线精品国自产拍免费| 亚洲欧美日韩国产综合在线| 久久无码av三级| 日韩欧美在线1卡| 欧美高清视频一二三区| 色视频成人在线观看免| 成人午夜精品一区二区三区| 久久国产精品一区二区| 午夜影视日本亚洲欧洲精品| 亚洲狠狠丁香婷婷综合久久久| 国产精品嫩草影院av蜜臀| 精品久久久久久久久久久久久久久久久 | 91天堂素人约啪| 一本大道久久a久久综合婷婷| 成人精品视频.| 91婷婷韩国欧美一区二区| 在线亚洲一区观看| av成人老司机| 欧美三级日韩三级| 欧美一区欧美二区| 欧美电视剧免费全集观看| 欧美mv日韩mv国产网站| 国产日产精品一区| 亚洲欧美色图小说| 天天色天天爱天天射综合| 久草中文综合在线| 国产精品自拍在线| 一本一道久久a久久精品| 欧美日韩精品一区二区三区蜜桃 | 国产福利91精品一区| 丁香啪啪综合成人亚洲小说| 一本一道综合狠狠老| 欧美剧情电影在线观看完整版免费励志电影 | 91老师片黄在线观看| eeuss鲁一区二区三区| 欧美三电影在线| 久久综合九色综合欧美98| 综合久久久久综合| 久草这里只有精品视频| 91蝌蚪porny九色| 2021国产精品久久精品| 亚洲午夜精品一区二区三区他趣| 久久99日本精品| 欧美图区在线视频| 久久久噜噜噜久久中文字幕色伊伊| 综合中文字幕亚洲| 国产毛片精品视频| 欧美mv日韩mv| 日韩高清一区二区| 欧美影院精品一区| 亚洲人成精品久久久久久| 国产一区在线精品| 337p日本欧洲亚洲大胆色噜噜| 亚洲一区二区三区免费视频| 成人免费av资源| 国产精品久久久久久久久动漫| 久久精品国产免费| 日韩精品一区二区三区在线观看| 亚洲国产精品尤物yw在线观看| 91免费视频观看| 一区二区三区中文在线观看| 99麻豆久久久国产精品免费| 日本一区二区高清| 91丨porny丨蝌蚪视频| 国产精品乱码久久久久久| 国产一区美女在线| 亚洲国产成人午夜在线一区| 成人av在线资源| 一区二区高清视频在线观看| 色综合久久久久综合体| 午夜a成v人精品| 久久一区二区三区四区| av在线不卡电影| 日韩在线一区二区三区| 欧美大白屁股肥臀xxxxxx| 丁香天五香天堂综合| 亚洲一二三专区| 国产午夜亚洲精品午夜鲁丝片| 99精品欧美一区二区三区综合在线| 狠狠狠色丁香婷婷综合久久五月| 久久亚洲综合色| 欧美写真视频网站| 日韩丝袜美女视频| 99久久精品国产导航| 午夜精品久久久久久久| 日韩精品亚洲专区| 国产精品国产三级国产a| 欧美激情一区二区三区全黄| 亚洲人精品午夜| 一区二区三区精品| 美洲天堂一区二卡三卡四卡视频| 青青青伊人色综合久久| 国产精品69久久久久水密桃| 成人综合激情网| 欧美日韩一卡二卡| 久久久综合网站| 免费看黄色91| 国产a久久麻豆| 91猫先生在线| 日韩你懂的电影在线观看| 国产精品久久久久久亚洲毛片| 亚洲国产日产av| 久久爱www久久做| 色婷婷综合激情| 日韩精品一区二区三区中文不卡| 国产精品久久免费看| 婷婷夜色潮精品综合在线| 国产精品综合网| 欧美精品第1页| 亚洲欧美另类小说视频| 久久成人综合网| 欧美三级三级三级爽爽爽| 国产精品家庭影院| 国产传媒日韩欧美成人| 欧美精品自拍偷拍| 一区二区三区在线影院| 成人午夜免费电影| 久久精品视频免费| 日本成人在线电影网| 欧美日韩国产经典色站一区二区三区 | 樱花影视一区二区| 国产成人一级电影| 久久免费偷拍视频| 裸体歌舞表演一区二区| 在线精品视频免费播放| 国产精品水嫩水嫩| 免费在线观看不卡| 日韩欧美国产午夜精品| 蜜臀av性久久久久蜜臀av麻豆| 欧美性生活久久| 亚洲一卡二卡三卡四卡五卡| 国产成人鲁色资源国产91色综 |