igrica

Vse kar se tiče programiranja iger.
Zaklenjeno
humma4
Prispevkov: 3
Pridružen: 05.06.2009 14:50:23

igrica

Odgovor Napisal/-a humma4 » 07.06.2009 00:33:51

mene pa zanima kako narediš v igrici da ko začneš igrico ti začne šteti čas in kako narediš pavzo v igrici(ko pritisneš pavzo se mora tudi čas ustaviti ko pa hočemo nadaljevati igrico pa mora čas teči naprej).

igrica:

unit premik;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls, MPlayer;

type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
ProgressBar1: TProgressBar;
procedure PaintBox1Paint(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure FormActivate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
x,Y_ball,X_ball,Score:integer;
implementation

{$R *.DFM}

procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
with PaintBox1.Canvas do
begin
Pen.Color:=clRed;
Pen.Width:=4;
MoveTo(PaintBox1.width div 2, PaintBox1.height-20);
LineTo(PaintBox1.width div 2+20, PaintBox1.height-20);
end;
end;

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
with PaintBox1.Canvas do
begin
if Key='6' then
begin
if x< PaintBox1.Width-20 then x:=x+12;
Pen.Color:=clRed;
MoveTo(x, PaintBox1.height-20);
LineTo(x+20, PaintBox1.height-20);
Pen.Color:=clWhite;
MoveTo(x-12, PaintBox1.height-20);
LineTo(x, PaintBox1.height-20);
end;
if Key='4' then
begin
if x> 5 then x:=x-12;
Pen.Color:=clRed;
Pen.Width:=4;
MoveTo(x, PaintBox1.height-20);
LineTo(x+20, PaintBox1.height-20);
Pen.Color:=clWhite;
MoveTo(x+25, PaintBox1.height-20);
LineTo(x+50, PaintBox1.height-20);
end;
end;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
x:=PaintBox1.width div 2;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
PaintBox1.Canvas.TextOut(X_ball,Y_ball,' ');
if Y_ball=PaintBox1.Height-20 then
begin
if (X_ball>x-20)and(X_ball<x+20) then
begin
Score:=Score +5;
Label2.Caption:=InttoStr(Score);
end
else begin
if ProgressBar1.Position<10 then Form1.Close
else ProgressBar1.Position:= ProgressBar1.Position -11;
Beep;
end;
Y_ball:=0;
X_ball:=Random(PaintBox1.width);
end
else Y_ball:=Y_ball+10;

PaintBox1.Canvas.TextOut(X_ball,Y_ball,'O');
end;
end.

prosim pomagajte prosim

lp :)

Uporabniški avatar
Lee_Nover
Prispevkov: 3653
Pridružen: 20.05.2001 14:31:55

igrica

Odgovor Napisal/-a Lee_Nover » 07.06.2009 01:42:44

a zdej bo pa poplava teh 'igrca' nalog al kaj. najprej nared search, kot to pise v pravilih!
.. my 2 c ..
- I hate noobs -

Zaklenjeno