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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? main.cpp

?? A*尋路算法, 源代碼中使用的SDL庫(kù)
?? CPP
字號(hào):
///////////////////////////////////////////////////////////////// A* pathfind using "manhattan distance" heuristic//// This program is a simple example of pathfind based on A*// algorithm.// I have implemented the algorithm using linked list, this is// not the best solution, because of the linear time need to access// to the listes, but this is the simplest way, and this is just// an example! ;)// For a better implementation of A* give a look at Mars source// code, when we will release it... :) //// for info about A* algorithm and "manhattan distance" heuristic// give a look at:// - http://theory.stanford.edu/~amitp/GameProgramming/// - http://www.policyalmanac.org/games/aStarTutorial.htm// guys, thanx for your articles!////// To play with it, just select the grey "robot", it should (I hope :)) // became blue, now you can select a destination, the program will calculate// the shortest path and move along it.//// During the "game" you could use these keys://// - SPACEBAR -> change video mode (window/fullscreen)// - p -> pause/restart the game// - ESC -> exit////// This software is released under GPL license, you can find a // copy of this license at http://www.gnu.org/copyleft/gpl.html// //// Last update date: // 	2005-02-15 //// Author:// 	Davide "M3xican" Coppola - dmc@dev-labs.net//// NOTE: // // This program is part of "Mars, Land of No Mercy" SDL examples, // you can find others examples on http://mars.sourceforge.net//	/////////////////////////////////////////////////////////////////#include <stdio.h>#include <stdlib.h>#include <string.h>#include <SDL/SDL.h>#include "define.h"#include "graphic.h"#include "grind.h"#include "pathfind.h"#include "struct.h"int main(int argc,char *argv[]){	//used surfaces	SDL_Surface *screen;	SDL_Surface *screen_backup;	SDL_Surface *robot;	SDL_Surface *bg_robot;	//three SDL_Color structures 	SDL_Color black = {0x00,0x00,0x00,0};	SDL_Color light_grey = {0xDD,0xDD,0xDD,0};	SDL_Color grey = {0x99,0x99,0x99,0};	SDL_Color light_blue = {0x33,0x66,0x99,0};	SDL_Color red = {0xFF,0x00,0x00,0};	SDL_Color white = {0xFF,0xFF,0xFF,0};	//the system video is initialized 	if( SDL_Init(SDL_INIT_VIDEO) <0 )	{		//SDL_GetError() returns a description of the error		printf("SDL Init Error: %s\n", SDL_GetError());	        return 1;	}	//when exit, execute SDL_Quit to restore everything	atexit(SDL_Quit);		//a 32 bit integer used to store screen's flags 	Uint32 flags = SDL_HWSURFACE|SDL_DOUBLEBUF;	//SDL_SetVideoMode is used to have screen associated to the monitor 	if(!( screen = SDL_SetVideoMode(DIM_H, DIM_V, 0,flags) ))	{		  printf("Screen Init Error : %s\n", SDL_GetError());		  return 1;	}	//white background	fill_square(screen, NULL, white);	//screen_backup is a surface of the same dimensions of screen used  to save the image when the user	//changes its form (window to full screen and vice versa). 	screen_backup = SDL_CreateRGBSurface(flags,screen->w,screen->h,screen->format->BitsPerPixel,0,0,0,0);	robot = SDL_CreateRGBSurface(flags,CELL_SIDE-ROBOT_DIST,CELL_SIDE-ROBOT_DIST,								screen->format->BitsPerPixel,0,0,0,0);	bg_robot = SDL_CreateRGBSurface(flags,CELL_SIDE-ROBOT_DIST,CELL_SIDE-ROBOT_DIST,									screen->format->BitsPerPixel,0,0,0,0);	//paint robot	fill_square(robot, NULL, grey);		//map rectangle	SDL_Rect grind = {CELL_SIDE/2,CELL_SIDE/2,DIM_H-CELL_SIDE,DIM_V-CELL_SIDE}; 	//manual test map 	int map[NUM_ROWS][NUM_COLS]={{1,1,1,1,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1},								 {1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,0,0,0,1},								 {1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1},								 {1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1},								 {1,0,0,0,0,0,1,1,1,1,0,1,1,1,1,1,1,1,1},								 {1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1},								 {1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1},								 {1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1},								 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},								 {0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1},								 {0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1},								 {1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1},								 {1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,1,0,1,1},								 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};	//secret MARS map :)	/* 	int map[NUM_ROWS][NUM_COLS]={{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},								 {1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1},								 {1,1,1,0,0,1,0,0,1,1,1,1,0,1,0,1,1,1,1},								 {1,1,1,0,1,0,1,0,1,1,1,1,0,1,0,1,1,1,1},								 {1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,1,1,1},								 {1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1},								 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},								 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},								 {1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1},								 {1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1},								 {1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1},								 {1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1},								 {1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,1,1,1},								 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};	*/	//draw map on screen	draw_map(screen,grind,map);	//cell occupied by the robot	cell_ind robot_cell;	//robot is selected?	bool robot_sel = false;	//destination point	point robot_dest;	//path indexes 	cell_ind * robot_path;	//path lenghth	int len_path = 0, bk_len = 0;	int ind_path = 0;	bool need_checkp = false;	//get a free cell to place the robot on the map	get_free_cell(map,&robot_cell);	//robot rect	SDL_Rect robot_rect = {grind.x + (robot_cell.col * CELL_SIDE) + ROBOT_DIST/2, 			 				grind.y + (robot_cell.row * CELL_SIDE) + ROBOT_DIST/2, robot->w, robot->h};		//upper left vertex of a cell 	point cell_vert;	//variables used to store row and column indexes of a cell	cell_ind mouse_cell = {0,0}, old_cell = {0,0}, dest_cell;	bool cell_sel = false;	point mouse = {0,0};	//SDL_Event struct used to manage events	SDL_Event event;	//variable used to control the game loop 	bool done = false;	bool paused = false;	//game or main loop (as you prefer)	while(!done)	 	{		//SDL_PollEvent manages user's events 		while(SDL_PollEvent(&event))		{						//the program quits if someone press the x simbol of the window with the mouse 			if(event.type == SDL_QUIT)  				done = true;  			if(event.type == SDL_KEYDOWN)			{				//it quits also if someone press ESC 				if ( event.key.keysym.sym == SDLK_ESCAPE ) 					done = true; 				else if ( event.key.keysym.sym == SDLK_p ) 					paused = !paused ;				//visualization form is changed if someone press SPACE 				//(from window to full screen and vice versa)				if(event.key.keysym.sym == SDLK_SPACE ) 				{					//the actual screen is saved in screen_backup					SDL_BlitSurface(screen,NULL,screen_backup,NULL);					//visualization form is changed					flags^=SDL_FULLSCREEN;					screen = SDL_SetVideoMode(DIM_H, DIM_V, 0,flags);					//the original image is reBlitted					SDL_BlitSurface(screen_backup,NULL,screen,NULL);				}			}			//a point is selected when the left mouse button is pressed       		if(event.button.button == BUTTON_SX && event.button.type == SDL_MOUSEBUTTONDOWN)			{				//robot cell clicked				if(mouse_cell.row == robot_cell.row && mouse_cell.col == robot_cell.col)				{					//robot not yet selected					if(!robot_sel)					{								robot_sel = true;						fill_square(robot, NULL, light_blue);					}					else	//robot selected					{						robot_sel = false;						fill_square(robot, NULL, grey);					}				}				//free cell clicked to move				else if(map[mouse_cell.row][mouse_cell.col] && robot_sel && !len_path)					{					cell_sel = true;					dest_cell.row = mouse_cell.row;					dest_cell.col = mouse_cell.col;					len_path = pathfind(map,robot_cell,dest_cell,&robot_path);					if(len_path)					{						//backup path lenght						bk_len = len_path;						need_checkp = true;						//draw path						colour_path(robot_path,len_path,screen,black,light_grey);					}				}			}				//moving with the mouse			if(event.motion.type == SDL_MOUSEMOTION)			{				//coordinates of rectangle that contains the pointer are updated				mouse.x = event.button.x;				mouse.y = event.button.y;				//horizontal bounds checks				if(mouse.x >= DIM_H)					mouse.x = DIM_H-1;				else if(mouse.x < 0)					mouse.x = 0;							//vertical bound checks				if(mouse.y >= DIM_V)					mouse.y = DIM_V-1;				else if(mouse.y < 0)					mouse.y = 0;								if(mouse.x >= (CELL_SIDE/2) && mouse.x <= (DIM_H - 1 - (CELL_SIDE/2)) && 	   			mouse.y >= (CELL_SIDE/2) && mouse.y <= (DIM_V - 1 - (CELL_SIDE/2)))				{					//column and row indexes of the cell where the mouse is located					mouse_cell.row = (mouse.y - grind.y) / CELL_SIDE;					mouse_cell.col = (mouse.x - grind.x) / CELL_SIDE;										//if the actual cell is different from the previous calculated we refresh 					//the selection					if((mouse_cell.row != old_cell.row || mouse_cell.col != old_cell.col) 					&& map[mouse_cell.row][mouse_cell.col])					{						//old cell borders are colored of black 						cell_vert.y = (old_cell.row * CELL_SIDE) + grind.y;							cell_vert.x = (old_cell.col * CELL_SIDE) + grind.x;						draw_square(screen,cell_vert,CELL_SIDE,black);							//new cell borders are colored of red 						cell_vert.y = (mouse_cell.row * CELL_SIDE) + grind.y;						cell_vert.x = (mouse_cell.col * CELL_SIDE) + grind.x;						draw_square(screen,cell_vert,CELL_SIDE,red);							//the old indexes are updated 						old_cell.row = mouse_cell.row;						old_cell.col = mouse_cell.col;					}				}			}		}		//robot have to move		if(len_path && !paused)		{			//get a new checkpoint			if(need_checkp)			{				need_checkp = false;				dest_point((*(robot_path+ind_path)),&robot_dest);			}			//move on!			if(update_position(&robot_rect,robot_dest))			{				//update current robot position				robot_cell.row = (robot_path+ind_path)->row;				robot_cell.col = (robot_path+ind_path)->col;				len_path--;				ind_path++;									//another checkpoint				if(len_path)					need_checkp = true;				//arrived to dest!				else				{					ind_path = 0;						decolour_path(robot_path,bk_len,screen,black,white);					free(robot_path);				}			}		}		//robot blit management		SDL_BlitSurface(screen, &robot_rect, bg_robot, NULL); 		SDL_BlitSurface(robot, NULL, screen, &robot_rect);				//the screen is refreshed		SDL_Flip(screen);				//clear robot trail		SDL_BlitSurface(bg_robot, NULL, screen, &robot_rect);		//a minimum delay 		SDL_Delay(1);	}	return 0;}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品福利一二区| 欧美激情一区二区三区| 精品一区二区三区在线观看国产| 国产偷v国产偷v亚洲高清| 欧美在线你懂的| 国产不卡免费视频| 美腿丝袜在线亚洲一区| 亚洲免费在线视频| 久久综合久色欧美综合狠狠| 欧美视频中文一区二区三区在线观看| 国产在线一区二区综合免费视频| 亚洲成人中文在线| 最新日韩在线视频| 久久久久99精品一区| 宅男在线国产精品| 欧美图区在线视频| 91日韩一区二区三区| 国产高清精品网站| 国产综合久久久久影院| 亚洲h在线观看| 一区二区三区蜜桃网| 国产精品色呦呦| 久久久蜜桃精品| 日韩欧美综合在线| 中文字幕av一区二区三区高| 欧美日韩一区高清| 从欧美一区二区三区| 狠狠色2019综合网| 美女性感视频久久| 日本系列欧美系列| 日韩 欧美一区二区三区| 亚洲午夜精品网| 亚洲情趣在线观看| 亚洲日韩欧美一区二区在线| 亚洲国产精品精华液2区45| 久久久欧美精品sm网站| 久久久亚洲午夜电影| 久久久亚洲高清| 国产亚洲欧美在线| 久久久三级国产网站| 久久久91精品国产一区二区精品| 亚洲精品一区在线观看| 26uuu亚洲综合色欧美| 精品国免费一区二区三区| 日韩你懂的在线播放| 精品对白一区国产伦| 精品国产免费人成电影在线观看四季 | 色8久久精品久久久久久蜜| 成人不卡免费av| 色综合久久99| 欧美日韩一区二区三区高清| 欧美电影一区二区| 欧美一区二区三区啪啪| 精品福利一区二区三区免费视频| 久久久美女毛片| 中文字幕在线观看一区二区| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 久久精品国产网站| 国产露脸91国语对白| 91成人看片片| 亚洲一区在线观看免费观看电影高清| 日韩精品最新网址| 久久综合国产精品| 中文字幕亚洲一区二区av在线| 亚洲青青青在线视频| 午夜a成v人精品| 激情图区综合网| 99久久国产综合精品麻豆| 色综合中文字幕| 51精品视频一区二区三区| 久久精品在线免费观看| 亚洲欧洲国产专区| 日韩av一级电影| 国产91对白在线观看九色| 91福利国产成人精品照片| 日韩一区二区三区视频| 中文字幕第一区二区| 亚洲福利一二三区| 国产精品伊人色| 欧美性受xxxx黑人xyx性爽| 欧美草草影院在线视频| 综合久久久久久久| 日本va欧美va瓶| 成人av免费在线播放| 欧美精品在欧美一区二区少妇| 国产婷婷一区二区| 亚洲高清不卡在线观看| 国产一区二区免费视频| 欧美视频日韩视频在线观看| 久久久精品2019中文字幕之3| 亚洲激情欧美激情| 国产麻豆欧美日韩一区| 欧美日本一区二区三区四区| 国产三级精品在线| 日韩电影一区二区三区四区| 99视频热这里只有精品免费| 日韩视频免费观看高清完整版在线观看 | 国产午夜精品理论片a级大结局| 一级中文字幕一区二区| 国产精品99久久久| 91精品国产全国免费观看| 成人欧美一区二区三区| 久久99深爱久久99精品| 91国偷自产一区二区使用方法| 久久青草国产手机看片福利盒子 | 国产精品1区二区.| 日本一区二区成人| 不卡影院免费观看| 精品日韩成人av| 韩国v欧美v亚洲v日本v| 亚洲色图视频网| 亚洲视频综合在线| 国产成人无遮挡在线视频| 欧美一级专区免费大片| 亚洲一二三四在线| 91在线porny国产在线看| 国产欧美综合色| 久热成人在线视频| 欧美日韩成人激情| 一区二区三区四区精品在线视频| 成人黄色电影在线 | 亚洲精品视频在线| 成人免费av网站| 国产色产综合色产在线视频| 国产专区综合网| 欧美精品一区二区三区蜜桃| 性做久久久久久免费观看欧美| 91九色02白丝porn| 亚洲精品国产一区二区精华液| 精品少妇一区二区三区免费观看 | 亚洲自拍都市欧美小说| 99riav一区二区三区| 国产精品色在线观看| 丁香婷婷综合色啪| 国产精品丝袜91| 日韩一级成人av| 人人狠狠综合久久亚洲| 69p69国产精品| 日本在线不卡视频| 日韩精品一区二区三区视频播放| 麻豆成人久久精品二区三区小说| 日韩丝袜情趣美女图片| 久久66热偷产精品| 久久久久久亚洲综合影院红桃| 狠狠色丁香婷婷综合| 久久噜噜亚洲综合| 成人美女在线观看| 亚洲精品福利视频网站| 欧美怡红院视频| 日韩电影一区二区三区四区| 日韩一区二区三区三四区视频在线观看| 蜜桃久久久久久久| 久久精品亚洲精品国产欧美kt∨ | 国产精品亚洲成人| 国产精品麻豆欧美日韩ww| 成人avav影音| 亚洲电影中文字幕在线观看| 99热精品一区二区| 欧美剧情片在线观看| 亚洲天堂av老司机| 欧美亚洲免费在线一区| 日日夜夜免费精品视频| 久久综合九色综合久久久精品综合 | 国产成人免费网站| 亚洲人成伊人成综合网小说| 欧美日韩国产bt| 国产一区二区三区最好精华液| 亚洲欧洲在线观看av| 欧美色视频一区| 国产一区二区三区在线观看免费| 中文字幕在线不卡| 欧美日韩国产综合久久| 久久精品国产亚洲5555| 综合久久一区二区三区| 欧美一三区三区四区免费在线看| 精品一区二区三区在线视频| 亚洲欧洲av另类| 91精品国产综合久久香蕉的特点| 国产宾馆实践打屁股91| 午夜精品123| 国产亚洲女人久久久久毛片| 欧美视频第二页| 国产一区二区调教| 亚洲444eee在线观看| 久久青草国产手机看片福利盒子| 在线观看视频一区二区 | 国产一区二区影院| 91美女视频网站| 国产精品视频免费| www.综合网.com| 国产精品毛片久久久久久| 国产成人夜色高潮福利影视| 国产欧美一区二区精品仙草咪| 欧美影视一区在线| 成人免费视频播放| 美国毛片一区二区三区| 亚洲午夜精品17c| 国产精品国产a| 久久一区二区三区四区| 欧美另类z0zxhd电影|