Hi all
I am very new to gaming and i am trying to learn gaming
i am using .net 2005 .. Problem is coming here
sprite.h
Code:
#ifndef SPRITE_H
#define SPRITE_H
#include "drawEngine.h"
enum
{
SPRITE_CLASSID,
};
struct vector
{
float x;
float y;
};
class Sprite
{
public:
Sprite(DrawEngine *de, int s_index, float x= , float y=1, int i_lives=1);
~Sprite();
vector getPosition(void);
float getX(void);
float getY(void);
virtual void addLives(int num = 1);
int getLives(void);
bool isAlive(void);
virtual bool move(float x, float y);
protected:
DrawEngine *drawArea;
vector pos;
int spriteIndex;
int numLives;
int classID;
void draw(float x, float y);
void erase(float x, float y);
vector facingDirection;
};
#endif
sprite.cpp
Code:
#include "sprite.h"
Sprite::Sprite(DrawEngine *de, int s_index, float x = 1, float y = 1, int i_lives = 1)
{
drawArea = de;
pos.x = x;
pos.y = y;
spriteIndex = s_index;
numLives = i_lives;
facingDirection.x = 1;
facingDirection.y = 0;
classID = SPRITE_CLASSID;
}
Sprite::~Sprite()
{
erase(pos.x,pos.y);
}
vector Sprite::getPosition(void)
{
return pos;
}
float Sprite::getX(void)
{
return pos.x;
}
float Sprite::getY(void)
{
return pos.y;
}
void Sprite::addLives(int num)
{
numLives += num;
}
int Sprite::getLives(void)
{
return numLives;
}
bool Sprite::isAlive(void)
{
return (numLives > 0);
}
bool Sprite::move(float x, float y)
{
erase(pos.x,pos.y);
pos.x += x;
pos.y += y;
facingDirection.x = x;
facingDirection.y = y;
draw(pos.x,pos.y);
return true;
}
void Sprite::draw(float x, float y)
{
drawArea->drawSprite(spriteIndex,x,y);
}
void Sprite::erase(float x, float y)
{
drawArea->eraseSprite(x,y);
}
error list
Error 1 error C2143: syntax error : missing ')' before '*' d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.h 19
Error 2 error C2143: syntax error : missing ';' before '*' d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.h 19
Error 3 error C2460: 'Sprite:

rawEngine' : uses 'Sprite', which is being defined d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.h 19
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.h 19
Error 5 error C2062: type 'int' unexpected d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.h 19
Error 6 error C2327: 'Sprite:

rawEngine' : is not a type name, static, or enumerator d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.h 29
Error 7 error C2065: 'de' : undeclared identifier d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.cpp 2
Error 8 error C2597: illegal reference to non-static member 'Sprite:

rawEngine' d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.cpp 2
Error 9 error C2062: type 'int' unexpected d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.cpp 2
Error 10 error C2143: syntax error : missing ';' before '{' d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.cpp 3
Error 11 error C2447: '{' : missing function header (old-style formal list?) d:\kurian\dotnet\vc\evlmonkeys\evlmonkeys\sprite.cpp 3
Realy i cant understand whats going on
please any one can help and i am attaching the full source code also..i hope i will get help
http://www.filefactory.com/file/2d3dc9/
Thanks
Kurian