Sign in to follow this  

"Identifier not found" error

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 ( 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 {
		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

		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);
		drawCircle(x, y, 20, RGB_Navy);

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

		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);
	// 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();   
    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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this