- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
//Unit1.h
const float RADIAN=0.01744444444;
TForm1 *Form1;
Graphics::TBitmap*ZadniyBuffer;
float ShipPosX,ShipPosY;
float ShipAngle;
float ShipSpeed;
bool LEFT,RIGHT,UP;
TList*Bullets;
TList*Asteroids;
class Bullet
{
public:
float x,y,dx,dy;
void CreateBullet()
{
x=ShipPosX;y=ShipPosY;
dx=10*cos(RADIAN*ShipAngle);
dy=10*sin(RADIAN*ShipAngle);
}
void Draw()
{
ZadniyBuffer->Canvas->Pen->Color=clRed;
ZadniyBuffer->Canvas->MoveTo(x,y);
ZadniyBuffer->Canvas->LineTo(x+dx,y+dy);
}
};
class CRock
{
public:
float x,y;
int Figure[50];
float Angle;
float Spin;
float XSpeed,YSpeed;
int Tip;
void CreateAsteroid(int t)
{
Tip=t;
XSpeed=random(4)+(random(9)/10.0)-2;
YSpeed=random(4)+(random(9)/10.0)-2;
Spin=random(10)-5;
for(int i=0;i<20;i++)
{
if(Tip==1)Figure[i]=random(10)+25;
if(Tip==2)Figure[i]=random(10)+10;
if(Tip==3)Figure[i]=random(5)+5;
}
}
void Move()
{
x+=XSpeed;y+=YSpeed;
Angle+=Spin;
if(x>440)x=-40;if(x<-40)x=440;
if(y>440)y=-40;if(y<-40)y=440;
}
void Draw()
{
ZadniyBuffer->Canvas->Pen->Color=clRed;
float tAng=0;
int tx=cos(RADIAN*(Angle+tAng))*Figure[0]+x;
int ty=sin(RADIAN*(Angle+tAng))*Figure[0]+y;
ZadniyBuffer->Canvas->MoveTo(tx,ty);
for(int i=0;i<20;i++,tAng+=19)
{
int tx=cos(RADIAN*(Angle+tAng))*Figure[i]+x;
int ty=sin(RADIAN*(Angle+tAng))*Figure[i]+y;
ZadniyBuffer->Canvas->LineTo(tx,ty);
}
}
};
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
randomize();
ZadniyBuffer=new Graphics::TBitmap();
ZadniyBuffer->Width =400;
ZadniyBuffer->Height=400;
ZadniyBuffer->Canvas->Pen->Color=clWhite;
Bullets =new TList();
Asteroids=new TList();
LEFT=false;RIGHT=false;
ShipPosX=200;ShipPosY=200;
ShipAngle=0;
ShipSpeed=0;
for(int i=0;i<4;i++)
{
CRock*a=new CRock();
a->x=random(400);
a->y=40;
a->CreateAsteroid(1);
Asteroids->Add((void*)a);
}
}
//---------------------------------------------------------------------------
void TForm1::CLS()
{
ZadniyBuffer->Canvas->Brush->Color=clBlack;
ZadniyBuffer->Canvas->FillRect(Rect(0,0,400,400));
Привет. Вот, украл, вернее, скачал с розришения автора код для курсача. На учебу билдера тупо времени нет, ибо есть много хвостов. Можете ли вы мне обьяснить весь код? Буду благодарен.