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

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

?? demo12_7.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
// DEMO12_7.CPP - memory demo
// 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 "WINCLASS"  // class name

#define WINDOW_WIDTH    320   // size of window
#define WINDOW_HEIGHT   240

// defines for ants
#define NUM_ANTS         16 // just change this to whatever, but only 8 ants will be displayed
                            // on HUD
#define ANT_ANIM_UP      0
#define ANT_ANIM_RIGHT   1
#define ANT_ANIM_DOWN    2
#define ANT_ANIM_LEFT    3
#define ANT_ANIM_DEAD    4

// states of ant
#define ANT_WANDERING             0   // moving around randomly
#define ANT_EATING                1   // at a mnm eating it
#define ANT_RESTING               2   // sleeping :)
#define ANT_SEARCH_FOOD           3   // hungry and searching for food
       
// these are the substates that occur during a search for food
        #define ANT_SEARCH_FOOD_S1_SCAN         31  // substate 1
        #define ANT_SEARCH_FOOD_S2_WANDER       32  // substate 2
        #define ANT_SEARCH_FOOD_S3_VECTOR_2CELL 33  // substate 3
        #define ANT_SEARCH_FOOD_S4_VECTOR_2FOOD 34  // substate 4
        #define ANT_SEARCH_FOOD_S5              35  // substate 5
        #define ANT_SEARCH_FOOD_S6              36  // substate 6
        #define ANT_SEARCH_FOOD_S7              37  // substate 7

#define ANT_COMMUNICATING         4   // talking to another ant  
#define ANT_DEAD                  5   // this guy is dead, got too hungry

#define ANT_INDEX_HUNGER_LEVEL       0  // the current hunger level of ant
#define ANT_INDEX_HUNGER_TOLERANCE   1  // the death tolerance of hunger
#define ANT_INDEX_AI_STATE           2  // the artificial intelligence state
#define ANT_INDEX_AI_SUBSTATE        3  // generic substate
#define ANT_INDEX_DIRECTION          4  // direction of motion
#define ANT_INDEX_LAST_TALKED_WITH   5  // last ant talked to
#define ANT_INDEX_MNM_BEING_DEVOURED 6  // the index of mnm being eaten
#define ANT_INDEX_FOOD_TARGET_X      7  // x,y target position of cell or off actual food
#define ANT_INDEX_FOOD_TARGET_Y      8    
#define ANT_INDEX_FOOD_TARGET_ID     9  // the id of the actual piece of food

#define ANT_MEMORY_RESIDUAL_RATE     0.2 // inversely proportional to plasticity of ant memory

#define BITE_SIZE                    5 // bite size of one mouthful in energy units

// defines for food
#define NUM_MNMS         32

// PROTOTYPES /////////////////////////////////////////////

// game console
int Game_Init(void *parms=NULL);
int Game_Shutdown(void *parms=NULL);
int Game_Main(void *parms=NULL);

// ants stuff
void Move_Ants(void);
void Init_Ants(void);
void Draw_Ants(void);

void Draw_Food(void);

// TYPES /////////////////////////////////////////////////

// this is the food
typedef struct MNM_TYP
{
int x,y;     // position of mnm
float energy;  // when this is 0, the mnm is dead

} MNM, *MNM_PTR;


typedef struct ANT_MEMORY_TYP
{

float cell[16][16];     // the actual memory
int   ilayer[16][16];   // used as an input layer to help display engine show
                        // areas during communication and forgetfulness

} ANT_MEMORY, *ANT_MEMORY_PTR;


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

#define RAND_RANGE(x,y) ( (x) + (rand()%((y)-(x)+1)))


// 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          ants[NUM_ANTS],   // the ants
             mnm;              // the little food mnm image

MNM food[NUM_MNMS];            // the array of mnms

ANT_MEMORY ants_mem[NUM_ANTS]; // each ant has a 256 cell memory, 16x16 structure

int niceday_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

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
						  "Memory and Learning 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 variable

// seed the random number generator
srand(Get_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, "SIDEWALK28.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 ant bitmaps
Load_Bitmap_File(&bitmap8bit, "ANTIMG8.BMP");

// create master ant
Create_BOB(&ants[0],320,200, 24,24, 9, BOB_ATTR_MULTI_ANIM | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY);

// load the ants in 
for (index=0; index < 9; index++)
    Load_Frame_BOB(&ants[0], &bitmap8bit, index, index, 0, BITMAP_EXTRACT_MODE_CELL);


// set the animations
int ant_anim_up[3]    = {0,1,-1};
int ant_anim_right[3] = {2,3,-1};
int ant_anim_down[3]  = {4,5,-1};
int ant_anim_left[3]  = {6,7,-1};
int ant_anim_dead[2]  = {8,-1};

Load_Animation_BOB(&ants[0],0,2, ant_anim_up);
Load_Animation_BOB(&ants[0],1,2, ant_anim_right);
Load_Animation_BOB(&ants[0],2,2, ant_anim_down);
Load_Animation_BOB(&ants[0],3,2, ant_anim_left);
Load_Animation_BOB(&ants[0],4,2, ant_anim_dead);

Set_Anim_Speed_BOB(&ants[0],3);
Set_Animation_BOB(&ants[0], ANT_ANIM_UP);

// clone the ants
for (index=1; index < NUM_ANTS; index++)
    Clone_BOB(&ants[0], &ants[index]);

// initialize the ants
Init_Ants();

// create the mnm
Create_BOB(&mnm,0,0, 8,8, 1, BOB_ATTR_SINGLE_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY);

// load the mnm 
Load_Frame_BOB(&mnm, &bitmap8bit, 0, 1, 141, BITMAP_EXTRACT_MODE_ABS);


// position all the mnms
int num_piles = 3+rand()%3;
int curr_mnm = 0;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区成人精品| 成人丝袜高跟foot| 精品1区2区3区| 亚洲综合精品自拍| 91成人国产精品| 一区二区三区欧美激情| 99久久99久久综合| 国产精品丝袜91| 成人激情小说乱人伦| 欧美国产精品中文字幕| 成人午夜碰碰视频| 国产精品美女一区二区三区| 不卡av在线免费观看| 国产精品国产三级国产有无不卡| 国产一区二区成人久久免费影院| 欧美精品一区二区在线播放| 国模大尺度一区二区三区| 日韩免费看的电影| 韩国女主播一区| 久久久高清一区二区三区| 高清国产一区二区| 中文字幕字幕中文在线中不卡视频| av在线一区二区| 亚洲精品自拍动漫在线| 欧美调教femdomvk| 婷婷丁香激情综合| 精品国产污污免费网站入口| 国产精品一区二区男女羞羞无遮挡| 国产欧美日韩不卡| 97精品国产露脸对白| 亚洲激情在线激情| 欧美日韩一卡二卡| 免费一级欧美片在线观看| 精品捆绑美女sm三区| 国产成人免费视频精品含羞草妖精| 国产精品网站在线观看| 97久久超碰国产精品电影| 亚洲国产日日夜夜| 日韩欧美国产一区在线观看| 国产一区二区免费视频| 中文字幕在线观看不卡视频| 日本韩国欧美在线| 日韩av二区在线播放| 久久精品夜色噜噜亚洲aⅴ| eeuss鲁片一区二区三区在线观看| 亚洲综合另类小说| 精品少妇一区二区三区日产乱码 | 色综合 综合色| 午夜私人影院久久久久| 26uuu国产日韩综合| av资源站一区| 日韩精品一二三| 国产亚洲精品精华液| 欧洲av一区二区嗯嗯嗯啊| 久久se精品一区二区| 中文字幕日本乱码精品影院| 欧美日韩精品一区二区天天拍小说 | 亚洲综合在线视频| 91精品国产综合久久福利| 福利视频网站一区二区三区| 亚洲免费在线播放| 精品国产91久久久久久久妲己| 成人福利视频在线看| 日韩中文字幕91| 欧美韩日一区二区三区| 欧美日韩亚洲综合| 成人免费视频caoporn| 亚洲成人自拍网| 中文字幕欧美三区| 欧美丰满一区二区免费视频| 丰满白嫩尤物一区二区| 视频在线观看一区| 国产精品欧美一区喷水| 91精品国产色综合久久久蜜香臀| 不卡影院免费观看| 久久精品久久精品| 亚洲精品日韩专区silk| 精品免费国产二区三区| 欧美无人高清视频在线观看| 国产精品91一区二区| 日日摸夜夜添夜夜添亚洲女人| 国产精品第一页第二页第三页| 日韩精品中午字幕| 在线观看免费一区| 成人免费毛片a| 久久精品国产99久久6| 夜夜爽夜夜爽精品视频| 国产欧美日本一区视频| 日韩一区二区三区观看| 欧美午夜电影一区| 成人激情文学综合网| 激情综合色丁香一区二区| 亚洲一区二区av在线| 国产精品久久久久一区二区三区 | 日韩欧美123| 在线亚洲人成电影网站色www| 国产成人在线色| 奇米影视一区二区三区小说| 一区二区三区日韩在线观看| 国产嫩草影院久久久久| 精品久久免费看| 欧美一区二区三区在线观看视频 | 欧美影院精品一区| av一区二区不卡| 国产成人综合网| 国产综合色在线视频区| 欧美aaa在线| 亚洲bt欧美bt精品777| 亚洲老司机在线| 中文字幕一区免费在线观看| 国产亚洲女人久久久久毛片| 精品日韩在线一区| 欧美一区二区三区免费大片| 欧美性生活大片视频| 色噜噜狠狠成人网p站| 99国产精品久久久久久久久久久| 丁香婷婷综合激情五月色| 狠狠色狠狠色合久久伊人| 蜜臀av一级做a爰片久久| 三级精品在线观看| 天堂久久一区二区三区| 亚洲国产婷婷综合在线精品| 一区二区三区欧美视频| 一区二区三区高清| 亚洲一区二区三区四区不卡| 亚洲精品菠萝久久久久久久| 亚洲激情欧美激情| 一区二区三区久久久| 亚洲免费观看高清完整版在线| 亚洲欧洲无码一区二区三区| 国产精品久久久久一区| 中文字幕一区日韩精品欧美| 日韩美女精品在线| 中文字幕一区视频| 亚洲欧美成aⅴ人在线观看| 中日韩av电影| 国产精品久久精品日日| 亚洲欧洲一区二区在线播放| 中文字幕在线不卡一区| 亚洲免费av网站| 亚洲自拍偷拍欧美| 亚洲国产成人va在线观看天堂| 亚洲国产精品麻豆| 日本三级韩国三级欧美三级| 毛片基地黄久久久久久天堂| 国内精品免费**视频| 国产九色精品成人porny | 成人a级免费电影| 91在线视频观看| 91黄色免费观看| 欧美一区二区精品在线| www精品美女久久久tv| 国产女主播在线一区二区| 中文字幕视频一区| 亚洲最快最全在线视频| 欧美96一区二区免费视频| 国产乱子伦视频一区二区三区| 大胆亚洲人体视频| 91国产福利在线| 日韩一区和二区| 国产日韩欧美在线一区| 亚洲日本在线视频观看| 亚洲国产成人tv| 精品在线观看免费| 成人在线视频一区二区| 在线看国产一区| 欧美一级精品在线| 欧美国产丝袜视频| 亚洲一二三区不卡| 美女网站一区二区| 99视频有精品| 欧美另类变人与禽xxxxx| 精品久久久久av影院| 国产精品久久久久久久裸模| 亚洲123区在线观看| 国产一区二区三区精品欧美日韩一区二区三区 | 精品夜夜嗨av一区二区三区| 粉嫩欧美一区二区三区高清影视 | www.日韩大片| 欧美精品高清视频| 日本一区二区成人在线| 亚洲国产一区二区在线播放| 九色|91porny| 色哟哟精品一区| 精品美女在线播放| 亚洲精品国久久99热| 久久99久国产精品黄毛片色诱| 99精品欧美一区| 欧美一级一区二区| 17c精品麻豆一区二区免费| 午夜精品免费在线| 成人做爰69片免费看网站| 在线不卡免费欧美| 国产精品理伦片| 麻豆精品久久精品色综合| 99久久er热在这里只有精品66| 911精品产国品一二三产区| 日本一区二区三级电影在线观看| 午夜精品久久久久久久久久| 福利一区二区在线|