亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产东北露脸精品视频| 国产在线精品一区二区三区不卡| 樱桃国产成人精品视频| 午夜精品成人在线| 成人av电影免费在线播放| 欧美三级日韩三级国产三级| 日韩免费看的电影| 亚洲精品乱码久久久久久久久| 九一久久久久久| 在线观看成人小视频| 久久综合九色综合97婷婷女人| 亚洲综合久久久久| 不卡免费追剧大全电视剧网站| 51精品秘密在线观看| 亚洲欧美偷拍另类a∨色屁股| 国产精品一区免费在线观看| 91麻豆精品国产91久久久使用方法 | 欧美日本免费一区二区三区| 国产片一区二区| 精品伊人久久久久7777人| 欧美日韩一级片在线观看| 综合激情成人伊人| 成人a区在线观看| 国产视频一区在线观看| 狠狠色狠狠色合久久伊人| 91精品国产一区二区人妖| 亚洲一级在线观看| 欧美性受极品xxxx喷水| 一区二区三区丝袜| 色综合久久综合网97色综合 | 一区二区国产盗摄色噜噜| 成人av网站在线观看免费| 久久久久久久久一| 国内精品自线一区二区三区视频| 欧美成人午夜电影| 六月丁香婷婷久久| 久久综合av免费| 国产毛片精品国产一区二区三区| 欧美精品一区二区久久婷婷| 免费在线一区观看| 精品日韩成人av| 国产一区二区不卡在线| 国产人成亚洲第一网站在线播放 | 久久99久久久久| 精品福利一二区| 国产精品综合久久| 欧美激情一区二区三区蜜桃视频 | 欧美电影一区二区三区| 日本在线不卡一区| 久久综合久色欧美综合狠狠| 国产激情一区二区三区四区| 国产精品毛片无遮挡高清| youjizz国产精品| 一区二区三区精品| 91精品国产美女浴室洗澡无遮挡| 美腿丝袜亚洲色图| 欧美激情在线一区二区三区| 91在线观看下载| 天天综合网 天天综合色| 亚洲精品一区二区三区香蕉| 国产电影精品久久禁18| 亚洲精品一卡二卡| 欧美一区二区三区日韩视频| 国产精品综合二区| 亚洲成人免费看| 久久蜜臀精品av| 在线看不卡av| 激情综合网av| 玉足女爽爽91| 国产欧美一区二区精品秋霞影院| 91视频一区二区| 开心九九激情九九欧美日韩精美视频电影 | 极品少妇xxxx偷拍精品少妇| 国产精品三级电影| 欧美男生操女生| 成人一区二区三区中文字幕| 亚洲国产日日夜夜| 中文字幕高清一区| 欧美三级三级三级爽爽爽| 国产成人在线看| 午夜a成v人精品| 综合久久久久久久| 精品国产一区二区三区av性色| 99国产精品久久| 国产中文字幕一区| 婷婷中文字幕综合| 亚洲婷婷国产精品电影人久久| 日韩一级欧美一级| 日本韩国精品一区二区在线观看| 黄色资源网久久资源365| 亚洲国产精品久久不卡毛片| 中文字幕永久在线不卡| 日韩免费成人网| 欧美日韩www| 色噜噜久久综合| 懂色中文一区二区在线播放| 六月丁香婷婷色狠狠久久| 午夜精品久久久久久久| 亚洲品质自拍视频| 中文字幕中文字幕在线一区| 久久色成人在线| 日韩欧美国产系列| 欧美一区二区三区影视| 欧美亚洲一区二区在线| 色综合天天综合色综合av| 99九九99九九九视频精品| 国产一区二区福利视频| 久久er精品视频| 久久99精品久久久久久动态图 | 国产精品天天摸av网| 2021久久国产精品不只是精品| 在线播放/欧美激情| 欧美日韩免费观看一区三区| 欧美性受xxxx| 欧美视频自拍偷拍| 欧美区一区二区三区| 欧美精品 国产精品| 欧美精品自拍偷拍| 91麻豆精品91久久久久久清纯| 欧美日韩一区二区三区免费看| 欧美性感一区二区三区| 欧美日本一道本| 日韩欧美国产系列| 久久久久久久久久久久久女国产乱 | 日韩一区二区免费在线观看| 日韩一卡二卡三卡国产欧美| 精品美女在线观看| 欧美经典三级视频一区二区三区| 欧美国产综合色视频| 最新国产精品久久精品| 亚洲欧美激情视频在线观看一区二区三区| 亚洲三级免费观看| 亚洲激情图片小说视频| 亚洲成人av在线电影| 蜜桃在线一区二区三区| 国产一区免费电影| 99久久99久久久精品齐齐| 91国内精品野花午夜精品| 在线成人免费视频| 久久亚洲一区二区三区明星换脸| 国产精品久久久久一区二区三区共| 18成人在线视频| 五月激情综合网| 风间由美一区二区av101| 色又黄又爽网站www久久| 欧美一区二区三区四区视频| 国产午夜精品一区二区| 亚洲激情五月婷婷| 国产一区二区三区四区在线观看| av在线不卡电影| 91麻豆精品国产91久久久久久久久| 久久网站热最新地址| 亚洲免费资源在线播放| 美国三级日本三级久久99| 91伊人久久大香线蕉| 777色狠狠一区二区三区| 国产欧美日韩三级| 视频一区二区三区中文字幕| 国产高清成人在线| 欧美军同video69gay| 国产欧美中文在线| 日韩av一区二区三区| 99国产欧美另类久久久精品| 欧美一区二区三区四区五区| 国产精品电影一区二区| 日韩精品福利网| 97精品国产97久久久久久久久久久久| 91麻豆精品国产无毒不卡在线观看| 中文字幕不卡在线播放| 日韩在线一区二区| 91视频在线观看| 国产午夜亚洲精品午夜鲁丝片| 性欧美大战久久久久久久久| 成人免费毛片aaaaa**| 精品美女一区二区| 图片区小说区区亚洲影院| 91蝌蚪porny| 国产欧美一区二区精品性色 | 青娱乐精品视频在线| 成a人片国产精品| 久久网站最新地址| 久久成人综合网| 欧美日韩一区三区| 1000精品久久久久久久久| 国产精品综合在线视频| 91精品国产丝袜白色高跟鞋| 亚洲免费在线播放| 成人午夜短视频| 久久久久亚洲蜜桃| 久久精品国产亚洲5555| 欧美美女网站色| 一区二区三区四区在线播放| 成人国产精品免费网站| 久久亚洲影视婷婷| 国内精品视频一区二区三区八戒| 欧美美女bb生活片| 亚洲一区二区视频在线观看| 91免费看视频| 亚洲伦理在线免费看| 成人av电影在线观看|