![]() |
|
Модераторы: Snowy, MetalFan, bems, Poseidon |
![]()
|
|
| vmagdn |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 15 Регистрация: 17.10.2008 Репутация: нет Всего: нет |
unit UMain;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, jpeg; type TMainForm = class(TForm) Car: TImage; Block1: TImage; Block2: TImage; Label1: TLabel; Label2: TLabel; Button1: TButton; Button2: TButton; Bevel3: TBevel; Timer1: TTimer; Timer2: TTimer; procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Timer2Timer(Sender: TObject); private { Private declarations } public { Public declarations } end; var MainForm: TMainForm; Bonus:integer; implementation {$R *.dfm} procedure GameOver; begin MainForm.Timer1.Enabled:=false; MainForm.Timer2.Enabled:=false; ShowMessage('Аварія'); end; procedure TMainForm.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin //Управление машиной кнопками мышки If (Button=mbLeft) and (Car.left>0) then Car.left:=Car.left-(Car.width div 2); If (Button=mbRight) and (Car.Left<(450-Car.Width)) then Car.Left:=Car.Left+(Car.Width div 2); end; procedure TMainForm.Button2Click(Sender: TObject); begin close; end; procedure TMainForm.Button1Click(Sender: TObject); begin //Располагаем препятсвия Block1.Left:=128; Block1.Top:=288; Block2.Left:=320; Block2.Top:=50; Bonus:=0; Label1.Caption:='0'; //Показываем препятствия Block1.Show; Block2.Show; Car.Show; //Включаем все таймеры; Timer1.Enabled:=true; Timer2.Enabled:=true; end; procedure TMainForm.Timer1Timer(Sender: TObject); begin //Отображаем очки игрока Label1.Caption:=IntToStr(Bonus); //Задаем движение препятствия1 Block1.Top:=Block1.Top+(block1.height div 2); //Проверяем не произошла ли авария if (Block1.Top+Block1.Height)>(Car.Top) then if (Block1.Left+1<=Car.Left) and (Car.Left<=(Block1.Left+Block1.Width-1)) then GameOver; if (Block1.Top+Block1.Height)>(Car.Top) then if (Block1.Left+1<=(Car.Left+Car.Width)) and ((Car.Left+Car.Width)<=(Block1.Left+Block1.Width-1)) then GameOver; //Дошло ли препятствие до нижней границы If Block1.Top>=(MainForm.ClientHeight) then begin Bonus:=Bonus+10; Block1.Hide; Block1.Top:=1; //препятствие не должно вылазить за левую границу repeat Block1.Left:=Random(450-Car.Width); until (Block1.Left>10); Block1.Show; end; end; procedure TMainForm.Timer2Timer(Sender: TObject); begin //Отображаем очки игрока Label1.Caption:=IntToStr(Bonus); //Задаем движение препятствия1 Block2.Top:=Block2.Top+(Block2.Height div 2); //Проверяем не произошла ли авария if (Block2.Top+Block2.Height)>(Car.Top) then if (Block2.Left+1<=Car.Left) and (Car.Left<=(Block2.Left+Block2.Width-1)) then GameOver; if (Block2.Top+Block2.Height)>(Car.Top) then if (Block2.Left+1<=(Car.Left+Car.Width)) and ((Car.Left+Car.Width)<=(Block2.Left+Block2.Width-1)) then GameOver; //Дошло ли препятствие до нижней границы If Block2.Top>=(MainForm.ClientHeight) then begin Bonus:=Bonus+10; Block2.Hide; Block2.Top:=1; //препятствие не должно вылазить за левую границу repeat Block2.Left:=Random(450-Car.Width); until (Block2.Left>10); Block2.Show; end; end; end. |
|||
|
||||
| Alexeis |
|
|||
![]() Амеба Профиль Группа: Админ Сообщений: 11743 Регистрация: 12.10.2005 Где: Зеленоград Репутация: 34 Всего: 459 |
Модератор: дубликат
-------------------- Vit вечная память. Обсуждение действий администрации форума производятся только в этом форуме гениальность идеи состоит в том, что ее невозможно придумать |
|||
|
||||
![]()
|
| Правила форума "Delphi: Для новичков" | |
|
|
Запрещается! 1. Публиковать ссылки на вскрытые компоненты 2. Обсуждать взлом компонентов и делиться вскрытыми компонентами
Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Snowy, MetalFan, bems, Poseidon, Rrader. |
| 0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей) | |
| 0 Пользователей: | |
| « Предыдущая тема | Delphi: Для новичков | Следующая тема » |
|
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |