Добавил:
sergey123
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
//---------------------------------------------------------------------------
#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;
}
//---------------------------------------------------------------------------