Приложение Листинг
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TShape *Shape[20];
TForm1 *Form1;
int m,m1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
class GraphicObject {
int x,y;
public:
int get_x(){return x;}
int get_y(){return y;}
void set_x(int value){x=value;}
void set_y(int value){y=value;}
}a1,a2;
class square_1: public GraphicObject {
public:
void draw(){
Shape[1]=new TShape(Form1);
Shape[1]->Parent=Form1;
Shape[1]->Shape=stCircle;
Shape[1]->Left=get_x();
Shape[1]->Top=get_y();
Shape[1]->Visible=true;
Shape[1]->Height=50;
Shape[1]->Width=50;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[1]->Left=get_x();
Shape[1]->Top=get_y();}
}square1;
class square_2: public GraphicObject {
public:
void draw(){
Shape[3]=new TShape(Form1);
Shape[3]->Parent=Form1;
Shape[3]->Shape=stCircle;
Shape[3]->Left=get_x();
Shape[3]->Top=get_y();
Shape[3]->Visible=true;
Shape[3]->Height=50;
Shape[3]->Width=50;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[3]->Left=get_x();
Shape[3]->Top=get_y();}
}square2;
class line1: public GraphicObject {
public:
void draw(){
Shape[4]=new TShape(Form1);
Shape[4]->Parent=Form1;
Shape[4]->Shape=stRectangle;
Shape[4]->Left=get_x();
Shape[4]->Top=get_y();
Shape[4]->Height=1;
Shape[4]->Width=150;
Shape[4]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[4]->Left=get_x();
Shape[4]->Top=get_y();}
}line1;
class line2: public GraphicObject {
public:
void draw(){
Shape[5]=new TShape(Form1);
Shape[5]->Parent=Form1;
Shape[5]->Shape=stRectangle;
Shape[5]->Left=get_x();
Shape[5]->Top=get_y();
Shape[5]->Height=1;
Shape[5]->Width=20;
Shape[5]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[5]->Left=get_x();
Shape[5]->Top=get_y();}
}line2;
class line3: public GraphicObject {
public:
void draw(){
Shape[6]=new TShape(Form1);
Shape[6]->Parent=Form1;
Shape[6]->Shape=stRectangle;
Shape[6]->Left=get_x();
Shape[6]->Top=get_y();
Shape[6]->Height=50;
Shape[6]->Width=1;
Shape[6]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[6]->Left=get_x();
Shape[6]->Top=get_y();}
}line3;
class line4: public GraphicObject {
public:
void draw(){
Shape[7]=new TShape(Form1);
Shape[7]->Parent=Form1;
Shape[7]->Shape=stRectangle;
Shape[7]->Left=get_x();
Shape[7]->Top=get_y();
Shape[7]->Height=1;
Shape[7]->Width=190;
Shape[7]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[7]->Left=get_x();
Shape[7]->Top=get_y();}
}line4;
class line5: public GraphicObject {
public:
void draw(){
Shape[8]=new TShape(Form1);
Shape[8]->Parent=Form1;
Shape[8]->Shape=stRectangle;
Shape[8]->Left=get_x();
Shape[8]->Top=get_y();
Shape[8]->Height=1;
Shape[8]->Width=20;
Shape[8]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[8]->Left=get_x();
Shape[8]->Top=get_y();}
}line5;
class line6: public GraphicObject {
public:
void draw(){
Shape[9]=new TShape(Form1);
Shape[9]->Parent=Form1;
Shape[9]->Shape=stRectangle;
Shape[9]->Left=get_x();
Shape[9]->Top=get_y();
Shape[9]->Height=50;
Shape[9]->Width=1;
Shape[9]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[9]->Left=get_x();
Shape[9]->Top=get_y();}
}line6;
class line7: public GraphicObject {
public:
void draw(){
Shape[10]=new TShape(Form1);
Shape[10]->Parent=Form1;
Shape[10]->Shape=stRectangle;
Shape[10]->Left=get_x();
Shape[10]->Top=get_y();
Shape[10]->Height=50;
Shape[10]->Width=1;
Shape[10]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[10]->Left=get_x();
Shape[10]->Top=get_y();}
}line7;
class line8: public GraphicObject {
public:
void draw(){
Shape[11]=new TShape(Form1);
Shape[11]->Parent=Form1;
Shape[11]->Shape=stRectangle;
Shape[11]->Left=get_x();
Shape[11]->Top=get_y();
Shape[11]->Height=1;
Shape[11]->Width=70;
Shape[11]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[11]->Left=get_x();
Shape[11]->Top=get_y();}
}line8;
class line9: public GraphicObject {
public:
void draw(){
Shape[12]=new TShape(Form1);
Shape[12]->Parent=Form1;
Shape[12]->Shape=stRectangle;
Shape[12]->Left=get_x();
Shape[12]->Top=get_y();
Shape[12]->Height=50;
Shape[12]->Width=1;
Shape[12]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[12]->Left=get_x();
Shape[12]->Top=get_y();}
}line9;
class line10: public GraphicObject {
public:
void draw(){
Shape[13]=new TShape(Form1);
Shape[13]->Parent=Form1;
Shape[13]->Shape=stRectangle;
Shape[13]->Left=get_x();
Shape[13]->Top=get_y();
Shape[13]->Height=1;
Shape[13]->Width=30;
Shape[13]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[13]->Left=get_x();
Shape[13]->Top=get_y();}
}line10;
/*
class Budka: public GraphicObject {
public:
void draw(){
Shape[14]=new TShape(Form1);
Shape[14]->Parent=Form1;
Shape[14]->Shape=stRectangle;
Shape[14]->Left=get_x();
Shape[14]->Top=get_y();
Shape[14]->Height=72;
Shape[14]->Width=188;
Shape[14]->Visible=true;}
void move(int value1, int value2){
set_x(value1);
set_y(value2);
Shape[14]->Left=get_x();
Shape[14]->Top=get_y();}
}budka;
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
square1.set_x(600);
square1.set_y(350);
square1.draw();
//
square2.set_x(400);
square2.set_y(350);
square2.draw();
//
line1.set_x(450);
line1.set_y(375);
line1.draw();
//
line2.set_x(650);
line2.set_y(375);
line2.draw();
//
line3.set_x(670);
line3.set_y(325);
line3.draw();
//
line4.set_x(480);
line4.set_y(325);
line4.draw();
//
line5.set_x(380);
line5.set_y(375);
line5.draw();
//
line6.set_x(380);
line6.set_y(325);
line6.draw();
//
line7.set_x(480);
line7.set_y(275);
line7.draw();
//
line8.set_x(410);
line8.set_y(275);
line8.draw();
//
line9.set_x(410);
line9.set_y(275);
line9.draw();
//
line10.set_x(380);
line10.set_y(325);
line10.draw();
//
Image1->Visible=true;
Timer1->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
m=square1.get_x();
m1=square1.get_y();
square1.move(m-1,m1);
//
m=square2.get_x();
m1=square2.get_y();
square2.move(m-1,m1);
//
m=line1.get_x();
m1=line1.get_y();
line1.move(m-1,m1);
//
m=line2.get_x();
m1=line2.get_y();
line2.move(m-1,m1);
//
m=line3.get_x();
m1=line3.get_y();
line3.move(m-1,m1);
//
m=line4.get_x();
m1=line4.get_y();
line4.move(m-1,m1);
//
m=line5.get_x();
m1=line5.get_y();
line5.move(m-1,m1);
//
m=line6.get_x();
m1=line6.get_y();
line6.move(m-1,m1);
//
m=line7.get_x();
m1=line7.get_y();
line7.move(m-1,m1);
//
m=line8.get_x();
m1=line8.get_y();
line8.move(m-1,m1);
//
m=line9.get_x();
m1=line9.get_y();
line9.move(m-1,m1);
//
m=line10.get_x();
m1=line10.get_y();
line10.move(m-1,m1);
//m=budka.get_x();
//m1=budka.get_y();
//budka.move(m-1,m1);
//
//Image[1].Left:=Image[1].Left-1;
Image1->Left=Image1->Left-1;
}
//---------------------------------------------------------------------------