Sign in to follow this  

"Identifier not found" error

This topic is 3617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using QuickCG and SDL... and I can't fathom why I am getting this error, as I'm doing exactly as this tutorial (http://student.kuleuven.be/~m0216922/CG/examples.html) does. Here's my code:
// First, I'm including the headers. SDL is for the graphics, sounds, and keyboard input.
#include "SDL/SDL.h"
#include <cmath>
#include <string>
#include <vector>
#include <iostream>

// QuickCG is a simple interface for SDL that I'm using.
#include "QuickCG/quickcg.h"

// Now, the global variables.
int level = 0;
int highScore = 0;

// And now, the key part: the classes and functions.
// Here's the class for the individual orbs.
class Orb {
	public:
		Orb(bool lit); // Constructor
		void Change(); // Changes from lit to unlit, or vice-versa
		void drawOrb(int x, int y) const; // Draw the actual orb

	private:
		bool m_lit;
};

Orb::Orb(bool lit) {
	m_lit = lit;
}

inline void Orb::Change() {
	m_lit = !m_lit;
}

void Orb::drawOrb(int x, int y) const {
	if (m_lit)
		drawDisk(x, y, 20, RGB_Navy);
	else
		drawCircle(x, y, 20, RGB_Navy);
}

// Here's the class for the example board.
class ExampleBoard {
	public:
		ExampleBoard(const std::vector<Orb>& exBoard); // Constructor
		void displayBoard() const; // Display the board
		bool isDone() const; // Checks to see if the board is complete

	private:
		std::vector<Orb> m_exBoard; // The board itself
};

ExampleBoard::ExampleBoard(const std::vector<Orb>& exBoard) {
	m_exBoard = exBoard;
}

void ExampleBoard::displayBoard() const {
	// Draw the orbs.
	int j = 0;
	for (std::vector<Orb>::const_iterator iter = m_exBoard.begin();
		iter != m_exBoard.end(); ++iter) {
			iter->drawOrb(((j % 5)* 20) + 10, ((j / 5) * 20) + 30);
			++j;
	}
	// Draw the vertical lines.
	for (int i = 0; i < 4; ++i) {
		int properX = ((i % 5) * 20) + 33;
		drawRect(properX, 22, properX + 3, 113, RGB_Black);
	}
	// Draw the horizontal lines.
	for (int i = 0; i < 4; ++i) {
		int properY = ((i / 5) * 20) + 27;
		drawRect(7, properY, 103, properY + 3, RGB_Black);
	}
}

// Let's start the main method!
int main(int argc, char* args[]) {
	screen(640, 384, 0, "Puzzle Trouble!");
    ColorRGB image[640][384];
	loadBMP("pt-menu.bmp", image[0], 640, 384);

	while (!done()) {
    // Draw each pixel of the image.
    for(int x = 0; x < w; x++)
    for(int y = 0; y < h; y++)
    {
        pset(x, y, image[x][y]);  
    }   

    if (keyPressed(SDLK_RIGHT)) end();   
    redraw();
    cls(); // Clear screen
	}
}

The main part is at the bottom. The top is unfinished but it has no effect on main.

Share this post


Link to post
Share on other sites
Whenever posting questions about errors, always post the exact text of the error. Otherwise, we can only guess at what might be wrong.

Also, while posting relevant source code is also important, it would really help if you pointed out the location of the error.

My guess is that drawDisk and drawCircle are the problem. Is it possible that they are in a namespace?

Share this post


Link to post
Share on other sites
The error: c:\documents and settings\administrator\my documents\visual studio 2008\projects\puzzle trouble\puzzle trouble\main.cpp(97) : error C3861: 'keyPressed': identifier not found

Sorry, I thought that I had specified that.

Share this post


Link to post
Share on other sites
Can you show the content of quickcg.h? According to that tutorial, keyPressed should be declared in one of those QuickCG files.

Share this post


Link to post
Share on other sites
Sign in to follow this