Zombie day. 10 . . , .
:
- -
-
-
-
. , . . .
, . .
, . , - .
C++
1980- , Bell Labs C . . 1998 C++: ISO/IEC 14882:1998 Standard for the C++ Programming Language; 2003 ISO/IEC 14882:2003.[6]
, C , 1980 .[7] . , , , . BCPL , . Bell Labs ( ). . , C ( BCPL) , . C, UNIX, Bell, , . . , ( - ) ( C). C ( ), , , inline- .
|
|
C ( C++), cfront , C C. , , , .
1983 C C++. , , , , , , , (//). 1985 .
Borland C++ Builder 6
C++ Builder
C++ Builder SDI-, () (). , C++ Builder () (). .
C++ Builder. C++ Builder, . C++ Builder , . C++ Builder , , .
C++ Builder
() (). , . . . , (, , Windows .)
. , , .
C++ Builder : , .
, , . , .
, . , (, ). (Properties). (published) . published-, (public), , . . . .
|
|
, , ( , , , ..).
(Events) , ( , , Windows 95 Windows NT , - ). . C++ Builder , , . , , .
, , , , C++ Builder . , , . {... }. , . , .
, , . , , : ->, :
Edit1->Show();
, *.h , (, ). , , .
, . : , .
:
( , , )
( , )
(- ).
.
, . , .
|
|
(HP), (Arm), , (Speed), W A S D. TPerson, TCreature.
(HP), 2 , (Speed), (Damage), . TMonster, TCreature. . 1. , 15 .
, . TArm.
, . TBullet, TCreature.
. TGrenade, TCreature.
- , , . 4 : , , , . TThing, TCreature.
TTotal .
TMap .
TCreature .
TPerson .
TMonster
TArm .
TBullet .
TGrenade
TThing .
TPerk
TTotal {
void Draw(); .
void DrawInfa(); .
void DrawONForm(); .
void DrawPerson(); .
void DrawBullet(); .
void DrawMonster(); .
void DrawGrenade(); .
void DrawThing();
float DetermineAngular(float XPos, float YPos); .
void ClashBullet(); .
void ClashTheng(); .
void MotionMonster(); .
void MotionBullet(); .
void MotionGrenade(); .
void BOOMGrenade(); .
void AddBullet(int damage, int Speed, float x1, float y1, float angle, bool shot); .
void AddGrenade(int Speed, float angle, float x0, float y0, float x1, float y1); .
void PosCursor(int X,int Y); .
void RotateDC(HANDLE dc,float angle);
void motion();
void AddMonster(int col); .
bool ClashWallX(float X, float Y, int len, float angle, float speed); .
bool ClashWallY(float X, float Y, int len, float angle, float speed); .
void RandThing(float x,float y); .
void IncTime(); .
void the_end(bool finish, int EX);
|
|
}
: Microsoft Windows XP, Vista, 7;
: 20 ;
: 128 ;
, ;
, , .
, , 2 :
1.
2.
2 , .
.
.
, , , .
W A S D. , .
.
G, .
, , .
.
10 . 100
. .
1.1 .
. .
.
10 .
, .
, . ,
, , .
: , .
- .
1. .. ++.2005
2. ., . (STL). 1999
3. http://www.cyberforum.ru
4. Wikipedia.org
5. http://bcb-games.narod.ru/index.htm
lass TTotal
{
private:
int x,y;
bool Is_X_Move, Is_Y_Move;
float angleMonster;
int offset_x, offset_y;
float _XFG, _YFG;
int cube;
public:
Graphics::TBitmap *back;
Graphics::TBitmap *infa;
Graphics::TBitmap *infaElement;
Graphics::TBitmap *cursor;
TMap *map;
TPerson *person;
TArm *arm;
vector<TMonster*> monster;
vector<TBullet*> bullet;
TThing *thing;
TPerk *perk;
TGrenade* Grenade;
float XCursor, YCursor;
bool IsRight, IsLeft, IsUp, IsDown;//
TTotal(int x, int y);
void Draw();
void DrawInfa();
void DrawONForm();
void DrawPerson();
void DrawBullet();
void DrawMonster();
void DrawGrenade();
void DrawThing();
float DetermineAngular(float XPos, float YPos);
void ClashBullet();
void ClashTheng();
void MotionMonster();
void MotionBullet();
void MotionGrenade();
void BOOMGrenade();
void AddBullet(int damage, int Speed, float x1, float y1, float angle, bool shot);
void AddGrenade(int Speed, float angle, float x0, float y0, float x1, float y1);
void PosCursor(int X,int Y);
void RotateDC(HANDLE dc,float angle);
void motion();
void AddMonster(int col);
bool ClashWallX(float X, float Y, int len, float angle, float speed);
bool ClashWallY(float X, float Y, int len, float angle, float speed);
void RandThing(float x,float y);
void IncTime();
void the_end(bool finish, int EX);
};
struct Respaun
{
int _X, _Y;
};
//---------------------------------------------------------------------------
class TMap
{
public:
int MonsteRespaun;
TStringList *file;
vector<Respaun> respaun;
Graphics::TBitmap *Textur;
Graphics::TBitmap *BG;
TMap(int cube);
};
class TCreature
{
public:
|
|
float _Speed;
Graphics:: TBitmap *_Picture;
float _Angle;
float _XPos, _YPos;
float _XCenter, _YCenter;
int len;
TCreature();
TCreature(float Speed, float Angle, float XPos, float YPos,
float XCenter, float YCenter, String str);
};
class TPerson: public TCreature
{
public:
unsigned int _MaxHP;
int _HP;
unsigned int _AP;
unsigned int _EX;
unsigned int Grenade;
float _Damage;
TArm *arm;
TPerk *perk;
TPerson(unsigned int MaxHP, unsigned int AP, float Speed,
float Angle, float XPos, float YPos, float XCenter, float YCenter, String str);
unsigned int HP();
void AddHP(int hp);
void AddGrenade();
void AddSpeed();
void AddSpeedArm();
};
class TMonster: public TCreature
{
public:
unsigned int _MaxHP;
unsigned int _HP;
TArm *arm;
TPerk *perk;
bool IsArm;
unsigned int _Damage;
TMonster();
TMonster(unsigned int MaxHP, unsigned int Damage, int time,
float Speed, float Angle, float XPos, float YPos,
float XCenter, float YCenter, String str);
void Update(unsigned int MaxHP, int time, unsigned int Speed, float Angle, unsigned int Damage,
float XPos, float YPos, String str);
void MotionX();
void MotionY();
void AddArm(bool IsArm);
float DetermineAngular(float XGoal, float YGoal);
};
class TArm
{
public:
unsigned int interpal_recharge;
unsigned int interpal_shot;
unsigned int max_patron;
unsigned int coll_patron;
unsigned int time_patron;
bool shot();
void InterpalShot();
TArm(int interpal_recharge);
TArm(int patron, int interpal_recharge, int interpal_shot);
void Update(int interpal_recharge);
void IncArm();
};
class TBullet: public TCreature
{
public:
bool _Include;
unsigned int _Damage;
TBullet();
TBullet(unsigned int Speed, float Angle, unsigned int Damage, float XPos, float YPos,
float XCenter, float YCenter, String str, bool existence);
void Update(unsigned int Speed, float Angle, unsigned int Damage,
float XPos, float YPos, bool existence);
void Motion(TStringList *file, int cube, float speed);
};
class TGrenade: public TCreature
{
public:
float _XF, _YF;
int include;
void Update(unsigned int Speed, float Angle, float XPos, float YPos, float _XF, float _YF);
void Motion();
};
struct Thing
{
Graphics::TBitmap *picha;
float _XPos, _YPos;
int time;
};
class TThing
{
public:
vector<Thing*> HP;
vector<Thing*> Grenade;
vector<Thing*> Speed;
vector<Thing*> SpeedArm;
TThing();
void AddHP(int x, int y);
void AddGrenade(int x, int y);
void AddSpeed(int x, int y);
void AddSpeedArm(int x, int y);
};
class TPerk
{
public:
float HP;
float Speed;
float Damag;
float time_patron;
float Bullet_Speed;
TPerk();
void Increase();
void Add(TPerk* perk);
};
TTotal *total;
bool shoot = false;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Screen->Cursors[1] = LoadCursorFromFile("date\\cursor.cur");
Form1->Cursor = TCursor(1);
total = new TTotal(Form1->ClientWidth, Form1->ClientHeight);
Timer1->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
total->IncTime();
total->Draw();
total->person->arm->InterpalShot();
if (shoot == true)
total->AddBullet(total->person->_Damage*total->person->perk->Damag, 10,total->person->_XPos, total->person->_YPos, total->person->_Angle, total->person->arm->shot());
if ((total->person->HP() <= 0))
{
Button2->Visible = true;
Button3->Visible = true;
Timer1->Enabled = false;
total->the_end(false, total->person->_EX);
}
if ((total->person->_EX >= 10000))
{
Button2->Visible = true;
Button3->Visible = true;
Timer1->Enabled = false;
total->the_end(true, total->person->_EX);
}
if (total->person->HP() > total->person->_MaxHP)
total->person->_HP = total->person->_MaxHP;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
total->PosCursor(X,Y);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key==87) { total->IsUp=True; total->IsDown=False; }
if (Key==83) { total->IsDown=True; total->IsUp=False; }
if (Key==68) { total->IsRight=True; total->IsLeft=False; }
if (Key==65) { total->IsLeft=True; total->IsRight=False;}
if (Key==71)
{ total->AddGrenade(10, total->person->_Angle, total->person->_XPos, total->person->_YPos, total->XCursor, total->YCursor);}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == 87) total->IsUp=False;
if (Key == 83) total->IsDown=False;
if (Key == 68) total->IsRight=False;
if (Key == 65) total->IsLeft=False;
if (Key == 27)
{
if (Timer1->Enabled == true)
{
//Form1->Canvas->Draw(0,0,new Graphics::TBitmap());
Button1->Visible = true;
Button2->Visible = true;
Button3->Visible = true;
Timer1->Enabled = false;
}
else
{
Button1->Visible = false;
Button2->Visible = false;
Button3->Visible = false;
Timer1->Enabled = true;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer2Timer(TObject *Sender)
{
Button1->Visible = false;
Button2->Visible = true;
Button3->Visible = true;
Button1->Left = Form1->ClientWidth/2 - Button1->Width/2;
Button1->Top = Form1->ClientHeight/2 - Button1->Height*3/2;
Button2->Left = Form1->ClientWidth/2 - Button2->Width/2;
Button2->Top = Form1->ClientHeight/2 - Button2->Height/2;
Button3->Left = Form1->ClientWidth/2 - Button3->Width/2;
Button3->Top = Form1->ClientHeight/2 + Button3->Height/2;
Timer2->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
shoot=False;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
shoot=true;
}
void TTotal:: DrawPerson()
{
RotateDC(back->Canvas->Handle,person->_Angle);
SetViewportOrgEx(back->Canvas->Handle, person->_XPos, person->_YPos, NULL);//
back->Canvas->Draw(person->_XCenter, person->_YCenter, person->_Picture);
SetViewportOrgEx(back->Canvas->Handle, 0, 0, NULL);//
RotateDC(back->Canvas->Handle, 0);
}
void TTotal:: RotateDC(HANDLE dc,float angle)
{
XFORM xform;
angle = angle *M_PI/ 180.0;
xform.eDx = 0.0f;
xform.eDy = 0.0f;
xform.eM11 = cos(angle);
xform.eM12 = sin(angle);
xform.eM21 = -sin(angle);
xform.eM22 = cos(angle);
SetGraphicsMode(dc, GM_ADVANCED);
SetWorldTransform(dc, &xform);
}
void TTotal:: motion()
{
if((IsLeft == True)&&(IsUp == True))
{
if (ClashWallX(person->_XPos, person->_YPos, person->len, -135, person->_Speed))
person->_XPos -= cos(45*M_PI/180.0)*person->_Speed;
if (ClashWallY(person->_XPos, person->_YPos, person->len, -135, person->_Speed))
person->_YPos -= sin(45*M_PI/180.0)*person->_Speed;
return;
}
if((IsRight == True)&&(IsUp == True))
{
if (ClashWallX(person->_XPos, person->_YPos, person->len, -45, person->_Speed))
person->_XPos += cos(45*M_PI/180.0)*person->_Speed;
if (ClashWallY(person->_XPos, person->_YPos, person->len, -45, person->_Speed))
person->_YPos -= sin(45*M_PI/180.0)*person->_Speed;
return;
}
if((IsLeft == True)&&(IsDown == True))
{
if (ClashWallX(person->_XPos, person->_YPos, person->len, 135, person->_Speed))
person->_XPos -= cos(45*M_PI/180.0)*person->_Speed;
if (ClashWallY(person->_XPos, person->_YPos, person->len, 135, person->_Speed))
person->_YPos += sin(45*M_PI/180.0)*person->_Speed;
return;
}
if((IsRight == True)&&(IsDown == True))
{
if (ClashWallX(person->_XPos, person->_YPos, person->len, 45, person->_Speed))
person->_XPos += cos(45*M_PI/180.0)*person->_Speed;
if (ClashWallY(person->_XPos, person->_YPos, person->len, 45, person->_Speed))
person->_YPos += sin(45*M_PI/180.0)*person->_Speed;
return;
}
if(IsUp == True)
if (ClashWallY(person->_XPos, person->_YPos, person->len, -90, person->_Speed))
{
person->_YPos -= person->_Speed;
return;
}
if(IsLeft == True)
if (ClashWallX(person->_XPos, person->_YPos, person->len, 180, person->_Speed))
{
person->_XPos -= person->_Speed;
return;
}
if(IsDown == True)
if (ClashWallY(person->_XPos, person->_YPos, person->len, 90, person->_Speed))
{
person->_YPos += person->_Speed;
return;
}
if(IsRight == True)
if (ClashWallX(person->_XPos, person->_YPos, person->len, 0, person->_Speed))
{
person->_XPos += person->_Speed;
return;
}
}
bool TTotal:: ClashWallY(float X, float Y, int len, float angle, float speed)
{
if(map->file->Strings[(int)(Y / cube)][(int)(X / cube)+1] == '1')
return false; //
if (angle >0)
{
if((hypot(cube - fmod(Y, cube),cube - fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)+1][(int)(X / cube)+2] == '1'))
return false; //
if((hypot(cube - fmod(Y, cube),fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)+1][(int)(X / cube)] == '1'))
return false; //
if((fmod(Y, cube)> cube - (len + speed))
&&(map->file->Strings[(int)(Y / cube)+1][(int)(X / cube)+1] == '1'))
return false; //
}
if (angle <0)
{
if((hypot(fmod(Y, cube),cube - fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)-1][(int)(X / cube)+2] == '1'))
return false; //
if((hypot(fmod(Y, cube),fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)-1][(int)(X / cube)] == '1'))
return false; //
if((fmod(Y, cube)< len + speed)
&&(map->file->Strings[(int)(Y / cube)-1][(int)(X / cube)+1] == '1'))
return false; //
}
if ((angle == 0)||(angle == 180))
{
if((hypot(cube - fmod(Y, cube),cube - fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)+1][(int)(X / cube)+2] == '1'))
return false; //
if((hypot(cube - fmod(Y, cube),fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)+1][(int)(X / cube)] == '1'))
return false; //
if((fmod(Y, cube)> cube - (len + speed))
&&(map->file->Strings[(int)(Y / cube)+1][(int)(X / cube)+1] == '1'))
return false; //
if((hypot(fmod(Y, cube),cube - fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)-1][(int)(X / cube)+2] == '1'))
return false; //
if((hypot(fmod(Y, cube),fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)-1][(int)(X / cube)] == '1'))
return false; //
if((fmod(Y, cube)< len + speed)
&&(map->file->Strings[(int)(Y / cube)-1][(int)(X / cube)+1] == '1'))
return false; //
}
return true;
}
bool TTotal:: ClashWallX(float X, float Y, int len, float angle, float speed)
{
if(map->file->Strings[(int)(Y / cube)][(int)(X / cube)+1] == '1')
return false; //
if (abs(angle)>90)
{
if((hypot(cube - fmod(Y, cube),fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)+1][(int)(X / cube)] == '1'))
return false; //
if((hypot(fmod(Y, cube),fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)-1][(int)(X / cube)] == '1'))
return false; //
if((fmod(X, cube)< len + speed)
&&(map->file->Strings[(int)(Y / cube)][(int)(X / cube)] == '1'))
return false; //
}
if (abs(angle)<90)
{
if((hypot(fmod(Y, cube),cube - fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)-1][(int)(X / cube)+2] == '1'))
return false; //
if((hypot(cube - fmod(Y, cube),cube - fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)+1][(int)(X / cube)+2] == '1'))
return false; //
if((fmod(X, cube)> cube - (len + speed))
&&(map->file->Strings[(int)(Y / cube)][(int)(X / cube)+2] == '1'))
return false; //
}
if((angle == -90)||(angle == 90))
{
if((hypot(fmod(Y, cube),cube - fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)-1][(int)(X / cube)+2] == '1'))
return false; //
if((hypot(cube - fmod(Y, cube),cube - fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)+1][(int)(X / cube)+2] == '1'))
return false; //
if((hypot(cube - fmod(Y, cube),fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)+1][(int)(X / cube)] == '1'))
return false; //
if((hypot(fmod(Y, cube),fmod(X, cube))< len)
&&(map->file->Strings[(int)(Y / cube)-1][(int)(X / cube)] == '1'))
return false; //
if((fmod(X, cube)> cube - (len + speed))
&&(map->file->Strings[(int)(Y / cube)][(int)(X / cube)+2] == '1'))
return false; //
if((fmod(X, cube)< len + speed)
&&(map->file->Strings[(int)(Y / cube)][(int)(X / cube)] == '1'))
return false; //
}
return true;
}