Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

ООП / ООП / ball / Unit1

.cpp
Скачиваний:
7
Добавлен:
18.02.2017
Размер:
2.48 Кб
Скачать
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "ball.h"
#include <math.h>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}

//---------------------------------------------------------------------------
CShelf Shelf1;
CBall Ball1;
CSnow Snow1;
int fff;

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{

Shelf1.Delete();
//Ball1.Delete();

Ball1.Fall(Shelf1);
Shelf1.Elevate();
Shelf1.Draw();
if (Ball1.qq==0) Ball1.DrawF(Shelf1);
else Ball1.Draw();
if (fff==1) {
Snow1.Draw();
}
}
//---------------------------------------------------------------------------





void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)

{
if(( Key == ' ')&&(Ball1.qq!=2)) {
Ball1.qq=1;
}
if (Key == 38) {
Shelf1.p=1;
}
if (Key == 40) {
Shelf1.p=2;
}
if (Key == 37) {
Shelf1.p=3;
}
if (Key == 39) {
Shelf1.p=4;
}
}
//---------------------------------------------------------------------------


void __fastcall TForm1::FormKeyPress(TObject *Sender, wchar_t &Key)
{
if((Key == ' ') && (Ball1.qq==1)&&((Shelf1.Rx1-5)>Shelf1.x1)) {
Shelf1.Rx1=Shelf1.Rx1-1;
Shelf1.Rx2=Shelf1.Rx2-1;
Shelf1.nat=Shelf1.nat+0.3;
}
}
//---------------------------------------------------------------------------


void __fastcall TForm1::FormCreate(TObject *Sender)
{
Timer1->Enabled=true;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormKeyUp(TObject *Sender, WORD &Key, TShiftState Shift)
{
if ((Key == ' ')) {
if ((Ball1.qq==1)) {
Shelf1.Rx1=Shelf1.x1+20;
Shelf1.Rx2=Shelf1.x1+40;
}
Ball1.qq=2;
}
Shelf1.p=0;


}
//---------------------------------------------------------------------------


void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------



void __fastcall TForm1::Image1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y)
{
if (fff!=1) fff=1;
else fff=0;

}
//---------------------------------------------------------------------------

Соседние файлы в папке ball
  • #
    18.02.2017901 б7ball.h
  • #
    18.02.20177.48 Кб7Project1.cbproj
  • #
    18.02.20171.04 Кб7Project1.cbproj.local
  • #
    18.02.2017870 б7Project1.cpp
  • #
    18.02.20175.28 Кб7Project1.res
  • #
    18.02.20172.48 Кб7Unit1.cpp
  • #
    18.02.2017692 б7Unit1.dfm
  • #
    18.02.20171.33 Кб7Unit1.h