I've been using C++ for about 2 weeks now and covered most of the basics so I decided to start making a game. I've started with the exploring system and already I'm getting lots of errors. I've just started with the basics of the exploring system (No functions for picking up items or anything). Here's the code:
Code:
#include <iostream>
#include <conio.h>
#define WALL 1
#define NOWALL 1
void wallcheck();
int map[4][4] =
{1,1,1,1,
1,0,0,1,
1,1,0,2,
1,1,1,1};
bool NORTH = true;
bool EAST = true;
bool SOUTH = true;
bool WEST = true;
struct {
int x;
int y;
} YOU = {1,1};
int main() {
map [YOU.x][YOU.y] = 8;
wallcheck();
if (NORTH == true) {
cout<<"North (n) "<<endl;
}
if (SOUTH == true) {
cout<<"SOUTH (s) "<<endl;
}
if (WEST == true) {
cout<<"West (w) "<<endl;
}
if (EAST == true) {
cout<<"East (e) "<<endl;
}
char direction;
cout<<endl<<endl<<"Which direction would you like to go in?";
cin>>direction;
if (direction == "n" && NORTH == true) {
YOU.x = YOU.x-1;
map [YOU.x][YOU.y] = 8;
}
else {
cout<<"You can't go that direction.";
}
if (direction == "s" && SOUTH == true) {
YOU.x = YOU.x+1;
map [YOU.x][YOU.y] = 8;
}
else {
cout<<"You can't go that direction.";
}
if (direction == "w" && WEST == true) {
YOU.y = YOU.y-1;
map [YOU.x][YOU.y] = 8;
}
else {
cout<<"You can't go that direction.";
}
if (direction == "e" && EAST == true) {
YOU.y = YOU.y+1;
map [YOU.x][YOU.y] = 8;
}
else {
cout<<"You can't go that direction.";
}
if (map [YOU.x][YOU.y] == 2) {
cout<<"You found an item.";
}
getch();
return 0;
}
void wallcheck () {
if (map [YOU.x-1][YOU.y] == WALL) {
NORTH = false;
}
else {
true;
}
if (map [YOU.x+1][YOU.y] == WALL) {
SOUTH = false;
}
else {
true;
}
if (map [YOU.x][YOU.y-1] == WALL) {
WEST = false;
}
else {
true;
}
if (map [YOU.x][YOU.y+1] == WALL) {
EAST = false;
}
else {
true;
}
}
Errors I'm getting:
Line 52 ANSI C++ forbids comparison between pointer and integer
Line 61 ANSI C++ forbids comparison between pointer and integer
Line 70 ANSI C++ forbids comparison between pointer and integer
Line 79 ANSI C++ forbids comparison between pointer and integer
Line 92 Implicit Declaration of function `int getchar(...)'
Could somebody help me correct this code? Thanks.
Edit: Oh yeah, I'm using the Dev-C++ 4 Compiler.