[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

maze game in C

Asked by cipher007 in C Programming Language

Tags: maze, c, game

Simple maze game using C... Here's what I want to do. ( I am using Dev-C++ compiler)
** game map should be loaded from a file (in the following code, map is generated runtime), and its format should be something like the following.
WWWWWWWWWWWWWWWW
W                                               W
W                                               W
W      $             $                        W
W        O                                    W
W        $                      M            W
W                                               W
W                    M                        W
W            M                          E    W
WWWWWWWWWWWWWWWW

W = wall
O = moving character
$ = money
E = exit
M = monsters (when game is started these monsters should be chasing the O character)
** keys A,S,W and Z are used to move the character O (in the following code only key the down movement (key S) is coded.
** username and score should be visible and when game ends this info should be saved to a file (may be top 5 scorers)


=====================================================
#include <iostream.h>
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>

char moveR;
char moveL;
char moveU;
char moveD;
char move;
int mx=1;
int my=1;
int i,j;
char direction;
const char up_key='w', down_key='s', left_key='a', right_key='d';
char keypress;
char matrix[100][100];
void gotoxy(short x, short y)
{
      HANDLE hConsoleOutput;
      COORD Cursor_an_Pos = {x,y};
      hConsoleOutput = GetStdHandle (STD_OUTPUT_HANDLE);
      SetConsoleCursorPosition(hConsoleOutput, Cursor_an_Pos);
}

void loadgrid()
{
      for (i=0; i<30; i++)
      {
            for (j=0; j<30; j++)
            {
                  matrix[i][j]= '.';
            }
      }
}

void printgrid()
{
      for (i=0; i<30; i++)
      {
            for (j=0; j<30; j++)
            {
                  printf("%c", matrix[i][j]);
            }
            printf("\n");
      }
}

int main()
{
loadgrid();
printgrid();

while (mx>0 && my>0)
{
      if (kbhit())
      {
            keypress=getch(); //keypress=(char)getchar()
            if ((keypress == right_key) || (keypress == left_key) ||
                  (keypress == up_key) || (keypress == down_key))
                  direction = keypress;
                  if (direction == 's')
                  {
                  gotoxy(mx,my);
                  printf(".");
                  my=my+1;
                  gotoxy(mx,my);
                  printf("O");
                  gotoxy(mx,my);
                  }
                  if (direction == 'w')
                  {
                  gotoxy(mx,my);
                  printf(".");
                  my=my-1;
                  gotoxy(mx,my);
                  printf("O");
                  gotoxy(mx,my);
                  }
                  if (direction == 'a')
                  {
                  gotoxy(mx,my);
                  printf(".");
                  mx=mx-1;
                  gotoxy(mx,my);
                  printf("O");
                  gotoxy(mx,my);
                  }
                  if (direction == 'd')
                  {
                  gotoxy(mx,my);
                  printf(".");
                  mx=mx+1;
                  gotoxy(mx,my);
                  printf("O");
                  gotoxy(mx,my);
                  }
                  direction = ' ';
      }
}

return 0;
}
 
Related Solutions
Keywords: maze game in C
 
Loading Advertisement...
 
[+][-]08/01/07 07:48 PM, ID: 19614221Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/01/07 08:13 PM, ID: 19614297Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/01/07 11:56 PM, ID: 19614968Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/02/07 05:30 PM, ID: 19621894Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/02/07 11:50 PM, ID: 19623012Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/03/07 01:32 PM, ID: 19628285Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/03/07 01:35 PM, ID: 19628314Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/03/07 02:04 PM, ID: 19628529Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/04/07 12:38 AM, ID: 19630228Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: C Programming Language
Tags: maze, c, game
Sign Up Now!
Solution Provided By: Infinity08
Participating Experts: 3
Solution Grade: B
 
[+][-]08/10/07 05:01 PM, ID: 19674328Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89