Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Feb 2011
    Posts
    6

    Evil Monkeys, drawEngine error c2511

    hi
    I've got 4 errors , I've tried to fix them but I just can't. Can anyone help me?

    • Error 1 error C2143: syntax error : missing ',' before 'constant' (LINE 7)

    • Error 2 error C2511: 'drawEngine::drawEngine(int,int,int)' : overloaded member function not found in 'drawEngine'
    (LINE 8 , drawEngine.cpp)

    • Error 3 error C2511: 'drawEngine::drawEngine(int,int,int)' : overloaded member function not found in 'drawEngine'
    (LINE 32 , drawEngine.cpp)

    • Error 4 error C2146: syntax error : missing ';' before identifier 'output_handle' (LINE 44, drawEngine.cpp)



    drawEngine.h

    Code:
    #ifndef DRAWENGINE_H
    #define DRAWENGINE_H
    
    class drawEngine
    {
    public:
    	drawEngine(int index, int xSize 30, int ySize 20);
    	~drawEngine();
    	int createSprite(int index, char c);
    	void deleteSprite(int index);
    	void eraseSprite(int posx, int posy);
    	void drawSprite(int index, int posx, int posy);
    protected:
    	int screenWidth, screenHeight;
    	char spriteImage[16];
    
    
    private:
    	void drawEngine::gotoxy(int index, int x, int y);
    	void cursorVisiblility(bool visibility);
    };
    
    #endif
    drawEngine.cpp

    Code:
    #include <iostream>
    #include "drawEngine.h"
    #include <windows.h>
    #include "Main.cpp"
    #include "Game.h"
    using namespace std;
    drawEngine::drawEngine(int index, int xSize, int ySize)
    {
    	screenWidth = x;
    	schreenHeight = y;
    
    	//set cursor visibility to false
    }
    
    drawEngine::~drawEngine()
    {
    	//set cursor visibility to true
    }
    
    int drawEngine::createSprite(int index, char c)
    {
    	if (index >= 0 && index < 16)
    	{
    	spriteImage[index] = c;
    	return index;
    	}
    
    	return -1;
    }
    
    drawEngine::drawEngine(int index, int posx, int posy)
    {
    	drawEngine::gotoxy (posx, posy);
    	cout << spriteImage[index];
    }
    
    void drawEngine::gotoxy(int index, int x, int y)
    {
    	HANDLE output_handle;
    	COORD pos;
    	pos.X = x;
    	pos.Y = y
    	
    	output_handle = GetStdHandle(STD_OUTPUT_HANDLE);
    
    	SetConsoleCursorPosition(output_handle, pos);
    }

    I'm using visual c++ 2008 express

  2. #2
    Join Date
    Dec 2004
    Location
    Atwater, CA
    Posts
    418
    I haven't coded in C++ in a long time, but I think the line in your drawEngine.h is supposed to look like this
    Code:
    drawEngine(int index, int xSize = 30, int ySize = 20);
    Also, it looks like you missed a semicolon in the gotoxy function.
    Code:
    pos.Y = y;

  3. #3
    Join Date
    Feb 2011
    Posts
    6
    Thanks,
    I missed A semicolon.
    Now I've got 3 errors instead of 4.
    I don't have the 4th error any more.
    I don't think I have to put the equal signs there it just makes me have more errors.

  4. #4
    Join Date
    Feb 2011
    Posts
    6
    please help

  5. #5
    Join Date
    Dec 2004
    Location
    Atwater, CA
    Posts
    418
    I took another look and I noticed that you have two constructors in drawEngine.cpp with the same signature.
    I believe this line
    Code:
    drawEngine::drawEngine(int index, int posx, int posy)
    should read this
    Code:
    drawEngine::drawSprite(int index, int posx, int posy)

  6. #6
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    Quote Originally Posted by Blackelfwolf View Post
    I don't think I have to put the equal signs there it just makes me have more errors.
    Well, thinking obviously doesn't help you here. The equal signs need to be there, as you could have found out through both a quick google search or another look at the VTMs within less than 2 minutes.
    If you have troubles remembering the syntax, write yourself a cheat sheet or buy a decent language reference book.

    Fixing simple syntax errors like this is part of the very 101 of programming and you really need to get more self-reliant with this. I know it can be frustrating, especially if you're a beginner, but if you're unable/unwilling to fix an error like "syntax error : missing ';' before identifier" by yourself, you are doing something wrong.
    None of the errors you have posted are hard to fix, and even a complete beginner should be able to do so without too much effort. Mind you, fixing errors is where you actually make the biggest learning progress as a programmer. So don't be afraid to play around a little and invest some time in fixing this stuff by yourself. You won't learn a thing if you keep running to the forums right away. If you are hopelessly stuck, you can still ask for advice, just don't give up too easily.

  7. #7
    Join Date
    Dec 2007
    Posts
    198
    Evil monkeys is not an easy project. You have to bust ass to learn from it. Yes, you need a book like Comic is saying. Figure out what TYPE of error you are making. These will happen again and again until you notice them.

  8. #8
    Join Date
    Feb 2011
    Posts
    6
    ok, thanks

  9. #9
    Join Date
    Feb 2011
    Posts
    6
    got 1 more error, c2512: main.cpp , line 6.

    "error C2512: 'Game' : no appropriate default constructor available"

    main.cpp
    Code:
    #include "Game.h"
    
    int main()
    {
    	
    	Game gameHeart;
    	gameHeart.run();
    	
    	return 0;
    
    }
    Game.cpp
    Code:
    #ifndef GAME_H
    #define GAME_H
    #include "drawEngine.h"
    class Game
    {
    public:
    	bool run(void);
    
    protected:
    	bool getInput(char *c);
    
    	void timerUpdate(void);
    private:
    	double frameCount;
    	
    	double startTime;
    	double lastTime;
    	
    	drawEngine drawArea;
    };
    
    #endif
    Game.cpp
    Code:
    #include "Game.h"
    #include <conio.h>
    #include <iostream>
    #include "drawEngine.h"
    #include <windows.h>
    using namespace std;
    //this will give ME 32 fps
    #define GAME_SPEED 3.33
    bool Game::run(void)
    {
    	drawArea.createSprite(0, '$');
    	drawArea.drawSprite(0, 5, 5);
    	
    	char key = ' ';
    
    	startTime = timeGetTime();
    	
    	frameCount = 0;
    	lastTime = 0;
    	
    	
    	
    	while (key != 'q')
    	{
    
    		while(!getInput(&key))
    		{
    			timerUpdate();
    		}
    		cout << "Here's what you pressed: " << key << endl;
    	}
    	
    	cout << frameCount / ((timeGetTime() - startTime) / 100) << " fps " << endl;
    	cout << "Game Over" << endl;
    	
    	return true;
    }
    
    bool Game::getInput(char *c)
    {
    	if (kbhit())
    	{
    		*c = getch();
    		return true;
    	}
    }
    
    void Game::timerUpdate(void)
    {
    	double currentTime = timeGetTime() - lastTime;
    
    	if (currentTime < 2.33333)
    	{
    		return;
    	}
    	frameCount++;
    
    	lastTime = timeGetTime();
    }

  10. #10
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    Quote Originally Posted by Blackelfwolf View Post
    got 1 more error, c2512: main.cpp , line 6.

    "error C2512: 'Game' : no appropriate default constructor available"
    what part of 'no default constructor available' do you not understand?

    sorry if this sound snippy, but really what answer did you expect? try to formulate your questions in a more precise way or all you'll get are vague answers.

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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