日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言while运行出现错误,【图片】为什么我的while(1)不执行啊?【c语言吧】_百度贴吧...

發布時間:2023/12/4 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言while运行出现错误,【图片】为什么我的while(1)不执行啊?【c语言吧】_百度贴吧... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

該樓層疑似違規已被系統折疊?隱藏此樓查看此樓

#include

#include

#include

#include

#include

/*

設定:

玩家:

攻擊力,生命值,技能效果,CD;

敵人:

攻擊力,生命值,CD;

//跳躍怎么做?如果我想要子彈打在敵人身上才算攻擊成功,怎么做?結構體:玩家,敵人。

子函數:畫布初始化。

玩家初始化。

敵人初始化。//需要么?

繪制玩家。

繪制敵人。

繪制玩家技能。

繪制敵人技能。

繪制玩家跳躍動畫(5幀)

玩家行為函數。

敵人行為函數。

//嘗試敵人攻擊頻率隨機。*/

void fun(int ch); //用于控制英雄的行為模式

void fun2(); //用于控制敵人的行為模式

void hero_init(); //初始化英雄 √

int random(); //產生隨機數 √

void paper_print(); //畫紙打印到命令行界面上 √

void paint_dragon(int x,int y); //把大龍畫到畫紙上 √

void paint_hero(int x,int y); //把英雄畫到畫紙上 √

void paint_dragon_health(); //把大龍生命條畫到畫紙上 //能不能做到攻擊敵人敵人生命條遞減? √(理論上遞減)

void paint_hero_skill_e(); //繪制技能動畫 √

void paint_hero_skill_w(); //跳躍動畫

void paint_dragon_skill(); //把大龍技能畫到畫紙上 √

void paper_init(); //清空畫紙 √

char paper[25][110];int mode1=0;

int mode2=0;

int protect=0;

struct hero

{

char name[100];

int health;

int attack;

int delay;

};struct dragon

{

char name[100];

int health;

int attack;

int delay;

};struct hero player;struct dragon enemy;void dragon_init()

{

// enemy.name = "dragon";

enemy.health = 50;

enemy.attack = 20;

enemy.delay = 10;

}int main(int argc, char *argv[]) //主函數

{

int ch,i,j;

srand((unsigned int)time(NULL));

hero_init();

dragon_init();

paper_init();

for(;;)

{

if(enemy.health<0||player.health<0)

// {break;}

// system("cls");

if(_kbhit)

{

ch = _getch();

}

paper_init();

paint_dragon_health();

fun(ch);

fun2();

ch = 0;

paint_dragon(106,23);

paper_print();

printf("\n");

printf("玩家: 姓名:%s 生命值:%d 攻擊力:%d 技能CD:%d s\n",player.name,player.health,player.attack,player.delay);

printf("%d",ch); sleep(50);

printf("%d",1);

}

system("cls");

if(player.health < 0)

{

printf("DEAD\n");

}

if(enemy.health < 0)

{

printf("WIN\n");

}

return 0;

}

void paper_init() //畫紙初始化

{

int i,j;

for(i=0;i<25;i++){

for(j=0;j<110;j++){

paper[i][j] = ' ';

}

}

}void paper_print() //繪制函數

{

int i,j;

for(i=0;i<25;i++)

{

for(j=0;j<110;j++){printf("%c",paper[i][j]);}

printf("\n");

}

}void paint_dragon_skill() //繪制敵人技能動畫

{

int i,j;

for(i = 99;i >5; i--){

for(j=23;j>22;j--){

paper[j][i] = '-';

}

}

}void paint_hero_skill_e(int x) //繪制玩家技能動畫

{

int i,j;

for(i = 24;i > 22; i--){

for(j=x;j

paper[i][j] = '|';

}

}

}void paint_hero_skill_w() //繪制玩家跳躍動畫

{

switch(player.delay)

{

case 3:

paint_hero(2,22);

protect=1;

break;

case 2:

paint_hero(2,21);

protect=1;

break;

case 1:

paint_hero(2,22);

protect=1;

break;

case 0:

paint_hero(2,23);

protect=0;

break;

}

}

void paint_hero(int x,int y) //繪制玩家

{

paper[y-1][x] = '@';

paper[y][x-1] = '/';

paper[y][x] = '|';

paper[y][x+1] = '-';

paper[y+1][x-1] = '/';

paper[y+1][x] = ' ';

paper[y+1][x+1] = '|';

}void paint_dragon(int x,int y) //繪制敵人

{

switch(mode2)

{

case 0://正常

paper[y][x] = ')';

paper[y][x-1] = ' ';

paper[y][x-2] = ' ';

paper[y][x-3] = '0';

paper[y][x-4] = 'w';

paper[y][x-5] = '0';

paper[y][x-6] = '(';

break;

case 1://被擊中

paper[y][x] = ')';

paper[y][x-1] = ' ';

paper[y][x-2] = ' ';

paper[y][x-3] = '

paper[y][x-4] = 'a';

paper[y][x-5] = '>';

paper[y][x-6] = '(';

break;

case 2://攻擊

paper[y][x] = ')';

paper[y][x-1] = ' ';

paper[y][x-2] = ' ';

paper[y][x-3] = '=';

paper[y][x-4] = 'W';

paper[y][x-5] = '=';

paper[y][x-6] = '(';

break;

case 3:

paper[y][x] = ')';

paper[y][x-1] = ' ';

paper[y][x-2] = ' ';

paper[y][x-3] = '>';

paper[y][x-4] = 'w';

paper[y][x-5] = '

paper[y][x-6] = '(';

break;

}

}void paint_dragon_health() //繪制大龍血條

{

int i,j;

for(i=110;i>(110-enemy.health);i--)

for(j=2;j<3;j++)

{

paper[j][i] = '*';

}

}int random()

{

return rand();

}void hero_init() //英雄初始化

{

int ch;

int time = 0;

printf("請輸入您的名字:\n");

scanf("%s",&player.name);

player.delay = 0;

do

{

if(time!=0)

if(_kbhit)

{

ch = _getch();

if(ch==13) {break;}

else if(ch!=32) {continue;}

}

else {continue;}

system("cls");

printf("自動生成數據如下:\n");

printf("玩家姓名:%s\n生命值:%d\n攻擊力:%d\n攻擊CD:%d s\n",player.name,player.health = random()%20+90,player.attack = random()%5+15,1);

printf("按 回車 鍵繼續,按 空格 鍵重新生成數據。");

time = 1;

}while(1);

}

void fun(int ch) //玩家行動函數

{

if(player.delay == 0)

{

switch(ch)

{

case 119:

player.delay = 3;

mode1 = 1;

break;

case 101:

player.delay = 5;

mode1 = 2;

if(paper[24][99] == '|')

{

mode2 = 1;

paint_dragon(106,23);

enemy.health = enemy.health - player.attack;

}

break;

}

}

switch(mode1)

{

case 0:

paint_hero(2,23);

break;

case 1:

paint_hero_skill_w();

break;

case 2:

paint_hero(2,23);

paint_hero_skill_e(3 + 20*(5 - player.delay));

break;

}

if(player.delay > 0)

{

player.delay--;

}

else {player.delay = 0;}

}void fun2() //敵人行動函數

{

if(enemy.delay == 0)

{

mode2 = 2;

paint_dragon(106,23);

paint_dragon_skill();

if(protect == 0) {player.health = player.health - enemy.attack;}

}

else if(enemy.delay == 3)

{

mode2 = 3;

paint_dragon(106,23);

}

else {paint_dragon(106,23);}

if(enemy.delay > 0)

{

enemy.delay--;

}

else {enemy.delay = 0;}

}

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的c语言while运行出现错误,【图片】为什么我的while(1)不执行啊?【c语言吧】_百度贴吧...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。