I don't understand this.
I can't find any fault.
The compiling errors:
Compiling...
Entities.cpp
i:\projects\programming\klingis\1 body part\klingis\game\classes\view.h(9) : error C2629: unexpected 'class View ('
i:\projects\programming\klingis\1 body part\klingis\game\classes\view.h(9) : error C2238: unexpected token(s) preceding ';'
i:\projects\programming\klingis\1 body part\klingis\game\classes\view.h(11) : error C2061: syntax error : identifier 'Entity'
i:\projects\programming\klingis\1 body part\klingis\game\classes\view.h(15) : error C2143: syntax error : missing ';' before '*'
i:\projects\programming\klingis\1 body part\klingis\game\classes\view.h(15) : error C2501: 'Position' : missing storage-class or type specifiers
i:\projects\programming\klingis\1 body part\klingis\game\classes\view.h(15) : error C2501: 'pTarget' : missing storage-class or type specifiers
i:\projects\programming\klingis\1 body part\klingis\game\classes\view.h(25) : error C2065: 'Entity' : undeclared identifier
i:\projects\programming\klingis\1 body part\klingis\game\classes\view.h(25) : error C2065: 'pEnt' : undeclared identifier
i:\projects\programming\klingis\1 body part\klingis\game\classes\view.h(25) : error C2182: 'InitView' : illegal use of type 'void'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.h(117) : error C2143: syntax error : missing ';' before '*'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.h(117) : error C2501: 'Entity' : missing storage-class or type specifiers
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.h(117) : error C2501: 'AddEntity' : missing storage-class or type specifiers
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(53) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'Sequence' (or there is no acceptable conversion)
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(54) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'Frame' (or there is no acceptable conversion)
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(84) : warning C4244: '=' : conversion from 'double' to 'short', possible loss of data
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(85) : warning C4244: '=' : conversion from 'double' to 'short', possible loss of data
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(108) : error C2059: syntax error : '>'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(114) : error C2143: syntax error : missing ';' before '{'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(118) : error C2143: syntax error : missing ';' before '}'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(122) : error C2143: syntax error : missing ';' before '{'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(123) : error C2653: 'EntityVector' : is not a class or namespace name
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(124) : error C2653: 'EntityVector' : is not a class or namespace name
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(127) : error C2143: syntax error : missing ';' before '{'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(130) : error C2143: syntax error : missing ';' before '}'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(131) : error C2143: syntax error : missing ';' before '}'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(136) : error C2143: syntax error : missing ';' before '{'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(137) : error C2653: 'EntityVector' : is not a class or namespace name
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(138) : error C2653: 'EntityVector' : is not a class or namespace name
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(141) : error C2143: syntax error : missing ';' before '{'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(144) : error C2143: syntax error : missing ';' before '}'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(145) : error C2143: syntax error : missing ';' before '}'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(319) : error C2143: syntax error : missing ';' before '}'
i:\projects\programming\klingis\1 body part\klingis\game\classes\entities.cpp(319) : fatal error C1001: INTERNAL COMPILER ERROR
Entities.cpp
#include "Entities.h"
#include <Math.h>
///////////////////////////////////////////////////////////////
#define HALF_DIR_ANGLE PI
#define FULL_DIR_ANGLE (HALF_DIR_ANGLE * 2)
#define QUARTER_DIR_ANGLE (HALF_DIR_ANGLE / 2)
#define EIGHT_DIR_ANGLE (QUARTER_DIR_ANGLE / 2)
double dirAngle[NUM_DIRECTIONS] =
{
0.0, // _direction_up
FULL_DIR_ANGLE - EIGHT_DIR_ANGLE, // _direction_up_left
FULL_DIR_ANGLE - QUARTER_DIR_ANGLE, // _direction_left
HALF_DIR_ANGLE + EIGHT_DIR_ANGLE, // _direction_left_down
HALF_DIR_ANGLE, // _direction_down
HALF_DIR_ANGLE - EIGHT_DIR_ANGLE, // _direction_down_right
QUARTER_DIR_ANGLE, // _direction_right
EIGHT_DIR_ANGLE // _direction_right_up
};
///////////////////////////////////////////////////////////////
Entity::Entity(EntityDef *pDef, Uint32 x, Uint32 y, Uint8 dir)
{
pEntDef = pDef;
pos.x = x;
pos.y = y;
direction = dir;
}
/*
Entity::Entity(SDL_RWops *dataSrc)
{
LoadData(dataSrc);
}
*/
void Entity::Update(void)
{
if (animation == _animation_back && curFrame == 0)
{
animation = _animation_idle;
}
if (curSequence != preSequence) curFrame = 0;
pSequence = pEntDef->pSequences[curSequence];
pFrame = pSequence->pFrames[curFrame];
switch (animation)
{
case _animation_loop:
if (++curFrame >= pSequence->nFrames) curFrame = 0;
break;
case _animation_forth:
if (curFrame < pSequence->nFrames - 1) curFrame++;
break;
case _animation_back:
if (curFrame > 0) curFrame--;
break;
default:
break;
}
pos.x += xmove;
pos.y += ymove;
xmove = 0;
ymove = 0;
}
void Entity::Move(short step)
{
double angle = dirAngle[direction];
xmove = sin(angle) * step;
ymove = cos(angle) * step;
}
void Entity::Draw(short x, short y)
{
Bitmap *bmp = pFrame->one ?
pFrame->dirs : pFrame->dirs + direction;
DrawBitmap(bmp->pBitmaps,bmp->index,x-bmp->xOrigin,y-bmp->yOrigin);
}
///////////////////////////////////////////////////////////////
void DrawBitmap(Bitmaps *bmps, Uint8 index, short x, short y)
{
DrawScreen(bmps->pSurface,bmps->pClips + index,x,y);
}
///////////////////////////////////////////////////////////////
#include <Vector>
typedef std::vector<Entity *> EntityVector;
EntityVector entities;
Entity *AddEntity(EntityDef *pDef, Uint32 x, Uint32 y, Uint8 dir)
{
Entity *pEnt = new Entity(EntityDef *pDef, Uint32 x, Uint32 y, Uint8 dir);
entities.push_back(pEnt);
return pEnt;
}
void UpdateEntities(void)
{
EntityVector::iterator cur = entities.begin();
EntityVector::iterator end = entities.end();
while (cur++ < end)
{
Entity *pEntity = *cur;
pEntity->Update();
}
}
void DrawEntities(View *pView)
{
EntityVector::iterator cur = entities.begin();
EntityVector::iterator end = entities.end();
while (cur++ < end)
{
Entity *pEntity = *cur;
pView->DrawEntity(pEntity);
}
}
View.h
#ifndef _View_h
#define _View_h
#include "Screen.h"
#include "Entities.h"
class View {
View(SDL_Rect *pFrm, Entity *pEnt); // line: 9
void Translate(void);
void DrawEntity(Entity *pEnt);
void Update(void);
SDL_Rect *pFrame;
Position *pTarget;
Sint32 topEdgePos;
Sint32 leftEdgePos;
Uint32 rightEdgePos;
Uint32 bottomEdgePos;
Uint16 centerOffsetX;
Uint16 centerOffsetY;
};
void InitView(Entity *pEnt);
void UpdateView(void);
#endif
Entities.h
#ifndef _Entities_h
#define _Entities_h
#include "Screen.h"
#include "View.h"
enum {
_direction_up,
_direction_up_left,
_direction_left,
_direction_left_down,
_direction_down,
_direction_down_right,
_direction_right,
_direction_right_up,
NUM_DIRECTIONS
};
enum {
_animation_idle,
_animation_loop,
_animation_forth,
_animation_back,
NUM_ANIMATIONS
};
typedef struct {
SDL_Surface *pSurface;
Uint8 nBitmaps;
Uint8 xUnit;
Uint8 yUnit;
SDL_Rect *pClips;
// BitMask *pBitMasks;
} Bitmaps;
void DrawBitmap(Bitmaps *bmps, Uint8 index, short x, short y);
typedef struct {
Bitmaps *pBitmaps;
Uint8 index;
Uint8 xOrigin;
Uint8 yOrigin;
} Bitmap;
typedef struct {
bool one;
Bitmap *dirs; //[NUM_DIRECTIONS];
} Frame;
typedef struct {
Frame *pFrames;
Uint8 nFrames;
} Sequence;
struct EntityDefinition {
Bitmaps *pBitmaps;
Uint8 nBitmaps;
Sequence *pSequences;
Uint8 nSequences;
};
typedef struct EntityDefinition EntityDef;
/*
enum {
_anim_dir_forwards,
_anim_dir_backwards
};
enum {
_animation_idle,
_animation_loop,
_animation_once
};
*/
typedef struct {
Uint32 x;
Uint32 y;
} Position;
class Entity {
bool remove;
EntityDef *pEntDef;
Sequence *pSequence;
Frame *pFrame;
Uint8 curFrame;
Uint8 preSequence;
Uint8 curSequence;
Uint8 direction;
Uint8 animation;
// Uint8 animdir;
Position pos;
short xmove;
short ymove;
Entity(EntityDef *pDef, Uint32 x, Uint32 y, Uint8 dir);
// Entity(SDL_RWops *dataSrc);
// bool LoadData(SDL_RWops *dataSrc);
// bool SaveData(SDL_RWops *dataDst);
Position *GetTarget(void);
void Draw(short x, short y);
void Move(short step);
void Update(void);
};
Entity *AddEntity(EntityDef *pEntDef, Uint32 x, Uint32 y, Uint8 dir);
void UpdateEntities(void);
void DrawEntities(View *pView);
#endif
I tried to find the fault myself, but I can't find any fault.
Please help.