Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
//--------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <Math.hpp>
#include <math.h>
#include "Ball.h"
#include <stdlib.h>
//--------------------------------------------------
#pragma package(smart_init)
CBall::CBall(TImage* _Img)
{ x=20;
y=150;
Img=_Img;
}
void CBall::Hide()
{ //стираем старое положение
Img->Canvas->Pen->Color = clWhite;
Img->Canvas->Brush->Color = clWhite;
Img->Canvas->Ellipse(x-10, y-10, x+10, y+10);
}
void CBall::Hide12(int f,int g)
{ //стираем старое положение
Img->Canvas->Pen->Color = clWhite;
Img->Canvas->Brush->Color = clWhite;
Img->Canvas->Ellipse(f-10, g-10, f+10, g+10);
}
void CBall::MoveDeltaXY(int dx, int dy)
{ x+=dx; y+=dy;
//рисуем в новом положении
Img->Canvas->Pen->Color = clGreen;
Img->Canvas->Brush->Color = clGreen;
Img->Canvas->Ellipse(x-10, y-10, x+10, y+10);
Img->Canvas->Pen->Color = clWhite;
Img->Canvas->Brush->Color = clWhite;
Img->Canvas->Ellipse(x-2-3, y-2-3, x+2-3, y+2-3);
}
void CBall::Move12(int u, int i)
{ //рисуем в новом положении
Img->Canvas->Pen->Color = clGreen;
Img->Canvas->Brush->Color = clGreen;
Img->Canvas->Ellipse(u-10, i-10, u+10, i+10);
Img->Canvas->Pen->Color = clWhite;
Img->Canvas->Brush->Color = clWhite;
Img->Canvas->Ellipse(u-2-3, i-2-3, u+2-3, i+2-3);
}
void CBall::MoveToY(int Y)
{ y=Y;
MoveDeltaXY(0,0);
}
void CBall::MoveToX(int X)
{ x=X;
MoveDeltaXY(0,0);
}
CSupport::CSupport(TImage* _Img)
{ Img=_Img;
xc=19;
yc=147;
x1=x2=xc;
y1=y2=yc;
len2= 166;
angle=3;
Rotate(0,0);
}
void CSupport::Hide()
{ Img->Canvas->Pen->Width=3;
Img->Canvas->Pen->Color = clWhite;
Img->Canvas->Arc(19+98*cos(DegToRad(p)+ArcTan2(37,91))-100,147-98*sin(DegToRad(p)+ArcTan2(37,91))-100,19+98*cos(DegToRad(p)+ArcTan2(37,91))+100,147-98*sin(DegToRad(p)+ArcTan2(37,91))+100,19,147,19+166*cos(DegToRad(p+270)+ArcTan2(162,34)),147-166*sin(DegToRad(p+270)+ArcTan2(162,34)));
Img->Canvas->Pen->Width=3;
Img->Canvas->Pen->Color = clWhite;
Img->Canvas->MoveTo(x1,y1);
Img->Canvas->LineTo(x2,y2);
Img->Canvas->Pen->Width=1;
}
void CSupport::Rotate(double dA,int t)
{ p=p+t;
Img->Canvas->Pen->Width=3;
Img->Canvas->Pen->Color=clBlack;
Img->Canvas->Arc(19+98*cos(DegToRad(p)+ArcTan2(37,91))-100,147-98*sin(DegToRad(p)+ArcTan2(37,91))-100,19+98*cos(DegToRad(p)+ArcTan2(37,91))+100,147-98*sin(DegToRad(p)+ArcTan2(37,91))+100,19,147,19+201*cos(DegToRad(p+270)+ArcTan2(191,63)),147-201*sin(DegToRad(p+270)+ArcTan2(191,63)));
angle=angle+dA;
float alp = AngleToRad();
x1=20;
y1=148;
x2=xc+len2*cos(alp);
y2=yc+len2*sin(alp);
}
int CSupport::ComputeBallY(int x)
{ if ((x<x1) || (x>x2)) throw Naklon();
return sqrt(abs(10000-pow(x-19-98*cos(DegToRad(p)+ArcTan2(37,91)),2)))+147-98*sin(DegToRad(p)+ArcTan2(37,91));
}
int CBall::ComputeBallY12(int x,int y)
{
if ((x>Img->Width)*(x<(Img->Width+30))) if ((y>140)*(y<190)) throw 1;}