The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 7 of 7

Thread: Help Not Sure with these Errors

  1. #1
    BrandonTN's Avatar
    37
    posts
    The Original Bulldog

    Help Not Sure with these Errors

    I have been reading these tutorials on c++ and have been programming for a bit. I already created a funny Coin flip game and programmed it without an help and figured out all the errors the comiler read to me. Anywho I am on to a new game just starting out with Console programming and these errors I cant seem to figure out.

    Code:
    1>------ Build started: Project: ASCII RPG, Configuration: Debug Win32 ------
    1>Compiling...
    1>Main.cpp
    1>c:\users\brandon newman\documents\visual studio 2008\projects\ascii rpg\ascii rpg\main.cpp(31) : error C2143: syntax error : missing ')' before ';'
    1>c:\users\brandon newman\documents\visual studio 2008\projects\ascii rpg\ascii rpg\main.cpp(31) : error C2059: syntax error : ')'
    1>c:\users\brandon newman\documents\visual studio 2008\projects\ascii rpg\ascii rpg\main.cpp(34) : error C2143: syntax error : missing ')' before ';'
    1>c:\users\brandon newman\documents\visual studio 2008\projects\ascii rpg\ascii rpg\main.cpp(34) : error C2059: syntax error : ')'
    1>c:\users\brandon newman\documents\visual studio 2008\projects\ascii rpg\ascii rpg\main.cpp(48) : error C2143: syntax error : missing ';' before '/'
    1>c:\users\brandon newman\documents\visual studio 2008\projects\ascii rpg\ascii rpg\main.cpp(49) : error C2143: syntax error : missing ';' before '/'
    1>Build log was saved at "file://c:\Users\Brandon Newman\Documents\Visual Studio 2008\Projects\ASCII RPG\ASCII RPG\Debug\BuildLog.htm"
    1>ASCII RPG - 6 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Those are the errors here is my code


    MAIN HEADER
    Code:
    #include< windows.h>
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    //Directions// 
    #define NORTH 0;
    #define SOUTH 1;
    #define EAST  2;
    #define WEST  3;
    
    //Screen Size Default Size Max//
    #define SCREEN_WIDTH  79;
    #define SCREEN_HEIGHT  24;
    
    //Erase And Draw//
    #define ERASE 0;
    #define DRAW 1;
    
    //Players Structure
    struct PLAYER{
        COORD Position;
        int   Direction;
    };

    MAIN CPP
    Code:
    #include "main.h"
    HANDLE hInput, hOutput;    
    
    CONSOLE_SCREEN_BUFFER_INFO ScrInfo;
    
    // This function creates our character
    void DrawPlayer(PLAYER Player, int Draw)
    {
        if(Draw)
        {
            SetConsoleCursorPosition(hOutput, Player.Position);
            cout<<"#";
        }
        else
        {
            SetConsoleCursorPosition(hOutput, Player.Position);
            cout<< " ";
        }
    }
    void MovePlayer(PLAYER &Player)
    {
        INPUT_RECORD InputRecord;
        DWORD Events=0;
        ReadConsoleInput(hInput, &InputRecord,1, &Events);
        if(InputRecord.EventType == MOUSE_EVENT)
        {
    
            if(InputRecord.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)
            {
                DrawPlayer (Player, ERASE);
                Player.Position.X = InputRecord.Event.MouseEvent.dwMousePosition.X;
                Player.Position.Y = InputRecord.Event.MouseEvent.dwMousePosition.Y;
                DrawPlayer (Player, DRAW);
            }    
        }
        FlushConsoleInputBuffer(hInput);
    }
    
    int main()
    {
        PLAYER Player;
        hInput = GetStdHandle(STD_INPUT_HANDLE);
        hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
        SetConsoleMode(hInput, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
    
        GetConsoleScreenBufferInfo(hOutput, &ScrInfo);
        Player.Position.X = SCREEN_WIDTH  / 2;
        Player.Position.Y = SCREEN_HEIGHT / 2;
    
        SetConsoleCursorPosition(hOutput, Player.Position);
        
        while(1)
        {
            MovePlayer(Player);
        }
    }

  2. #2
    What compiler are you using?
    Web Design and Web Development blog
    Designer Notice: Browser List for design compatibility

  3. #3
    BrandonTN's Avatar
    37
    posts
    The Original Bulldog
    Quote Originally Posted by alexgeek View Post
    What compiler are you using?
    Visual C++ Express Edition
    should i try DevC++ Or something

  4. #4
    actionAction's Avatar
    1,142
    posts
    humanBeing._beard=true;
    No semi-colons are allowed in #define statement, change to this:
    Code:
    //Directions// 
    #define NORTH 0
    #define SOUTH 1
    #define EAST  2
    #define WEST  3
    
    //Screen Size Default Size Max//
    #define SCREEN_WIDTH  79
    #define SCREEN_HEIGHT  24
    
    //Erase And Draw//
    #define ERASE 0
    #define DRAW 1

  5. #5
    BrandonTN's Avatar
    37
    posts
    The Original Bulldog
    Quote Originally Posted by actionAction View Post
    No semi-colons are allowed in #define statement
    Thank you so much. I figured the error was occurring in all the function I was calling so I figured I was doing something wrong with #define but I never noticed the semi colons. Sometimes all I need is someone else to point it out now ill never make that mistake again. God I love programming lol.

  6. #6
    actionAction's Avatar
    1,142
    posts
    humanBeing._beard=true;
    It gets tedious after awhile, glad I could help!

  7. #7
    BrandonTN's Avatar
    37
    posts
    The Original Bulldog
    Quote Originally Posted by actionAction View Post
    It gets tedious after awhile, glad I could help!
    I have a question about the functions, because I have the www.gametutorials.com cd pack and its all source code commented with what the lines do and sometimes it doesent mention certain things.

    My question is why is the Structure Declared with a small "player"
    Code:
    void DrawPlayer(PLAYER Player, int Draw)
    and why is there a "&player" with the move function
    Code:
    void MovePlayer(PLAYER &Player)
    I like to completly understand the code so I can almost like read the code to myself and completly understand because it helps me remember what i need to do for certain parts of programming.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012