欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

怎么用C語言寫推箱子游戲

本篇內(nèi)容介紹了“怎么用C語言寫推箱子游戲”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

成都創(chuàng)新互聯(lián)主營甘井子網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,app軟件定制開發(fā),甘井子h5小程序開發(fā)搭建,甘井子網(wǎng)站營銷推廣歡迎甘井子等地區(qū)企業(yè)咨詢

#include <stdio.h>#include <stdlib.h>#include<string.h>#include <conio.h>//行和列 #define ROW 10#define COL 11/* run this program using the console pauser or add your own getch, system("pause") or input loop *//*****///地圖char map[ROW][COL] = { "##########",//0 "###  ##",//1 "###  ##",//2 "##AX # ##",//3 "### ## ",//4 "##### #",//5 "##  #",//6 "#  ####",//7 "###  ",//8 "##########" //9 //A:人 , X:箱子  } ;//打印地圖 void showMap();//接收小人的方向char enterDirection(); //小人向上移動(dòng)的方法void moveToUp(); //小人向下移動(dòng)的方法void moveToDown(); //小人向右移動(dòng)的方法void moveToRight(); //小人向左移動(dòng)的方法void moveToLeft();  //當(dāng)前小人的坐標(biāo)int currentPersonRow = 3;int currentPersonCol = 2;//當(dāng)前箱子的坐標(biāo) int currentBoxRow = 3;int currentBoxCol = 3;   int main(int argc, char *argv[]) { //system("clear"); printf("點(diǎn)擊回車鍵開始游戲 ^_^\n\n"); //1代表運(yùn)行 0停止  int flag = 1; while(flag==1){ //顯示地圖  showMap(); //接收小人的方向 char dir = enterDirection(); switch(dir){  //小人向上移動(dòng)   case 'w':  case 'W':   moveToUp();  break;    //小人向下移動(dòng)   case 's':  case 'S':   moveToDown();  break;  //小人向右移動(dòng)   case 'd':  case 'D':   moveToRight();  break;  //小人向左移動(dòng)   case 'a':  case 'A':   moveToLeft();  break;  //停止運(yùn)行   case 'q':  case 'Q':   printf("你的智商真低!T_T\n");   flag = 0;  break; } showMap(); if(currentBoxRow==8&¤tBoxCol==9){  printf("你的智商真高^_^!!!");  flag = 0;   } } }/*方法的實(shí)現(xiàn) */  //打印地圖 void showMap(){ int i; for(i = 0;i < ROW; i++){  printf("%s\n",map[i]); } printf("\n\n\n\n\n");  printf("W:上,S:下, A:左, D:右。Q:退出"); printf("\n\n\n\n\n");}//接收小人的方向char enterDirection(){ //清除SCANF中的緩沖區(qū)  rewind(stdin); char dir; dir = getch(); //scanf("%c",&dir); return dir;}//小人向上移動(dòng)的方法void moveToUp(){ //小人的下一個(gè)坐標(biāo)  int nextPersonCol = currentPersonCol; int nextPersonRow = currentPersonRow - 1; //箱子的下一個(gè)坐標(biāo) int nextBoxRow = currentBoxRow - 1; int nextBoxCol = currentBoxCol;   //如果小人的下一個(gè)坐標(biāo)是路  if(map[nextPersonRow][nextPersonCol]==' '){ map[nextPersonRow][nextPersonCol] = 'A'; map[currentPersonRow][currentPersonCol] = ' '; currentPersonRow = nextPersonRow; currentPersonCol = nextPersonCol; } //如果小人的下一個(gè)坐標(biāo)是墻  if(map[nextPersonRow][nextPersonCol]=='#'){  //什么也不做  } //如果小人的下一個(gè)坐標(biāo)是箱子  if(map[nextPersonRow][nextPersonCol]=='X'){  if(map[nextBoxRow][nextBoxCol] == ' '){    map[nextPersonRow][nextPersonCol] = 'A';  map[currentPersonRow][currentPersonCol] = ' ';    map[nextBoxRow][nextBoxCol] = 'X';  map[currentBoxRow][currentBoxCol] = 'A';     currentPersonRow = nextPersonRow;  currentPersonCol = nextPersonCol;  currentBoxRow = nextBoxRow;  currentBoxCol = nextBoxCol; } }}//小人向下移動(dòng)的方法void moveToDown(){  //小人的下一個(gè)坐標(biāo)  int nextPersonCol = currentPersonCol; int nextPersonRow = currentPersonRow + 1; //箱子的下一個(gè)坐標(biāo) int nextBoxRow = currentBoxRow + 1; int nextBoxCol = currentBoxCol;   //如果小人的下一個(gè)坐標(biāo)是路  if(map[nextPersonRow][nextPersonCol]==' '){ map[nextPersonRow][nextPersonCol] = 'A'; map[currentPersonRow][currentPersonCol] = ' '; currentPersonRow = nextPersonRow; currentPersonCol = nextPersonCol; } //如果小人的下一個(gè)坐標(biāo)是墻  if(map[nextPersonRow][nextPersonCol]=='#'){  //什么也不做  } //如果小人的下一個(gè)坐標(biāo)是箱子  if(map[nextPersonRow][nextPersonCol]=='X'){  if(map[nextBoxRow][nextBoxCol] == ' '){    map[nextPersonRow][nextPersonCol] = 'A';  map[currentPersonRow][currentPersonCol] = ' ';    map[nextBoxRow][nextBoxCol] = 'X';  map[currentBoxRow][currentBoxCol] = 'A';    currentPersonRow = nextPersonRow;  currentPersonCol = nextPersonCol;  currentBoxRow = nextBoxRow;  currentBoxCol = nextBoxCol; } }} //小人向右移動(dòng)的方法void moveToRight(){ //小人的下一個(gè)坐標(biāo)  int nextPersonCol = currentPersonCol + 1; int nextPersonRow = currentPersonRow; //箱子的下一個(gè)坐標(biāo) int nextBoxRow = currentBoxRow; int nextBoxCol = currentBoxCol + 1;   //如果小人的下一個(gè)坐標(biāo)是路  if(map[nextPersonRow][nextPersonCol]==' '){ map[nextPersonRow][nextPersonCol] = 'A'; map[currentPersonRow][currentPersonCol] = ' '; currentPersonRow = nextPersonRow; currentPersonCol = nextPersonCol; } //如果小人的下一個(gè)坐標(biāo)是墻  if(map[nextPersonRow][nextPersonCol]=='#'){  //什么也不做  } //如果小人的下一個(gè)坐標(biāo)是箱子  if(map[nextPersonRow][nextPersonCol]=='X'){  if(map[nextBoxRow][nextBoxCol]==' '){    map[nextPersonRow][nextPersonCol] = 'A';  map[currentPersonRow][currentPersonCol] = ' ';    map[nextBoxRow][nextBoxCol] = 'X';  map[currentBoxRow][currentBoxCol] = 'A';    currentPersonRow = nextPersonRow;  currentPersonCol = nextPersonCol;  currentBoxRow = nextBoxRow;  currentBoxCol = nextBoxCol; } }}//小人向左移動(dòng)的方法void moveToLeft(){ //小人的下一個(gè)坐標(biāo)  int nextPersonCol = currentPersonCol - 1; int nextPersonRow = currentPersonRow; //箱子的下一個(gè)坐標(biāo) int nextBoxRow = currentBoxRow; int nextBoxCol = currentBoxCol - 1;   //如果小人的下一個(gè)坐標(biāo)是路  if(map[nextPersonRow][nextPersonCol]==' '){ map[nextPersonRow][nextPersonCol] = 'A'; map[currentPersonRow][currentPersonCol] = ' '; currentPersonRow = nextPersonRow; currentPersonCol = nextPersonCol; } //如果小人的下一個(gè)坐標(biāo)是墻  if(map[nextPersonRow][nextPersonCol]=='#'){  //什么也不做  } //如果小人的下一個(gè)坐標(biāo)是箱子  if(map[nextPersonRow][nextPersonCol]=='X'){  if(map[nextBoxRow][nextBoxCol]==' '){  map[nextPersonRow][nextPersonCol] = 'A';  map[currentPersonRow][currentPersonCol] = ' ';    map[nextBoxRow][nextBoxCol] = 'X';  map[currentBoxRow][currentBoxCol] = 'A';    currentPersonRow = nextPersonRow;  currentPersonCol = nextPersonCol;  currentBoxRow = nextBoxRow;  currentBoxCol = nextBoxCol; } }}

“怎么用C語言寫推箱子游戲”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

文章名稱:怎么用C語言寫推箱子游戲
URL鏈接:http://aaarwkj.com/article20/isjeco.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)標(biāo)簽優(yōu)化、面包屑導(dǎo)航企業(yè)網(wǎng)站制作、品牌網(wǎng)站設(shè)計(jì)、外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計(jì)
国语少妇高潮对白在线| 国产成人亚洲综合色影视| 玩弄丰满熟妇留守妇女| 国产亚洲一区二区三区在线| 97免费公开在线观看| 国产亚洲精品第一最新| 蜜桃国产精品视频网站| 久久婷婷综合激情亚洲| 精品国产美女主播在线| 国产精品国产三级国产不产一地| 尤物视频最新在线观看| 少妇人妻精品一区三区二区| 国产一区二区91精品| jvid视频在线观看免费| 国产欧美日韩精品三级| 日本欧美高清一区二区| 精品欧美国产日韩在线观看| 日韩精品一区二区av在线| 日本午夜一区二区在线观看| 美女床上激情啪啪网页| 欧美成人午夜精品一区二区| 久久亚洲春色中文字幕| 91中文字幕精品一区二区| 91在线国产精品视频| 久久久久久成人综合色| 日韩精品一区二区三区人妻视频| 亚洲成在人天堂一区二区| av天堂网站在线观看| 大香蕉国产精品视频在线| 亚洲 欧美 日韩一区| 国产一区av剧情巨作| 黄色av链接在线观看| 亚洲综合国产一二三四五区| 99久久久精品国产免费| 神马视频一区二区在线观看| 一区二区高清免费日本| 国产蜜臀视频在线播放| 久久久国产精品视频一区| 亚洲欧洲一区二区免费| 97免费人妻在线视频| 国产成人精品免费视频大|