主题:练习C++编的一个小程序
强强 [专家分:4740] 发布于 2010-03-08 00:00:00
空格开始,场景是鱼缸里,代码再检查一下再帖吧
最后更新于:2010-03-08 00:02:00
回复列表 (共18个回复)
11 楼
强强 [专家分:4740] 发布于 2010-03-08 14:55:00
Class_InterFace.hpp:
class InterFace
{
private:
//
protected:
//
public:
bool ShouldExist;
InterFace(){};
virtual ~InterFace(){};
virtual void CallEveryTime()=0;
};
12 楼
强强 [专家分:4740] 发布于 2010-03-08 14:55:00
Class_GetResource.hpp:
class GetResource
{
private:
//
protected:
//
public:
GetResource(){};
virtual ~GetResource();
void GetTextures();
};
//
inline void GetResource::GetTextures()
{
FILE *fp;
int i=0,FileLenth;
while((fp=fopen(TextureFileName[i],"rb"))!=NULL)
{
fseek(fp,0,SEEK_END);
FileLenth=ftell(fp);
p_TextureBuffer[i]=new char[FileLenth];
fseek(fp,0,SEEK_SET);
if(fread(p_TextureBuffer[i],FileLenth,1,fp)!=1)
{
MessageBox(NULL,"File Read Error",TextureFileName[i],MB_OK);
}
fclose(fp);
i+=1;
}
return;
}
inline GetResource::~GetResource()
{
for(int i=0;i<MAX_TYPE;i++)
{
if(p_TextureBuffer[i]!=NULL)
{
delete []p_TextureBuffer[i];
p_TextureBuffer[i]=NULL;
}
}
return;
}
13 楼
强强 [专家分:4740] 发布于 2010-03-08 14:56:00
Class_Enviroment.hpp:
class Enviroment:public Draw
{
private:
//
protected:
//
public:
Enviroment(int);
virtual ~Enviroment(){};
void CallEveryTime();
};
inline Enviroment::Enviroment(int i_Texture)
{
x=0;
y=0;
z=-1000;
Width=100000;
Height=75000;
BindTexture(p_TextureBuffer[i_Texture]);
return;
}
//
inline void Enviroment::CallEveryTime()
{
DrawToScreen();
return;
}
14 楼
强强 [专家分:4740] 发布于 2010-03-08 14:56:00
Class_Buble.hpp:
class Buble:public Draw
{
private:
//
protected:
//
public:
Buble(int);
virtual ~Buble();
void CallEveryTime();
};
//
inline Buble::Buble(int iTexture)
{
x=(rand()-16384)*2.5;
y=-40000;
z=-50;
Width=2000+rand()%3000;
Height=Width;
BindTexture(p_TextureBuffer[iTexture]);
return;
}
//
inline Buble::~Buble()
{
return;
}
//
inline void Buble::CallEveryTime()
{
y+=300;
if(y>35000)
{
ShouldExist=false;
}
DrawToScreen();
return;
}
15 楼
强强 [专家分:4740] 发布于 2010-03-08 15:01:00
可能有点长,恳请各位高手不吝赐教,再帮我挑挑错
16 楼
suzhoutaicang18 [专家分:360] 发布于 2010-03-08 17:23:00
对于强强哥的 无限钻研的精神感到钦佩
同时 对于 我在学校做一些不得不装B 的行为感到惋惜
学习
17 楼
强强 [专家分:4740] 发布于 2010-03-08 21:25:00
上次看了CXXCOMP改过的程序后我受益很多,恳请大家再帮我找一找不规范的和错的地方,请大家务必帮忙.大概点一下就行,拜谢.
18 楼
cxxcomp [专家分:2370] 发布于 2010-03-08 21:31:00
这两天比较累,一直没有状态。代码我已保存,过后一定细细研读。先 顶!
我来回复