Playing Star Games

Source: Internet
Author: User

Freshman Summer vacation # include <stdio.h> #include <stdlib.h> #include <conio.h> #define N 10//map size int m=1; int g=5;//////////////////////////person is 1, wall is 9, star is 8/10, vacancy is 0, light 2;int count=0;int point= ' W '; void move (int a[][10],int i,int j);//move function void Huatu (int a[n][n]);//Draw void Guang (int a[][10]); int main (void) {int a[n][n]={{9,9,9,9,9,9,9,9,9,9},{ 9,0,0,0,9,1,0,8,8,9},{9,0,0,0,9,0,0,0,0,9},{9,0,0,0,0,0,0,0,0,9},{9,0,8,0,0,0,0,0,0,9},{9,0,0,0,0,0,9,0,0,9},{    9,0,0,0,0,0,9,0,0,9},{9,0,0,8,8,0,0,0,0,9},{9,0,0,0,9,0,0,0,0,9},{9,9,9,9,9,9,9,9,9,9}};    int ch;    Huatu (a); while (1) {ch=getch (), switch (CH) {case 72:move (a,-1,0); Break;case 80:move (a,1,0); Break;case 75:move (a,0,-1); Brea K;case 77:move (a,0,1); Break;case ' W ': point= ' w '; Continue;case ' s ': point= ' s '; Continue;case ' a ': point= ' a '; continue; Case ' d ': point= ' d ', Continue;case ' J ': Guang (a); break;};    System ("CLS"); Huatu (a); if (count==5)/////////termination condition {printf ("Success \ n"); _sleep (+); exit (0);}} return 0;} void Move (int a[][10],int i,intj) {if (a[m+i][g+j]==9| |  a[m+i][g+j]==8) printf ("banging against the Wall or stars"); Man-wall/Star else if (a[m+i][g+j]==0)//person-no {a[m][g]-=1;a[m+i][g+j]+=1;m+=i;g+=j;}}     void Guang (int a[][10]) {int i,j; if (point== ' W ') for (i=m-1;i>0 && a[i][g]!=9;--i) {a[i][g]+=2;if (a[i][g]==10) ++count;} else if (point== ' s ') for (i=m+1;i<9 && a[i][g]!=9;++i) {a[i][g]+=2;if (a[i][g]==10) ++count;} else if (point== ' a ') for (i=g-1;i>0 && a[m][i]!=9;--i) {a[m][i]+=2;if (a[m][i]==10) ++count;} else if (point== ' d ') for (i=g+1;i<9 && a[m][i]!=9;++i) {a[m][i]+=2;if (a[m][i]==10) ++count;} Displays the attack system ("CLS"), Huatu (a), _sleep (I=1;i<n-1;++i)///////is attacked and becomes 0for (j=1;j &LT;N-1;++J) if (a[i][j]==2 | | a[i][j]==10) a[i][j]=0;}  void Huatu (int a[n][n]) {int count=0;    int i,j;            for (i=0;i<n;i++) {for (j=0;j<n;j++) {if (a[i][j]==5) count++;                Switch (A[i][j]) {case 9:printf ("");               Case 0:printf (""); Break;case 10: Case 2:printf ("-"); break;//attack case 1:printf ("㊣"); break;///man case 8:printf ("☆"); break;//star default:printf ("?");}}  printf ("\ n"); } printf ("\ n \ nyou move up and down;;; W s a D adjusts the attack direction;;; J attack");}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Playing Star Games

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.