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

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

?? demo13_2_16b.cpp

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

// setup a 640x480 16-bit windowed mode example
#define WINDOW_TITLE      "16-Bit Acceleration 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

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

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

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

// 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, "GANTRY24.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 bitmaps
Load_Bitmap_File(&bitmap16bit, "ROCKET24.BMP");

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

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

// load the bob in 
for (index=0; index < 3; index++)
    Load_Frame_BOB16(&rocket, &bitmap16bit, 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(&bitmap16bit);

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

// 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(&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_Bitmap16(&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_BOB16(&rocket, lpddsback);

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

// return success
return(1);

} // end Game_Main

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人一区在线观看| 亚洲女人小视频在线观看| 色域天天综合网| 国产精品资源网站| 老司机一区二区| 手机精品视频在线观看| 亚洲午夜成aⅴ人片| 亚洲美女视频在线观看| 一区二区三区在线观看网站| 欧美精品一区视频| 成人动漫在线一区| 亚洲自拍偷拍网站| 久久免费美女视频| 91.麻豆视频| 国产成人在线视频网站| 日韩激情视频在线观看| 亚洲免费在线播放| 久久精品夜夜夜夜久久| 精品久久久久久综合日本欧美| 一本色道久久综合亚洲aⅴ蜜桃 | 亚洲mv在线观看| 亚洲丝袜另类动漫二区| 久久久亚洲欧洲日产国码αv| 色又黄又爽网站www久久| 成人免费高清在线| 国产69精品久久777的优势| 久久综合久久综合亚洲| 欧美tickle裸体挠脚心vk| 欧美日韩在线电影| 欧美曰成人黄网| 欧美日韩小视频| 欧美系列一区二区| 色94色欧美sute亚洲13| www..com久久爱| 亚洲午夜免费电影| 一区二区三区欧美亚洲| 一区二区三区在线观看欧美| 国产精品麻豆视频| 综合中文字幕亚洲| 中文字幕亚洲欧美在线不卡| 欧美日韩在线观看一区二区| 色94色欧美sute亚洲线路一久 | 国产精品18久久久久久vr| 狠狠色丁香久久婷婷综合_中| 久久精品国产免费看久久精品| 日韩综合在线视频| 日产国产欧美视频一区精品| 青娱乐精品视频在线| 日韩国产欧美在线视频| 午夜一区二区三区视频| 亚洲麻豆国产自偷在线| 午夜精品一区二区三区免费视频| 欧洲精品一区二区三区在线观看| 欧美日韩一级黄| 色系网站成人免费| 欧美精品日韩精品| 日韩免费视频一区二区| 91女人视频在线观看| 色成人在线视频| 日韩一级二级三级精品视频| 久久香蕉国产线看观看99| 国产精品久久久久影视| 亚洲国产成人av网| 99久久精品国产导航| 精品国产乱码久久久久久牛牛| 亚洲国产成人91porn| 91视视频在线观看入口直接观看www| 日韩女优电影在线观看| 亚洲欧美另类图片小说| 久久99蜜桃精品| 粉嫩13p一区二区三区| 欧美亚一区二区| 久久美女艺术照精彩视频福利播放 | 国产一二精品视频| 99精品国产热久久91蜜凸| 欧美一卡2卡三卡4卡5免费| 国产女人18毛片水真多成人如厕| 亚洲一区二区三区四区的| 国产尤物一区二区| 精品一区二区三区在线观看国产| 国产成人精品影视| 精品国产一区二区在线观看| 亚洲美女淫视频| 国产麻豆视频一区| 色婷婷激情综合| 久久亚洲一区二区三区明星换脸| 午夜精品一区二区三区电影天堂 | 欧美日韩一区国产| 欧美国产日韩精品免费观看| 蜜臀国产一区二区三区在线播放 | 日韩欧美一级特黄在线播放| 亚洲三级在线播放| 国产99久久久久久免费看农村| 欧美日韩成人高清| 一区二区三区在线观看视频| 成年人国产精品| 欧美日韩精品一二三区| 亚洲欧美日韩国产成人精品影院| 国产综合色产在线精品| 日韩一级大片在线| 午夜精品久久久久久久99水蜜桃| 色偷偷88欧美精品久久久| 欧美精彩视频一区二区三区| 精品一区在线看| 成人99免费视频| 国产免费成人在线视频| 国产91富婆露脸刺激对白| 精品国产一区a| 日本成人中文字幕| 日本不卡视频在线| 日韩色在线观看| 黄一区二区三区| 欧美国产视频在线| 99久久婷婷国产综合精品电影| 亚洲国产岛国毛片在线| 国产高清精品久久久久| 久久先锋资源网| 福利一区二区在线| 国产精品久久久久9999吃药| 韩国视频一区二区| 欧美国产丝袜视频| 成人av在线一区二区| 国产成人在线视频网址| 日韩毛片一二三区| 欧美日韩视频在线第一区| 秋霞电影一区二区| 久久伊人蜜桃av一区二区| 男男gaygay亚洲| 国产亚洲精品免费| 国产成人免费高清| 2014亚洲片线观看视频免费| 国产成人av一区| 一区二区三区四区在线免费观看| 99热精品一区二区| 玉米视频成人免费看| 91精品欧美久久久久久动漫| 国产一区不卡精品| 亚洲精品国产无天堂网2021 | 日韩欧美专区在线| 国产精品一区二区果冻传媒| 中文字幕亚洲视频| 91精品国产色综合久久不卡电影 | 欧美日韩国产综合一区二区| 九九国产精品视频| 洋洋av久久久久久久一区| 欧美中文字幕一区| 国产在线精品一区二区不卡了| 日韩无一区二区| 91麻豆免费观看| 国产精品一区二区三区99| 成人深夜视频在线观看| 日韩vs国产vs欧美| 亚洲视频免费在线| 一本大道久久a久久综合| 麻豆91精品91久久久的内涵| 中文字幕在线不卡一区二区三区| 一本一道久久a久久精品| 日本不卡视频在线观看| 精品国产乱码久久久久久免费| av一区二区不卡| 国产成人综合在线播放| 国产欧美日本一区二区三区| 国产在线国偷精品免费看| 欧美刺激脚交jootjob| 激情五月播播久久久精品| 亚洲另类春色校园小说| 欧美日韩免费高清一区色橹橹 | 亚洲美女少妇撒尿| 欧美激情中文字幕一区二区| 欧美日韩国产免费一区二区| 91麻豆精东视频| 福利一区在线观看| 国产福利一区在线| 精品国产百合女同互慰| 色婷婷av一区二区| 欧美日韩精品专区| 亚洲精品在线免费播放| 中文文精品字幕一区二区| 一区二区三区国产豹纹内裤在线| 午夜电影网一区| 国产 日韩 欧美大片| 在线免费亚洲电影| 欧美成人性战久久| 亚洲欧美日本韩国| 美国毛片一区二区三区| 成人免费视频网站在线观看| 欧美性生活影院| 国产亚洲一区二区三区| 亚洲精选视频在线| 久草在线在线精品观看| 色狠狠色狠狠综合| 久久夜色精品一区| 亚洲资源在线观看| 国产成人av自拍| 日韩欧美另类在线| 一个色综合网站| 成人激情小说网站| 精品三级av在线| 亚洲成人激情综合网| av影院午夜一区|