Jump to content
  • Advertisement

VishalAchmare

Member
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

97 Neutral

About VishalAchmare

  • Rank
    Newbie
  1. VishalAchmare

    Need help in understanding this code...

    Well, then she should post what exactly she doesn't understand and ask specific questions... You can't just "make code easier to understand". [/quote] alright thanks guys. vl post it asap.
  2. VishalAchmare

    Need help in understanding this code...

    yes she is understanding it upto a certain extent. but needs help for some portions of the code. you seem to have a very good knowledge. can u make the code a lil simpler to understand?
  3. VishalAchmare

    Need help in understanding this code...

    1 of my friends have good C programming knowledge. would it be sufficient? if yes. please explain it step by step..excluding the very basic parts. please i need to do it. and i can't without your help..
  4. VishalAchmare

    Need help in understanding this code...

    1 of my friends have good C programming knowledge. would it be sufficient?
  5. VishalAchmare

    Need help in understanding this code...

    yes i know its cheating. and i don't have any programming knowledge. this project was decided by my group members. i can't change it. can u please help me in understanding it?
  6. [size="4"]Well [size="4"]its a code of a game called mind guesser. Its not my code and i don't have any knowledge about game programming. its a college project. i got d code from net. but i seriously need some help from pros to understand it. even the slightest help will be greatly appreciated. Thanks. #include<stdio.h> #include<conio.h> #include<math.h> #include<ctype.h> #include<graphics.h> #include<stdlib.h> #include<string.h> #define ENTER_KEY '\r' #define ESCAPE_KEY 27 #define SPECIAL_KEY 0 #define UP_ARROW 72 #define DOWN_ARROW 80 #define LEFT_ARROW 75 #define RIGHT_ARROW 77 /* following values can be changed to alter the game flow LEN: no. of balls MAX_COLOR: no. of colors MAX_TURN: no. of turns */ #define LEN 4 #define MAX_COLOR 6 #define MAX_TURN 10 void graphic_mode(void); //initializes graphics mode void input_pattern(void); //inputs pattern from player1 void guess_pattern(void); //inputs pattern from player2 int color[LEN]; void main(void) { clrscr(); randomize(); graphic_mode(); char opt; do { input_pattern(); guess_pattern(); cleardevice(); outtextxy(200,getmaxy()/2-20, "Play again (Press \"y\" for yes)"); opt=getch(); } while ( opt=='y' || opt=='Y'); closegraph(); } void graphic_mode(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, "..\\bgi\\"); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } } void input_pattern(void) { cleardevice(); char temp[100]; setcolor(15); sprintf(temp, "Each of the following %d balls can have 1 out of %d colors",LEN,MAX_COLOR); outtextxy (300,10, "Mind Guesser"); setcolor(7); outtextxy (10,22, "Programmed by Syed Mehroz Alam"); outtextxy (10,34, "CIS-61, First Year, Batch 2002-03"); outtextxy (10,46, "Computer & Information Systems Dept, NED University."); outtextxy (10,58, "NED University."); outtextxy (10,70, "Email: smehrozalam@yahoo.com"); outtextxy (10,95,temp); outtextxy (10,110, "Player 1, Choose your pattern"); outtextxy (10,122, "Press Left & Right arrow keys to change current ball"); outtextxy (10,134, "Press Up & Down arrow keys to toggle color"); outtextxy (10,146, "Press 'R' for generating a random pattern"); outtextxy (10,158, "Press <ENTER> when done"); setcolor(15); int pos=0, key, key2; for (int i=0;i<LEN;i++) { setfillstyle(1,1); fillellipse(30+i*45, 200, 20, 20); } for (i=0;i<LEN;i++) color=1; do { key=getch(); if (key==ESCAPE_KEY) exit(0); if (key=='r' || key=='R') { for (i=0;i<LEN;i++) color=(rand()%MAX_COLOR)+1; return; } else if (key==SPECIAL_KEY) { key2=getch(); switch(key2) { case UP_ARROW: color[pos]++; break; case DOWN_ARROW: color[pos]--; break; case LEFT_ARROW: pos--; break; case RIGHT_ARROW: pos++; break; } if ( color[pos]>MAX_COLOR ) color[pos]=1; else if ( color[pos]<1) color[pos]=MAX_COLOR; if (pos>LEN-1) pos=LEN-1; else if (pos<0) pos=0; } //end elseif special key setfillstyle(1,color[pos]); fillellipse(30+pos*45, 200, 20, 20); } while (key!=ENTER_KEY); } void guess_pattern(void) { int y=0,x=0,turn=0, pos=0,key,key2,color[LEN]={0}; cleardevice(); char temp[80]; setcolor(7); outtextxy (2,2, "Player 2, Enter your choice then press <ENTER>"); sprintf(temp, "You have %d turns, Each ball can have 1 out of %d colors, ", MAX_TURN, MAX_COLOR); outtextxy (2,12, temp); outtextxy (2,25, "Scoring Criteria:"); outtextxy (2,35, "No. of blue pegs = no. of correct balls at correct places"); outtextxy (2,45, "No. of green pegs = no. of correct balls at incorrect places"); setcolor(15); for (int j=0;j<MAX_TURN;j++) { pos=0; for (int i=0;i<LEN;i++) { setfillstyle(1,1); fillellipse(30+i*45+x*300, 90+y*50, 20, 20); setfillstyle(1,0); fillellipse(30+i*15+x*300+45*LEN, 90+y*50, 6, 6); } for (i=0;i<LEN;i++) color=1; do { key=getch(); if (key==ESCAPE_KEY) exit(0); else if (key==SPECIAL_KEY) { key2=getch(); switch(key2) { case UP_ARROW: color[pos]++; break; case DOWN_ARROW: color[pos]--; break; case LEFT_ARROW: pos--; break; case RIGHT_ARROW: pos++; break; } if ( color[pos]>MAX_COLOR ) color[pos]=1; if ( color[pos]<1) color[pos]=MAX_COLOR; if (pos>LEN-1) pos=LEN-1; if (pos<0) pos=0; } //end elseif special key setfillstyle(1,color[pos]); fillellipse(30+pos*45+x*300, 90+y*50, 20, 20); } while (key!=ENTER_KEY); //start scoring int blue_peg=0,green_peg=0; for (i=0;i<LEN;i++) if ( color==::color ) blue_peg++; for (i=0;i<LEN;i++) for (int k=0;k<LEN;k++) if ( color[k]==::color ) { green_peg++; color[k]=0; break; } setfillstyle(1,2); for (i=0;i<green_peg;i++) fillellipse(30+i*15+x*300+45*LEN, 90+y*50, 6, 6); setfillstyle(1,1); for (i=0;i<blue_peg;i++) fillellipse(30+i*15+x*300+45*LEN, 90+y*50, 6, 6); //end scoring if ( blue_peg==LEN ) // if win { char str[25]; sprintf(str, "You won in %d turns!",turn+1); outtextxy (getmaxx()/2-100, getmaxy()-15, str); getch(); return; } y++; if (y==8) { y=0; x=(x==0)?1:0; // x!=x } turn++; } char str[60]; sprintf(str, "You lost! Press any key to see the actual pattern"); outtextxy (100, getmaxy()-15, str); getch(); for (int i=0;i<LEN;i++) { setfillstyle(1,::color); fillellipse(100+i*150, 250, 65, 65); } getch(); }
  7. [size="4"] Well [size="4"]its a code of a game called mind guesser. Its not my code and i don't have any knowledge about game programming. its a college project. i got d code from net. but i seriously need some help from pros to understand it. even the slightest help will be grealy appriciated. Thanks.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!