mazerunner HW help

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions mazerunner HW help
# 1  
Old 04-30-2011
Java mazerunner HW help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
i know what to use for this part but i dont know where to add it. the program just move the mouse throughout the maze but what i want it to do is to read the walls around it . the display.h is a given from the professor


2. Relevant commands, code, scripts, algorithms:
display.h
Code:
#define MAXR 16
#define MAXC 16

#define NORTH 0
#define EAST  1
#define WEST  2
#define SOUTH 3
#define CRASH 4


/*  This file contains the prototypes for useful funcitons in the display.o
        library  */

void init_display(int level);
/* This function initializes the display environment and clears the screen
   and draws the template maze from the local file maze.template.  The
   parameter, level, determines the level of difficulty (see the spec).
   For Level 0 and 1 it also initializes the maze from the local file
   maze.dat.
 */

void show_mouse(int dir, int row, int col);
/* This function shows the mouse at the row and col position headed in
   the direction dir. Available at all levels.
 */

void write_message(char str[], int line);
/* This function writes the given message at one of the lines (0 to 10)
   on the bottom of the screen.  The string is truncated at 64 characters.
   Available at all levels.
 */

void clear_screen(void);
/* This function clears the screen and shuts down the display environment
   Available at all levels.
 */

void show_position(int y, int x);
/*  This functions displays the position under the X and Y on the right
    of the screen.  Available at all levels.
 */

void show_cells(int cells);
/*  This function displays the number of cells explored under CELLS on the
    right of the screen.  Available at Level 1 and higher.
 */

void show_unique_cells(int cells);
/*  This function displays the number of unique cells explored under
    UNIQUE CELLS on the right of the screen. Available at Level 2 or higher.
 */

void mouse_cam(int left, int front, int right);
/*  This functions displays the mouse view of left, front and side walls
     under MOUSE CAM on the right side of the screen. Available at all
     levels.
 */

void lvl0_get_walls(int y, int x, int *North, int *East, int *West, int *South);
/*  This function indirectly returns the walls (1 for present, 0 of absent)
    in the cell y, x from the internal maze.  Avaliable only at Level 0
    or 1.
 */

void put_walls(int y, int x, int North, int East, int West, int South);
/*  This function shows the given North, East, West and South walls
    (1 for present, 0 for absent) for the cell y, x on the screen.
    Avaliable only at Level 1 or higher.
 */

3. The attempts at a solution (include all code and scripts):
lev0.c (level 0)
Code:
#include <stdio.h>
#include "display.h"

 main()
{ int dir, row, col;
  int no,we,so,ea;  // north, west, south, east


  /*direction, rows, clounm*/
  dir = NORTH;   /* initialize the */
  row = 0;
  col = 0;
  char c;

int level = 0;

init_display(level);

show_mouse(dir, row, col);

show_position( row, col);
lvl0_get_walls(row, col, *no, *we, *so, *ea);
while( c = getchar())
        {



                switch(c)
               {
                case 'a': if(dir==NORTH)
                        {dir=WEST;
                        break;
                        }
                          if( dir==WEST)
                        {dir=SOUTH;
                        break;
                        }
                          if (dir==SOUTH)
                        {dir=EAST;
                        break;
                        }
                          if (dir == EAST)
                        {dir=NORTH;
                        break;
                        }

                case 's': if(dir == NORTH)
                         { dir =SOUTH;
                           break;
                         }
                         if(dir == SOUTH)
                        { dir = NORTH;
                         break;
                        }
                case 'd': if(dir == NORTH)
                         {dir = EAST;
                          break;
                         }
                         if (dir == EAST)
                         {dir = SOUTH;
                          break;
                         }
                         if(dir==SOUTH)
                         {dir=WEST;
                         break;
                         }
                        if ( dir==WEST)
                        { dir = NORTH;
                         break;
                        }

                case 'w': if (dir == NORTH)
                        {row++;
                         break;
                        }
                        if ( dir == EAST)
                        { col++;
                         break;
                        }
                        if(dir==SOUTH)
                        { row--;
                         break;
                        }
                        if (dir==WEST)
                        { col--;
                         break;
                        }


                case 'q': return;
                default:
                break;
               }
        show_mouse(dir,row, col);
        }
}

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
university of Hawaii at Manoa, Honolulu(HI), Oahu(hawaii), Tep Dobry, ee160
EE 160: Final Project

Last edited by Scott; 04-30-2011 at 12:43 PM.. Reason: Added code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

MAzerunner menu help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have all the functions working for the game but dont know how to make the menu or even start should i use a dat... (0 Replies)
Discussion started by: mgyeah
0 Replies
Login or Register to Ask a Question