本弱蒟今天也是终于想起来更新了,上一次还是在三个月以前
为大家找到了亿点点小程序(亲测可过,包括Dev-c++)
含注释!!!
1、草原战争(单机版)
//感觉解释不全,很难玩
#include <bits/stdc++.h> //WEWILLFINDYOUANDHANTYOU
#include <windows.h> //GETYOUANDKILLYOUEATYOU!
#include <conio.h>
using namespace std;
int t,g[15][15],h;
int xf=1,yf=1,hf=10,ff=1,gf=1;
int xs=12,ys=12,hs=10,fs=0,gs=1;
int xt,yt,xln,yln,fx[]={-1,1,0,0},fy[]={0,0,-1,1};
int dp[15][15][15][15],cd;
bool bt,bl,bn,bs;
string st="▓",f[4]={"↑","↓","←","→"},s;
string gz=" <( 操作方法 )>\n1.A 用w a s d移动, 按x键攻击.\n2.B 用u h j k移动, 按n键攻击.\n";
void col(int c1,int c2,string c){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c1*16+c2);
cout<<c;
} void HideCursor(){
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
} int makeg(int k){
if(k<=600) return 0;//荒原
if(k<=690) return 1;//草地
if(k<=780) return 2;//沼泽
if(k<=870) return 3;//冰川
if(k<=980) return 4;//废墟
if(k<=986) return 5;//小炮
if(k<=988) return 6;//大炮
if(k<=991) return 7;//穿透枪
if(k<=992) return 8;// 弹炮
if(k<=997) return 9;//火矢
if(k<=999) return 10;//脉冲枪
if(k<=1000) return 11;//手榴弹
} void make(){
int i=14,j;
col(cd,7,"");
while(i--) cout<<st;
cout<<endl;
for(i=1;i<=12;i++){
col(cd,7,st);
for(j=1;j<=12;j++){
if(i==xf&&j==yf) col(10,2,f[ff]);
else if(i==xs&&j==ys) col(12,4,f[fs]);
else if(g[i][j]==4) col(cd,7,st);
else if(g[i][j]==3) col(cd,11,st);
else if(g[i][j]==2) col(cd,13,st);
else if(g[i][j]==1) col(cd,10,st);
else if(g[i][j]==11) col(cd,2,"⊕");
else if(g[i][j]==10) col(cd,7,"◎");
else if(g[i][j]==9) col(cd,13,"Δ");
else if(g[i][j]==8) col(cd,12,"¤");
else if(g[i][j]==7) col(cd,11,"≈");
else if(g[i][j]==6) col(cd,14,"≡");
else if(g[i][j]==5) col(cd,10,"=");
else col(cd,7," ");
} col(cd,7,st);
cout<<endl;
} i=14;
col(cd,7,"");
while(i--) cout<<st;
cout<<endl<<endl;
col(10,0,"");
if(gf==1) cout<<" ";
if(gf==5) cout<<"=";
if(gf==6) cout<<"≡";
if(gf==7) cout<<"≈";
if(gf==8) cout<<"¤";
if(gf==9) cout<<"Δ";
if(gf==10) cout<<"◎";
if(gf==11) cout<<"⊕";
col(cd,10," ph : ");
printf("%-4d",hf);
col(12,0,"");
if(gs==1) cout<<" ";
if(gs==5) cout<<"=";
if(gs==6) cout<<"≡";
if(gs==7) cout<<"≈";
if(gs==8) cout<<"¤";
if(gs==9) cout<<"Δ";
if(gs==10) cout<<"◎";
if(gs==11) cout<<"⊕";
col(cd,12," ph : ");
printf("%-4d",hs);
} bool dfs(int x,int y,int xl,int yl){
if(x==xl&&y==yl) return dp[x][y][xl][yl]=1;
if(dp[x][y][xl][yl]!=-1) return dp[x][y][xl][yl];
int te=g[x][y];
bool btool=0;
g[x][y]=-1;
for(int i=0;i<4;i++){
xln=x+fx[i]; yln=y+fy[i];
if(xln>0&&xln<13&&yln>0&&yln<13&&(g[xln][yln]==0||g[xln][yln]>4)){
if(dfs(xln,yln,xl,yl)) btool=1;
}
} g[x][y]=te;
return dp[x][y][xl][yl]=btool;
} int main(){
system("title skgame");
srand((unsigned)time(0));
HideCursor();
cd=0;
system("cls");
for(int i=1;i<=12;i++)
for(int j=1;j<=12;j++)
for(int k=1;k<=12;k++)
for(int l=1;l<=12;l++)
dp[i][j][k][l]=-1;
for(int i=1;i<=12;i++)
for(int j=1;j<=12;j++)
g[i][j]=makeg(rand()%1000+1);
g[1][1]=g[12][12]=0;
col(cd,7,"");
for(int i=0;i<gz.length();i++){
cout<<gz[i];
Sleep(30);
}
string que="3.武器:\n(1).小炮";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,10,"=");
col(cd,7,"");
cout<<endl;
Sleep(30);
que="(2).大炮";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,14,"≡");
col(cd,7,"");
cout<<endl;
Sleep(30);
que="(3).穿透枪";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,11,"≈");
Sleep(30);
cout<<endl;
col(cd,7,"");
que="(4).弹炮";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,12,"¤");
col(cd,7,"");
cout<<endl;
Sleep(30);
que="(5).火栓";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,13,"Δ");
col(cd,7,"");
cout<<endl;
Sleep(30);
que="(6).脉冲枪";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,7,"◎");
col(cd,7,"");
cout<<endl;
Sleep(30);
que="(7).手榴弹";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,2,"⊕");
col(cd,7,"");
cout<<endl;
Sleep(30);
cout<<"4.周围:"<<endl;
que="(1).墙";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,7,"▓");
col(cd,7,"");
cout<<endl;
Sleep(30);
que="(2).草";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,10,"▓");
col(cd,7,"");
cout<<endl;
Sleep(30);
que="(3).沼泽地";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,13,"▓");
col(cd,7,"");
cout<<endl;
Sleep(30);
que="(4).湖";
for(int i=0;i<que.length();i++){
cout<<que[i];
Sleep(30);
}
col(cd,11,"▓");
col(cd,7,"");
Sleep(30);
cout<<endl;
cout<<"按s键开始游戏\n按0键结束游戏"<<endl;
t=getch();
while(t!='s') t=getch();
system("cls");
make();
col(cd,12,"\n Game will start on 3 s\b\b");
for(int i=3;i>=1;i--){
Sleep(1000);
cout<<"\b"<<i;
} cout<<"开始!"<<endl;
system("cls");
make();
t=getch();
while(t!='0'){
bl=1;
if(t=='w'&&xf>1&&(g[xf-1][yf]==0||g[xf-1][yf]==1)&&!((xf-1==xs)&&(yf==ys))){
xf--; ff=0;
} else if(t=='w'&&xf>1&&g[xf-1][yf]==2&&!((xf-1==xs)&&(yf==ys))){
xf--; hf--; ff=0;
if(hf<=0) break;
} else if(t=='w'&&xf>1&&g[xf-1][yf]>4&&!((xf-1==xs)&&(yf==ys))){
xf--; ff=0;
gf=g[xf][yf];
g[xf][yf]=0;
} else if(t=='s'&&xf<12&&(g[xf+1][yf]==0||g[xf+1][yf]==1)&&!((xf+1==xs)&&(yf==ys))){
xf++; ff=1;
} else if(t=='s'&&xf<12&&g[xf+1][yf]==2&&!((xf+1==xs)&&(yf==ys))){
xf++; hf--; ff=1;
if(hf<=0) break;
} else if(t=='s'&&xf<12&&g[xf+1][yf]>4&&!((xf+1==xs)&&(yf==ys))){
xf++; ff=1;
gf=g[xf][yf];
g[xf][yf]=0;
} else if(t=='a'&&yf>1&&(g[xf][yf-1]==0||g[xf][yf-1]==1)&&!((xf==xs)&&(yf-1==ys))){
yf--; ff=2;
} else if(t=='a'&&yf>1&&g[xf][yf-1]==2&&!((xf==xs)&&(yf-1==ys))){
yf--; hf--; ff=2;
if(hf<=0) break;
} else if(t=='a'&&yf>1&&g[xf][yf-1]>4&&!((xf==xs)&&(yf-1==ys))){
yf--; ff=2;
gf=g[xf][yf];
g[xf][yf]=0;
} else if(t=='d'&&yf<12&&(g[xf][yf+1]==0||g[xf][yf+1]==1)&&!((xf==xs)&&(yf+1==ys))){
yf++; ff=3;
} else if(t=='d'&yf<12&&g[xf][yf+1]==2&&!((xf==xs)&&(yf+1==ys))){
yf++; hf--; ff=3;
if(hf<=0) break;
} else if(t=='d'&&yf<12&&g[xf][yf+1]>4&&!((xf==xs)&&(yf+1==ys))){
yf++; ff=3;
gf=g[xf][yf];
g[xf][yf]=0;
} else if(t=='x'){
xt=yt=bt=bn=bs=0; h=1;
if(gf==8){
if(dfs(xf,yf,xs,ys)) bt=1;
} if(gf==10){
if(sqrt(pow(xf-xs,2)+pow(yf-ys,2))<4){
bt=1; h=2;
}
} if(gf==11){
if(ff==0) xt=-1;
if(ff==1) xt=1;
if(ff==2) yt=-1;
if(ff==3) yt=1;
int xn,yn;
for(xn=xf+xt,yn=yf+yt;xn<=12&&xn>=1&&yn<=12&&yn>=1;xn+=xt,yn+=yt){
if(g[xn][yn]==0||g[xn][yn]>4) break;
} if(xn<=12&&xn>=1&&yn<=12&&yn>=1){
if(sqrt(pow(xn-xs,2)+pow(yn-ys,2))<3){
bt=1;
h=2;
}
}
} else{
if(gf==9) bs=1;
if(gf==7) bn=1;
if(gf==6) h=3;
if(gf==5) h=2;
if(ff==0) xt=-1;
if(ff==1) xt=1;
if(ff==2) yt=-1;
if(ff==3) yt=1;
for(int xn=xf,yn=yf;xn<=12&&xn>=1&&yn<=12&&yn>=1;xn+=xt,yn+=yt){
if(xn==xs&&yn==ys){
bt=1;
break;
} if((g[xn][yn]==1||g[xn][yn]==4)&&bn==0) break;
}
} if(bt==1){
hs-=h;
if(hf<10) hf+=bs;
} if(hs<=0) break;
} else if(t=='u'&&xs>1&&(g[xs-1][ys]==0||g[xs-1][ys]==1)&&!((xs-1==xf)&&(ys==yf))){
xs--; fs=0;
} else if(t=='u'&&xs>1&&g[xs-1][ys]==2&&!((xs-1==xf)&&(ys==yf))){
xs--; hs--; fs=0;
if(hs<=0) break;
} else if(t=='u'&&xs>1&&g[xs-1][ys]>4&&!((xs-1==xf)&&(ys==yf))){
xs--; fs=0;
gs=g[xs][ys];
g[xs][ys]=0;
} else if(t=='j'&&xs<12&&(g[xs+1][ys]==0||g[xs+1][ys]==1)&&!((xs+1==xf)&&(ys==yf))){
xs++; fs=1;
} else if(t=='j'&&xs<12&&g[xs+1][ys]==2&&!((xs+1==xf)&&(ys==yf))){
xs++; hs--; fs=1;
if(hs<=0) break;
} else if(t=='j'&&xs<12&&g[xs+1][ys]>4&&!((xs+1==xf)&&(ys==yf))){
xs++; fs=1;
gs=g[xs][ys];
g[xs][ys]=0;
} else if(t=='h'&&ys>1&&(g[xs][ys-1]==0||g[xs][ys-1]==1)&&!((xs==xf)&&(ys-1==yf))){
ys--; fs=2;
} else if(t=='h'&&ys>1&&g[xs][ys-1]==2&&!((xs==xf)&&(ys-1==yf))){
ys--; hs--; fs=2;
if(hs<=0) break;
} else if(t=='h'&&ys>1&&g[xs][ys-1]>4&&!((xs==xf)&&(ys-1==yf))){
ys--; fs=2;
gs=g[xs][ys];
g[xs][ys]=0;
} else if(t=='k'&&ys<12&&(g[xs][ys+1]==0||g[xs][ys+1]==1)&&!((xs==xf)&&(ys+1==yf))){
ys++; fs=3;
} else if(t=='k'&ys<12&&g[xs][ys+1]==2&&!((xs==xf)&&(ys+1==yf))){
ys++; hs--; fs=3;
if(hs<=0) break;
} else if(t=='k'&&ys<12&&g[xs][ys+1]>4&&!((xs==xf)&&(ys+1==yf))){
ys++; fs=3;
gs=g[xs][ys];
g[xs][ys]=0;
} else if(t=='n'){
xt=yt=bt=bn=bs=0; h=1;
if(gs==8){
if(dfs(xf,yf,xs,ys)) bt=1;
} if(gs==10){
if(sqrt(pow(xf-xs,2)+pow(yf-ys,2))<4){
bt=1; h=2;
}
} if(gs==11){
if(fs==0) xt=-1;
if(fs==1) xt=1;
if(fs==2) yt=-1;
if(fs==3) yt=1;
int xn,yn;
for(xn=xs+xt,yn=ys+yt;xn<=12&&xn>=1&&yn<=12&&yn>=1;xn+=xt,yn+=yt){
if(g[xn][yn]==0||g[xn][yn]>4) break;
} if(xn<=12&&xn>=1&&yn<=12&&yn>=1){
if(sqrt(pow(xn-xf,2)+pow(yn-yf,2))<3){
bt=1;
h=2;
}
}
} else{
if(gs==9) bs=1;
if(gs==7) bn=1;
if(gs==6) h=3;
if(gs==5) h=2;
if(fs==0) xt=-1;
if(fs==1) xt=1;
if(fs==2) yt=-1;
if(fs==3) yt=1;
for(int xn=xs,yn=ys;xn<=12&&xn>=1&&yn<=12&&yn>=1;xn+=xt,yn+=yt){
if(xn==xf&&yn==yf){
bt=1;
break;
} if((g[xn][yn]==1||g[xn][yn]==4)&&bn==0) break;
}
} if(bt==1){
hf-=h;
if(hs<10) hs+=bs;
} if(hf<=0) break;
} else bl=0;
if(bl==1){
system("cls");
make();
} t=getch();
} system("cls");
if(hf<=0){
col(cd,7,"\n ");
col(12,0," ");
col(cd,12," wins!");
} else if(hs<=0){
col(cd,7,"\n ");
col(10,0," ");
col(cd,10," wins!");
} else col(cd,7,"\n end!\n\n");
Sleep(1000);
col(cd,7,"");
return 0;
}
2.吃豆人
#include <stdio.h>
#include <iostream>
#include <time.h>
#include <conio.h>
#include <windows.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
const int n = 809;
struct Point {
int x, y;
};
int dali;
int fx[4] = {-1, 27, 1, -27};
int fxfx[4][2] = {
{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
int dis[1000][1000]; //0:墙 1:有分的路 2:没分的路 3:怪物的家
int changdi[30][27] = {
{0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0},
{0, 1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int x, x1, x2, x3, x4, y, y1, y2, y3, y4;
int now, now1, now2, now3, now4;
int g1, g2, g3, g4;
int fangx, nextfx, last1, last2, last3, last4;
int fenshu, guozi, guaitimer;
int T1, T2, t1, t2, stopped; //T:计时 t1:玩家速度 t2:怪物速度
int f; //f:{0:继续 1:被吃 2:赢了 3:输了}
int beichi;
void color (int a) {//颜色函数
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), a);
}
void gotoxy(int x, int y) {//位置函数(行为x 列为y)
COORD pos;
pos.X=2*y;
pos.Y=x;
SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE),pos);
}
void begin () {
system ("cls");
color (11);
printf (" ★");
color (10);
printf ("吃豆人");
color (11);
printf ("★\n\n");
color(7);
printf (" 正在初始化,请耐心等待");
for (int i = 0; i <= n; i++) {
for (int j = 1; j <= n; j++) {
dis[i][j] = 900;
}
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= 3; j++) {
if (i + fx[j] >= 0 && i + fx[j] <= n) {
int k = i + fx[j], xx = k/27, yy = k % 27, kk;
if (changdi[i / 27][i % 27] && changdi[xx][yy]) {
dis[i][k] = kk = 1;
}
}
}
}
for (int k = 0; k <= n; k++) {
if (changdi[k]) {
for (int i = 0; i <= n; i++) {
if (changdi[i]) {
for (int j = 0; j <= n; j++) {
if (changdi[j]) {
if (dis[i][j] > dis[i][k] + dis[k][j]) {
dis[i][j] = dis[i][k] + dis[k][j];
}
}
}
}
}
if (k % 80 == 0) {
color (13);
gotoxy (3, 12);
printf("│");
} else if (k % 80 == 20) {
color (13);
gotoxy (3, 12);
printf ("╱");
} else if (k % 80 == 40) {
color (13);
gotoxy (3, 12);
printf ("─");
} else if (k % 80 == 60) {
color(13);
gotoxy (3, 12);
printf ("╲");
}
if (k % 60==0) {
color (11);
gotoxy (5, k / 60);
printf("●");
}
}
}
}
void shuru () {
char ch = getch ();
if (ch == 75) {
if (changdi[x + fxfx[0][0]][y + fxfx[0][1]] == 1 | changdi[x + fxfx[0][0]][y + fxfx[0][1]] == 2) {
fangx = nextfx = 0;
} else {
nextfx = 0;
}
} else if (ch == 80) {
if (changdi[x + fxfx[1][0]][y + fxfx[1][1]] == 1 | changdi[x + fxfx[1][0]][y + fxfx[1][1]] == 2) {
fangx = nextfx = 1;
} else {
nextfx = 1;
}
} else if (ch == 77) {
if (changdi[x + fxfx[2][0]][y + fxfx[2][1]] == 1 | changdi[x + fxfx[2][0]][y + fxfx[2][1]] == 2) {
fangx = nextfx = 2;
} else {
nextfx = 2;
}
} else if (ch == 72) {
if (changdi[x + fxfx[3][0]][y + fxfx[3][1]] == 1 | changdi[x + fxfx[3][0]][y + fxfx[3][1]] == 2) {
fangx = nextfx = 3;
} else {
nextfx = 3;
}
} else if (ch == ' ') {
stopped = (stopped + 1) % 2;
} else if (ch == '-') {
t1++;
} else if ((ch == '+') && t1 - 1 > 0) {
t1--;
}
else if (ch == '$') {
dali = (dali + 1) % 2;
}
}
void reset () {
system ("cls");
color (7);
x = 22;
y = 13;
x1 = x2 = x3 = x4 = 14;
y1 = 11;
y2 = 12;
y3 = 14;
y4 = 15;
now = 607;
now1 = 389;
now2 = 390;
now3 = 392;
now4 = 393;
for (int k = 0; k <= n; k++) {
int i = k / 27, j = k % 27;
gotoxy (i, j);
if (changdi[i][j] == 1) {
color (7);
printf("·");
} else if (!changdi[i][j]) {
color (1);
printf ("■");
}
if (j==26) {
gotoxy (i, 27);
color (7);
printf ("%d", i);
}
}
gotoxy (0, 0);
gotoxy (x, y);
color (14);
printf ("●");
gotoxy (x1, y1);
color (4);
printf ("◆");
gotoxy (x2, y2);
color (5);
printf ("◆");
gotoxy (x3, y3);
color (3);
printf ("◆");
gotoxy (x4, y4);
color (2);
printf ("◆");
fangx = 0;
T1 = T2 = guaitimer = 0;
t1 = 75;
t2 = 100;
stopped = 0;
fenshu = 0;
guozi = 237;
g1 = g2 = g3 = g4 = 0;
dali = 0;
gotoxy (14, 30);
printf (" ");
}
void move1 () {
int xx, yy;
xx = x + fxfx[nextfx][0];
yy = y + fxfx[nextfx][1];
if (changdi[xx][yy]) {
if (changdi[xx][yy] == 1) {
fenshu++;
changdi[xx][yy] = 2;
}
color (14);
gotoxy (x, y);
printf (" ");
gotoxy (xx, yy);
if (!dali) {
printf ("♀");
} else {
printf ("☆");
}
now = x * 27 + y;
x = xx;
y = yy;
fangx = nextfx;
} else {
if (x == 13 && y == 0 && fangx == 0) {
xx = x;
yy = 26;
} else if (x == 13 && y == 26 && fangx == 2) {
xx = x;
yy = 0;
} else {
xx = x + fxfx[fangx][0];
yy = y + fxfx[fangx][1];
}
if (changdi[xx][yy]) {
if (changdi[xx][yy] == 1) {
fenshu++;
changdi[xx][yy] = 2;
}
color (14);
gotoxy (x, y);
printf (" ");
gotoxy (xx, yy);
if (!dali) {
printf ("♀");
} else {
printf ("☆");
}
now = x * 27 + y;
x = xx;
y = yy;
}
}
color (7);
}
void move2 () {
int haha, minhaha, xx, yy, chi = 0;
if (g1) {
minhaha = 2147483647; //相当于INT_MAX
if (now1 % 27 == 0 | now1 % 27 == 26) {
haha = last1;
} else if (!dali) {
for (int i = 0; i <= 3; i++) {
if (changdi[(now1 + fx[i]) / 27][(now1 + fx[i]) % 27] && i != last1 &&
minhaha > dis[now1 + fx[i]][now]) {
minhaha = dis[now1 + fx[i]][now];
haha = i;
}
}
} else {
minhaha = -minhaha;
for (int i = 0; i <= 3; i++) {
if (changdi[(now1 + fx[i]) / 27][(now1 + fx[i]) % 27] && i != last1 &&
minhaha < dis[now1 + fx[i]][now]) {
minhaha = dis[now1 + fx[i]][now];
haha = i;
}
}
}
xx = now1 / 27;
yy = now1 % 27;
gotoxy (xx, yy);
if (changdi[xx][yy] == 1) {
printf ("·");
} else {
printf (" ");
}
now1 += fx[haha];
last1 = (haha + 2) % 4;
xx = now1 / 27;
yy = now1 % 27;
gotoxy (xx, yy);
color (4);
printf ("◆");
color (7);
if (xx == x && yy == y) {
if (!dali) {
chi++;
} else {
guozi += 50;
fenshu += 50;
last1 = 0;
gotoxy (now1 / 27, now1 % 27);
if (changdi[now1 / 27][now1 % 27] == 1) {
printf ("·");
} else {
printf (" ");
}
now1 = 389;
}
}
}
if (g2) {
int k;
minhaha = 2147483647;
if (fangx == 0 | fangx == 2) {
k = y + (fxfx[fangx][1]) * 3;
while (k > 25 | !changdi[x][k]) {
k--;
}
while (k < 1 | !changdi[x][k]) {
k++;
}
} else {
k = x + (fxfx[fangx][0]) * 3;
while (k > 28 | !changdi[k][y]) {
k--;
}
while (k < 1 | !changdi[k][y]) {
k++;
}
}
if (fangx == 0 | fangx == 2) {
k += x * 27;
} else {
k = k * 27 + y;
}
if (now2 % 27 == 0 | now2 % 27 == 26) {
haha = last2;
}
else if (!dali) {
for (int i = 0; i <= 3; i++) {
if (changdi[(now2 + fx[i]) / 27][(now2 + fx[i]) % 27] && i != last2 &&
minhaha > dis[now2 + fx[i]][k]) {
minhaha = dis[now2 + fx[i]][k];
haha = i;
}
}
} else {
minhaha = -minhaha;
for (int i = 0; i <= 3; i++) {
if (changdi[(now2 + fx[i]) / 27][(now2 + fx[i]) % 27] && i != last2 &&
minhaha < dis[now2 + fx[i]][k]) {
minhaha = dis[now2 + fx[i]][k];
haha = i;
}
}
}
xx = now2 / 27;
yy = now2 % 27;
gotoxy (xx, yy);
if (changdi[xx][yy] == 1) {
printf ("·");
} else {
printf (" ");
}
now2 += fx[haha];
last2 = (haha + 2) % 4;
gotoxy (18, 30);
xx = now2 / 27;
yy = now2 % 27;
gotoxy (xx, yy);
color (5);
printf ("◆");
color (7);
if (xx == x && yy == y) {
if (!dali) {
chi++;
} else {
guozi += 50;
fenshu += 50;
last2 = 0;
gotoxy (now2 / 27, now2 % 27);
if (changdi[now2 / 27][now2 % 27] == 1) {
printf ("·");
} else {
printf (" ");
}
now2 = 390;
}
}
}
if (g3) {
int k;
minhaha = 2147483647;
if (fangx == 0 | fangx == 2) {
k = y + (fxfx[(fangx + 1) % 4][1]) * 3;
while (k > 25 | !changdi[x][k]) {
k--;
}
while (k < 1 | !changdi[x][k]) {
k++;
}
} else {
k = x + (fxfx[(fangx + 1) % 4][0]) * 3;
while (k > 28 | !changdi[k][y]) {
k--;
}
while (k < 1 | !changdi[k][y]) {
k++;
}
}
if (fangx == 0 | fangx == 2) {
k += x * 27;
} else {
k = k * 27 + y;
}
if (now3 % 27 == 0 | now3 % 27 == 26) {
haha = last3;
} else if (!dali) {
for (int i = 0; i <= 3; i++) {
if (changdi[(now3 + fx[i]) / 27][(now3 + fx[i]) % 27] && i != last3 &&
minhaha > dis[now3 + fx[i]][k]) {
minhaha = dis[now3 + fx[i]][k];
haha = i;
}
}
} else {
minhaha = -minhaha;
for (int i = 0; i <= 3; i++) {
if (changdi[(now3 + fx[i]) / 27][(now3 + fx[i]) % 27] && i != last3 &&
minhaha < dis[now3 + fx[i]][k]) {
minhaha = dis[now3 + fx[i]][k];
haha = i;
}
}
}
xx = now3 / 27;
yy = now3 % 27;
gotoxy (xx, yy);
if (changdi[xx][yy] == 1) {
printf ("·");
} else {
printf (" ");
}
now3 += fx[haha];
last3 = (haha + 2) % 4;
gotoxy (18, 30);
xx = now3 / 27;
yy = now3 % 27;
gotoxy (xx, yy);
color (3);
printf ("◆");
color (7);
if (xx == x && yy == y) {
if (!dali) {
chi++;
} else {
guozi += 50;
fenshu += 50;
last3 = 0;
gotoxy (now3 / 27, now3 % 27);
if (changdi[now3 / 27][now3 % 27] == 1) {
printf ("·");
} else {
printf (" ");
}
now3 = 341;
}
}
}
if (chi) {
beichi++;
}
}
int main () {
MessageBox (NULL, "欢迎来到吃豆人游戏!", "温馨提示", MB_OK);
begin ();
int jixu = 1;
reset ();
string bb[4] = {"●", "①", "②" ,"③"};
color (7);
gotoxy (12, 12);
printf ("倒计时");
color (12);
for (int i = 3; i >= 0; i--) {
if (i==0) {
color (11);
}
gotoxy (13, 13);
cout << bb[i];
Sleep (1000);
}
gotoxy (12, 12);
printf (" ");
gotoxy (13, 13);
printf (" ");
while (!f) {
Sleep (1);
gotoxy (7, 30);
color (3);
printf ("得分:%d ", fenshu);
gotoxy (3, 30);
printf ("怪物速度:%d ", 300 - t2);
gotoxy (5, 30);
printf ("你的速度:%d ", 300 - t1);
gotoxy (9, 30);
printf ("被吃次数:%d ", beichi);
gotoxy (11, 30);
printf ("控制小人行走:方向键");
gotoxy (13, 30);
printf ("复活次数:无限次");
gotoxy (15, 30);
printf ("小人加速/减速:'+'/'-'");
gotoxy (17, 30);
printf ("大力丸(怪物们不会主动吃您):$键");
gotoxy (20, 10);
color (4);
if (kbhit ()) {
shuru ();
}
if (stopped) {
continue;
}
T1 = (T1 + 1) % t1;
T2 = (T2 + 1) % t2;
if (T1 % t1 == 0 && now + fx[fangx] > 0 && now + fx[fangx] < n) {
move1 ();
}
if (T2 % t2 == 0) {
if (guaitimer <= 8) {
if (guaitimer==0) {
g1 = 1;
}
if (guaitimer == 8) {
g2 = 1;
}
guaitimer++;
}
if (!g3 && fenshu >= 30) {
g3 = 1;
}
move2 ();
}
if (fenshu == guozi) {
f=2;
}
}
if (f == 2) {
Sleep (3000);
system ("cls");
gotoxy (10, 20);
color (3);
string str = "恭喜您吃完了所有豆子!";
for (int i = 0; i < str.size (); i++) {
Sleep (80);
cout << str[i];
}
Sleep (2000);
gotoxy (12, 20);
str = "您一共被怪物吃掉了";
for (int i = 0; i < str.size (); i++) {
Sleep (80);
cout << str[i];
}
Sleep (80);
cout << beichi;
Sleep (80);
cout << "次";
Sleep (80);
cout << "!";
gotoxy (14, 20);
Sleep (2000);
}
}
3、斗破苍穹(如果想使用外挂,名字请输入:“圣战斗士 ”)
//斗破苍穹
#include<stdio.h>
#include<ctime>
#include<time.h> //suiji
#include<windows.h> //SLEEP函数
struct Player //玩家结构体,并初始化player
{
char name[21];
int attack;
int defense;
int health;
long int max_health;
int level;
int exp;
int range_exp;
long int max_exp;
} player= {"勇者",50,40,100,100,1,0,0,100};
struct Enemy //怪的结构体,并初始化各种怪
{
char name[20];
char wupin[12];
int attack;
int defense;
int health;
int money;
long int exp;
int wupin_sign;
int wupinpro;
int double_attack;
int miss;
} strongman= {"森林巨人","黄金圣衣",40,50,350,200,100,1,2,1,0},
witch= {"森林女巫","银甲",25,15,100,50,50,2,2,1,1},
xiyi= {"森林蜥蜴","铁甲",18,10,50,30,35,3,3,2,2},
big_strongman= {"森林巨人王","巨人晶石",40*5,50*5,200*5,200*5,100*5,4,4,2,0},
lion= {"草原雄狮","绝世好剑",60,30,280,200,100,5,2,1,0},
horse= {"草原野马","碧血剑",28,12,90,50,50,6,2,1,1},
bee= {"草原黄蜂","长剑",17,11,60,30,35,7,3,2,2},
shitu= {"使徒","\0",60*8,30*8,280*8,200*8,100*8,9,1,1,0},
guai= {"\0","\0",0,0,0,0,0,0,0,0,0};
struct Place
{
int bar,hotel,forest1,forest2,forest3,grass1,grass2,grass3;
} place= {1,2,3,4,5,6,7,8};
int max_exp=0;
int choose_number=0,s=0,strongman_arm=0,battle=0,money=500,place_sign=9;
int cao=3,jijiubao=2,baiyao=2,superbaiyao=1,boom=3,dubiao=2,atom_boom=1;
int fang=0,fang1=10,fang1n=0,fang2=20,fang2n=0,fang3=40,fang3n=0,fang4=100,fang4n=0;
int gong=0,gong1=8,gong1n=0,gong2=15,gong2n=0,gong3=25,gong3n=0,gong4=60,gong4n=0;
int jingyancao=0,jingyanbao=0,jingyanshi=0;
char gongname[20]="无",fangname[20]="无";
char proof;
void AddWupin(int);
int AttackResult();
void BattleAct();
void ChooseWupin();
void DisplayState();
void OrdinaryAct();
int SuiJi();
int SuiJi100();
void WhetherLevelUp();
void SlowDisplay(char *);
int main()
{
int i=0,j=0,k=0;
char player_name[21];
Sleep(1000);
printf("--------------------------欢迎来到 [苍穹世界] 2.2 测试版-----------------------\n\n\n");
//如果想使用外挂,名字请输入:“圣战斗士 ”。
Sleep(1000);
printf("这里是苍穹世界! 雅莉萨斯国的罗茜公主被陌生人绑架了!\n\n\n 伟大的勇者啊~拿起你们的武器,营救公主!\n\n\n输入你的名字: (20个字符)\n\n\n");
scanf("%s",player_name);
strncpy(player.name,player_name,20);
if(strcmp(player.name,"圣战斗士")==0)
{
printf(