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

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

?? demo13_5.cpp

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

#define FRICTION_FACTOR     (float)(0.1)  // friction of table
#define PUCK_START_X        30            // starting location of puck
#define PUCK_START_Y        220
#define PUCK_STATE_RESTING  0             // puck is sitting
#define PUCK_STATE_MOVING   1             // puck has been hit

// extents of table
#define TABLE_MAX_X     620
#define TABLE_MIN_X     14
#define TABLE_MAX_Y     370
#define TABLE_MIN_Y     80

// 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          puck;             // the ship

int sound_id = -1;             // general sound

float friction = FRICTION_FACTOR; // frictional coefficient

// 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
						  "Simple Friction 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, "HOCKEY8.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 for ship
Load_Bitmap_File(&bitmap8bit, "PUCK8.BMP");

// create bob
Create_BOB(&puck,PUCK_START_X,PUCK_START_Y,32,32,1,BOB_ATTR_SINGLE_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY);

// set state of puck
puck.anim_state = PUCK_STATE_RESTING;

// use varsF[0,1] for the x and y velocity
puck.varsF[0] = 0;
puck.varsF[1] = 0;

// use varsF[2,3] for the x and y position, we need more accuracy than ints
puck.varsF[2] = puck.x;
puck.varsF[3] = puck.y;

// load the frame
Load_Frame_BOB(&puck, &bitmap8bit, 0, 0,0,BITMAP_EXTRACT_MODE_CELL);

// 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("PUCK.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(&puck);

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

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

// is player changing friction
if (keyboard_state[DIK_RIGHT])
   friction+=0.005;
else
if (keyboard_state[DIK_LEFT])
   if ((friction-=0.005) < 0)
       friction = 0.0;

// check if player is hiting puck
if (keyboard_state[DIK_SPACE] && puck.anim_state == PUCK_STATE_RESTING)
    {
    // first set state to motion
    puck.anim_state = PUCK_STATE_MOVING;    

    // reset puck position
    puck.varsF[2] = PUCK_START_X;
    puck.varsF[3] = PUCK_START_Y;

    // select random initial trajectory
    puck.varsF[0] = 12+rand()%8;
    puck.varsF[1] = -8 + rand()%17;

    } // end if

// move puck
puck.varsF[2]+=puck.varsF[0];
puck.varsF[3]+=puck.varsF[1];

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

// apply friction in direction opposite current trajectory
float fx = -puck.varsF[0];
float fy = -puck.varsF[1];
float length_f = sqrt(fx*fx+fy*fy); // normally we would avoid square root at all costs!

// compute the frictional resitance

if (fabs(length_f) >= 0.50)
    { 
    fx = friction*fx/length_f;
    fy = friction*fy/length_f;
    } // end if
else
   {
   // force 0.0
   fx=fy=0.0;

   // kill velocity
   puck.varsF[0]=0.0;
   puck.varsF[1]=0.0;
   
   // puck is stuck, let player fire again
   puck.anim_state = PUCK_STATE_RESTING;  
   } // end if

// now apply friction to forward velocity
puck.varsF[0]+=fx;
puck.varsF[1]+=fy;

// test if puck is off screen
if (puck.varsF[2]+puck.width >= TABLE_MAX_X || puck.varsF[2] <= TABLE_MIN_X)
    {
    // invert velocity
    puck.varsF[0] = -puck.varsF[0];

    // move puck
    puck.varsF[2]+=puck.varsF[0];
    puck.varsF[3]+=puck.varsF[1];

    DSound_Play(sound_id, 0);
    } // end if

if (puck.varsF[3]+puck.height >= TABLE_MAX_Y || puck.varsF[3] <= TABLE_MIN_Y)
   {
   // invert velocity
   puck.varsF[1] = -puck.varsF[1];

   // move puck
   puck.varsF[2]+=puck.varsF[0];
   puck.varsF[3]+=puck.varsF[1];

   DSound_Play(sound_id, 0);

   } // end if

// copy floating point position to bob x,y
puck.x = puck.varsF[2]+0.5;
puck.y = puck.varsF[3]+0.5;

// draw skid marks to table if puck is in motion
if (fabs(puck.varsF[0]) > 0 || fabs(puck.varsF[1]) > 0)
   {
   Draw_Pixel(puck.x+puck.width/2-2+rand()%4,puck.y+puck.height/2-2+rand()%4, 16+rand()%8,
               background_bmp.buffer, background_bmp.width);    
   } // end if

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

// draw the title
Draw_Text_GDI("SIMPLE FRICTION DEMO - Hit Space to Shoot Puck, Arrows to Change Friction.",10,10,RGB(0,255,255), lpddsback);

sprintf(buffer,"Friction: X=%f, Y=%f",fx, fy);
Draw_Text_GDI(buffer,10,410,RGB(0,255,0), lpddsback);

sprintf(buffer,"Velocity: X=%f, Y=%f",puck.varsF[0], puck.varsF[1]);
Draw_Text_GDI(buffer,10,430,RGB(0,255,0), lpddsback);

sprintf(buffer,"Frictional Coefficient: %f",friction);
Draw_Text_GDI(buffer,10,450,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_DARKNESS,NULL,0);
    } // end if

// return success
return(1);

} // end Game_Main

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区不卡免费| 91福利社在线观看| 91国产福利在线| 2020日本不卡一区二区视频| 亚洲精品自拍动漫在线| 激情综合色综合久久| 欧美特级限制片免费在线观看| 亚洲国产成人午夜在线一区| 日韩成人一区二区| 欧美性生活一区| 亚洲色图清纯唯美| 大美女一区二区三区| 日韩视频国产视频| 午夜成人免费电影| 欧美色图12p| 亚洲精品久久嫩草网站秘色| 国产91色综合久久免费分享| 欧美大黄免费观看| 免费不卡在线视频| 91麻豆精品久久久久蜜臀| 亚洲电影一区二区三区| 色先锋资源久久综合| 中文字幕在线播放不卡一区| 国产xxx精品视频大全| 久久精品亚洲乱码伦伦中文| 久久精品国产秦先生| 在线观看91av| 午夜婷婷国产麻豆精品| 欧美日韩精品专区| 五月天中文字幕一区二区| 欧美日韩亚洲综合在线| 亚欧色一区w666天堂| 69堂精品视频| 日本vs亚洲vs韩国一区三区| 日韩欧美资源站| 国产自产v一区二区三区c| 久久九九久久九九| 成人性生交大片| 亚洲私人影院在线观看| 日本高清视频一区二区| 午夜不卡在线视频| 日韩一二三区不卡| 国产精品综合在线视频| 国产欧美日韩精品在线| jiyouzz国产精品久久| 国产精品福利一区二区三区| 色婷婷综合中文久久一本| 亚洲成人免费在线观看| 日韩一区二区在线观看视频| 国产一区二区三区精品视频| 国产欧美视频一区二区| 91在线视频播放地址| 亚洲国产一区二区三区青草影视| 777午夜精品免费视频| 精品午夜一区二区三区在线观看| 久久久久久影视| 99久久国产综合精品麻豆| 怡红院av一区二区三区| 日韩精品专区在线影院观看| 激情国产一区二区| 亚洲视频1区2区| 欧美日韩午夜在线| 国产精品系列在线播放| 亚洲永久精品大片| 精品免费国产一区二区三区四区| 国产成人精品免费看| 亚洲午夜精品一区二区三区他趣| 欧美一区二区精品在线| 成人伦理片在线| 丝袜美腿亚洲色图| 欧美激情在线看| 欧美三级欧美一级| 国产suv精品一区二区三区| 亚瑟在线精品视频| 亚洲欧洲日本在线| 日韩视频一区二区| 91精品福利在线| 国产 日韩 欧美大片| 视频一区免费在线观看| 国产精品久久久久久久久免费相片 | 亚洲国产精品视频| 国产午夜亚洲精品不卡| 3d动漫精品啪啪| 99re热这里只有精品视频| 久久aⅴ国产欧美74aaa| 亚洲一区视频在线| 中文字幕中文字幕在线一区| 日韩你懂的在线观看| 日本高清不卡在线观看| 粉嫩蜜臀av国产精品网站| 日韩va欧美va亚洲va久久| 亚洲乱码国产乱码精品精的特点 | www.亚洲色图| 国模套图日韩精品一区二区| 亚洲一区二区偷拍精品| 亚洲欧美综合色| 国产欧美精品一区二区色综合| 91精品在线免费观看| 91国产成人在线| 91在线观看污| 99精品在线观看视频| 国产999精品久久久久久| 国产精品主播直播| 精品亚洲国内自在自线福利| 日韩影院免费视频| 亚洲国产精品一区二区www在线 | 欧美性猛交xxxx黑人交| 色婷婷精品大视频在线蜜桃视频 | 国产一区二区美女| 美洲天堂一区二卡三卡四卡视频 | 日韩精品一区国产麻豆| 日本韩国精品在线| 色妹子一区二区| 欧美在线free| 欧美亚州韩日在线看免费版国语版| 99精品国产99久久久久久白柏 | 国产精品久久久久久久久果冻传媒| 久久综合色综合88| 久久久影院官网| 日本一区二区电影| 中文一区一区三区高中清不卡| 日本一区二区免费在线| 亚洲国产成人午夜在线一区| 国产精品嫩草影院av蜜臀| 国产精品二三区| 亚洲精品v日韩精品| 亚洲在线视频网站| 日韩国产精品久久久| 极品少妇一区二区三区精品视频| 国产一区二区三区美女| 不卡av在线网| 欧洲中文字幕精品| 91精品国产免费久久综合| 久久综合色婷婷| 18成人在线观看| 丝袜脚交一区二区| 国产精品一卡二卡在线观看| 成人妖精视频yjsp地址| 在线观看国产一区二区| 欧美一级在线观看| 久久久高清一区二区三区| 中文字幕亚洲一区二区va在线| 一区二区在线电影| 亚洲一二三四在线观看| 美女mm1313爽爽久久久蜜臀| 国产精品一区二区免费不卡 | 亚洲成av人片在线观看| 麻豆极品一区二区三区| 成人激情免费视频| 91高清视频在线| 亚洲精品在线观看网站| 亚洲欧美日本韩国| 久久国产乱子精品免费女| 91片黄在线观看| 欧美大尺度电影在线| 亚洲另类色综合网站| 久久99热这里只有精品| 欧美性一级生活| 久久精子c满五个校花| 五月综合激情日本mⅴ| 成人精品视频.| 日韩免费看的电影| 一区二区三区美女| 国产成人精品免费看| 日韩丝袜美女视频| 亚洲一级片在线观看| www.亚洲色图| 国产欧美一区二区三区网站| 午夜精品福利在线| 在线影院国内精品| 国产精品久久久久影院亚瑟| 免费在线观看一区二区三区| 日本道在线观看一区二区| 国产女人18毛片水真多成人如厕 | 蜜臀va亚洲va欧美va天堂 | 亚洲第一综合色| av高清不卡在线| 日本一区二区视频在线| 美女任你摸久久| 欧美高清视频不卡网| 亚洲精品成人悠悠色影视| 99精品黄色片免费大全| 国产精品少妇自拍| 国产麻豆精品久久一二三| 精品国内片67194| 全部av―极品视觉盛宴亚洲| 欧美色偷偷大香| 亚洲国产精品久久久久婷婷884| 不卡视频在线观看| 中文字幕不卡的av| eeuss国产一区二区三区| 久久久777精品电影网影网| 国产一区二区久久| 久久精品欧美日韩精品| 国产精品亚洲午夜一区二区三区 | 国产乱码精品一区二区三区av| 制服丝袜亚洲网站| 麻豆一区二区三区| xf在线a精品一区二区视频网站| 美洲天堂一区二卡三卡四卡视频|