1 Attachment(s)
I'll post the code for the mouse
I'll post the code for the mouse.h and mouse.cpp, also I have uploaded a zip with mouse.h, mouse.cpp, and main.cpp. assume maze works (cause it does).
PHP Code:
#include <iostream>
using std:: ostream;
using std::endl;
#include "maze.h"
//#include "screen.h"
class mouse
{
protected:
unsigned short x;
unsigned short y;
unsigned int steps;
// N = 1; E = 2; S = 3; W = 4;
unsigned int direction;
char footprint;
bool righthand;
void turnLeft();
void turnRight();
void stepForward();
public:
mouse(maze<char> m, char charfoot);
void takeOneStep(maze<char> m);
bool AmIInTheExit(maze<char> m, unsigned short x, unsigned short y);
bool AmIInTheEntrance(maze<char> m, unsigned short x, unsigned short y);
//friend ostream & operator << (ostream & o, const mouse m);
friend ostream & operator << (ostream & o, const mouse m);
};
Above is mouse.h
PHP Code:
#include "mouse.h"
mouse::mouse(maze<char> m, char charfoot)
{
m.getEntrance(x, y);
steps = 0;
// N = 1; E = 2; S = 3; W = 4;
direction = 2;
footprint = charfoot;
righthand = true;
}
void mouse::turnLeft()
{
direction--;
if (direction < 1)
direction = 4;
}
void mouse::turnRight()
{
direction++;
if (direction > 4)
direction = 1;
}
void mouse::stepForward()
{
}
void mouse::takeOneStep(maze<char> m)
{
//What's the difference between this and stepForward()?
switch (direction)
{
case 1:
if ( !( m.IsThisCellBlocked(x, ( y-1 )) ) )
y--;
break;
case 2:
if ( !( m.IsThisCellBlocked(( x+1 ), y-1) ) )
x++;
break;
case 3:
if ( !( m.IsThisCellBlocked(x, ( y+1 )) ) )
y++;
break;
case 4:
if ( !( m.IsThisCellBlocked(( x-1 ), y-1) ) )
x--;
break;
default:
break;
}
}
bool mouse::AmIInTheExit(maze<char> m, unsigned short x, unsigned short y)
{
return m.IsThisCellTheExit (x, y);
}
bool mouse::AmIInTheEntrance(maze<char> m, unsigned short x, unsigned short y)
{
return m.IsThisCellTheEntrance (x, y);
}
ostream & operator << (ostream & o, const mouse m)
{
//Clear screen and set
//CURSOR AT TOP LEFT!!!
//ClearScreen();
// PRINT MOUSE
cout << "M";
return o;
}
//End mouse.cpp
Above is mouse.cpp
Anyway, hope someone can help cause I'm stumped. I just have a feeling its something stupid so keep your eyes open! :eek:
NOMAD