? 刚学了一学期的C语言,记录一下
?
#include <stdio.h>
#include <Windows.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#define SIZE sizeof(struct chizu)
struct de_ta {
int ima;//现在的关卡
}de_ta;
struct chizu {
int x;
struct chizu *tsugi;
};
int lianbiao=0;//链表是否存在的判断
int panduanjikann;//判断函数中时间
int npcaiii=time(NULL);
bool huanchong=0; //布尔型
HANDLE *houtpoint;//句柄指针 用于双重缓冲
struct chizu *head; //链表首地址
int chizu1[10][10]=
{
{2,2,2,2,2,2,2,2,2,2},
{2,0,0,0,0,0,0,0,0,2},
{2,-1,9,7,10,6,11,12,0,2},
{2,0,7,7,0,0,5,0,0,2},
{2,0,7,7,0,0,0,0,0,2},
{2,0,0,0,0,0,4,4,0,2},
{2,0,0,0,5,0,4,4,0,2},
{2,0,0,0,0,0,0,0,0,2},
{2,0,1001,1001,1001,1001,1001,1001,0,2},
{2,2,2,2,3,3,2,2,2,2},
};
char setsu[80];//说明对话等
char tenonaka[10];
char data1[10][30];
int chizu2[29][60]=//15木 1002叶 1001草 13瓦 2墙 14窗 8人 17人(npc2)
{
{0,0,13,13,13,13,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,13,13,13,13,13,13,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{13,13,13,13,13,13,13,13,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{13,13,13,13,13,13,13,13,13,0,0,1002,1002,1002,0,0,0,1002,1002,1002,0,0,0,1002,1002,1002,0,0,0,1002,1002,1002,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{2,0,0,0,0,0,0,0,2,0,0,1002,1002,1002,0,0,0,1002,1002,1002,0,0,0,1002,1002,1002,0,0,0,1002,1002,1002,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{2,0,14,0,0,0,14,0,2,0,0,1002,15,1002,0,0,0,1002,15,1002,0,0,0,1002,15,1002,0,0,0,1002,15,1002,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{2,0,0,0,3,0,0,0,2,0,0,0,15,0,0,0,0,0,15,0,0,0,0,0,15,0,0,0,0,0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{2,2,2,2,3,2,2,2,2,0,1001,1001,15,1001,1001,1001,1001,1001,15,1001,1001,1001,1001,1001,15,1001,1001,1001,1001,1001,15,1001,1001,1001,1001,0,0,0,2001,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,-1,0,0,0,0,0,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,2,2,1001,1001,1001,1001,1001,1001,1001,1001,1001,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,0,0,0,0,0,0},
};
char data2[28][122];
char shangyibu='\0';
int chizu3[40][80]={
{0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0},
{0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0},
{13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0},
{13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0},
{2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0},
{2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0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,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0},
{13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0},
{13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0},
{2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0},
{2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0},
{2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0},
{2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0},
{0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0},
{13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0},
{13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0,0,0,13,13,13,13,13,0,0,0},
{0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0,0,13,13,13,13,13,13,13,0,0},
{13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0},
{13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0,13,13,13,13,13,13,13,13,13,0},
{2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,2,0},
{2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0,2,0,14,0,0,0,14,0,2,0},
{2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,0,3,0,0,0,2,0,2,0,0,3,3,3,0,0,2,0},
{2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,2,3,2,2,2,2,0,2,2,2,3,3,3,2,2,2,0},
};
//两个句柄用于双重缓冲
HANDLE gamenn1 = CreateConsoleScreenBuffer(
GENERIC_WRITE, //定义进程可以往缓冲区写数据
FILE_SHARE_WRITE, //定义缓冲区可共享写权限
NULL,
CONSOLE_TEXTMODE_BUFFER,
NULL
);
HANDLE gamenn2 = CreateConsoleScreenBuffer(
GENERIC_WRITE, //定义进程可以往缓冲区写数据
FILE_SHARE_WRITE, //定义缓冲区可共享写权限
NULL,
CONSOLE_TEXTMODE_BUFFER,
NULL
);
HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);//标准输出的字变色
int yakux,yakuy,chizux,chizuy;//玩家坐标和地图大小
int main(void)
{
void setsume();
void guanqia(int x);
int shuchu(int x,int y,int z,int guanqia);
void iku();
int panduan(int x);
FILE *fp;
int sousa;
int panduan0=0;
SetConsoleTitle("文字ゲーム----zwk");//更改控制台文字
setsume();
if((fp=fopen("データ.dat","rb"))==NULL) {
fp=fopen("データ.dat","wb");
de_ta.ima=1;
fwrite(&de_ta,sizeof(struct de_ta),1,fp);
fclose(fp);
fp=fopen("データ.dat","rb");
}
fread(&de_ta,sizeof(struct de_ta),1,fp);
fclose(fp);
printf("\n\n\t\t\t\t1.从头开始 2.从上次开始 3.选择关卡\n");
koko:
sousa=getch();
switch(sousa) {
case '1':de_ta.ima=1;break;
case '2':break;
case '3':{
int ikuu;
printf("\n\t\t\t\t\t输入要去的关卡:");
scanf("%d",&ikuu);
de_ta.ima=ikuu;
break;
}
default:goto koko;
}
system("cls");//清空标准缓冲区内的数据防止退出时发现有字
SetConsoleTextAttribute(handle,4);
achira:
guanqia(de_ta.ima);
//接下来一个循环 通关返回初始化地图
printf("\n\n\n\n\n\n\n\t\t\t\t\t\t\t鬼隠し\n");
while(1) {
panduan0=shuchu(chizux,chizuy,panduan(de_ta.ima),de_ta.ima);
if(panduan0) {
de_ta.ima++;
goto achira;
}
iku();
}
}
void setsume()
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),12);
printf("\n\n\t\t\t\t\t 文字游戏(模仿版)\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
puts("\n\t\t\t\t\tWSAD移动");
puts("\t\t\t\t\tJ键交互,K键攻击(攻击可以打坏某些物品)");
printf("\n\n\n\t\t............................按任意键继续............................");
getch();
system("cls");
}
void guanqia(int x)//将关卡地图给链表 用链表保证地图大小可以自适应
{
void mugennnaosu(int i,int j,int z);
if(lianbiao) {//链表存在的话要先删除再重新开辟内存
struct chizu *p=head;
for(int i=0;i<chizux*chizuy;i++) {
head=head->tsugi;
free(p);
p=head;
}//删除链表完成
lianbiao=0;
for(int i=0;i<28;i++)//清空缓冲区
for(int j=0;j<122;j++)
data2[i][j]='\0';
}
switch (x) {
case 1:{
yakux=2;
yakuy=1;//玩家坐标
chizux=10;
chizuy=10;//地图大小
struct chizu*p,*p1;
head=p=(struct chizu*) malloc(SIZE);
for(int i=0;i<99;i++) {
p1=(struct chizu*) malloc(SIZE);
p->tsugi=p1;
p=p1;
}
p->tsugi=NULL;//创建链表
for(int i=0;i<10;i++)
for(int j=0;j<10;j++) {
mugennnaosu(i,j,chizu1[i][j]);
}//给链表赋值
lianbiao=1;
break;
}
case 2:{
panduanjikann=time(NULL); //时间用于自动运动npc
yakux=8;
yakuy=4;//玩家坐标
chizux=29;
chizuy=60;//地图大小
struct chizu*p,*p1;
head=p=(struct chizu*) malloc(SIZE);
for(int i=0;i<1739;i++) {
p1=(struct chizu*) malloc(SIZE);
p->tsugi=p1;
p=p1;
}
p->tsugi=NULL;//创建链表
for(int i=0;i<29;i++)
for(int j=0;j<60;j++) {
mugennnaosu(i,j,chizu2[i][j]);
}//给链表赋值
lianbiao=1;
break;
}
case 3:{
panduanjikann=time(NULL);
yakux=8;
yakuy=4;//玩家坐标
chizux=40;
chizuy=80;//地图大小
struct chizu*p,*p1;
head=p=(struct chizu*) malloc(SIZE);
for(int i=0;i<3199;i++) {
p1=(struct chizu*) malloc(SIZE);
p->tsugi=p1;
p=p1;
}
p->tsugi=NULL;//创建链表
for(int i=0;i<40;i++)
for(int j=0;j<80;j++) {
mugennnaosu(i,j,chizu3[i][j]);
}//给链表赋值
lianbiao=1;
break;
}
}
}
void iku()//移动玩家和玩家移动物品 要对链表进行操作 玩家操作物品
{
int mugennmiru(int i,int j);
void mugennnaosu(int i,int j,int z);
void mugennnaosuc(int i,int j,int z);
void gotoxy(int i,int j);
char sousa;
int wupinx=-1,wupiny=-1;//物品坐标为负时 不移动物品
if(yakuy-1>=0) {
if(mugennmiru(yakux,yakuy-1)<0) {
wupinx=yakux;
wupiny=yakuy-1;
}
}
if(yakuy+1<=chizuy-1) {
if(mugennmiru(yakux,yakuy+1)<0) {
wupinx=yakux;
wupiny=yakuy+1;
}
}
if(yakux-1>=0) {
if(mugennmiru(yakux-1,yakuy)<0) {
wupinx=yakux-1;
wupiny=yakuy;
}
}
if(yakux+1<=chizux-1) {
if(mugennmiru(yakux+1,yakuy)<0) {
wupinx=yakux+1;
wupiny=yakuy;
}//中间
}
koko:
if(kbhit()) {
sousa=getch();
switch (sousa) {
case 27:{
FILE*fp;
fp=fopen("データ.dat","wb");
fwrite(&de_ta,sizeof(struct de_ta),1,fp);
fclose(fp);
exit(0);
break;
}
case 'j':
case 'J':{
if(wupinx<0) {
switch(shangyibu) {
case 'w':{
if(yakux-1<0) return;
if(mugennmiru(yakux-1,yakuy)<2000) mugennnaosuc(yakux-1,yakuy,-1);
break;
}
case 's':{
if(yakux+1>chizux-1) return;
if(mugennmiru(yakux+1,yakuy)<2000) mugennnaosuc(yakux+1,yakuy,-1);
break;
}
case 'a':{
if(yakuy-1<0) return;
if(mugennmiru(yakux,yakuy-1)<2000) mugennnaosuc(yakux,yakuy-1,-1);
break;
}
case 'd':{
if(yakuy+1>chizuy-1) return;
if(mugennmiru(yakux,yakuy+1)<2000) mugennnaosuc(yakux,yakuy+1,-1);
break;
}
}
}
else mugennnaosuc(wupinx,wupiny,-1);
break;
}
case 'k':
case 'K':{
switch(shangyibu) {
case 'w':{
if(yakux-1<0) return;
if(mugennmiru(yakux-1,yakuy)>1000&&mugennmiru(yakux-1,yakuy)<2000) mugennnaosu(yakux-1,yakuy,0);
break;
}
case 's':{
if(yakux+1>chizux-1) return;
if(mugennmiru(yakux+1,yakuy)>1000&&mugennmiru(yakux+1,yakuy)<2000) mugennnaosu(yakux+1,yakuy,0);
break;
}
case 'a':{
if(yakuy-1<0) return;
if(mugennmiru(yakux,yakuy-1)>1000&&mugennmiru(yakux,yakuy-1)<2000) mugennnaosu(yakux,yakuy-1,0);
break;
}
case 'd':{
if(yakuy+1>chizuy-1) return;
if(mugennmiru(yakux,yakuy+1)>1000&&mugennmiru(yakux,yakuy+1)<2000) mugennnaosu(yakux,yakuy+1,0);
break;
}
}
break;
}
case 'w'://要做移动玩家和手里的物品 手里最多拿一个
case 'W':{
if(yakux==0) return;
if(wupinx>=0) {//需要移动物品和玩家
if(mugennmiru(yakux-1,yakuy)==0&&mugennmiru(wupinx-1,wupiny)==0) {
mugennnaosu(yakux-1,yakuy,-1);
mugennnaosu(yakux,yakuy,0);
yakux-=1;
yakuy=yakuy;//移动玩家
mugennnaosu(wupinx-1,wupiny,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx-=1;
wupiny=wupiny;//移动物品
}
else {
if(yakux-2<0) goto kokow;
if(mugennmiru(yakux-1,yakuy)<0&&mugennmiru(yakux-2,yakuy)==0) {//解决物品在玩家上的移动
mugennnaosu(wupinx-1,wupiny,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx-=1;
wupiny=wupiny;//移动物品
mugennnaosu(yakux-1,yakuy,-1);
mugennnaosu(yakux,yakuy,0);
yakux-=1;
yakuy=yakuy;//移动玩家
}
kokow:
if(yakux-1<0) return;
if(mugennmiru(yakux+1,yakuy)<0&&mugennmiru(yakux-1,yakuy)==0) {//解决物品在玩家下的移动
mugennnaosu(yakux-1,yakuy,-1);
mugennnaosu(yakux,yakuy,0);
yakux-=1;
yakuy=yakuy;//移动玩家
mugennnaosu(wupinx-1,wupiny,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx-=1;
wupiny=wupiny;//移动物品
}
}
}
else {//如果不需要移动物品 只需要移动玩家
if(mugennmiru(yakux-1,yakuy)==0) {
mugennnaosu(yakux-1,yakuy,-1);
mugennnaosu(yakux,yakuy,0);
yakux-=1;
yakuy=yakuy;
}
}
shangyibu='w';
break;
}
case 's':
case 'S':{
if(yakux==chizux-1) return;
if(wupinx>=0) {//需要移动物品和玩家
if(mugennmiru(yakux+1,yakuy)==0&&mugennmiru(wupinx+1,wupiny)==0) {
mugennnaosu(yakux+1,yakuy,-1);
mugennnaosu(yakux,yakuy,0);
yakux+=1;
yakuy=yakuy;//移动玩家
mugennnaosu(wupinx+1,wupiny,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx+=1;
wupiny=wupiny;//移动物品
}
else {
if(yakux+2>chizux-1) goto kokos;
if(mugennmiru(yakux+1,yakuy)<0&&mugennmiru(yakux+2,yakuy)==0) {//物品在玩家下方
mugennnaosu(wupinx+1,wupiny,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx+=1;
wupiny=wupiny;//移动物品
mugennnaosu(yakux+1,yakuy,-1);
mugennnaosu(yakux,yakuy,0);
yakux+=1;
yakuy=yakuy;//移动玩家
}
kokos:
if(yakux+1>chizux-1) return;
if(mugennmiru(yakux-1,yakuy)<0&&mugennmiru(yakux+1,yakuy)==0) {//物品在玩家上方
mugennnaosu(yakux+1,yakuy,-1);
mugennnaosu(yakux,yakuy,0);
yakux+=1;
yakuy=yakuy;//移动玩家
mugennnaosu(wupinx+1,wupiny,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx+=1;
wupiny=wupiny;//移动物品
}
}
}
else {//如果不需要移动物品 只需要移动玩家
if(mugennmiru(yakux+1,yakuy)==0) {
mugennnaosu(yakux+1,yakuy,-1);
mugennnaosu(yakux,yakuy,0);
yakux+=1;
yakuy=yakuy;
}
}
shangyibu='s';
break;
}
case 'a':
case 'A':{
if(yakuy==0) return;
if(wupinx>=0) {//需要移动物品和玩家
if(mugennmiru(yakux,yakuy-1)==0&&mugennmiru(wupinx,wupiny-1)==0) {
mugennnaosu(yakux,yakuy-1,-1);
mugennnaosu(yakux,yakuy,0);
yakux=yakux;
yakuy-=1;//移动玩家
mugennnaosu(wupinx,wupiny-1,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx=wupinx;
wupiny-=1;//移动物品
}
else {
if(yakuy-2<0) goto kokoa;
if(mugennmiru(yakux,yakuy-1)<0&&mugennmiru(yakux,yakuy-2)==0) { //物品在玩家左边
mugennnaosu(wupinx,wupiny-1,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx=wupinx;
wupiny-=1;//移动物品
mugennnaosu(yakux,yakuy-1,-1);
mugennnaosu(yakux,yakuy,0);
yakux=yakux;
yakuy-=1;//移动玩家
}
kokoa:
if(yakuy-1<0) return;
if(mugennmiru(yakux,yakuy+1)<0&&mugennmiru(yakux,yakuy-1)==0) {//物品在玩家右边
mugennnaosu(yakux,yakuy-1,-1);
mugennnaosu(yakux,yakuy,0);
yakux=yakux;
yakuy-=1;//移动玩家
mugennnaosu(wupinx,wupiny-1,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx=wupinx;
wupiny-=1;//移动物品
}
}
}
else {//如果不需要移动物品 只需要移动玩家
if(mugennmiru(yakux,yakuy-1)==0) {
mugennnaosu(yakux,yakuy-1,-1);
mugennnaosu(yakux,yakuy,0);
yakux=yakux;
yakuy-=1;
}
}
shangyibu='a';
break;
}
case 'd':
case 'D':{
if(yakuy==chizuy-1) return;
if(wupinx>=0) {//需要移动物品和玩家
if(mugennmiru(yakux,yakuy+1)==0&&mugennmiru(wupinx,wupiny+1)==0) {
mugennnaosu(yakux,yakuy+1,-1);
mugennnaosu(yakux,yakuy,0);
yakux=yakux;
yakuy+=1;//移动玩家
mugennnaosu(wupinx,wupiny+1,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx=wupinx;
wupiny+=1;//移动物品
}
else {
if(yakuy+2>chizuy-1) goto kokod;
if(mugennmiru(yakux,yakuy+1)<0&&mugennmiru(yakux,yakuy+2)==0) {//物品在玩家右边
mugennnaosu(wupinx,wupiny+1,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx=wupinx;
wupiny+=1;//移动物品
mugennnaosu(yakux,yakuy+1,-1);
mugennnaosu(yakux,yakuy,0);
yakux=yakux;
yakuy+=1;//移动玩家
}
kokod:
if(yakuy+1>chizuy-1) return;
if(mugennmiru(yakux,yakuy-1)<0&&mugennmiru(yakux,yakuy+1)==0) {//物品在玩家左边
mugennnaosu(yakux,yakuy+1,-1);
mugennnaosu(yakux,yakuy,0);
yakux=yakux;
yakuy+=1;//移动玩家
mugennnaosu(wupinx,wupiny+1,mugennmiru(wupinx,wupiny));
mugennnaosu(wupinx,wupiny,0);
wupinx=wupinx;
wupiny+=1;//移动物品
}
}
}
else {//如果不需要移动物品 只需要移动玩家
if(mugennmiru(yakux,yakuy+1)==0) {
mugennnaosu(yakux,yakuy+1,-1);
mugennnaosu(yakux,yakuy,0);
yakux=yakux;
yakuy+=1;
}
}
shangyibu='d';
break;
}
default:goto koko;
}
}
}
int shuchu(int x,int y,int z,int guanqia)//输出图像 0是空白 -1是玩家 其他数为物品 -是可移动物品
{
int i,j;
void gotoxy(int i,int j);//移动光标
void setsumei(char a[80]);//输出说明相关
void strkurasu(char a[3],int i,int guanqia); //输出图像相关
int mugennmiru(int x,int y);
void te(char a[5]);//手中拿的东西
int ugokuxowari,ugokuyowari,ugokuxhajime,ugokuyhajime;//使地图和输出区域分开 实现镜头随玩家移动的效果
int ue,shita,uey,shitay;//距离上和距离下的距离
int d;//用于data2数据的行
ue=yakux;
shita=x-yakux;
uey=yakuy;
shitay=y-yakuy;
if(x<=28) {
ugokuxowari=x;
ugokuxhajime=0;
}
else {
if(ue<=shita) {
//输出上半边
if(ue<14) ugokuxhajime=0;
else ugokuxhajime=ue-14;
ugokuxowari=ugokuxhajime+28;
if(ugokuxowari>x) {
ugokuxowari=x;
ugokuxhajime=x-28;
}
}
else {
//输出下半边
if(shita<14) ugokuxowari=x;
else ugokuxowari=x-(shita-14);
ugokuxhajime=ugokuxowari-28;
}
}
if(y<=60) {
ugokuyhajime=0;
ugokuyowari=y;
}
else {
if(uey<=shitay) {
//输出左半边
if(uey<30) ugokuyhajime=0;
else ugokuyhajime=uey-30;
ugokuyowari=ugokuyhajime+60;
if(ugokuyowari>y) {
ugokuyowari=y;
ugokuyhajime=y-60;
}
}
else {
//输出右半边
if(shitay<30) ugokuyowari=y;
else ugokuyowari=y-(shitay-30);
ugokuyhajime=ugokuyowari-60;
}
}
#if 0
ugokuyowari=80;
ugokuyhajime=20;
#endif
d=0;
for(i=ugokuxhajime;i<ugokuxowari;i++) {
for(j=ugokuyhajime;j<ugokuyowari;j++) {
switch (mugennmiru(i,j)) {
case 0:strkurasu(" ",d,de_ta.ima);break;
case -1:strkurasu("我",d,de_ta.ima);break;
case 2:strkurasu("墙",d,de_ta.ima);break;
case -2:te("墙");strkurasu("墙",d,de_ta.ima);break;
case 3:strkurasu("门",d,de_ta.ima);break;
case -3:te("门");strkurasu("门",d,de_ta.ima);break;
case 4:strkurasu("桌",d,de_ta.ima);break;
case -4:te("桌");strkurasu("桌",d,de_ta.ima);break;
case 5:strkurasu("凳",d,de_ta.ima);break;
case -5:te("凳");strkurasu("凳",d,de_ta.ima);break;
case 1001:strkurasu("草",d,de_ta.ima);break;
case -1001:te("草");strkurasu("草",d,de_ta.ima);break;
case 6:strkurasu("醒",d,de_ta.ima);break;
case -6:te("醒");strkurasu("醒",d,de_ta.ima);break;
case 7:strkurasu("床",d,de_ta.ima);break;
case -7:te("床");strkurasu("床",d,de_ta.ima);break;
case 2001:strkurasu("人",d,de_ta.ima);break;
case -2001:te("人");strkurasu("人",d,de_ta.ima);break;
case 9:strkurasu("从",d,de_ta.ima);break;
case -9:te("从");strkurasu("从",d,de_ta.ima);break;
case 10:strkurasu("上",d,de_ta.ima);break;
case -10:te("上");strkurasu("上",d,de_ta.ima);break;
case 11:strkurasu("过",d,de_ta.ima);break;
case -11:te("过");strkurasu("过",d,de_ta.ima);break;
case 12:strkurasu("来",d,de_ta.ima);break;
case -12:te("来");strkurasu("来",d,de_ta.ima);break;
case 13:strkurasu("瓦",d,de_ta.ima);break;
case -13:te("瓦");strkurasu("瓦",d,de_ta.ima);break;
case 14:strkurasu("窗",d,de_ta.ima);break;
case -14:te("窗");strkurasu("窗",d,de_ta.ima);break;
case 15:strkurasu("木",d,de_ta.ima);break;
case -15:te("木");strkurasu("木",d,de_ta.ima);break;
case 1002:strkurasu("叶",d,de_ta.ima);break;
case -1002:te("叶");strkurasu("叶",d,de_ta.ima);break;
case 16:strkurasu("路",d,de_ta.ima);break;
case -16:te("路");strkurasu("路",d,de_ta.ima);break;
case 8:strkurasu("人",d,de_ta.ima);break;
case -8:te("人");strkurasu("人",d,de_ta.ima);break;
case 17:strkurasu("屎",d,de_ta.ima);break;
case -17:te("屎");strkurasu("屎",d,de_ta.ima);break;
case 18:strkurasu("钮",d,de_ta.ima);break;
case -18:te("钮");strkurasu("钮",d,de_ta.ima);break;
case 2002:strkurasu("牌",d,de_ta.ima);break;
case 19:strkurasu("鸡",d,de_ta.ima);break;//19-24都是鸡
case -19:te("鸡");strkurasu("鸡",d,de_ta.ima);break;
case 20:strkurasu("鸡",d,de_ta.ima);break;
case -20:te("鸡");strkurasu("鸡",d,de_ta.ima);break;
case 21:strkurasu("鸡",d,de_ta.ima);break;
case -21:te("鸡");strkurasu("鸡",d,de_ta.ima);break;
case 22:strkurasu("鸡",d,de_ta.ima);break;
case -22:te("鸡");strkurasu("鸡",d,de_ta.ima);break;
case 23:strkurasu("鸡",d,de_ta.ima);break;
case -23:te("鸡");strkurasu("鸡",d,de_ta.ima);break;
case 24:strkurasu("鸡",d,de_ta.ima);break;
case -24:te("鸡");strkurasu("鸡",d,de_ta.ima);break;
case 25:strkurasu("石",d,de_ta.ima);break;
case -25:te("石");strkurasu("石",d,de_ta.ima);break;
case 26:strkurasu("栏",d,de_ta.ima);break;
case -26:te("栏");strkurasu("栏",d,de_ta.ima);break;
case 1003:strkurasu("蛋",d,de_ta.ima);break;
case -1003:te("蛋");strkurasu("蛋",d,de_ta.ima);break;
case 2003:strkurasu("车",d,de_ta.ima);break;
}//负数为可搬运 1-1000为可搬运 1000-2000为可搬运可破坏 2000以上为不可破坏不可移动
}
d++;
}
switch(z) {
case 1:setsumei("我:房间门被草堵住了");break;
case 2:setsumei("我:我要怎么打开门?");break;
case 3:return 1;break;
case 4:setsumei("我:门锁上了,进不去");break;
case 5:setsumei("人:让我成为人上人,我就告诉你怎么离开这里");break;
case 6:setsumei("这个人试图逃跑");break;
case 7:setsumei("有一个按钮");break;
case 8:setsumei("人上人:告诉你,有一个草下面藏了东西");break;
case 9:setsumei("告示牌:不是所有字都可以被搬运,比如上面那人");break;
case 10:setsumei("别被泥头车创死了");break;
break;
}
#if 1
COORD coord={0,0};
DWORD bytes = 0;
huanchong=!huanchong;//切换输出缓冲区
if(!huanchong) {
houtpoint = &gamenn1;
}else {
houtpoint = &gamenn2;
}
CONSOLE_CURSOR_INFO cci;
cci.bVisible = 0;
cci.dwSize = 1;
SetConsoleCursorInfo(*houtpoint, &cci);//隐藏光标
WriteConsoleOutputCharacterA(*houtpoint,setsu,80, coord,&bytes);
for(int as=0;as<50;as++) setsu[as]='\0';
coord.X=60;
WriteConsoleOutputCharacterA(*houtpoint,tenonaka,7, coord,&bytes);
for(int as=0;as<10;as++) tenonaka[as]='\0';
coord={0,1};
if(chizux<=28) {
for(i = 0; i <chizux; i++) {
coord.Y++ ;
WriteConsoleOutputCharacterA(*houtpoint,data1[i],20, coord,&bytes);
data1[i][0]='\0';
}
}
else {
for(i = 0; i <28; i++) {
coord.Y++ ;
WriteConsoleOutputCharacterA(*houtpoint,data2[i],120, coord,&bytes);
data2[i][0]='\0';
}
}
#endif
SetConsoleActiveScreenBuffer(*houtpoint);
return 0;
}
int panduan(int x)
{ int mugennmiru(int i,int j);
void mugennnaosu(int i,int j,int z);
void npc_kuruma_migi(int x,int jibunn);
void npcai(int jibunn);
switch(x) {
case 1:{
struct chizu *p;
p=head;
while(p!=NULL) {
if(p->x==1001||p->x==-1001) return 1;
p=p->tsugi;
}
if(mugennmiru(8,4)==-1||mugennmiru(8,5)==-1) return 2;
if(mugennmiru(9,4)==-1||mugennmiru(9,5)==-1) return 3;
break;
}
case 2:{
if(panduanjikann+1==time(NULL)) {
panduanjikann+=1;
npcai(8);
npcai(19);
npcai(20);
npcai(21);
npcai(22);
npcai(23);
npcai(24);
}
if(yakux<7&&yakuy<8) return 4;
if(mugennmiru(7,21)==-18) return 3;
if(mugennmiru(7,21)==0) mugennnaosu(7,21,18);
if(yakux-1>0) {
if(mugennmiru(yakux-1,yakuy)==2001) {
if(mugennmiru(yakux,yakuy)==2001) return 8;
return 5;
}
}
if(yakux+2<=chizux-1) {
if(mugennmiru(yakux+1,yakuy)==2001) {
if(mugennmiru(yakux+2,yakuy)==8) return 8;
return 5;
}
}
if(yakuy+1<=chizuy-1) {
if(mugennmiru(yakux,yakuy+1)==2001) {
if(mugennmiru(yakux+1,yakuy+1)==8) return 8;
return 5;
}
}
if(yakuy-1>0) {
if(mugennmiru(yakux,yakuy-1)==2001) {
if(mugennmiru(yakux+1,yakuy-1)==8) return 8;
return 5;
}
}
if(yakux-1>0) {
if(mugennmiru(yakux-1,yakuy)==8) return 6;
}
if(yakux+1<chizux-1) {
if(mugennmiru(yakux+1,yakuy)==8) return 6;
}
if(yakuy+1<chizuy-1) {
if(mugennmiru(yakux,yakuy+1)==8) return 6;
}
if(yakuy-1>0) {
if(mugennmiru(yakux,yakuy-1)==8) return 6;
}
if(yakux-1>0) {
if(mugennmiru(yakux-1,yakuy)==18) return 7;
}
if(yakux+1<chizux-1) {
if(mugennmiru(yakux+1,yakuy)==18) return 7;
}
if(yakuy+1<chizuy-1) {
if(mugennmiru(yakux,yakuy+1)==18) return 7;
}
if(yakuy-1>0) {
if(mugennmiru(yakux,yakuy-1)==18) return 7;
}
if(yakux-1>0) {
if(mugennmiru(yakux-1,yakuy)==2002) return 9;
}
if(yakux+1<chizux-1) {
if(mugennmiru(yakux+1,yakuy)==2002) return 9;
}
if(yakuy+1<chizuy-1) {
if(mugennmiru(yakux,yakuy+1)==2002) return 9;
}
if(yakuy-1>0) {
if(mugennmiru(yakux,yakuy-1)==2002) return 9;
}
break;
}
case 3:{
npc_kuruma_migi(9,2003);
npc_kuruma_migi(18,2003);
npc_kuruma_migi(19,2003);
npc_kuruma_migi(20,2003);
npc_kuruma_migi(29,2003);
npc_kuruma_migi(30,2003);
npc_kuruma_migi(31,2003);
if(yakux-1>=0) {
if(mugennmiru(yakux-1,yakuy)==2002) return 10;
}
if(yakux+1<=chizux-1) {
if(mugennmiru(yakux+1,yakuy)==2002) return 10;
}
if(yakuy+1<=chizuy-1) {
if(mugennmiru(yakux,yakuy+1)==2002) return 10;
}
if(yakuy-1>=0) {
if(mugennmiru(yakux,yakuy-1)==2002) return 10;
}
if(mugennmiru(yakux,yakuy)!=-1) {
yakux=8;
yakuy=4;
mugennnaosu(yakux,yakuy,-1);
}
break;
}
}
return 0;
}
int mugennmiru(int i,int j)//将链表作为二维数组看 返回一个值
{
int kazu;
struct chizu *p;
p=head;
kazu=i*chizuy+j;
for(int x=0;x<kazu;x++) p=p->tsugi;
return (p->x);
}
void mugennnaosu(int i,int j,int z)//将链表作为二维数组看 修改链表中的数据
{
int kazu;
struct chizu *p;
p=head;
kazu=i*chizuy+j;
for(int x=0;x<kazu;x++) p=p->tsugi;
p->x=z;
}
void mugennnaosuc(int i,int j,int z)//将链表作为二维数组看 修改链表中的数据 *
{
int kazu;
struct chizu *p;
p=head;
kazu=i*chizuy+j;
for(int x=0;x<kazu;x++) p=p->tsugi;
p->x*=z;
}
void gotoxy(int x,int y)//光标定位函数
{
COORD p;//定义结构体变量p
HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);//获取当前函数句柄
p.X=x;p.Y=y;//将光标的目标移动位置传递给结构体
SetConsoleCursorPosition(handle,p);//移动光标
}
void strkurasu(char a[5],int i,int guanqia)
{
switch(guanqia) {
case 1:strcat(data1[i],a);break;
case 2:strcat(data2[i],a);break;
case 3:{
strcat(data2[i],a);
break;
}
}
}
void setsumei(char a[80])
{
setsu[0]='\0';
strcat(setsu,a);
}
void te(char a[5])
{
strcat(tenonaka,"手中:");
strcat(tenonaka,a);
}
void npcai(int jibunn) //npc移动ai 随机移动静止且有一个特殊动作
{
int mugennmiru(int i,int j);
void mugennnaosu(int i,int j,int z);
srand(npcaiii);
npcaiii+=3;
npcaiii+=shangyibu;
int panding,i,j,x=-1,y;
panding=rand()%10+1;
for(i=0;i<chizux;i++)
for(j=0;j<chizuy;j++)
if(mugennmiru(i,j)==jibunn) {
x=i;
y=j;
}
if(x<0) return;
switch(panding) {
case 1:{//左
if(y-1>=0&&mugennmiru(x,y-1)==0) {
mugennnaosu(x,y,0);
mugennnaosu(x,y-1,jibunn);
}
break;
}
case 2:{//右
if(y+1<=chizuy-1&&mugennmiru(x,y+1)==0) {
mugennnaosu(x,y,0);
mugennnaosu(x,y+1,jibunn);
}
break;
}
case 3:{//上
if(x-1>=0&&mugennmiru(x-1,y)==0) {
mugennnaosu(x,y,0);
mugennnaosu(x-1,y,jibunn);
}
break;
}
case 4:{//下
if(x+1<=chizux-1&&mugennmiru(x+1,y)==0) {
mugennnaosu(x,y,0);
mugennnaosu(x+1,y,jibunn);
}
break;
}
case 5:break;//静止
case 6:{//特殊动作
if(jibunn==19||jibunn==20||jibunn==21||jibunn==22||jibunn==23||jibunn==24) if(x+1<=chizux-1&&mugennmiru(x+1,y)==0) mugennnaosu(x+1,y,1003);
break;
}
}
}
void npc_kuruma_migi(int x,int jibunn)//车的ai向右走
{
int j,y,i=0;
int mugennmiru(int i,int j);
void mugennnaosu(int i,int j,int z);
srand(npcaiii);
npcaiii+=3;
npcaiii+=shangyibu;
if(rand()%2==0) {
srand(npcaiii/4);
for(j=0;j<chizuy;j++)
if(mugennmiru(x,j)==jibunn) {
i=1;
y=j;
}
if(i) {
if(y+1<=chizuy-1) mugennnaosu(x,y+1,jibunn);
mugennnaosu(x,y,0);
}
else {
if(rand()%5==0) mugennnaosu(x,0,jibunn);
}
}
}
?
|