Смекни!
smekni.com

Гра Перший мільйон (стр. 3 из 4)

Form1->Table6->FieldValues[("C")]=Form1->Table3->FieldValues[("C")];

Form1->Table6->FieldValues[("D")]=Form1->Table3->FieldValues[("D")];

Form1->Table6->FieldValues[("PR_OTV")]=Form1->Table3->FieldValues[("PR_OTV")];

Form1->Table3->Next();

Form1->Table6->Next();

}

}

//---------------------------------------------------------------------------

void init_form ()

{

telefon=0;auditoria=0;fift=0;summa=0;// Global variables

count_fields=0;

clear_level ();

Form1->Image8->Show();

Form1->StaticText3->Hide();

Form1->StaticText4->Hide();

Form1->Panel1->Hide();

Form1->Panel2->Hide();

Form1->Panel3->Hide();

Form1->Panel4->Hide();

Form1->Panel5->Hide();

if (Form1->Table4->RecordCount==0) restore_base1 ();

if (Form1->Table5->RecordCount==0) restore_base2 ();

if (Form1->Table6->RecordCount==0)restore_base3 ();

out_text ("","","","","");

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image3Click(TObject *Sender)

{

if (auditoria==1)

{

auditorium=pr_otv;

Form5->ShowModal();

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N9Click(TObject *Sender)

{

if (auditoria==1)

{

auditorium=pr_otv;

Form5->ShowModal();

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)

{

init_form ();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button8Click(TObject *Sender)

{

Label1->Font->Color=clGreen;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N3Click(TObject *Sender)

{

Form2->Show ();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N8Click(TObject *Sender)

{

Form1->Close();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N10Click(TObject *Sender)

{

if (telefon==0) Form3->Close();

else Form3->ShowModal();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image1Click(TObject *Sender)

{

if (telefon==0) Form3->Close();

else Form3->ShowModal();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image1DragOver(TObject *Sender, TObject *Source,

int X, int Y, TDragState State, bool &Accept)

{

Image4->Visible=false;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image1MouseDown(TObject *Sender,

TMouseButton Button, TShiftState Shift, int X, int Y)

{

Image4->Show();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image1MouseUp(TObject *Sender, TMouseButton Button,

TShiftState Shift, int X, int Y)

{

Image4->Hide();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image3MouseDown(TObject *Sender,

TMouseButton Button, TShiftState Shift, int X, int Y)

{

Image5->Show();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image3MouseUp(TObject *Sender, TMouseButton Button,

TShiftState Shift, int X, int Y)

{

Image5->Hide();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image5MouseUp(TObject *Sender, TMouseButton Button,

TShiftState Shift, int X, int Y)

{

Image5->Hide();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image2MouseDown(TObject *Sender,

TMouseButton Button, TShiftState Shift, int X, int Y)

{

Image6->Show();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image2MouseUp(TObject *Sender, TMouseButton Button,

TShiftState Shift, int X, int Y)

{

Image6->Hide();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Panel1MouseUp(TObject *Sender, TMouseButton Button,

TShiftState Shift, int X, int Y)

{

Panel1->Color=clBtnFace;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N4Click(TObject *Sender)

{

telefon=1;auditoria=1;fift=1;summa=0;// Global variables

position=1;

clear_level ();

out_text ("","","","","");

next_player++;

Form4->Show();

}

//---------------------------------------------------------------------------

void reset_all ()

{

Form1->Close();

Form1->Show();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Panel1Click(TObject *Sender)

{

int panel=1;

verify (panel);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Panel2Click(TObject *Sender)

{

int panel=2;

verify (panel);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Panel3Click(TObject *Sender)

{

int panel=3;

verify (panel);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Panel4Click(TObject *Sender)

{

int panel=4;

verify (panel);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Image2Click(TObject *Sender)

{

if (fift==1)

{

AnsiString sound="Fifty.wav";

play (sound);

auditorium=pr_otv;

fifty ();

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N7Click(TObject *Sender)

{

PasswDlg->StaticText1->Caption="Введіть пароль:";

PasswDlg->Edit1->Clear();

PasswDlg->ShowModal();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N6Click(TObject *Sender)

{

fmRating->ShowModal();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)

{

Timer1->Tag++;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormActivate(TObject *Sender)

{

random_question ();

update ();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N11Click(TObject *Sender)

{

AnsiString sound="Stop.wav";

play (sound);

save_rating ();

fmStop->ShowModal();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N50x501Click(TObject *Sender)

{

if (fift==1)

{

AnsiString sound="Fifty.wav";

play (sound);

auditorium=pr_otv;

fifty ();

}

}

Модуль Auditorium.cpp

#include <vcl.h>

#pragma hdrstop

#include "Auditorium.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma link "CGAUGES"

#pragma resource "*.dfm"

TForm5 *Form5;

//---------------------------------------------------------------------------

__fastcall TForm5::TForm5(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm5::FormActivate(TObject *Sender)

{

extern auditorium;

extern auditoria;

extern play(AnsiString);

AnsiString sound="Zal.wav";

play (sound);

int x1,x2,x3,x4;

randomize ();

int x=50+random (50);

int y=random (100-x);

int z=random (100-(x+y));

int j=random (100-(x+y+z));

int n=100-(x+y+j+z);j=j+n;

if (auditorium==1){x1=x;x2=y;x3=z;x4=j;}

if (auditorium==2){x1=y;x2=x;x3=z;x4=j;}

if (auditorium==3){x1=z;x2=y;x3=x;x4=j;}

if (auditorium==4){x1=j;x2=y;x3=z;x4=x;}

CGauge1->Progress=x1;

CGauge2->Progress=x2;

CGauge3->Progress=x3;

CGauge4->Progress=x4;

auditoria=0;

}

Модуль Telefon.cpp

#include <vcl.h>

#include <string.h>

#pragma hdrstop

#include "Telefon.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm3 *Form3;

//---------------------------------------------------------------------------

__fastcall TForm3::TForm3(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

extern int telefon; AnsiString c;

extern play(AnsiString);

//---------------------------------------------------------------------------

void out (AnsiString z)

{

if (telefon==0) Form3->Close();

if (z=="Clear")

{

Form3->Edit1->Clear();

z="";

}

Form3->Edit1->Text=Form3->Edit1->Text+z;

}

//---------------------------------------------------------------------------

void dial (void)

{

if ((Form3->Edit1->Text.Length())==6)

{

extern auditorium;

AnsiString telc=Form3->Edit1->Text;

double tel=StrToInt(Form3->Edit1->Text);

if (tel==634512)

{

Form3->Label1->Caption=" Б.Єльцін не знає правильної відповіді.";

telefon=0;

}

if (tel==398276)

{

Form3->Label1->Caption="В.Ющенко точно знає,що провильний варіант A.";

telefon=0;

}

if (tel==158204)

{

Form3->Label1->Caption=" Б.Гейтс не сумнівається у варіанті С.";

telefon=0;

}

if (tel==834577)

{

Form3->Label1->Caption=" Дід Мороз гадає, що правильна відповідь B.";

telefon=0;

}

if (tel==597420)

{

Form3->Label1->Caption=" Б.Ступка думає, що правильний варіант D.";

telefon=0;

}

if (tel==964816)

{

Form3->Label1->Caption=" Буратіно впевнений у варіанті В.";

telefon=0;

}

}

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button10Click(TObject *Sender)

{

c="0";

out (c);

dial ();

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button1Click(TObject *Sender)

{

c="1";

out (c);

dial ();

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button2Click(TObject *Sender)

{

c="2";

out (c);

dial ();

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button3Click(TObject *Sender)

{

c="3";

out (c);

dial ();

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button4Click(TObject *Sender)

{

c="4";

out (c);

dial ();

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button5Click(TObject *Sender)

{

c="5";

out (c);

dial ();

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button6Click(TObject *Sender)

{

c="6";

out (c);

dial ();

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button7Click(TObject *Sender)

{

c="7";

out (c);

dial ();

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button8Click(TObject *Sender)

{

c="8";

out (c);

dial ();

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button9Click(TObject *Sender)

{

c="9";

out (c);

dial ();

}

//---------------------------------------------------------------------------

void __fastcall TForm3::Button11Click(TObject *Sender)

{

Label1->Caption="";

c="Clear";

out (c);

dial ();

}

//---------------------------------------------------------------------------