I'm trying to write some classes for my game, but I keep running into some stupid errors.
Here is my Board.h file:
#ifndef BOARD_H
#define BOARD_H
#define PIECE_WIDTH 65
#define PIECE_HEIGHT 67
#define BOARDSIZE 8
#include <SFML/Graphics.hpp>
#include <list>
enum BoardState { INTERACTIVE, FALLING_JEWELS, SWAPPING_JEWELS };
class Board
{
public:
Board();
Board(sf::Randomizer rand);
~Board();
int TileSize() { return tileSize; }
int CurrentlyMovingPieces;
sf::Vector2f TopLeft;
protected:
int tileSize;
BoardState boardState;
bool isActive;
bool canSwap;
sf::Sprite pieceSet;
sf::Sprite pieceHighlight;
sf::Sprite selectionSprite;
sf::Sprite bonusBarSprite;
//Piece pieceMap[BOARDSIZE][BOARDSIZE];
int mouseTileX, mouseTileY;
//Piece highlighedPiece;
float hilightAlpha;
int currenltyMOvingJewels;
float delayDrop;
float swapAlpha;
//SwapInfo swappingInfo;
bool validateSwap;
bool needToDropJewels;
sf::Randomizer rand;
//std::list<Piece> pieceRemains;
//std::list<Piece> hintPieces;
float hintTimer;
float hintDelay;
int baseScore;
int bonusLevel;
int removedPieces;
float removedPieceCounter;
int nextLevelLimit;
int totalRemovedPieces;
bool aboutToChangeLevel;
int longestChain;
float bonusFlashAlpha;
float timeLeft;
float maxTimeLeft;
float timePerJewel;
float timeReductionSpeed;
float timeLeftCounter;
float noMovesAlpha;
bool populatingPieces;
bool populatePieceCounterX;
bool populatePieceCounterY;
int populatePieceCursorDir;
float delayPerPiece;
};
#endif
and here is my Piece.h file:
#ifndef PIECE_H
#define PIECE_H
#include <SFML/Graphics.hpp>
#include "Board.h"
enum Direction { NONE, UP, DOWN, LEFT, RIGHT };
enum Type { YELLOW = 0, BLUE, CYAN, GREEN };
class Piece
{
public:
Piece();
Piece(Board parent);
Piece(Board parent, int x, int y, Type type);
void StartMoving(Direction dir, int howManySlots);
void StartMoving(Direction dir);
void Die();
void Update(float elapsedTime);
void Draw(sf::RenderWindow &App, sf::Color color, sf::Sprite sprite);
private:
sf::Vector2f position;
Type pieceType;
Board parentBoard;
bool moving;
int movedSlots;
bool reportedMove;
Direction movingDir;
float movingCounter;
sf::Vector2f targetPosition;
sf::Vector2f startPosition;
sf::Vector2f moveDirVector;
float movingAccel;
bool isDying;
float deathCounter;
bool readyToGo;
};
#endif
If I uncomment the Piece highlightedPiece in the Board.h file, or add the line:
#include "Piece.h"
to my Board.H file, I get a ton of compiler errors, I don't know how to fix.
Can anyone help me?
Here is the compiler log when I added
#include "Piece.h"
and uncommented the Piece highlitedPiece line in my Board.h file:
1>------ Build started: Project: TreasureHunt, Configuration: Debug Win32 ------
1>Compiling...
1>Board.cpp
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(14) : error C2061: syntax error : identifier 'Board'
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(14) : error C2535: 'Piece::Piece(void)' : member function already defined or declared
1> c:\dev\treasurehunt\treasurehunt\src\piece.h(13) : see declaration of 'Piece::Piece'
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(15) : error C2061: syntax error : identifier 'Board'
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(15) : error C2535: 'Piece::Piece(void)' : member function already defined or declared
1> c:\dev\treasurehunt\treasurehunt\src\piece.h(13) : see declaration of 'Piece::Piece'
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(27) : error C2146: syntax error : missing ';' before identifier 'parentBoard'
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\dev\treasurehunt\treasurehunt\src\board.cpp(10) : warning C4482: nonstandard extension used: enum 'BoardState' used in qualified name
1>Main.cpp
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(14) : error C2061: syntax error : identifier 'Board'
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(14) : error C2535: 'Piece::Piece(void)' : member function already defined or declared
1> c:\dev\treasurehunt\treasurehunt\src\piece.h(13) : see declaration of 'Piece::Piece'
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(15) : error C2061: syntax error : identifier 'Board'
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(15) : error C2535: 'Piece::Piece(void)' : member function already defined or declared
1> c:\dev\treasurehunt\treasurehunt\src\piece.h(13) : see declaration of 'Piece::Piece'
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(27) : error C2146: syntax error : missing ';' before identifier 'parentBoard'
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\dev\treasurehunt\treasurehunt\src\piece.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>Piece.cpp
1>c:\dev\treasurehunt\treasurehunt\src\board.h(39) : error C2146: syntax error : missing ';' before identifier 'highlighedPiece'
1>c:\dev\treasurehunt\treasurehunt\src\board.h(39) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\dev\treasurehunt\treasurehunt\src\board.h(39) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\dev\treasurehunt\treasurehunt\src\piece.cpp(27) : warning C4482: nonstandard extension used: enum 'Direction' used in qualified name
1>c:\dev\treasurehunt\treasurehunt\src\piece.cpp(37) : warning C4482: nonstandard extension used: enum 'Direction' used in qualified name
1>c:\dev\treasurehunt\treasurehunt\src\piece.cpp(40) : warning C4482: nonstandard extension used: enum 'Direction' used in qualified name
1>c:\dev\treasurehunt\treasurehunt\src\piece.cpp(43) : warning C4482: nonstandard extension used: enum 'Direction' used in qualified name
1>c:\dev\treasurehunt\treasurehunt\src\piece.cpp(46) : warning C4482: nonstandard extension used: enum 'Direction' used in qualified name
1>Generating Code...
1>Build log was saved at "file://c:\Dev\TreasureHunt\TreasureHunt\Obj\Debug\BuildLog.htm"
1>TreasureHunt - 17 error(s), 6 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If anyone could help me that would be great!
Thanks