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

怎么用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ì)
四虎在线免费视频播放| 99热这里在线只有精品| 国产精品欧美久久久久无| av熟女乱一区二区三区| 未满18禁止观看在线| 欧美日韩国产福利在线观看| 很黄无遮挡在线免费网站| 91免费观看视频高清| 加勒比视频在线观看一区| 亚洲人妻av一区二区| 粉嫩在线一区二区懂色| 午夜精品视频免费91| 欧美 成人一区二区三区| 国产美女高潮流白浆视频免费看 | 一区二区三区在线观看淫| 一区二区三区蜜桃91| 日韩国产传媒在线精品| 久青青国产综合自拍视频在线观看| 美女丝袜诱惑国产在线观看| 中出亚洲精品日韩在线视频 | 国产91高清视频在线观看| 欧美成人精品三级在线网站| 欧美日韩台湾一区二区| 蜜臀91精品视频在线观看| 视频一区视频二区在线| 亚洲最大av在线精品国产| 97水蜜桃视频在线观看| 久久久亚洲熟妇熟女一区二区| va精品人妻一区二区三区| 在线观看高清国产黄色片| 亚洲伦理国产一国产二| 91精品国产91久久综合桃花| 久久国产精品99亚洲| 成年人收看黄色一二级片| 中文字幕人成乱码在线观看| 久草国产免费福利在线视频| 91久久精品国产一区蜜臀| av黄色成人在线观看| 日韩成人高清免费在线| 少妇被啪出水在线视频| 日韩乱码高清一本免费啪|