Rpg exploring system errors.

This is a discussion on Rpg exploring system errors. within the Game Programming forums, part of the General Programming Boards category; I've been using C++ for about 2 weeks now and covered most of the basics so I decided to start ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    1

    Thumbs down Rpg exploring system errors.

    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.
    Last edited by gameprognewbie; 12-02-2004 at 01:38 PM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,335
    > map [YOU.x][YOU.y] = 8;
    A 1x1 array seems pretty pointless, and what does 8 mean?

    > if (NORTH == true) {
    Comparing booleans to true and false is a waste of effort when you can simply say
    if (NORTH) {

    > if (direction == "n" && NORTH == true) {
    This is your error - direction is a char (which is a small int), and "n" is a string (or a pointer to a char)
    Use single quotes for single letters, like so
    if (direction == 'n' && NORTH == true) {

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Also, why are "WALL" and "NOWALL" both defined to be the same thing?

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. School Mini-Project on C/C++ (Need Your Help)..
    By EazTerence in forum C++ Programming
    Replies: 4
    Last Post: 09-08-2005, 01:08 AM
  2. Why Can't C++ Be Used to Develop Operating System?
    By Antigloss in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2005, 06:16 AM
  3. Char Variable Probelm
    By Krak in forum C++ Programming
    Replies: 1
    Last Post: 01-26-2003, 11:34 AM
  4. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 05:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21